Leave Your Message
News Categories
Featured News

Detailed explanation of MODBUS_ASCII communication protocol

2026-03-04

The MODBUS-ASCII protocol is a text-based serial communication protocol in industrial automation, specifically designed for RS-232/RS-485 serial ports. Its core advantage lies in the readability of data and the ease of debugging.

The MODBUS ASCII communication protocol uses ASCII characters to encode data, with each 8-bit data byte being split into two ASCII characters (one byte corresponds to two ASCII characters) for transmission. For example, hexadecimal 0x01 is encoded as 30 31 (i.e., the characters '0' and '1'). Although this reduces transmission efficiency, it makes it more reliable in certain types of serial communication, especially in noisy environments or over long communication distances, greatly facilitating manual inspection and troubleshooting.

I.Core Features:

  • Text Format: Messages start with a colon ":" and end with a carriage return and line feed "\r\n". All data (including address, function code, and checksum) are represented in hexadecimal ASCII characters for easy reading.
  • Verification method: Longitudinal Redundancy Check (LRC) is used to detect transmission errors by calculating the sum of all bytes (excluding the start and end characters) in the frame and generating a complement.
  • Frame structure: A complete MODBUS-ASCII frame comprises a start character, device address, function code, data, LRC check sum, and a stop character.

II. Communication Parameter Settings The key to MODBUS-ASCII communication parameters lies in the four items: baud rate, data bits, parity bits, and stop bits. These must be fully matched between the master and slave stations for normal communication.

  • Baud Rate: Determines the communication speed. Common values include 9600, 19200, 38400, and 115200 bps. The higher the baud rate, the faster the speed, but the anti-interference capability may decrease.
  • Data Bits: Typically 8 bits, with a few cases where it may be 7 bits.
  • Parity: Used for error detection, with options including None, Even, and Odd. In ASCII mode, parity is optional.
  • Stop Bits: Used to indicate the end of a character, commonly represented by 1 or 2 bits. When no parity is used, 2-bit stop bits are typically employed.

图片1.jpg

III.Communication format

  • Start character: A colon ":" is usually used as the start character.
  • Address field: Immediately following the start symbol, it is the address of the target device (one byte, usually two hexadecimal digits).
  • Function code: Immediately following the address field, it indicates the type of operation to be executed (one byte, typically represented by two hexadecimal digits).

Data Field: Depending on the function code, it may contain additional data (usually hexadecimal values, with two characters per byte).

  • Checksum: A two-character checksum field used to ensure data integrity.
  • End marker: Usually carriage return (CR) and line feed (LF), i.e. 0D 0A or 30 44 30 41.

图片2.jpg

Example: Suppose we want to send a request to read the hold register (function code 03) from a device with an address of 01, starting from register 0000 and reading two registers. The start character is 3A (i.e., :),

 the address field is 30 31 (i.e., 01),

the function code is 30 33 (i.e., 03),

the data field is 30 30 30 30 30 30 30 32 (i.e., the register address and quantity, here 0000 and quantity 0002),

the checksum is 46 41 (calculated as theLRC( Longitudinal Redundancy Check ) from the start character to the end of the data field),

The end character is 0D 0A.

The complete request would be: 3A 30 31 30 33 30 30 30 30 30 30 30 32 46 41 0D 0A

IV.Core Application Scenarios

  • Device Debugging and Diagnosis

This is the most prominent advantage of the MODBUS-ASCII communication protocol. ASCII messages are in human-readable text format (e.g., 020300030002F6\r), which greatly facilitates engineers in quickly viewing and understanding data, making it particularly suitable for on-site debugging, configuration, and teaching demonstrations.

  • Communication with old or low-speed devices:

 Many early industrial controllers, instruments, or actuators only support ASCII mode. When upgrading old systems or networking with devices from different eras, ASCII is a reliable choice to ensure compatibility.

  • High-noise or low-speed serial environment

In industrial sites where motors are frequently started and stopped and there is significant ground wire noise (such as wastewater treatment plants), ASCII mode has higher tolerance for timing and interference, effectively reducing the communication bit error rate and ensuring the reliability of data transmission.

  • Teaching and development environment

Due to its clear and easily comprehensible message structure, the ASCII protocol is often used for learning Modbus communication principles, developing testing tools, or performing protocol analysis.

V.Precautions

  • Data encoding: Each byte must be encoded as two ASCII characters.
  • Frame interval: After sending a frame, a minimum idle interval of 3.5 characters is required before sending the next frame. For example, when the baud rate is 9600, 1 character time is approximately 1.1ms, and 3.5 characters time is approximately 3.9ms.

图片3.jpg

  • Character interval: Within the same frame, the interval between character transmissions should not exceed 1 second; otherwise, the receiving end may consider it a transmission error.
  • Checksum calculation: LRC (Longitudinal Redundancy Check) is commonly used to calculate the checksum. The checksum of the entire message is calculated before sending and appended at the end of the message.
  • Error handling: The receiver needs to verify the correctness of the checksum and the correctness of the message format.
  • Communication rate: Typically, a baud rate of 9600 bps is used, but it can be adjusted as needed.
  • By correctly implementing the MODBUS ASCII protocol, stable and reliable communication between devices can be ensured. In the implementation process, it is crucial to ensure correct hardware connections, consistent baud rate settings, and proper handling of all communication details.