Reference

The article provides a detailed explanation of the Modbus-RTU communication protocol, covering basic parameters, data frame format, register addresses, and practical examples for sensor data reading and calibration.

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 PLC Address Content Supported Function Codes Definition Description
0000H 40001 EC value 0x03/0x04 μS/cm; 16-bit unsigned integer, actual value
0001H 40002 Temperature 0x03/0x04 °C; 10 times the actual value
0002H 40003 Salinity 0x03/0x04 ppm; 16-bit unsigned integer
0003H 40004 TDS 0x03/0x04 ppm; 16-bit unsigned integer
0050H 40081 Temperature deviation value 0x03/0x04/0x06/0x10 16-bit signed integer, 10 times the actual value
0051H 40082 EC deviation value 0x03/0x04 16-bit unsigned integer, actual value
0052H, 0053H 40083, 40084 EC temperature compensation coefficient 0x03/0x10 Floating-point number, big-endian, default resolution 0.02
0054H, 0055H 40085, 40086 Electrode constant 0x03/0x10 Floating-point number, big-endian, default resolution 0.1
0110H, 0111H 40273, 40274 EC calibration 0x10 Write 00 04 to register 0110H, write the calibration standard solution value to register 0111H, actual value
07D0H 42001 Device address 0x03/0x04/0x06/0x10 1~254 (16-bit unsigned integer, factory default 1)
07D1H 42002 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, 7 represents 1200

3. Communication Protocol Examples and Explanation

3.1 Reading EC 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 0x27 0x10 0x01 0x09 0x30 0xD4

Conductivity calculation: 2710H=10000 => EC=10000μS/cm
Temperature calculation: 0109H=265=>Temperature=26.5℃

3.2, Set deviation value for current conductivity value for numerical correction

Query frame: If the current sensor output conductivity value is 900, to correct the value to 1000, the difference is 1000-900=100=>64H, write 0064H in the register content

Address code Function code Register address Register content Checksum low bit Checksum high bit
0x01 0x06 0x00 0x50 0x00 0x64 0x88 0x30

Response Frame:

Address Code Function Code Register Address Register Content Checksum Low Byte Checksum High Byte
0x01 0x06 0x00 0x50 0x00 0x64 0x88 0x30

3.3 Calibrate the sensor with a 1413μS/cm standard solution

Query Frame: Write 00 04 to 0110H and 0111H respectively, 1413 =>0585H.

During calibration, the electrode is placed in a standard solution with a known conductivity value. The electrode is shaken to accelerate the response, then allowed to stand until the conductivity value stabilizes. This conductivity value is then written into the conductivity solution calibration log and calibrated to complete the calibration.

Address Code Function Code Registry Address Registry Length Byte Length Registry Content Checksum Low Byte Checksum High Byte
0x01 0x10 0x01 0x10 0x00 0x02 0x04 0x00 0x04 0x05 0x85 0x7C 0x01

Response Frame:

Address Code Function Code Registry Address Registry Length Checksum Low Byte Checksum High Byte
0x01 0x10 0x01 0x10 0x00 0x02 0x41 0xf1

3.4, Modify 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.5, 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?

TOP