Read/Write Memory - Four Register Write Command (31)
PreviousRead/Write Memory Dual-Register Write Command (30)NextSingle Bit Data Read/Write Commands (01 / 05) – Common for HMI
Last updated
When large values are processed using different data formats (e.g., float32 vs. int64), minor differences may occur due to internal calculation methods, typically less than 1/10,000, and are considered normal.
This command applies only to memory items with a register length of 4. Refer to the parameter list for details.
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)
A standard 32-bit floating-point number (Function Code 30) has a precision of about 7 significant digits. When the value exceeds ten million, using 32-bit floats may cause accuracy loss and rounding errors.
In such cases, it is recommended to use Function Code 31 with 64-bit integers (Int64) to ensure the data is accurately stored in memory without any rounding errors.

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.
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
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
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)
When the write is successful, the slave echoes the TX frame for verification.
Last updated
TX: 01 31 02 83 00 00 00 00 3B 9A C9 FF 0B 7ARX: 01 31 02 83 00 00 00 00 3B 9A C9 FF 0B 7A