Serial Communications Using RS-485
- Paul Peterkin, Danbury, CT
Overview
TIA/EIA-485 (RS-485) is a serial digital communication medium that uses two differential balanced lines (full duplex) or a single differential balanced line (half duplex).
Full Duplex vs Half Duplex
· Full Duplex allows simultaneous transmitting and receiving between any 2 nodes. However, 4 wires (two twisted) pairs would have to be run between the nodes.
· Half Duplex allows only one node transmitter to be active at a time. Conversely only 1 twisted pair of wires is needed for half-duplex communications.
Most industrial/commercial devices (including all Preferred Utilities RS-485 products) only support half-duplex communications and we will only look at this mode for the rest of this document.
RS-485, if properly wired and configured, provides reliable data transfer up to 4000 feet using 2 wires (plus a third wire for ground connection). It’s used in industrial communications for interfacing to HMI’s, OIT’s, computers, control equipment, monitoring equipment, intra-device data transfer, among other uses. It’s wide & growing industry use is due to:
· It provides a robust communication interface which is inherently noise tolerant since it uses differential as opposed to ground referenced signals.
· It can be cheaply deployed & the cabling is simple, a single pair of wires plus a ground wire.
· As opposed to ethernet, no switches, hubs, routers, IT department setup, etc. are needed.
· Up to 32 devices can be daisy-chained together in a network. Note: New IC’s allow up to 256 nodes in a network, so check if the 32 node limit applies to your device.
· Using repeaters multiple networks can be chained together. The trade-off of too large a network is the data rate may become unreasonably low.
Typical Wiring
For a RS-485 to work properly good wiring is needed. Even though the signal transport only requires a differential pair of wires a third ground connection is usually needed. If the device isolates the communication circuitry, then a third connection is provided for the common connection. For multi-node setup, all the commons must be tied together. Controlled impedance shielded twisted pair cable is recommended and provides the best protection from inductive & capacitive coupling. Preferred Instruments recommends Belden 3106A Industrial RS-485 cable. This is a shielded cable with 1 twisted pair (22 AWG), 1 single wire for the ground connection, 120 Ω impedance, and 300 VAC insulation rating.
Notes
1. The twisted pair is used for the “ + “ and “ – “ circuits
2. RT = Termination resistor 120Ω. Not used in most applications, see below.
3. RB = Bias resistors typical values for a 5VDC power supply are 750Ω. Note that modern transceiver chips have built-in failsafe states & these may not be necessary.
4. Shield is only connected at 1 end. Depending on the source of the electrical noise, connect shield to either DC common, or to earth ground.
All commons are tied together. The figure assumes isolated communication ports. Non-isolated ports with long cable runs, are not recommended.
Connection Terminals Confusion
Due to vendor fragmentation, numerous if not directly opposite naming conventions can be found on different devices. The RS-485 Standard defines the two differential signal lines as “A” & “B”.
Signal states are defined by the difference in voltage between the two lines. When the voltage at “B” is greater than the voltage at “A” by at least 0.2V, this is a Logic 1.
Conversely, when the voltage at “A” is greater than the voltage at “B” by at least 0.2V, this is a Logic 0. Said another way:
· (Vb – Va) > +0.2V = Logic 1
· (Vb – Va) < -0.2V = Logic 0
· Voltages between +0.2 V and -0.2V are not Logic 1, nor Logic 0!! See Bias and Termination below
Some manufacturers label the “A” line as Negative (-) & the “B” line as Positive (+). Others label them exactly the opposite. Preferred Instruments uses “+” & “-“, instead of letters on all our devices or terminal strip labels.
What to do if unsure? Luckily there will be no damage to a device if the data lines are wired incorrectly, swap the lines if the device is not communicating properly. A voltmeter can be used to determine the “+’, “-“ lines correctly as follows:
1. Using a voltmeter measure the D.C. Voltage between the 2 lines noting what line the positive & negative leads are attached to.
2. If the voltage is positive the line going to the positive lead of the voltmeter is the “+” line and the other the “-“ line.
3. If the voltage is negative the line going to the positive lead is the “-“ line & the other the “+” line.
Bias
All systems with baud rates slower than ~76,800 baud, or even systems with higher baud rates, but infrequent transmissions, it is important to include Bias resistors for reliable communications.
During the pause between messages, all transmitters are turned off, and the voltage across the “A” and “B” wires decays toward 0 volts.
+0.2 to -0.2 volts is un-defined, so when the next message is sent the first byte can be corrupted. Bias resistors ensure that the cable voltage never drops below +0.2V, thus preventing these garbled messages.
Bias resistors are frequently built into “Master” devices, and may need to be enabled via jumpers or DIP switches, check the data sheet for your device.
Termination
Do NOT install terminating resistors unless the Bias resistors are installed, and are 750Ω or smaller. Terminating resistors make the cable voltage decay to 0 volts much more rapidly and can prevent communications, See the Bias Resistor section.
Frequently, devices do not specify the Bias resistor ohms. For systems at 38,400 baud or slower, and with cable lengths less than 500 ft, terminating resistors generally are not needed.
For systems with significantly faster baud rates, or with longer cable runs, Bias resistors AND terminating resistors are needed to prevent signal reflections/echoes which can garble communications. If used termination should be done at both ends of the network. The value of the terminating resistor is dependent on the line impedance of the cable used & is usually between 100 & 120 ohms. Some devices have built-in terminating resistors (usually selected by a jumper). NOTE: ONLY 2 Terminating Resistors should be used on any network.
Converting between Full & Half Duplex
Some devices provide 4 terminals for connections for either full or half duplex operation. Full vs Half Duplex mode maybe selected via software or a hardware jumper or switch. In most cases the selection is simply done by wiring the RX+/TX+ (A/Y) & RX-/TX- (B/Z) pairs together as shown below. As always check device literature for proper wiring. All Preferred Instrument devices are configured for 2-Wire half duplex unless stated otherwise.
Abbreviation:
HMI Human Machine Interface
OIT Operator Interface Terminal
TIA Telecommunications Industries Association
EIA Electronic Industries Alliance
Instrumentation and Controls | Embedded Systems Software | Mechatronics
1 年Excellent article ??
Fuel Storage Tank & Controls Contractor
7 年Nice article.