View Data On RS-232 Port

I am trying to modify and existing "lightning detector circuit" so that rather that going to another circuit that does counting it triggers a signal on a RS-232 port. I am thinking that I would create a program that monitors the port and simply counts the number of times a line goes high? Does this sound possible? If so which RS-232 pin should I place the "signal"? Sorry about these basic questions and any help appreciated.

--


Jim Douglas
http://www.genesis-software.com
Latitude     32.96
Longitude -96.89
Reply to
Jim Douglas
Loading thread data ...

that

signal

monitors

Does this

Sorry

[I'm assuming here that the OP has an IBM PC for which he's writing software. The OP also has an electrical signal available for interface to his computer.]

Good morning, Jim. One of the tricks I used to use in the old DOS days, when getting a user trigger for a GPIB test where the operator's hands were busy, was to hook up a small footswitch with a form C contact to the serial port. One original project description actually included purchasing an GPIB digital I/O box just to supply the footswitch input signal to the PC running the instruments. We saved the money and finished the CER below budget.

It's actually simple in DOS. Let's say you're using COM1, with base address 0x3F8. You want to get your electrical signal to drive a Form C reed relay made for dry contact switching. Once you're there, hook up the reed relay common to the PC CTS pin. Also hook up the NC to the RTS pin, and the NO to the DTR pin.

Now use software to write a "1" to RTS and a "0" to DTR by forcing those bits on the read/write Modem Control Register (base address + 4,

0x3FC). Note that bit 1 of that port address when writing is Force RTS, and Bit 0 is Force DTR.

Then all you have to find out the status of your switch is to read the read-only Modem Status Register (Base + 6, 0x3FE), then AND the result with 0x10 (note that bit 4 is a direct read of CTS). This setup will allow you to cobble a "bit banging" program in C which will reliably catch contact closures just about as fast as a relay can go, including a software debounce routine. And if you're getting more than 100 lightning strikes a second in the vicinity, I'm not sure tweaking software is your first priority, bud. I think you should then probably move yourself and your laptop away from the Eddie G. Robinson (Dathan) side, and toward the Charleton Heston (Moses) side of the divide as quickly as you can, before the earth's crust opens and swallows you up.

This is covered very well at

formatting link

(except for the 10 Commandments stuff. ;-) At first glance, this seems to be a cheesy solution, but it's technically sound, and definitely gets the job done well. If all you need is one or two input or output bits on a PC, the serial port has advantages. It's usually got more resistance to ESD than a printer port bit, and the logic levels are generally (excluding laptops) higher than the TTL levels of a printer port. The serial port isn't ideal for TTL-level signals (although you can actually read those too on most PCs, with the cost of losing all noise immunity -- don't do this at home), but great for reed relays, transistors, or footswitches.

If you want to do this in Windows, you'll need a driver and some other support like ActiveX controls. This is covered in another post above. In addition, you're going to have to look at latency issues. If your signals are less than 100ms. wide, or less than 100mS. apart, you may have problems doing direct "bit banging" in Windows. The software might miss something. You may want to explore the use of some of the other features of the port to detect transistions, or utilize interrupts.

One good place to look for help is "Serial Port Complete" by Jan Axelson. It's got everything you will need to program in just about any language in DOS or Windows for the serial port, with drivers and scads of program examples on the accompanying CD.

formatting link

There are many links on this page (including the one mentioned above) which can help you get the job done.

Good luck Chris

Reply to
Chris

Assumed unstated requirements:

  1. The "port monitoring" occurs on a consumer-grade desktop Wintel PC running Win2K or WinXP.
  2. The primary purpose of the PC is to host this application.
  3. Serial port access will be by means of a drop-in ActiveX control in VB, VC++, VC#, BCB, Delphi or similar application vice a custom, low-level device driver.
  4. The trigger from the detector consists of a single TTL-compatible edge (high-low or low-high transition) per event.
  5. Transition events are time-stamped and logged to disk.
  6. A transition event summary is displayed on-screen, including an instantaneous event rate and mean rates for fixed or user-selectable periods.
  7. This is a one-off product intended, at most, as a proof of concept and not a final consumer product design.

Acquire:

  1. One MAX233A level translator. Widely available. Data sheet at
    formatting link

  1. Appropriate mounting hardware, cables.

Perform:

  1. Wire-up the MAX233A with power and appropriate jumpers as per the data sheet.

  1. Connect the lightning detector circuit output to MAX233A pin 1.

  2. Connect MAX233A pin 18 to a DB-9 pin 8 (CTS) to the PC.

  1. Enable the OnCTSChange event of the ActiveX control and handle the time stamping, logging, etc. as desired.

Note that nearly simultaneous events will be recorded as a single event. The MAX233A will want a separation of about 10 usec. The interrupt latency and processing speed of the PC is TBD.

--
Rich Webb   Norfolk, VA
Reply to
Rich Webb

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.