DIAGRAMA Conversor R232 422

6
RS485 to RS232 converter ROV RS485 RS232 MAX485 MAX232 06 Dec 2006 RS485 is an alternatve for RS232 for long distances. Maximum length of the cable for RS232 is only 15m. For RS485 it is about 1200m. In addition you can connect many devices to RS485 bus (unlike RS232 — only 2). 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). 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 LEDs are used to indicate current state of the interface.

Transcript of DIAGRAMA Conversor R232 422

Page 1: DIAGRAMA Conversor R232 422

RS485 to RS232 converterROVRS485RS232MAX485MAX23206 Dec 2006

RS485 is an alternatve for RS232 for long distances. Maximum length of the cable for RS232 is only 15m. For RS485 it is about 1200m. In addition you can connect many devices to RS485 bus (unlike RS232 — only 2).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).OverviewPopular 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 LEDs are used to indicate current state of the interface.

Page 2: DIAGRAMA Conversor R232 422

DuplexIf your control system needs to receiving and sending data in the same time you must use full duplex transmission mode. It is possible (and in real world this is the most popular case) that control system first sends request message and than waits for the response. For this kind of

Page 3: DIAGRAMA Conversor R232 422

systems half duplex communication is sufficient. This interface operates in half duplex mode at it only require 2 wires (full duplex 4 wires) and is simpler to build.TerminatorRS485 bus must be terminated on the ends for long lines. By default it is [b]120Ω[/b] resistor. If there are more then 2 devices on the bus, terminator is needed only on the first and last unit. Terminator can be omitted for short lines.

PCBSingle layered, size is 63×48mm. PCB artwork, the schematic and part list is available as PDF documents at the end of this article.

TestingAfter soldering all the elements, power the device. Red LED (LED2) should be bright. Check voltage between pins 15 & 16 of MAX232 and between pins 5 & 8 of MAX485. It should be 5V.Initial testThis 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.

Page 4: DIAGRAMA Conversor R232 422

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, the voltage between CON2-1 and CON2-2 should change quickly.Note You can use any other serial terminal program.

Real testTo see if converter works well some data must be properly sent and received. For the real test you need another device with RS485 interface.

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.

ProgrammingFrom 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 dataRTS low – you can send dataFor 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 highdcb.fRtsControl = RTS_CONTROL_DISABLE; //manual RTS control & RTS initally low

Page 5: DIAGRAMA Conversor R232 422

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 the current status of RTS line.

Esquema conversor

Se trata de un convertidor de niveles RS232 (puerto serie) a RS422 (señales diferenciales).Como se puede ver en el esquema se trata de un clásico max232,(aunque yo he usado el Sp3232ECP) para convertir niveles de puerto com a niveles TTL, y seguido de un circuito conversor SP490ECN de la casa Sipex que convierte las señales serie Tx y Rx a señales +Tx -Tx y +Rx - Rx para el protocolo RS422.Son dos señales diferenciales,es decir estan equilibradas y su suma tiene el valor absoluto cero.Si predomina una sobre la otra se interpreta un uno o cero lógico segun el valor que predomine.Tiene muchas utilidades para la transmision a

Page 6: DIAGRAMA Conversor R232 422

larga distancia o en ambientes de alto ruido eléctrico e interferencias,yo por ejemplo lo uso para comunicar una LCB_II de OTIS con el programa SVT, un emulador de test tool para PC.La he fabricado en circuito impreso de pruebas de prototipo (Protoboard) y la he "encerrado" en una caja de filtro para teléfono de "Timofonica", ver fotos.