The Modbus protocol is widely used in the field of industrial automation. Its main derivative forms are Modbus RTU (Remote Terminal Unit) and Modbus TCP (Transmission Control Protocol), which are used for serial bus and Ethernet transmission respectively. Although the two belong to the Modbus family, there are significant differences in the physical layer, data encapsulation, communication reliability, etc.
Our company has a rich and complete Modbus equipment. For Modbus RTU, you can refer to the MA01 series, Modbus TCP can refer to the serial port server series, and Modbus RTU and TCP integration can refer to the distributed IO series.
1. Physical layer and transmission medium
Modbus RTU
Relying on RS-485 (or RS-232) serial communication, bus topology, the typical baud rate is in the range of 9600 to 115200 bps.
The RS-485 bus can realize half-duplex multi-point communication, allowing up to 32 devices in parallel, and the bus length can reach about 1200 meters under ideal conditions.
Modbus TCP
Runs on the Ethernet physical layer and transmits data based on the TCP/IP protocol stack. Industrial Ethernet switches, routers or wireless LANs can be used to increase network coverage and transmission speed.
Theoretically, it supports 100 Mbps, 1 Gbps or higher rates. The transmission distance is limited by the network equipment and link architecture. The LAN environment can achieve coverage of several kilometers, and cross-segment global remote connection can be achieved.
2.Protocol frame structure and encapsulation method
Modbus RTU frame format
It consists of "silent interval (at least 3.5 characters) → slave address (1 byte) → function code (1 byte) → data field (N bytes) → CRC check (2 bytes)".
CRC (cyclic redundancy check) is used to detect bit errors during data transmission. If the idle time between frames exceeds the specified threshold, it will be regarded as the start of a new frame.
Modbus TCP frame format
Modbus protocol data is embedded in the TCP message. The typical structure is:
1) MBAP (Modbus Application Protocol Header, 7 bytes): transaction identifier (2 bytes), protocol identifier (2 bytes, fixed to 0), length field (2 bytes, used to indicate the number of subsequent bytes), unit identifier (1 byte, used to be compatible with traditional slave addresses).
2) PDU (Protocol Data Unit, N bytes): Contains function code (1 byte) and data field (N-1 bytes).
Since TCP itself has a checksum and retransmission mechanism, Modbus TCP frames do not require additional CRC checks. Frame boundaries are managed by TCP flow control and do not rely on silent intervals.
The MBAP header adds addressing and transaction processing capabilities, allowing multiple clients to distinguish between their requests and responses when accessing the same slave device concurrently.
3. Communication reliability and real-time performance
Modbus RTU
Serial bus communication has low latency, and the protocol itself has controllable latency, but the bus topology is prone to signal attenuation and frame errors due to too many nodes or wiring quality problems.
Due to the CRC checksum mechanism, erroneous data can be identified and discarded to a certain extent. Usually, in sites with a limited number of devices, the performance is stable when the bus load is not high.
It is very sensitive to the idle time between frames. If there is "jitter" between the host and the slave or the cable is in poor contact, communication interruption or retransmission may occur.
Modbus TCP
Based on Ethernet and TCP protocols, congestion control and retransmission mechanisms can improve data integrity. However, this will also introduce additional handshake delays and confirmation delays, and the overall delay is slightly higher than RTU.
In an environment with a reasonable network architecture and standardized switch and router configurations, the packet loss rate is extremely low and retransmission is possible, which can achieve high reliability. This is particularly suitable for large-scale concurrent access and remote monitoring.