I am laying out register definitions for an RTU based slave device. Previously, I would leave holes in my Modbus address map for registers that spanned more than one 16-bit word. For example, for two floating point registers (32 bits each), I might define the following (note that Modbus Addr 11 is undefined):
<pre>
Modbus Addr: 10, Register Type: float, Register Name: sensor_1
Modbus Addr: 12, Register Type: float, Register Name: sensor_2
</pre>
But since my slave device is controlling what gets returned in response to the master's request, leaving a hole isn't necessary:
<pre>
Modbus Addr: 10, Register Type: float, Register Name: sensor_1
Modbus Addr: 11, Register Type: float, Register Name: sensor_2
</pre>
The slave device would have no trouble returning the floating point value for sensor_1 when requested on address 10, nor the floating point value for sensor_2 when requested on address 11.
Though not immediately intuitive, I don't see any problem with this approach, and it would let me compact the register addresses.
<b>The question:</b> Is this "compressed" approach idiomatically acceptable? Or do slave implementations always allocate unused registers to reflect the number of words actually spanned?
<pre>
Modbus Addr: 10, Register Type: float, Register Name: sensor_1
Modbus Addr: 12, Register Type: float, Register Name: sensor_2
</pre>
But since my slave device is controlling what gets returned in response to the master's request, leaving a hole isn't necessary:
<pre>
Modbus Addr: 10, Register Type: float, Register Name: sensor_1
Modbus Addr: 11, Register Type: float, Register Name: sensor_2
</pre>
The slave device would have no trouble returning the floating point value for sensor_1 when requested on address 10, nor the floating point value for sensor_2 when requested on address 11.
Though not immediately intuitive, I don't see any problem with this approach, and it would let me compact the register addresses.
<b>The question:</b> Is this "compressed" approach idiomatically acceptable? Or do slave implementations always allocate unused registers to reflect the number of words actually spanned?