SEARCH

— 葡萄酒 | 威士忌 | 白兰地 | 啤酒 —

Understanding Modbus RTU, ASCII, and TCP: Key Differences and Applications in Industrial Communication

BLOG 630
Understanding Modbus RTU, ASCII, and TCP

Understanding Modbus RTU, ASCII, and TCP

Differences between Modbus RTU and Modbus ASCII protocols, both based on serial physical layer:

RTU stands for Remote Terminal Unit, while ASCII is the American Standard Code for Information Interchange. ASCII is a character representation format that encodes text editing symbols, uppercase and lowercase letters, numbers, and some invisible control characters. It includes 127 character codes, excluding the null character.
Modbus uses a master-slave protocol for communication. The client acts as the master, sending requests to the server, and the server (slave) responds to the master’s requests. The communication frame used is called the Application Data Unit (ADU), which includes address, function code, data, and error check segments.
The function code and data segments together are called the Protocol Data Unit (PDU). The function code occupies one byte, with values ranging from 1 to 255. Values 128-255 are reserved for exception message response frames. Function codes 1-127 are used for numbering, with 65-72 and 100-110 being user-defined codes.
a. Address field: Refers to the address of the device on the bus node. Valid addresses range from 0-247, with 0 being the broadcast address. Node device addresses can be selected from 1-247, and each address on the bus node must be unique.
b. Function code: Specifies the action to be performed by the server.
c. Data field: Contains request and response parameters.
d. Error check: The calculation result of “redundancy check” on the message content (Modbus RTU uses CRC check, Modbus ASCII uses LRC check).

I. Modbus RTU Communication Frame

The Modbus RTU communication frame consists of slave address + function code + data + CRC check. The maximum length of the data frame is 256 bytes.
In the RTU data frame, each byte of data is defined as 8 bits. Each 8-bit byte in the message contains two 4-bit hexadecimal characters (0-9, A-F).
The character transmission format is: 1 start bit + 8 data bits + 1 parity bit + 1 stop bit. During transmission, LSB is sent first, followed by MSB.

II. Modbus ASCII Communication Frame

The Modbus ASCII communication frame consists of start + slave address + function code + data + LRC check + end. The maximum length of the data frame is 513 bytes.
Compared to Modbus RTU protocol, Modbus ASCII protocol has two main differences:

Modbus ASCII protocol has a start and end. In this protocol, the colon “:” is used as the start, and carriage return and line feed are used as the end.
In Modbus ASCII protocol, each byte of data is sent as two ASCII characters. For example, the data byte 0X5B would be encoded as two characters: 0X35=”5″ and 0X42=”B”, while Modbus RTU would directly send 0X5B.

III. Modbus TCP

Modbus TCP is essentially the same as Modbus RTU, with the main difference being that Modbus TCP protocol is transmitted over Ethernet using TCP port 502. This protocol uses TCP for the physical layer, data link layer, network layer, and transport layer. At the application layer, the Modbus protocol is modified and encapsulated into TCP.W
The receiving end unpacks the TCP data packet, retrieves the original Modbus frame, parses it according to the Modbus protocol specification, and then repackages the return data into the TCP protocol to send back to the sender.
In Modbus TCP, there is no concept of slave address; instead, devices are identified by their IP addresses.
CRC check is not used, as the TCP packet already includes a checksum to ensure data accuracy.
These are the basic differences between Modbus RTU, Modbus ASCII, and Modbus TCP protocols. Understanding these distinctions is crucial for implementing effective industrial communication systems and choosing the right protocol for specific applications in automation and IoT projects.

The prev: The next:

Related recommendations

Expand more!

Mo