Win XP PRO SP3 as external event logger - Page 1
Forum section: electronics / general

author: soldar
author_rank: Super Contributor
timestamp: January 16, 2019, 04:57:15 pm
content: I would like to use a an old PC to log events like closing of switches. Very simple requirements. Log, in a text file, time and change in switch status.First problem to resolve is how to get the info to the PC. I have a PC with two serial DB9 connectors. That seems to me like the simplest way to interface. I would have no problem building some external electronics if needed or buying something inexpensive. I suppose if I am going to get an external interface it could also be USB.What software can I find that would do this? I am looking for something simple, quick and dirty.

author: metrologist
author_rank: Super Contributor
timestamp: January 16, 2019, 06:54:10 pm
content: I would attach an Arduino with some sensors to your switches. Then Arduino could write the data to serial and you could use PuTTy to capture the serial data to a log file.

author: soldar
author_rank: Super Contributor
timestamp: January 16, 2019, 09:18:39 pm
content: I am not familiar with Arduino and it is more effort than I can put into this. I am hoping for a very simple, low cost board or interface, be it RS232 serial or USB that will monitor some switches and log any changes.I guess it would need some software.Come to think about it controlling one or two outputs would be nice although not strictly necessary at this point.Another thing that would be nice is the ability to send an email on any input change.I would think this would be something relatively common but I do not even know what words to search for.

author: MrMobodies
author_rank: Super Contributor
timestamp: January 16, 2019, 10:29:39 pm
content: I know of something similar to measure voltage of serial battery chargers but can be altered by the device templates.Logview (Free):http://www.logview.info/forum/index.php?pages/home/V2 logs all but only displays one sensor at a time.It has a built in web server that can be turned on.V3 Studio requires Net Framework 4, installs Mysql and has stability issues.I don't think it does email.

author: digsys
author_rank: Unknown
timestamp: January 16, 2019, 11:07:03 pm
content: These are a few methods I use / used for many years -1/ Deluxe method - sensoriumembedded.com/products.htm up to 24in, other devices that do I/O + analogue .. everything sent to HID .. then from there -https://joytokey.net/en/redirect / modify the Inputs to any keyboard command to any program. All done for you and extremely flexible.2/ Write direct to an LPT port (buffered) - I do it on XP3 very often. I may still even have buffered / decoded LPT IO pcbs somewhere.That gives you 8in (and/or op) plus a few LPT control lines. 378h - 37Fh , 278h - 27Fh3/ Write direct to a serial port. 3F8 , 2F8 , 3E8 , 2E8. You get about 2-3 in / 2-3 op lines. Or make up a simple command to IO decoder. I may even have someof those around.4/ Various other hardware ports. Back in the XP3 days, we could easily write / read direct from literally any M/Board IC :-)I'll see what I have around in the next day or 2

author: soldar
author_rank: Super Contributor
timestamp: January 16, 2019, 11:15:19 pm
content: MrMobodies, that looks like it might work but it does not explain what hardware I need or might work with it. I need to know what hardware I need because I want something really low cost.

author: Flenser
author_rank: Regular Contributor
timestamp: January 17, 2019, 02:53:10 am
content: Using your serail ports would likely mean you will have to build or buy an external circuit that converts the state of your switch to a serial transmission which probably isn't going to be "simple, quick and dirty".Does your old PC have a parallel port?A parallel port has 5 or 8 bits which can be read directly, depending on the parallel port type, and it's the sort of project people did with PC's before microcontrollers, and microcontroller projects, became common. So you might be able to find a simple circuit and some existing software on the web.I've just had a quick look and found this which has a simple circuit and links to software for monitoring switches:http://www.epanorama.net/circuits/parallel_output.html#inputThe other project people did was parallel port logic analyzers. There are a _lot_ of logic analyzer projects but you will need to find one that logs continuously to a file or write/modify software yoursellf to do this logging.

