Search code examples
modbus

What Problems Might Occur if I Overlap Multi-Register Modbus Data Items?


It is common to use 2 registers to read/write a floating point value in Modbus. My question is what problems or compatibility issues arise if I specify my device register map with overlapping data as follows..

40001 (float a), 40002 (float b), 40003 (float c), 40004 (float d), and so on.

Float (a) can be read at 40001 with FC03, number of registers is 2. Float (b) can be read at 40002 with FC03, number of registers is 2. Float (a) and (b) can be read at 40001 with FC03, number of registers is 4.


Solution

  • This will render your device to become not a modbus-compatible device, but just a modbus-like device.

    The drawback is that there are plenty of modbus clients, mostly SCADA systems, which would simply stop working with such register map. So if you don't care about 3rd party clients, you can do it, but what is the purpose?

    UPD

    Also you get undefined behavior on reading registers which belong to different values at the same time. What is the expected output of reading single word at 4002? LSB of a or MSB of b?

    How do I read 2 consequent numbers (a and b)??

    Modbus is already only modbus-like when it comes to multi-register values

    Wrong, it is still modbus, but whenever you ready multi-register values or implement time stamps, you explicitly define them in documentation and you rules should not violate general modbus rules like mention above. There is nothing wrong in telling you are using 2 registers with MSB BOM.

    So the answer is it could work for some specific cases but is generally not usable at all.