Modbus RTU Function 16 'Preset Multiple Registers'
To write 3 words (48 bits) to 3 consecutive registers you send the following:
Byte 0 Modbus Device Address (1 to 247)
Byte 1 Function Code / Message Type (0x10)
Byte 2 Start Register Number (high byte)
Byte 3 Start Register Number (low byte)
Byte 4 Number of registers to write(high byte)
Byte 5 Number of registers to write (low byte)
Byte 6 Number of data bytes that follow(3 registers x 2 bytes each = 6)
Byte 7 Data0
Byte 8 Data1
Byte 9 Data2
Byte 10 Data3
Byte 11 Data4
Byte 12 Data5
Byte 13 CRC of bytes 1 to 6 (high byte)
Byte 14 CRC of bytes 1 to 6 (low byte)
The response:
Byte 0 Modbus Device Address
Byte 1 Function Code / Message Type (0x10)
Byte 2 Start Register Number (high byte)
Byte 3 Start Register Number (low byte)
Byte 4 The number of registers written (high byte)
Byte 5 The number of registers written (low byte)
Byte 6 CRC of bytes 1 to 6 (high byte)
Byte 7 CRC of bytes 1 to 6 (low byte)
4 years ago
Check the crc byte order, first low then high