Reference

This article provides an in-depth guide on the Modbus-RTU communication protocol, covering essential parameters, data frame formats, and detailed register address descriptions for sensor communication.

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, 0001H Blue-green algae value 0x03/0x04 cells/ml; floating-point big-endian, actual value
0002H Temperature 0x03/0x04 °C; 16-bit signed integer, 10 times the actual value
0050H Blue-green algae deviation value 0x03/0x04/0x06/0x10 16-bit signed integer, actual value
0051H Temperature deviation value 0x03/0x04/0x06/0x10 16-bit signed integer, 10 times the actual value
0060H Blue-green algae slope 0x03/0x04/0x06/0x10 16-bit signed integer, 100 times the 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, 7 represents 1200

3. Communication Protocol Examples and Explanation

3.1 Reading Blue-Green Algae Values ​​and Temperature

Query Frame:

Address Code Function Code Register Address Register Length Checksum Low Byte Checksum High Byte
0x01 0x03 0x00 0x00 0x00 0x03 0x05 0xCB

Response Frame:

Address Code Function Code Number of Valid Bytes Register Content Checksum Low Byte Checksum High Byte
0x01 0x03 0x06 0x44 0xEF 0x4F 0x91 0x00 0xE8 0x25 0x4F

Blue-green algae calculation: Floating-point big-endian 44EF4F91 = 1914 => 1914 cells/ml
Temperature calculation: 00E8H = 232 => Temperature is 232/10 = 23.2℃

3.2, Set the current blue-green algae value deviation for numerical correction

Query frame: If the current sensor output blue-green algae value is 1200, to correct it to 1000, the difference is 1000-1200=-200, -200=FF38. Calculation method: FFFF-00C8+1=FF38, register content is written as 0xFF38

Address Code Function Code Registry Address Registry Content Check Digit Low Bit Check Digit High Bit
0x01 0x06 0x00 0x50 0xFF 0x38 0xC9 0xF9

Response Frame:

Address Code Function Code Register Address Register Content Checksum Low Byte Checksum High Byte
0x01 0x06 0x00 0x50 0xFF 0x38 0xC9 0xF9

3.3 Setting the Slope of Blue-Green Algae Concentration

If measuring 2000 cells/ml The standard solution, after setting the deviation value, was measured to be 2200.0 cells/ml. Therefore, 2000/2200 = 0.91 was written into register 0x0060. Multiplying this by 100, the written value is 91, which is 0x005B in hexadecimal.

Query Frame:

Address Code Function Code Registry Address Registry Content Checksum Low Byte Checksum High Byte
0x01 0x06 0x00 0x60 0x00 0x5B 0xC8 0x2F

Response Frame:

Address Code Function Code Registry Address Registry Content Checksum Low Byte Checksum High Byte
0x01 0x06 0x00 0x60 0x00 0x5B 0xC8 0x2F

3.4, 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.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