Electrical – Checking the voltage of serial port

rs232serial

I'm currently working on a project that requires me to check if a device is still connected on an RS232 port. Since I do not have access to the code on the connected device(it is a fire alarm panel), I cannot have it transmit a keep alive signal. So I'm just wondering if I could check the voltage of the DCD pins and use that the check if the connection is broken. Thanks.

Best Answer

It depends:

  • What sort of disconnection are you trying to detect? Wire cut, unpluged, etc.?
  • Do you only care about RX and GND on your end or what will happen if TX is cut? i.e. Do you have to transmit to the remote device.

Assuming that you only need to monitor the RX line you can put an opto-isolator LED (and resistor) across the line to monitor the status.

enter image description here

Figure 1. An RS232 mini-tester.

RS232 signal levels can be monitored visually by means of LEDs (and suitable series resistors) connected between each line and GND. This principle is used in the mini-testers shown in Figure 1.

In your application you would use an opto-isolator instead of the visible LED.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 2. Opto-isolator monitor for RS232 line.

How it works:

  • In idle condition the alarm TX line will be pulled negative. D1 will turn on and switch on Q1, pulling the GPIO low. The GPIO will require a pull-up and this can usually be configured in the micro.
  • On loss of connection the LED will turn off.
  • On transmission of data the LED will also turn off for any '0' bit transmitted. Worst case is all eight bits low so the monitor will have to allow for that.
  • Bi-polar opto-isolators are available with back to back LEDs internally. This would be the preferred option as:
    1. It eliminates any polarity concerns when building the circuit.
    2. It will keep Q1 turned on during '0' and '1' bits. You now just have to add enough delay to cover the transition from one state to the other.

schematic

simulate this circuit

*Figure 3. Revised schematic showing bipolar LED and Vince Patton's filter capacitor. (See comments.)


Note that the opto-isolated monitor allows complete electrical isolation between the RS232 and monitor electronics. This will avoid any ground-loop problems, etc.


Watchdog option

An idea worth considering is to examine the possibility of converting one of the alarm panel inputs into a watchdog input. This will work if you can configure an input to transmit an RS232 event without setting off the alarm. Now you have your "keep-alive" signal.

Related Topic