RS232 to RS485 Conversion: There and Back Again

 

image

RS232 and RS485 conversion can allow you to convert a serial port to a multi-drop network.  Both electrical standards were designed to allow serial communication to be transmitted over long wires while maintaining immunity to noise.  RS232 is a point-to-point connection where logic signals are converted to +/- 5 to 12VDC (logic 1 is represented by a negative voltage, and logic 0 by a positive voltage).  It is primarily used when two devices need to communicate, and was common on PCs prior to USB ports.  RS485 provides a pair of wires where the differential voltage determines the serial data on the bus.  RS485 is generally better for longer wire runs, and can be used to create a network with multiple devices on the bus.  RS485 comes in two flavors, half-duplex and full-duplex, with full-duplex more appropriate for communication between just two devices.   RS485 is popular in industrial control settings.

Here are a couple of diagrams comparing the two types of communication buses.

image

image

With half-duplex RS485 when a device needs to send data it needs to assert a “drive enable” pin on the RS485 IC.  When drive enable is not asserted the RS485 is listening for data (in receive mode).  You can get around the need for a separate i/o dedicated to the drive enable connection by placing an inverter between the drive enable pin and the data you are transmitting (which is connected to the RS485 “data in” pin).   This causes the RS485 chip to transmit only logic “0”s.   When a logic “1” is sent all of the RS485 ICs on the bus are in receive mode and are outputting a logic 1 anyway.

There’s a downside to the inverter trick.  You need to keep and eye on the propagation delay that occurs when the drive enable pin is asserted.  This delay will clip the leading edge of your logic “0” causing the data baud rate to shift.  So you normally only want to use this trick when your baud rates can be low.  You also lose some noise immunity since you are only driving logic “0” signals, and logic “1”s are created by operating in receive mode.

On the boards shown above we used the MAX3221 (RS232 converter) and the MAX13430 (RS485 converter) to convert between logic levels (3-5V logic) and RS232 and RS485.  We sent serial data at 4800BPS from an Arduino Uno to one module which converted the data to RS485.  The second module received the RS485 data and converted it to RS232 data which was sent to Microsoft’s Hyperterminal program.

All in all the design worked pretty well.  There are still some tests that need to be done, but we’ll likely manufacture these simple circuits for resale.   There’s one particular issue that needs to be figured out before we can move forward.

The MAX3221 has a neat RS232 auto-detect feature.  If it doesn’t see a valid RS232 signal on it’s RS232 input it sets its digital outputs to high impedance.  This is a great feature because if you want to use the module for TTL to RS485 conversion you don’t want the RS232 chip driving your logic level output pin and creating short circuits.  This was something planned into the design.  However, if you try to connect two of these modules together to create an RS232 link neither one of the modules will turn on its RS232 circuitry because neither one sees a valid signal.  So you get this chicken and egg thing where the modules won’t work together.  Its an interesting problem, and yet another example of why we build prototypes.

Speak Your Mind

*