Reference

The article explains the Modbus-RTU protocol, detailing its data frame format and communication parameters, essential for managing chlorine sensors.

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 Residual Chlorine Value 0x03/0x04 16-bit unsigned integer, 100 times the actual value
1010H, 1011H 44113, 44114 Residual Residual chlorine slope 0x03/0x04/0x10 Floating-point number, actual value
1012H, 1013H 44115, 44116 Residual Chlorine Deviation Value 0x03/0x04/0x10 Floating-point number, 100 times the 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 Current Chlorine Residual Value

Query Frame:

Address Code Function Code Registry Address Registry Length Checksum Low Byte Checksum High Byte
0x01 0x03 0x00 0x00 0x00 0x01 0x84 0x0A

Response Frame:

Address Code Function Code Number of Valid Bytes Registry Content Checksum Low Byte Checksum High Byte
0x01 0x03 0x02 0x03 0x16 0x39 0x7A

Chlorine Residual Calculation: 0316H=790=>Chlorine Residual=7.90mg/L

3.2, Set Deviation Value for Current Chlorine Residual Value for Numerical Correction

Query Frame: If the current device outputs Chlorine Residual of 7.90, and the value needs to be corrected to 8.00, the difference is 8.00-7.90=0.10, 0.1*100=10=>41200000(Floating-point number), register content is written as 0x4120,0x0000)

Address Code Function Code Registry Address Registry Length Byte Length Registry Content Checksum Low Byte Checksum High Byte
0x01 0x10 0x10 0x12 0x00 0x02 0x04 0x41 0x20 0x00 0x00 0xAB 0x4C

Response Frame:

Address Code Function Code Registry Address Registry Length Checksum Low Byte Checksum High Byte
0x01 0x10 0x10 0x12 0x00 0x02 0xE5 0x0D

3.3 Setting the Slope for Current Chlorine Residual Value for Numerical Correction

Query Frame: If the current device outputs an Chlorine Residual of 8.00, and you want to correct the value to 9.00, the slope is (9-0.1)/( 8.00-0.10)≈1.1267=>3F9037B5(Floating-point number),and the register content is written as 0x3F90,0x37B5.

Address Code Function Code Registry Address Registry Length Byte Length Registry Content Checksum Low Byte Checksum High Byte
0x01 0x10 0x10 0x10 0x00 0x02 0x04 0x3F 0x90 0x37 0xB5 0xE4 0xDD

Response Frame:

Address Code Function Code Registry Address Registry Length Checksum Low Byte Checksum High Byte
0x01 0x10 0x10 0x10 0x00 0x02 0x44 0xCD

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