What should I pay attention to when creating a Modbus RTU network?
What is (RS485) Modbus RTU communication?
Modbus RTU is an open serial protocol derived from the master/slave architecture (now client/server) originally developed by Modicon (now Schneider Electric). It is a widely accepted protocol at the serial level because of its ease of use and reliability. Modbus RTU is widely used in building management systems (BMS) and industrial automation systems (IAS). Modbus RTU messages are a simple 16-bit structure with a cyclic-redundant checksum. The simplicity of these messages ensures reliability. Because of this simplicity, the basic 16-bit Modbus RTU register structure can be used to pack floating point, tables, ASCII text, queues and other unrelated data. This protocol mainly uses an RS-232 or RS-485 serial interface for communication and is supported by every commercial SCADA, HMI, OPC server and data acquisition software program on the market. This makes it very easy to integrate Modbus-compatible equipment into new or existing monitoring and control applications.
RS485 is a protocol similar to RS232 that is used to implement serial data communication. The two protocols use different electric signals to enable data transmission. One of the reasons that RS485 interfacing is employed in industrial settings is its ability to serve several devices attached to the same bus. This eliminates the need to have several interfaces available when querying multiple devices. You can do this by using a bus terminator, moving a switch or with a small resistor screwed onto a terminal. Care must be taken to ensure that the correct interface is being used as the RS485 and RS232 protocols are not completely compatible. You can construct a gateway between RS232 and RS485 interfaces, but usually you will see the RS485 protocol connecting directly to USB or Ethernet ports. This less expensive approach removes the requirement for any additional components to be used.
Devices using RS485 ports usually employ the Modbus protocol and provides half-duplex transmission on a balanced line covering distances of up to 1200 m. A half-duplex system is comprised of one or more transmitters and receivers where only one transmitter can be active at a time. Communication is enacted by a transmitter making a request directed at a specific receiver. The transmitter then waits a pre-determined length of time for a reply or decides that no reply will be forthcoming from the receiver.
An RS485 network is built based on a master/slave framework. The master performs the role of the transmitter, making requests to a designated slave which acts as the receiver. The master listens for the response and if not obtained in an appropriate time-frame will terminate the communication. In a Modbus RS485 network, communication begins when the master device sends a query to a connected slave. A slave device spends its time monitoring the network for queries specifically addressed to it. When a query is received, it will either perform an action or reply with a response to the master. Queries are only initiated by the master device.
The Modbus protocol affords the master the choice of addressing messages to specific slave devices or communicating with all slaves simultaneously. This is done using a special “Broadcast” address. Some products such as those from Integra and SPR do not support the use of this broadcast address. Read and write operations are sent through Modbus messages using coils. A coil consists of 16-bit words and binary registers. A slave can only respond to a received message and never initiates communication with the master.
Each slave device attached to the RS485 bus in parallel is assigned a unique Modbus slave ID. All Modbus communication begins with the slave ID being sent, either to alert a slave device to accept a query or inform the master which device supplied the reply. In the same way that RS232 connectivity works, slave and master devices need to be configured correctly. Parameters such as speed and parity need to be synchronized throughout the network.
The message format is used in Modbus communication between master and slave is defined in the protocol:
- A Modbus query is made up of the device (or broadcast) address, a function code that defines any requested action, data returned with the request, and an error-checking field.
- A Modbus response is comprised of fields that verify the requested action has been taken, data sent with the response, and an error-checking field. The slave device will create an error message as its response if it is unable to fulfil the request or if errors impacted the receipt of the message.
Modbus RTU (Remote Terminal Unit) mode transmits messages in a different format. Here, an 8-bit message contains two 4-bit hexadecimal characters. Data using this transmission mode is required to be sent in a continuous stream and enables better throughput for a comparable baud rate than does ASCII mode.
Modbus Network Bus Terminator or NBT
Most of the communication buses we use are specified with Network Bus Termination (NBT) or also called End of Line (EoL) in mind. It’s a line termination resistor used for the RS485/ Modbus RTU communication cable. A reflection in a transmission line is the result of an impedance discontinuity that a travelling wave sees as it propagates down the line. To minimize the reflections from the end of the network cable it is required to place a Line Termination near each of the 2 ends of the Bus. The NBT should be installed at the last device on the loop. Some Sentera devices provide an internal NBT jumper, the most recent designs offer a Modbus holding register (HR 9) where the NBT can be set or not to activate the network line termination. In case the NBT jumper or register control is not available on the device a 120Ω 1/2 W resistor between the differential pair should be placed.
Bus Terminators are not always required
In the field these terminations are not always present, especially in short runs. Do we need them? There’s an analogy that illustrates why we need end of line terminations: a bus behaves like a rope held between two people. When one person wants to talk they whip pulses down the rope towards their partner. The other person feels these pulses and figures out what the message means. Those pulses don’t go away, though, they’ll reflect back at the person who whipped it down the line. It’ll keep reflecting back and forth, a little weaker each time as losses eat it up. These reflections are confusing to both people, who waste time trying to decode this false message over and over again. A bus terminated on both ends is like a rope fixed on either side with springs. When the pulses reach the end, the person there can feel them and then the pulses are absorbed by the springs. If the springs are appropriately sized, the pulses will be “fully dampened” and there will be no reflection back.
Since we’re typically using RS-485, the end of line termination is selected based on something called the characteristic impedance of the cable you’re using. This is something the manufacturer stamps on the box the cable comes in, so it’s no secret. Typically we use something around 108-120 ohms. You don’t need to use exactly that value, but try to be close and don’t use resistors that are much less than it!
Do you always need an end of line termination? Not really, no. It depends on two things: communication speed (baud rate) and bus length. The lower your baud rate, the less reflection will matter. The greater the distance, the more reflection will matter. High speed buses are much more sensitive because everything happens at a much lower time scale. A single bit transferred at 38400 bps lasts only 26 microseconds. For a 9600 bps, it’s 104 microseconds. A voltage spike in the wrong place that lasts the length of one bit length can cause communication errors. Longer buses are more sensitive to reflection because any reflection will tend to dissipate after several trips back and forth down the bus. For a longer bus, that dissipation takes longer. If it’s long enough, controllers could send new messages on the bus while the older reflections are still bouncing around.
Wiring guidelines for a Modbus network
A Modbus RS485 RTU network connects a master device to one or more slave devices. Henceforth, we shall consider Slave devices to be measuring instruments with serial communication, even if the cabling is similar for all Modbus devices. 9 main rules that must be followed for the cabling of this type of network:
1. Connection port
Each device has a communication port with 2-signals which are indicated as A and /B. These two signals connect the communication cable so that all the devices that take part in the communication are connected in parallel. All the ‘A’ terminals must be connected together and all the ‘/B’ terminals must be connected together respectively. In order to avoid errors when many devices are connected, cables of the same colour should be used to connect the A-terminals and cables of the same colour should be used for all the connections to the terminals /B of the various devices (e.g. blue(/green-white) for A and green(/blue-white) for /B). Note: Inverting the ‘A’ and ‘/B’ connections of a device does not only prevent it from communicating but may also stop the entire communication system from working owing to incorrect direct (polarisation) voltage found on the connections of the incorrectly connected device. This makes it easier to identify cabling errors.
2. Connection between devices
Unlike what happens in many energy distribution systems, the manner in which the devices are connected in parallel is important. The RS485 system used for Modbus communication provides a main cable (bus or backbone), to which all the devices have to be connected with branches that are as short as possible. Note: the total length must be no longer than 1200 m! Longer network communication lines could cause signal reflections and generate disturbances and consequent errors in the reception of data.
3. Maximum distance and maximum number of devices
The main cable must be no longer than 700 m! This distance does not include the branches (which must nevertheless be short). The maximum number of devices that can be connected to a main cable is 247, including the Master. Note: Keep in mind the maximum current consumption and the number of devices when PoM (Power over Modbus) is used during cabling. Consult always the datasheet information of the articles used inside the network.
4. Use of repeaters
In order to increase the extent of the Modbus network, repeaters can be used with signal amplifying and regenerating devices provided with two communication ports that transfer to each what they receive from the other. Using a repeater, the main cable is divided into different segments and connect 32 devices (this number includes the repeaters). The maximum number of repeaters that should be serially connected is 3. A higher number introduces excessive delays in the communication system.
5. Type of cable to be used
The cable to be used is shielded twisted pair like UTP cat 5e or cat6 cable, but different types of cable with equivalent characteristics can be used. The twin consists of two conductors that are twisted together. The shielding may be braided (be formed by a mesh of thin conducting wires) or be a foil (consisting of a sheet of metal wound around the conductors). Note: This arrangement improves immunity to electromagnetic disturbances because the cable forms a series of successive coils, each of which faces in the opposite direction to the next one. In this manner any magnetic field of the environment traverses each pair of coils in opposite directions and its effect thus very reduced (theoretically, the effect on each coil is exactly the opposite of the effect on the next one thus the effect is cancelled)
6. Connecting devices
In some countries, inserting two cables into the same screw terminal is permitted. In this case it is possible to connect the main inlet and outlet terminal directly to the terminals of an article without creating a branch. If on the other hand each terminal can accept only a single cable, a proper branch must be created using three auxiliary terminals for each article to be connected. Consult with our sales peoples for correct adapter article to be used (like ADPT-3RJ-TB). In case of connecting devices with shielded twisted pair and RJ45 connectors the is no such problem.
7. Earth connection of the shield
The cable shield must be earthed only in one point. Normally, this connection is made at one end of the main cable.
8. Network Bus Termination resistance
In order to avoid signal reflections, a 120 Ohm termination resistance must be fitted on each end of the main cable. The end resistance must be used only at the ends of the main cable. If the total length of the main cable is less than 50 m termination resistances can be avoided at the ends of the main cable.
9. Connection to PC or SenteraWeb
If the master used is a personal computer or when the network cabling needs to be verified before commissioning, a USB to RS485 serial converter (CNVT-USB-RS485-V2) provides the connection to the bus to check proper wiring and functionality. In case of connection with internet is needed an Internet Gateway article can be inserted inside the Modbus RTU network as a communication bridge to connect to SenteraWeb. This option gives you complete freedom connecting to installed devices from any location. Please consult directly with our sales department for correct article codes.