author: soldar
author_rank: Super Contributor
timestamp: January 17, 2019, 09:13:15 am
content: ThanksFlenserfor your input. I mentioned serial port input thinking it would be as easy as parallel port input but, after thinking about it, you are right and it is not so easy. Since I have no parallel ports I will forget about legacy serial and parallel ports.Thanksdigsys. Thatsensoriumembeddeddevice looks like it might do what I want but it is a bit pricey and I would need to get the software separately. I think I will keep looking for now.Ideally I think there would be a USB board with binary switch inputs. I am surprised this is not quite common and readily available at low cost.Another option might be to hack a keyboard and put relay switches in parallel with some keys.I am really surprised there is not more variety of offers for this type of interface to log inputs and maybe control some outputs.I wonder if I could use a PLC module; something likehttps://www.ebay.com/itm/172919922474. Maybe it could work autonomously and independent of the computer until I wanted to download that log data. Anybody have any experience with that?

author: PlainName
author_rank: Super Contributor
timestamp: January 17, 2019, 09:24:11 am
content: QuoteDepends on what you call low cost - to DIY would cost you much more than you'd pad for some of these:https://www.poscope.com/products/pokeys-devices/

author: digsys
author_rank: Unknown
timestamp: January 17, 2019, 09:31:08 am
content: Quote from: soldarA serial port has 5x Inputs and 3x Outputs. You address those pins directly - NOT as a serial comms, you don't need any of that. Just read / write the registers.You can use even the simplest of languages, even DOS. Just set up a timer interrupt for the poll time you need.Since you have 2x serial ports, that's 10x Inputs and 6x Outputs. Simple buffers / level protection in / out. Very simpleQuote from: soldarThat's also a very cheap / easy solution, and you can get that type of thing in USB as well. Just check what level of software you get with it, or if it easy to writeyour own. Also used heaps of those types of I/Face

author: soldar
author_rank: Super Contributor
timestamp: January 17, 2019, 02:33:40 pm
content: Quote from: dunkemhigh on January 17, 2019, 09:24:11 amThanks. That looks in line with what I am looking for but, like other things I have looked at, it seems not explained simply and clearly.I foundVelleman K8055which looks like it connects using USB, has 5 digital & 2 analog inputs and 8 digital + 2 analog outputs. It comes already with some basic software and you can write your own using Visual Basic. Since I have no idea of Visual Basic I would have to learn. I do not know how much effort I would need to put into learning VB.It sounds like an alternative would be to use and learn Arduino or Raspberry Pi but, again, it would be a new learning ting for me.

author: soldar
author_rank: Super Contributor
timestamp: January 17, 2019, 02:40:54 pm
content: digsysI guess you are right and I could access the serial port pins directly but the more I think about this the more I think it might be better to go with some USB solution which will not be obsolete before I even start.If that PLC can keep time and log events then that would be just what I need because the computer would not have to be running all the time. Just connect from time to time and download the data. I don't know how to find out about this. I'll have to keep looking. If anyone can give me documentation it would be good.I miss the old days of basic BASIC when you could do all this with peeking and poking and "GOTO 10".

author: PlainName
author_rank: Super Contributor
timestamp: January 17, 2019, 08:16:01 pm
content: I think we are all in danger of diving off the deep end without knowing if there's any water in the pool...Perhaps it would be a good idea to give us an idea of a) what you want as the end result, and b) your abilities/desires in regards to programming and the like. At second glance, a 10 euro Logic8 clone from China and free logic analyzer software might do the thing (it would give you a history of what changed and when), and it's pretty instant to get going. But that's probably not appropriateSo, are you after an actual log file with, say, "timestamp, switch ID, state" on each line? Or a graph along the lines of anRRD chart?Next, do you want to do any coding yourself and, if so, how deep into that would you go (for instance, accessing the data via some library DLL API)? Any languages you know or could learn (and would want to learn)?

author: T3sl4co1l
author_rank: Super Contributor
timestamp: January 17, 2019, 08:30:46 pm
content: Quote from: digsys on January 16, 2019, 11:07:03 pmIf your "old PC" has these ports onboard, it's not at all a bad way to go.You will need to use a device driver like GiveIO to be able to use them on WinNT (XP, etc.).This is what I did for the somewhat more elaborate project I did back in college:The ribbon cable coming in from the left is a parallel port from the PC, which was running, some old (already, at the time) motherboard with a Duron 1.6GHz CPU I think, and WinXP. On Win98, straight IO from user-land can be done, but on NT you need to ask the OS "pretty please". Installation and use is straightforward.For logging, of course, you'd just be polling the inputs, and checking for state change. Or if you don't mind a little logic, an external latch to hold the trigger state, then a read-and-clear-latch operation from the PC would allow more freedom, since, keep in mind, we're talking a multitasking OS here, so you can't assume your program will be running on time, every single millisecond.Tim

