3.4.4 "Function Code" 23 (ReadWrite Multiple Registers)
This "Function Code" 23 (ReadWrite Multiple Registers) allows you to
read and write several consecutive parameters, starting at any
address.
Modbus request Structure of the Modbus request:
Field Bytes Value Meaning
Function Code 1 23 = 17
h
Read/Write Multiple Registers
Read Starting
Address
2 (various) Address of the first parameter to be read
Quantity To Read 2 2 * n Number of 16 bit values to be read
(1 parameter has the value 2 since a parameter
consists of a 32 bit value)
Write Starting
Address
2 (various) Address of the first parameter to be written
Quantity To Write 2 2 * m Number of 16 bit values to be written
(1 parameter has the value 2 since a parameter
consists of a 32 bit value)
Write Byte Count 1 4 * m Number of data bytes
Write Registers
Value
4 * m (various) Parameter values
Modbus response Structure of the positive Modbus response:
Field Bytes Value Meaning
Function Code 1 23 = 17
h
Read/Write Multiple Registers
Byte Count 1 2 * n Number of data bytes
Read Registers
Value
2 * n (various) Parameter values
Structure of the negative Modbus response
Field Bytes Value Meaning
Function Code 1 17
h
+ 80
h
= 97
h
Read/Write Multiple Registers
Exception Code 1 01
h
... 04
h
See chapter
"3.3.2 Modbus response to a Modbus request"
LXM32M
3 Basics
Modbus-TCP module 31
0198441113843, V1.01, 01.2012