Connect with us

View Data On RS-232 Port

Discussion in 'Electronic Basics' started by Jim Douglas, Apr 17, 2005.

Scroll to continue with content
  1. Jim Douglas

    Jim Douglas Guest

    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
     
  2. Rich Webb

    Rich Webb Guest

    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
    http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1798

    2. Appropriate mounting hardware, cables.

    Perform:

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

    2. 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.

    3. 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.
     
  3. Chris

    Chris Guest

    [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

    http://www.beyondlogic.org/serial/serial.htm

    (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.

    http://www.lvr.com/serport.htm

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

    Good luck
    Chris
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-