Read/Write Memory - Four Register Write Command (31)
Function Code 31
The Four Register Write command (Function Code 31) writes 4 consecutive registers (64-bit), supporting Int64 or other 64-bit values. It is recommended for writing large parameters such as: D11 Total Target (64-bit), C04 Dosing Target (64-bit)

Function Code 31 uses a mirror-response mechanism. When the write is successful, the RX response frame from the slave will exactly match the TX request in both format and content.
Read/Write Memory – Four Register Write Command (Function Code 31) Format
This example demonstrates how the master uses Function Code 31 to write a target value of +999,999,999 to the parameter C04 Dosing Target.
Register Address: 02 83
Register Length: 4 (4 consecutive registers, 64-bit)
Data Type: Int64
1. Value Conversion and Data Preparation (Hex Data)
Target Value:
999,999,999(decimal)Hex Conversion:
3B 9A C9 FF。Packed in Int64 Format (8 Bytes): Since Function Code 31 requires 8 bytes, prepend zeros: Complete 64-bit Data:
00 00 00 00 3B 9A C9 FF
2. Master Sends Write Command (TX Frame)
Slave Address:
01(Flow meter address)Function Code:
31(Write 4 Registers)Starting Register Address:
02 83(C04 Dosing Target 64-bit memory address)Data to Write:
00 00 00 00 3B 9A C9 FF(C04 Dosing Target 64-bit value)CRC:
0B 7A(Calculated CRC for error checking)
3. Slave Response (RX Frame)
When the write is successful, the slave echoes the TX frame for verification.
Last updated