15
8. Protocol Examples: Modbus
Note that different software uses different ways to express Modbus
addresses, so you may need to look up the address in a different style. For
full tables of Modbus-addressable controls and inputs, please refer to the
manual.
Example 1: Set digital output channel 3 to ON
Request: Write Single Coil (function code=5), logical address=0x0003,
data=0xFF00
Response: Function code=5, logical address=0x0003, data=0xFF00
The response just acknowledges that the request was handled without error
Example 2: Read state of all digital inputs
Request: Read Holding Registers (function code=3), logical address=0x0020,
quantity=0x0001
Response: Function code=3, no. of bytes=2, data=0x0013
This data value means that inputs 0, 1 and 4 are in a ‘1’ state, and others are
in a ‘0’ state
Example 3: Read state of analogue input channels 3, 4 and 5, as 16-bit
integer values
Request: Read Holding Registers (function code=3), logical address=0x0003,
quantity=0x0003
Response: Function code=3, no. of bytes=6, data=0x4000, 0x2000, 0xE000
The encoding of values to integers is congurable, but this example could
mean the inputs are at 50%, 25%, and -25% of the +FSR of the input channels