author: T3sl4co1l
author_rank: Super Contributor
timestamp: January 17, 2019, 08:36:27 pm
content: Quote from: soldar on January 17, 2019, 02:40:54 pmI mean, you can easily pick up an old PC-compatible something or other, load up MS-DOS and QBASIC, and INP(&H3F8) or what have you. The downside is, you'll need a compatible floppy drive to copy the files from, or else a serial connection (in which case we're back to the start), or a network card with compatibility to modern Ethernet or whatever (which isn't hard to find actually, but you will most likely have to find one, plus install the drivers).This canalmostbe done in DOSbox -- serial IO works, with a USB adapter configured as the serial device. I don't think it works as a bit-bang port though (RTS/CTS pins)?I mean, if you have one, you can give it try though anyway.Tim

author: soldar
author_rank: Super Contributor
timestamp: January 17, 2019, 08:51:36 pm
content: dunkemhigh, yeah, I'm sorry I am a bit unclear on the idea. I started out thinking input through a legacy port would be easier but I am changing my mind. This exchange is helping me clarify my own ideas.Ideally I would be knowledgeable and experience with Arduino but I've missed that boat. Maybe I should start down that way.Let's see. For now the ideal would be something like a "$10 usb board" which with very basic programming just adds a line to a text file each time an input changes. Something like this would do:Code:.2019/01/17 12:31:23 PM - Input 5 = 12019/01/17 12:31:24 PM - Input 5 = 02019/01/17 12:32:26 PM - Input 1 = 12019/01/17 12:32:28 PM - Input 2 = 12019/01/17 12:32:27 PM - Input 1 = 0I can interpret each input as "door open" or whatever it is.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: January 17, 2019, 09:12:50 pm
content: You could literally do that with Notepad, and a keyboard cut down to just the F5 key. B) (Or an analog switch or relay closing the connections to the button.)Well, almost. Doesn't add the pin data, or start a newline. Doesn't auto-save the file either, changes would be lost if the computer shuts down unexpectedly.An AutoHotKey script could solve all of that, I think. A hacky solution for a hacky method.The canonical heavy-weight solution these days would be either something like Labview, or the serial converter and a logger (which could be as simple as a Bash script, for those using Linux, I think?).Arduino isn't hard to learn, it's a good excuse to pick up if you don't need this solved super urgently.Tim

author: soldar
author_rank: Super Contributor
timestamp: January 17, 2019, 09:21:42 pm
content: Quote from: T3sl4co1l on January 17, 2019, 09:12:50 pmHow can I get Notepad to note the time when the key is pressed and when it is released?Quote from: T3sl4co1l on January 17, 2019, 09:12:50 pmIf we had some ham we could have some ham and eggs ... if we had some eggs.I am afraid Notepad does not seem to get anywhere close.Quote from: T3sl4co1l on January 17, 2019, 09:12:50 pmI might ask in the Linux forum. Maybe the software side would be easier. Good idea.Quote from: T3sl4co1l on January 17, 2019, 09:12:50 pmYes, I have been thinking for years now that I should learn Arduino. Maybe this is the time to finally get my butt in gear.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: January 17, 2019, 09:28:15 pm
content: Quote from: soldar on January 17, 2019, 09:21:42 pmYeah, not release....... heh, well, it could be a parsing solution. Hold down F5 and it spams timestamps... just find the last one that was <keyboard repeat rate> apart and you've likely found the keyup event.Now let's throw our heads back and laugh at that mess of an idea...Tim

author: metrologist
author_rank: Super Contributor
timestamp: January 17, 2019, 09:30:30 pm
content: Arduino's are so cheap and there is so much online and support for them. I think you will be surprised how easy! And I'm sure many here will help with code.

