Reference
This article offers an in-depth look at the Modbus-RTU communication protocol, detailing data frame formats, register addresses, function codes, and practical examples to effectively manage and configure communication networks, including setting ORP values, temperature adjustments, and device configurations.
Communication Protocol Description
1. Basic communication parameters
| Interface | Encoding | Data bits | Parity bits | Stop bits | Error checking | Baud rate |
|---|---|---|---|---|---|---|
| RS485 | 8-bit binary | 8 | None | 1 | CRC | 1200bit/s,2400bit/s, 4800bit/s, 9600bit/s, 19200bit/s, 38400bit/s, 57600bit/s, 115200bit/s configurable, default 4800bit/s |
2. Data frame format definition
Using Modbus-RTU communication protocol, the format is as follows:
Initial structure ≥4 bytes of time
Address code = 1 byte
Function code = 1 byte
Data area = N bytes
Error check = 16-bit CRC code
End structure ≥4 bytes of time
Address code: The address of the sensor, which is unique in the communication network (factory default 0x01).
Function code: The function indication of the command sent by the host. This sensor reads the register function code 0x03/0x04 and writes the register function code 0x06/0x10
Data area: The data area is the specific communication data. Note that the high byte of 16-bit data is in front!
CRC code: A two-byte check code.
Register address
| Register Address | Content | Supported Function Codes | Definition Description |
|---|---|---|---|
| 0000H | ORP Value | 0x03/0x04 | mV; 16-bit signed integer, actual value |
| 0001H | Temperature Value | 0x03/0x04 | °C; 16-bit signed integer, 10 times the actual value |
| 0050H | ORP Deviation Value | 0x03/0x04/0x06/0x10 | 16-bit signed integer, actual value |
| 0051H, 0052H | ORP Slope | 0x03/0x04/0x10 | Floating-point big-endian |
| 0053H | Temperature Deviation Value | 0x03/0x04/0x06/0x10 | 16-bit signed integer, 10 times the actual value |
| 0120H, 0121H | Electrode calibration | 0x10 | Calibration is performed by writing parameters to registers 0x0120 and 0x0121 using function code 0x10, actual value |
| 07D0H | Device address | 0x03/0x04/0x06/0x10 | 1~254 (16-bit unsigned integer, factory default 1) |
| 07D1H | Device baud rate | 0x03/0x04/0x06/0x10 | 0 represents 2400, 1 represents 4800, 2 represents 9600, 3 represents 19200, 4 represents 38400, 5 represents 57600, 6 represents 115200, and 7 represents 1200. |
3. Communication Protocol Examples and Explanation
3.1 Reading Current ORP Value and Temperature
Query Frame:
| Address Code | Function Code | Registry Address | Registry Length | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|
| 0x01 | 0x03 | 0x00 0x00 | 0x00 0x02 | 0xC4 | 0x0B |
Response Frame:
| Address Code | Function Code | Number of Valid Bytes | Registry Content | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|
| 0x01 | 0x03 | 0x04 | 0x01 0x35 0x01 0x01 | 0x2B | 0x91 |
ORP Calculation: 0135H=309=>ORP=309mV
Temperature Calculation: 0101H=257=>Temperature=25.7℃
3.2, Set Deviation Value for Current ORP Value for Numerical Correction
Query Frame: If the current device outputs ORP of 309, and the value needs to be corrected to 293, the difference is 293-309=-16, -16=>Calculation method: FFFF-0010+1=0xFFF0, register content is written as FFF0H)
| Address Code | Function Code | Register Address | Register Content | Check Digit Low Bit | Check Digit High Bit |
|---|---|---|---|---|---|
| 0x01 | 0x06 | 0x00 0x50 | 0xFF 0xF0 | 0xC8 | 0x6F |
Response Frame:
| Address Code | Function Code | Registry Address | Registry Content | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|
| 0x01 | 0x06 | 0x00 0x50 | 0xFF 0xF0 | 0xC8 | 0x6F |
3.3 Setting the Slope for Current ORP Value for Numerical Correction
Query Frame: If the current device outputs an ORP of 309, and you want to correct the value to 293, the slope is 293/309≈0.7735, 0.7735=>0x3F460419 (floating-point big-endian), and the register content is written as 3F460419.
| Address Code | Function Code | Registry Address | Registry Length | Byte Length | Registry Content | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|---|---|
| 0x01 | 0x10 | 0x00 0x51 | 0x00 0x02 | 0x04 | 0x3F 0x46 0x04 0x19 | 0x19 | 0x94 |
Acknowledgement Frame:
| Address Code | Function Code | Registry Address | Registry Length | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|
| 0x01 | 0x10 | 0x00 0x51 | 0x00 0x02 | 0x10 | 0x19 |
3.4 Register Calibration of Electrodes
If electrode calibration is required, parameters can be written to registers 0x0120 and 0x0121 using function code 0x10. This device uses two-point calibration, requiring two known ORP standard solutions. For the first calibration point, write 0x0001 to register 0x0120 and the standard ORP value for the first point to register 0x0121; for the second calibration point, write 0x0002 to register 0x0120 and the standard ORP value for the second point to register 0x0121. Calibration complete.
Query Frame: Select 86mV ORP standard solution to calibrate the first point. 86=0056H
| Address Code | Function Code | Register Address | Register Length | Byte Length | Register Content | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|---|---|
| 0x01 | 0x10 | 0x01 0x20 | 0x00 0x02 | 0x04 | 0x00 0x01 0x00 0x56 | 0x2D | 0xD9 |
Response Frame:
| Address Code | Function Code | Register Address | Register Length | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|
| 0x01 | 0x10 | 0x01 0x20 | 0x00 0x02 | 0x41 | 0xFE |
Query frame: Select 256mV of ORP standard solution to calibrate the second point. 256 = 0100H
| Address Code | Function Code | Registry Address | Registry Length | Byte Length | Registry Content | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|---|---|
| 0x01 | 0x10 | 0x01 0x20 | 0x00 0x02 | 0x04 | 0x00 0x02 0x01 0x00 | 0x5C | 0x77 |
Response Frame:
| Address Code | Function Code | Registry Address | Registry Length | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|
| 0x01 | 0x10 | 0x01 0x20 | 0x00 0x02 | 0x41 | 0xFE |
3.5, Change the current address to 0x02
Query Frame:
| Address Code | Function Code | Registry Address | Registry Content | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|
| 0x01 | 0x06 | 0x07 0xD0 | 0x00 0x02 | 0x08 | 0x86 |
Response Frame:
| Address Code | Function Code | Registry Address | Registry Content | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|
| 0x01 | 0x06 | 0x07 0xD0 | 0x00 0x02 | 0x08 | 0x86 |
3.6, Modify the current baud rate to 9600
Query Frame:
| Address Code | Function Code | Registry Address | Registry Content | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|
| 0x01 | 0x06 | 0x07 0xD1 | 0x00 0x02 | 0x59 | 0x46 |
Response Frame:
| Address Code | Function Code | Registry Address | Registry Content | Checksum Low Byte | Checksum High Byte |
|---|---|---|---|---|---|
| 0x01 | 0x06 | 0x07 0xD1 | 0x00 0x02 | 0x59 | 0x46 |
Was this article helpful?
