I want to send data a cross an RS485 connection between a MB Connect Line device and one or more RS485 devices.
How can I do that?
The most common cause of RS485 connection problems is cabling. There are two types of RS485 connection, "2-Wire" and "4-Wire". Here are some examples showing both types of connections:
In two-wire mode, the devices operate in half duplex mode: one pair of wires shares transmit and receive signals, and a third wire can be used for shield/signal ground. A termination resister of 120W is placed on the beginning and end of the RS485-bus. To cover long distances at high data rates bias resisters might be required
The main advantage of using two-wire mode is reduced cabling costs See below examples of a RS248-2W bus network.
On a two-wire RS-485 network, the device server must turn its transmitter on when it is ready to send data and then off a certain period of time after the data has been sent so that the line is available to receive again. At most baud rate settings, the timing delay is typically one character length with a maximum of 1.5 character lengths.
NOTE: In some implementations, for 600 baud and 4800 baud operation, the timing delay is doubled.
In four-wire mode, the nodes operate in full duplex: one pair of wires functions as the transmit pair, another pair of wires functions as the receive pair, and there is a shield/signal ground wire for each pair. There can be only one node transmitting on each of the wire pares In most cases a four-wire RS-485 network, consists of a master while the other nodes are slaves (listeners) as can be seen below.
It is important to connect the transmitter of the master device to the wire that is connected to the receive terminals on the slave devices, and connect the receiver of the master device to the wire that is connected to the transmit terminals on the slave devices. A protocol or addressing scheme is required to prevent multiple nodes sending on the same wire pair. A slave can become master after the Master relinquish control and become a slave. So the role of master/slave is not fixed per definition and depends on the application.
The advantages of four-wire mode are double the throughput of two-wire mode and a guaranteed open path to each slave device’s receiver.
Grounding and preventing ground loops:
As discussed previous it is important to connect the signal ground/shield of all nodes. This will ensure that the reference for decoding the received signal is equal for all nodes. To prevent excessive ground currents a 100W/0.5W resister can be added for all nodes. Please see the picture below. One other way to prevent ground loops only connect one end of the shield wire to ground. As mbConnectLine devices shield and chassis ground are hard wired together, the only option to prevent ground loops between 2 mb Connect devices is either to isolate one of the units from the DIN-rail or use the 100W/0.5W resisters as proposed above.
While termination resisters are not required for short distances as long as the return delay is far less than a single bit-time, its recommended to apply them anyhow as they eliminate the effect of signal reflections. These signal reflections can deform the original signal to such extend that the receiver is unable to decode it correctly, resulting in data errors. It is strongly recommend to use termination resistors when using multi-drop network where you connect more than 2 nodes on the RS485 bus. The termination resisters are chosen to be equal or slightly larger (+10%) than the characteristic impedance of the cable. For twisted-pair the characteristic impedance is usually 120W. Please appreciate that the connections to the bus should be a short as possible.
Please see the picture below for how to implement termination resisters in a four-wire RS485 or RS422 bus.
On some RS485 devices the terminals are labelled TXA, TXB, RXA and RXB to comply with the EIA-485 specification. Other RS485 devices label the same terminals TX-, TX+, RX- and RX+. Both types of labelling are widely used in the industry.
When an RS-485 network is in an idle state, all nodes are in listen (receive) mode. Under this condition there are no active drivers on the network. All drivers are tri-stated. Without anything driving the network, the state of the line is unknown. If the voltage level at the receiver’s A and B inputs is less than ±200 mV the logic level at the output of the receivers will be the value of the last bit received. In order to maintain the proper idle voltage state, bias resistors must be applied to force the data lines to the idle condition. Bias resistors are nothing more than a pullup resistor on the data B-line (typically to 5 volts) and a pulldown (to ground) on the data A-line. The figure on the right illustrates the placement of bias resistors on a transceiver in a two wire configuration.
Calculating Bias resister example:
Assume that each RS-485 node has a load impedance of 12KΩ. 12 nodes in parallel gives a total load of 1kΩ. In order to maintain at least 200 mV across 1kΩ we need a current of 200 µA. To generate this current from a 5V supply requires a total resistance of 25kΩ maximum. Since the receiver sees a load of 1kΩ the bias resistors should be 12KΩ or less.
Note that very little bias current is required in systems without termination.
Bias resistors can be placed anywhere in the network or can be split among multiple nodes. The parallel combination of all bias resistors in a system must be equal to or less than the calculated biasing requirements.
Note that in an RS-485four-wire configuration, the bias resistors should be placed on the receiver lines.
Thing get more complicated when:
- You are using cables longer than 10 feet or 3 meter,
- Running high data rates,
- Connect multiple RS485 devices into a RS485-bus,
- There is some source of electrical noise nearby.
One common symptom of serial data transmission problems is Framing Errors
A framing error indicates that at least one character in the data stream was garbled.
Framing errors can be caused by:
- Cable problems. Check to make sure all connections are tight and that you're using a good quality cable wired per the above diagram. Bad serial port(s). Try replacing the RS485 devices one at a time with a known good device. If you're doing multi-drop RS485 then any one device with a bad serial port can cause problems for all the other devices on that cable.
- Termination and/or biasing problems. This is usually only a problem if the cable is fairly long or if there are lots of RS485 devices on the same cable.
- Electrical Noise. If there is an electric motor, high voltage power line, radio transmitter, microwave oven or other source of electrical noise near the device server, the cable or the connected serial device(s) it may cause framing errors.
- Misconfigured serial ports. If one serial port is set to 7 bit, even parity and the other is set to 8 bit, no parity (for instance) then one of the symptoms may be framing errors.
- A ground loop. If more than one device on the RS485 cable connects the shield to ground it can cause a ground loop. A ground loop can interfere with data by distorting the RS485 signal. If the shield is grounded in the middle of the cable (because it's accidentally touching some grounded metal object for instance) it can also cause a ground loop.