author: soldar
author_rank: Super Contributor
timestamp: January 17, 2019, 09:31:42 pm
content: I did this some forty years ago with a 6502 development system called AIM 65, in assembler, and it seemed extremely easy. I thought I would repeat the same idea.Basically the idea is to have a log or record of events. When somebody rings the bell, when the cabinet for the water meter is opened and I know the meter has been read, when the cat goes in or out that cat door (if I had a cat), ... that kind of thing.

author: metrologist
author_rank: Super Contributor
timestamp: January 17, 2019, 09:35:51 pm
content: The Arduino also has several adc inputs so you can read voltage levels. My favorite flavor is a Nano.There is a real time clock library to make regular timekeeping quite easy.

author: fourtytwo42
author_rank: Super Contributor
timestamp: January 17, 2019, 09:36:59 pm
content: Maybe off subject by now but just a plug for winXP/SP3 I use it everyday as far as I am concerned it is the last stable release of windows!

author: soldar
author_rank: Super Contributor
timestamp: January 17, 2019, 09:37:33 pm
content: Quote from: metrologist on January 17, 2019, 09:30:30 pmYeah, it seems like I really should get started. I am going to look into it. Thanks for the encouragement. Maybe you can suggest a particular model?

author: OwO
author_rank: Super Contributor
timestamp: January 18, 2019, 02:14:39 am
content: Oh god this isn't 1810, please don't recommend parallel port/MSDOS/BASIC based solutions, plus an old PC running for any significant time will cost you more in electricity than anything you would have saved by reusing old hardware. It's not worth it.I would really recommend a Pee based solution (raspberry, orange, banana, any of the flavors). You have access to the GPIOs directly from userspace and can simply write a C or Python program to log the data to a file. It will take what, 30 lines of code? The only thing I would really add is input protection for the GPIOs. If this is really slow stuff (<1MHz), a large (~220ohm) series resistor and a diode clamp would be sufficient.EDIT: You can also easily have a script running in the background to periodically rsync the logs to a remote server or PC for ease of access, or even have a web interface where you can view the logs. None of this would be easy to do on WinXP.

author: Flenser
author_rank: Regular Contributor
timestamp: January 18, 2019, 04:28:49 am
content: soldar,You said:QuoteYou were using a microcomputer chip that had instructions for reading an 8-bit digital port and a built in hardware serial port. If you were sending a timestamp then it also had a clock and you knew, or learnt, how to program in assembler.Today I imagine that most people who already have some experience coding in C or assembler for a microcontoller would probably use it to do your project.These microcontrollers have instructions for reading an 8- bit digital portAll but the smallest ones have hardware UARTs that can be simply connected to PCs to communicate over serial using USB-to-serial cablesThese chips cost a frew $These people already own a programmer.People who don't have experience using microctontrollers directly but do have experience using Arduino or Raspberry Pi would likely use them to do your project for almost exactly the same reasons.If you are at all considering checking out Arduino then I recommend that you don't be put off by the learning curve and give it a try.The Arduino software envionrment sets everything up for you, including the base code for a program that consists of an endless main loop. i.e. for a simple program you start by adding your code into this loopThere are a _lot_ of people using them. This means there are a lot of people who can answer any of your questions in ForumsThis also means that there are a lot of code and project examples on the web that you can take advantage of cut-and-paste into your arduino sketchThe hardware is very cheap. Especially the clone boards coming out of China. Search ebay for "Arduino Nano" to see what I mean. Under US$3 with free shipping so it's really cheap to try outYou don't need to buy a programmer as the program is downloaded to the Arduino over a USB cable.The Arduino does not include a clock but you can get real-time clock modules on ebay for US$0.75 including shipping.These modules communcate via I2C but this is something you will find tutorials on the web with code.Here is an example of what I'm taking about. This link logs the temperature from a DHT11 chip, gets the timestamp from a real-time clock module and logs the data to a file on an SD Card module:https://randomnerdtutorials.com/arduino-temperature-data-logger-with-sd-card-module/You would only need to this code to read the digital port instead of reading the temp sensor and either write that out to the SD card or open a serial connection to the PC and write it there.

