Sunday, May 4, 2008

RS232-RS485 Converter

When you need to convert your serial communication from RS232 to RS422/RS485 or when you need to communicate to an RS485 device from a computer that uses RS232, you can use RS485 converter. This kind of converters are easily available. As an example, IC-485SN bidirectional converter is shown in the following figures.




As shown in the first figure, this RS485 converter can be configured by using two switches.
The first switch is used to select device mode. If the RS232 side (where DB25 Female connector is located) is connected to a Computer or a Data Terminal Equipment, it must switch to DTE. If that side is connected to a modem or a device (data communication equipment), it must switch to DCE.
The second switch is used to select transmitting and receiving mode.

1. TxON, RxON Mode


TxON, RxON is used for point to point operations. Transmit driver is always enabled and it is also always receiving. We can say, it is converting from RS232 to RS422. In RS232 side, RTS and CTS, DTR and DSR are loopback connected.
RS485 side connections are as follow:


Pin 1 = Tx+
Pin 2 = Tx-
Pin 3 = Rx-
Pin 4 = Rx+


2. TxRTS, RxON Mode


TxRTS, RxON is used for multidrop operations. Although it is always receiving, transmit driver is enabled only when RTS is high. For a DCE, CTS must be used instead of RTS. It can be used as four wire RS485 full duplex communication. In RS232 side, RTS and CTS, DTR and DSR are loopback connected.
RS485 side connections are as follow:


Pin 1 = Tx+
Pin 2 = Tx-
Pin 3 = Rx-
Pin 4 = Rx+


3. TxDTR/RTS, RxDSR/ON Mode


TxDTR/RTS, RxDSR/ON is used for RS485 half duplex communication. For a DTE, transmit drivers for data lines and busy lines are enabled only when RTS is true. When DTR is true, busy signal will be transmitted. On the receiving side, DSR will be true when a busy signal is received. For a DCE, CTS must be used instead of RTS. And DTR and DSR are inverse. In RS232 side, only RTS and CTS are loopback connected.
RS485 side connections are as follow:


Pin 1 = Data+
Pin 2 = Data-
Pin 3 = Busy-
Pin 4 = Busy+

The connections for DB 9 female and DB25 male Cable are as follow


Female DB9 -------------- Male DB25
pin 1 ---------------------- pin 8 .......... Black
pin 2 ---------------------- pin 3 .......... Brown
pin 3 ---------------------- pin 2 .......... Red
pin 4 ---------------------- pin 20 ........ Orange
pin 5 ---------------------- pin 7 .......... Yellow
pin 6 ---------------------- pin 6 .......... Green
pin 7 ---------------------- pin 4 .......... Blue
pin 8 ---------------------- pin 5 .......... Magenta
pin 9 ---------------------- pin 22 ........ Gray