Exploring the differences between Modbus RTU and Modbus TCP protocols

In the 1970s, the field of industrial automation was in a period of rapid development. The rapid development of the industry also brought some problems, at that time, different manufacturers of equipment used different protocols which made their equipment unable to communicate with each other.

To solve this problem, the Modbus protocol was created. It is an open, standardized protocol that can support a variety of data types and function codes to meet different communication needs. Modbus-protocol has 3 types, including ASCII, RTU, and TCP. When Modbus protocol uses serial port transmission, the first two types can be selected, but the data needs to be checked. When Ethernet transmission is used, the TCP type is used, which does not require checksums. Modbus ASCII is less commonly used due to the inefficiency of transmitting data using mainly ASCII codes. In contrast, Modbus RTU and Modbus TCP are more suitable for use in modern industrial environments that require higher transmission efficiency. In this article, we will analyze these two protocols, introduce their working principles and application scenarios, and hope to be helpful to you.

modBus1

Modbus Communication Principle

Modbus communication is the principle like this, it uses master-slave communication mode. It means that there are master and slave devices, and the master device can initialize the transmission and then send a request to the slave device. The slave device cannot answer the request actively, but can only answer according to the request of the master device. The slave device then performs the requested operation and then sends a response to the master device. The master device receives the response and parses it, thus completing the communication process. A master device can be connected to one or more slave devices at the same time, but there can only be one master device and one slave device in one communication. If a master device connects to one slave device, they communicate with each other in unicast mode. However, if the master device is connected to more than one slave device, it is necessary to select the broadcast mode for communication.

How Modbus RTU works

modbusRTU

Modbus RTU supports a variety of electrical interfaces, such as RS 232, RS 485 and RS 422. It transmits data in binary form, and each byte contains two 4-bit hexadecimal numbers. RTU protocol commands consist of 5 parts: address code, function code, start address, data, and check code. For example, send instruction: 01 03 76 83 00 0C AE 6F, where 01 is the address code, on behalf of the slave address; 03 is the function code, which means “read”; 76 83 is the address of the register; 00 0C is the number of read registers; AE 6F represents the CRC checksum.

Modbus RTU Toepassingsscenario's

Because Modbus RTU is simple and stable in binary form for data transmission. So it is very suitable for long-distance communication, difficult wiring scenarios, or scenarios with a wide distribution of devices. For example, industrial automation scenarios, small control systems, etc.

Modbus TCP Working Principle

modbusTCP

Modbus TCP is created for Modbus data can be transmitted on Ethernet, using the TCP502 port. Modbus TCP is based on Modbus RTU, plus the MBAP header. Since TCP is based on a reliable connection service, it no longer uses CRC checksums but relies on TCP’s own error detection and correction mechanisms. For example, send the command: 68 68 00 00 00 06 01 03 33 65 00 04. Among them, 68 68 is the message sequence number; 00 00 indicates that it is the Modbus TCP protocol used; 00 06 indicates the number of subsequent bytes; 01 is the slave address; 03 is the function code; 33 65 indicates the register address; 00 04 is the number of registers.

Modbus TCP Toepassingsscenario's

Modbus TCP is often used in more complex scenarios because of its high transmission speed and reliability. For example, large control systems, building control systems, etc.

In practice, we need to consider whether to use Modbus RTU or Modbus TCP protocol. If you have an existing network infrastructure, need to exchange large amounts of data, fast response, TCP is a good choice. If you need simple, low-cost, long-distance communication, then using RTU is a wise choice.

Modbus RTU and Modbus TCP are like a pair of good friends, they each have their advantages, and together they help the effective data exchange between devices. With the development of Industry 4.0, they will be integrated into more new technologies. Let’s look forward to the future, they will create more value for the development of industrial automation!

 

Neem contact met ons op