Download the PDF of the entire series of articles on Modbus
The RS485 Modbus is certainly one of the most popular implementation thanks to its simplicity, economy and reliability in the industrial environment.
It is realized by means of a two-wire cable that connects all the devices on the network in parallel. As a Master/Slave protocol, only one Master device and one or more Slave devices will always be present:
The two-wire connection is as economical as possible but at the same time it offers excellent performance in terms of communication speed and immunity to any electromagnetic disturbance signals. This is thanks to the particular technique of using the electrical signals applied to the pair of wires that will be described below.
Bits 0/1 communication between the devices occurs by applying on the two wires of the couple a small continuous voltage whose polarity changes according to the 0/1 logic level to be transmitted:
Normally, in the absence of transmission by the device, all four switches of the transmission block are OFF and therefore both RS485 line conductors are not connected to any electrical potential. However, it is preferable not to leave the line floating and therefore a default potential is always applied, positive to A and negative to B. This polarization is obtained by connecting two resistors, one between the power supply + 5V and the signal A and another between signal B and GND reference.
When a device needs to transmit bits, it temporarily takes control of the line by switching its two-to-two diagonal switches. To transmitt a logic 0, the line is forced with A=GND and with B=+5V, while for transmitting a logic 1 the line is forced with A=+5V and with B=GND. In this way, the voltage measured between conductor A and conductor B will be +5V or -5V respectively to transmit bit 1 or bit 0.
Each device also includes a reception block that can determine the polarity of signal A relative to that of signal B. Therefore, the receiving interface is able to measure the voltage difference between pole A and pole B.
If this difference is positive (A > B) reception corresponds to logic state 1, if the difference is negative (A < B), the received logic status is 0. The reception block then allows to perform the inverse process, decoding the 0/1 information previously encoded with the transmitter block.
NOTE: the transmitter block was ideally represented by switches. In reality, these switches are made with transistors capable of switching high-speed signals. A wide range of integrated circuits have been developed as RS485 interface drivers by incorporating both the transmission and receiving parts inside them.
This driving technique of the serial line originates the name “differential signal” referring to that applied to the A/B wires of the line. Note that in a differential connection it is not strictly necessary to connect the common GND reference of a device to that of the others, as it normally happen when connecting signals between two distinct devices. In fact, in the case of the differential signal, it is not important the voltage of A or B with respect to GND, but the relative difference between A and B. Differential signals are very much used, such as in the USB connection, for their high performance associated to the maximum simplicity of the physical support.
A great advantage of the differential signals is achieved realizing the cable with a pair of conductors tightly interconnected, obtaining a high degree of equality of the two wires in terms of physical location in the space. Any interference, caused by the proximity of the line to the cables of other systems, will cause a disturbance voltage on both pair wires, injecting undesired voltages over these with the same polarity (positive or negative) respect to the reference:
The receivers of each device, which perform a voltage difference evaluation between the A and B wires, will then be able to eliminate this disturbance component because of the same sign and entity on both wires. That is why it is important that any disturbance interferes in the same way with both conductors of the line.
In the previous diagrams two 120 ohm resistors at the ends of the RS485 line were also highlighted. The purpose of these resistances is to define the load impedance in the terminal parts of the line in order to avoid that, in the propagation of signals along the wires, reflections are generated at the open ends, resulting in alteration of the signal waveform.
This phenomenon is more evident as the signal frequencies are high, but also at the lower frequencies of fieldbus usage, these effects can be noticed. Then the insertion of line termination resistors is strictly required in all applications.
In addition to the correct termination of the differential line it is very important that the connection of this to the various devices takes place in a single linear path, ie without branches. Attention to this rule must be adopted also in the point of line connection to the two terminals of each device. The cable line must be interrupted only at the terminal block of each device, tightening the incoming cable with the outcoming cable directly in the same terminals. Only the first and last device, whether Master or Slave, should also have connection to termination resistance. This resistance is usually incorporated into the devices and can be enabled by a specific switch.
The RS485 serial network makes it possible to create distributed systems by placing the various devices at considerable distances between them. The maximum length of the connection depends on many factors such as communication speed (typically from 9600 to 115200b/s for the Modbus protocol), cable quality and features of the device hardware driver.
Using specific cables for differential lines such as those produced by Belden, the maximum reachable distance is 1200m with communication speeds in the range of 10Kb/s and 100Kb/s, while, with increasing speeds up to 1Mb/s, the distance drops proportionally to 120m. These are typical specifications for cable only, but there are many other factors that depend on the particular application, such as the near environment and the accuracy of the installation, which can lead to a significant reduction in the maximum distance reached for a given communication speed.
The maximum number of devices that can be connected to the RS485 network depends primarily on the characteristics of the driver integrated circuits used in the interfaces of the individual nodes.
The EIA/TIA-485 specification requires that the transmitter circuit be capable of driving up to 32 load units where a load unit (UL) equals an impedance of about 12Kohm. The ever-evolving technologies of driver chips has introduced in the market devices capable of reaching fractions of the load unit so that the maximum number of devices can be greater than 32. For example, components with 1/2UL allow to connect up to 64 devices, while with 1/8UL up to 256 nodes can be reached. Note, however, that this data is based solely on the evaluation of the unit load, without considering the polarization resistances of the bus and many other elements of the specific application, in particular the quality and length of the connections and also the speed of communication that can substantially reduce the maximum number of devices.