Wednesday, March 23, 2016

W&T 36201 Isolated USB to RS485 Interface: Fix "automatic" RS485 Transmit mode

Some time ago, I bought three used W&T 36201 isolated USB to RS485 interfaces. They have pretty good build quality and are intended to be mounted in control cabinets (on “DIN Rails”). You can see them in this photograph, it's the blue thing.

From Chris’ Miscellanea

And while I'm pretty impressed by their build quality, I found out that even for (normally pretty expensive) industrial kit, they get the control of RS485 transmission wrong.

RS485, in short, is a pair of cables named A and B which carry a differential signal. This means that the signal in one wire should always be the inverse of the signal in the other wire: If voltage on A increases, the voltage on B should decrease. The state of the bus is “1” when the voltage on B is higher than the voltage on A, and the state of the bus is “0” when the voltage on B is lower than the voltage on A. A RS485 bus, when idle, is kept at the level corresponding to a “1” bit by the termination voltage, which pull B to a higher voltage than A, keeping an impedance of 100 Ohms on the differential pair A and B.

When data is exchanged over the bus, the first thing being transmitted is the stop bit, at “0” level, then the first byte, ... until transmission is completed. Naively, one would think that a driver only has to supply the “0” level and let go of the wires, making the termination resistors pull them to “1” again.

Unfortunately, these resistors aren't typically able to do this fast enough, especially for higher baud rates, and active drive of the bus therefore must be maintained throughout the complete transmission.

Thus, we need some control signal that tells the driver IC when to turn on its output drivers, and there are several methods for this.

  1. some RS485 adapters cheat by only transmitting the “0” in full, and only output a very short “1” runt pulse to charge up the bus, leaving maintaining the idle voltage to the termination resistors,
  2. some RS485 adapters use a serial control line (RTS, DTR) as a control signal and
  3. many USB to RS485 adapters use a signal provided by the USB-UART for exactly this purpose.
2 has the downside that one typically has problems being fast enough in switching the control lines over USB, and 3 is obviously the preferred version.

Unfortunately the W&T 36201 interfaces only do 1 and 2, so I tried to modify them to provide for 3.

Here's a (very slow) 9600 baud transmission via the unmodified interface in "automatic" mode. The driver is only activated (blue) during 0-bits.

From Chris’ Miscellanea

The used USB to UART bridge fortunately has a TXEN pin (#16), which we jumper over to the line normally carrying the #DTR (inverted) signal that can be used to implement method (2). The chip is mounted on a separate small PCB which makes working on it pretty easy:

From Chris’ Miscellanea

From Chris’ Miscellanea

Unfortunately the polarity of TXEN is high-active, but as built the converter needs #DTR to go LOW to transmit. So we use a spare gate of the HC04 hex inverter conveniently located on the baseboard. One has to scratch open the very short trace between the pullup for the optocoupler and the via left to it.

From Chris’ Miscellanea

After this modification, set the device to computer-controlled transmit control (normally DTR, now TXEN). As can be seen on the scope, now the transmitter IC drives the bus for the whole duration of a character.

From Chris’ Miscellanea