author: soldar
author_rank: Super Contributor
timestamp: January 18, 2019, 09:35:33 pm
content: Flenser, thanks so much for your input. I think I might give Arduino a try. I might need a lot of encouragement and hoandholding though because I get tired and discouraged easily. When I was younger I would toil for hours and never get tired but now I start to think, "you know, I've lived all these years without knowing all this... maybe it can wait a day or two..." and that is why I have a ton of projects half way done and unfinished. I am going to have a look at Arduino and will report back.

author: Ian.M
author_rank: Super Contributor
timestamp: January 18, 2019, 10:23:20 pm
content: No worries. Arduino related handholding is one of the things this forum does very well indeed usually with a better signal to noise ratio than the official forum.I should caution you: if you've *NEVER* done any C programming or programming in a structured, procedural high level language before, the learning curve will be quite steep.If you go down the Arduino road, it may be worth considering a data logger shield*which will give you a SD card socket and a RTC chip so the logger can run standalone without having to have a PC powered on. Seehttps://learn.adafruit.com/adafruit-data-logger-shield/overviewData retrieval could be via the Arduino USB serial interface - send a plain text command to dump events since the last successful retrieval (or for a specified date time range) and get back text or binary data in whatever format you decide to code it to give you.It is possible to put an Arduino on your LAN using the Ethernet shield and retrieve date from it over the network, but that's fairly advanced, even if you follow one of the 'cookbook' recipes for using that shield.N.B. many of the shields use up a significant number of the 18 available I/Os (excluding UART RX & TX pins) on an Arduino Uno so if you've got a *LOT* of switches to monitor and don't want to use I/O expanders, take a look at the Arduino Mega 2560.Another option for the logger that' s already been mentioned is the Raspberry Pi. Pi Zero models and all model A boards don't have on-board Ethernet or USB hub, but OTOH because they don't have the on-board hub chip, you can put the SoC in USB OTG device mode and connect directly to it via USB from your PC. The Pi Zero W is probably the best option for a simple logger, as its bluetooth and WiFi capabilities make it much easier to connect to. You *will* need to get it on your LAN to get it internet access to install and update software packages, and its a lot easier if you don't have to do that through a USB tether to your PC.OTOH if you prefer wired Ethernet capabiity, get any of the B models, but the tradeoff is they cant be USB tethered to a PC as they don't support USB OTG.None of the PIs have an on-board RTC, so you either need them to have network connectivity so they can get the time from a time server, or to add a RTC module. They all have a single SD card socket, which they boot the Linux OS from. You can log to a file on the SD card, but keep a spare exact copy of the card as SD cards that are frequently written to tend to go bad after a while. Also note that a Pi is *MUCH* more power hungry than an Arduino.* Plug in daughter boards that match the Arduino pinout and form factor to extend its capabilities are called shields. The Raspberry Pi equivalent are called hats (though strictly speaking a standards compliant Pi hat must have an ID EEPROM, which not all boards impement).

author: soldar
author_rank: Super Contributor
timestamp: January 18, 2019, 11:00:12 pm
content: Wow, you are already beginning to scare me! Let us start with the very simplest bare minimum. Let us say a system that connects using solely USB which I assume is included. With 4 to 8 digital inputs and 4 to 8 outputs. With ability to keep real time and keep the output text file in memory until it is transferred via USB to the computer. Is that the simplest way? What kind of memory does it have. I wouldn't need a lot but let us say 100 events. What hardware do I need for that?

author: Ian.M
author_rank: Super Contributor
timestamp: January 18, 2019, 11:40:18 pm
content: It depends on the accuracy of the timestamp. 8 inputs = 4 bits for the input number + on/off , then you need 11 bits to record a time of day to the nearest minute, or 17 bits to the nearest second. Add another 9 bits for day of the year if you need the date. Best case that's twobytes, worst case its four bytes. An Arduno Uno (or Nano) has 2K RAM so allocating 1K of it to hold an array for 256 four byte events would be one option, but the data would be lost if the power failed. Another would be to log to its MCU's internal EEPROM, which is 1K. Your logger program would convert the binary log to ASCII text immediately before transfer to the PC as storing it as ASCII would use *FAR* more memory, limiting the number of events it could retain.An Arduino Uno (or Nano) has 20 I/O pins, but its on-board USB serial link to the PC reserves two of them and another two are needed if you connect an I2C RTC module for accurate timekeeping. Therefore 16 I/Os would be available to your application - its up to you how you choose to divide them between inputs and outputs. After you've reserved the I2C pins, four of the remaining I/Os are analog capable and the voltage on them can be read as a 10 bit number (so basically the resolution is approx 5mV if the 5V supply is used as the ADC reference. six other I/Os can do PWM, which can be used for lighting brightness or DC power control or after filtering, can output an analog control voltage.A Uno is a better option for the solder adverse, due to the wide range of shields available for that form factor. A Nano is basically the same but in a 0.6" wide DIL-28 footprint. Both have on-board USB serial to connect to your PC. The Nano is the better choice if you want to assemble the switch and output interfaces on strip board or matrix board, as some of the Uno's headers are offset from a 0.1" pitch grid.

author: metrologist
author_rank: Super Contributor
timestamp: January 19, 2019, 12:51:20 am
content: Ian, you convinced me to order 5 more Arduinos.

author: Flenser
author_rank: Regular Contributor
timestamp: January 19, 2019, 04:14:22 am
content: soldar,QuoteYou do not have a USB connection to the arduino. At least not the type of usb connection you have with a flash drive that I suspect you may be thinking of.The Arduinos have a USB-to-serial converter on the PCB. The USB cable you plug in provides one way to power the arduino and you can use the virtual serial ports you see on your PC to communicate with the arduino.QuoteNo matter which way you go you are going to be writing the software yourself, or modifying software from an existing tutorial.Sending the samples to the PC via serial is probably "simpler" in terms of your effort learing Arduino and starting with C as sending data over a serial link is a very common thing people want to do so there will be plenty of examples on the web for you to checkout and/or copy code from. The trade-off is that you have to have PC running with logging software that writes the serial data to a file.If you choose to write the data to an SD card using data logger shield, as suggested by Ian.M, then you don't need to have a PC running to collect the data. The arduino runs as stand-alone data logger hardware and just needs power, which can be batteries.Transfering the data to your PC is arguably simpler as you just turn off the arduino, take out the SD card, plug it into your PC and copy the files off the card onto your PC. You will have to write the C code to write the data to the SD card but there will be plenty of examples on the web of how to do this.If you choose to send the data to you PC via serial then you don't need a real-time clock on the ardunio. You can just use logging sofware on the PC that adds a timestamp to the serial bytes/lines it reveives.- The LogView software suggested by MrMobodies does this- ExtraPutty is also described as doing thishttp://www.extraputty.com/index.phpand can be downloaded and the install folder extracted from the zip file run without needing to do an install.QuoteThe ATmega48P/88P/168P/328P chips that I think is commonly used on arduino boards have 512/1K/1K/2K Bytes of Internal SRAM so checkout the board you plan to buy to make sure it is one of the larger ones and you shold have plenty of RAM to store 100 samples + timestamp. If you store the data in RAM it will, of course, be lost when the power to the arduino is turned off.These ATmega48P/88P/168P/328P chips also have 256/512/512/1K Bytes EEPROM which you can use as non-volitile storage. i.e. the stored values will not be lost when the power is turned off. You will still need to write the code to get the data over to the PC some way.

author: soldar
author_rank: Super Contributor
timestamp: January 19, 2019, 07:21:18 pm
content: Yeah, thanks again. I am seeing this is going to take dedicating some time to it. It is not a one afternoon thing.I am trying to somewhat improve security at home and this is part of trying to keep a log of when passive IR sensors were triggered, doors opened, etc.I already have a bunch of security cams and I am also trying to improve that part. Every little thing takes countless hours. Maybe I am just not too bright. So once I get the camera system done I will get started with Arduino.Maybe I will start another thread about the video cams because I am slo pretty frustrated with that after burning many hours.

author: metrologist
author_rank: Super Contributor
timestamp: January 20, 2019, 12:14:50 pm
content: 5 Arduino's arrived. I like the Nano version because they plug into solderless breadboards. You could certainly get a breadboard wired up to some sensors and programmed in an afternoon. A lot of "Arduino" modules are layed out with pin headers to plug into breadboards, like a RTC module and temp sensors, etc.