Homebuilt underwater robot

 

RS485 to RS232 converter

Converter is intended to use with PC computer to communicate with ROV using 2 wires in half duplex mode. Send/receive mode is selected by RTS signal. The converter was designed to be as simple as possible, so it has no some features that can be found in commercial grade products (e.g. galvanic separation).

I do not describe here RS485 standard, for more information and how to use RS485 with micro controller please read RS485 article.

RS485/RS232 Converter: Prototype deviceRS485/RS232 Converter: Prototype device

Overview

Popular chip MAX232 is used to convert RS232 signals from/to TTL level. MAX485 converts TTL level signals to RS485 standard. RTS line is used to change transmission mode of MAX485. RTS signal is first converted to TTL level by MAX232 then connected to DE and RE/ pins.
2 LED are used to indicate current state of the interface.

Schematic of RS485 converterSchematic of RS485 converter

PCB

Single layered, size is 63x48mm. PCB artwork, schematic and part list is available as PDF documents at the end of this article.

RS485 converter: Top viewRS485 converter: Top view

Testing

After soldering all the elements, power the device. Red LED (LED1) should be bright. Check voltage between pins 15 & 16 of MAX232 and between pins 5 & 8 of MAX485. It should be 5V.

Initial test

This test is just to prove that some parts of the converter works. It needs only PC computer; another RS485 device is not required at this stage.

Connect your PC computer with converter using RS232 cable. Run Hyperterminal in Windows or any other terminal program, set 9600bps, 8N1 and handshaking None. When you click hook on and hook off icons you should notice change in green LED.

Click hook on icon and type anything in terminal window, green LED should blink.

Hyperterminal hook on/off iconsHyperterminal hook on/off icons

Real test

To see if converter works well some data must be properly sent and received. For the real test you need another device with RS485 interface. You can built simple test board as shown in RS485 article (AVR chip + MAX485).

If you have two RS485 interfaces you can check interface using simpler method. Just connect two interfaces, run 2 terminal programs and see if one terminal program can receive what you type in the other window. You must remember to switch appropriate send/receive mode for both interfaces (set appropriate state of RTS signal).

When the converter is in TX mode and transmits data you can notice voltage change between A-B pins.

If you want to test converter with ROV Control Unit full description and test programs are available in RS485 communication test article.

Programming

From programmers point of view data transmission through RS485 is the same as serial port transmission. The only difference is that you have to set appropriate state of RTS line before sending/receiving any data. Because RTS line is very often used in half-duplex converters to switch TX/RX mode, many programs can be used without any modifications.

Transmission modes of converter:
RTS high - you can receive data
RTS low - you can send data

For Win32 API (MS Windows) when you setup serial port set manual control of RTS line in DCB structure.

dcb.fRtsControl = RTS_CONTROL_ENABLE; //manual RTS control & RTS initally high

dcb.fRtsControl = RTS_CONTROL_DISABLE; //manual RTS control & RTS initally low

Before transmission set appropriate RTS state:
To receive data set RTS high:

EscapeCommFunction(hSerialPortHandle, SETRTS);

To send data set RTS low:
EscapeCommFunction(hSerialPortHandle, CLRRTS);

Green LED indicates current status of RTS line.


AttachmentSize
RS485_to_RS232_Converter_Schematic.pdf38.5 KB
RS485_to_RS232_Converter_Elements.pdf59.61 KB
RS485_to_RS232_Converter_BOM.pdf43.22 KB
RS485_to_RS232_Converter_PCB.pdf50.35 KB