The RS232 and RS485 standards, although old, are still used in various applications, from point of sale peripherals, electronic measuring instruments and industrial automation. Since modern PCs only have USB ports for communication with key peripheral, conversion of USB to RS232 or RS485 standards is a fairly common practice. More information on the standards can be found at: http://www.lammertbies.nl/comm/info/RS-485.html.
USB-RS485 converters are easy to be purchased from the Web, but do not expect it to be easy to find one for sale in the electronic and computer shops, at least here in Rio de Janeiro. Conversely USB-RS232 converters are much easier to find anywhere.
This article has two objectives: To discuss the operation of converters USB-RS485 and USB-RS232 and show how to modify a USB-RS232 converter for USB-RS485.
Recently I needed another USB-RS485 converter for my projects but did not want to wait it to arrive from China or Hong Kong … A relatively easy method (if you have the components) is to buy a USB-RS232 converter (which as I said earlier are much easier to find) and buy or build a RS232-RS485 converter, then this is what you have at the end:
USB (PC) → TTL → RS232 → RS232 → TTL → RS485
Particularly I don´t like the idea of having to convert to RS-232, and even add (besides the RS485 transceiver) an RS232 transceiver to the game, thats what I would like:
USB (PC) → TTL → RS485
To do that we can buy a USB-RS232 converter and obviously modify it. Besides circuit leaner and less consumption what is gained by this is that we can add some bonuses in our hacked converter, such as:
- Input for external power supply with voltage regulator
- Jumper to activate the bus terminator resistor
- Jumper to enable biasing resistors bus
- Optical Isolation (not implemented in this project)
Most USB-RS232 “converter cables” use PL2303 (Prolific) chip or FT232 (FTDI) chip on the USB → TTL side, then use a complete RS232 transceiver (eg MAX213) on the TTL → RS232 side. What we will do as you can imagine is to remove the MAX213 and connect the RS485 transceiver in his place, directly in the FT232 or PL2303, as appropriate. To make this hack you will need:
- A USB-RS232 converter based on FT232 or PL2303 chips (all I’ve seen so far)
- A 7805 voltage Regulator
- A RS-485 transceiver chip (MAX485, LTC485, DS1487, 75176B and many, many others)
- A 555 (only if the purchased cable is based on PL2303)
- Some simple resistors and capacitors
It is then removed the DB-9 connector and MAX213, adding the circuit below (done in Eagle, but only the schematic). Note that we connect the circuit to positive (+5 V), ground (GND) and pin 1 (TX) and 5 (RX) of PL2303:
In the photo below we have the circuit mounted on a universal board with four wires connected to the converter. Note the external power connectors (blue) and RS485 bus (green) placed at the ends of the board. The circuit pictured below was the first version, and differs slightly from the diagram shown above (actual and improved version).
If your USB-RS232 converter is based on FT232, the circuit is simpler, but note that in this case we will use a connection to pin 13 of the FT232.
The JP3 and JP1 jumpers make the connection of biasing resistors, according to the standard and essential to the operation of the circuit in the case of the converter based on PL2303. In the RS485 bus is necessary that only one device do polarization.
The JP2 jumper connects the terminator (120 ohms) that it is necessary on the ends of the bus, according to the standard.
The JP4 jumper is used to select between USB power by itself or through external source. If many devices are connected to the bus is recommended to use external source.
The RS485 is a half-duplex bus. The control of transmission and reception is done generally through a single line. The pins enabling the transceiver buffers (pins 2 and 3) are linked together in this line because they operate in different logic levels (‘1 ‘for TX and ‘0’ for RX). In the circuit for the FT232 this line can connect directly to the line pin 13 of FT232 because this (when in its default setting) places the pin 13 at logic level 1 when transmitting data, ie, FT232 already has a specific pin which can be used to control transmission and reception of an external transceiver. In the circuit for the PL2303 note that the difference is the use of 555 chip. The 555 operates as a monoastável (timer) and has a very interesting way to avoid the use of jumpers to select the baud rate. This circuit was based on Circuit Cellar magazine 177 (June 1999) as shown below: