Byte order and word order pitfalls
Sometimes Modbus communication works, but the value still looks wrong. This often happens because of byte order or word order.
Start with the basics
One Modbus register is 16 bits. That means some values fit into one register, but larger values need two or more registers.
Examples:
- a small integer may fit in one register
- a 32-bit integer uses two registers
- a float usually uses two registers
What byte order means
Byte order is the order of bytes inside a value.
If the byte order is not what the client expects, the final number can be wrong.
What word order means
Word order matters when a value uses more than one 16-bit register.
If the two registers are combined in the wrong order, the value may still be read, but it will not make sense.
What this looks like in practice
Common symptoms are:
- very large numbers
- impossible negative values
- values that jump strangely
- correct-looking communication but wrong readings
A simple example
A temperature may be stored across two registers as a float. If the registers are combined in the wrong order, the result may be a meaningless number instead of a real temperature.
How to solve it
Check the device documentation.
Make sure it clearly states:
- data type
- byte order
- word order
If the manual is unclear, test the possible combinations and compare the result with a known real value.
What manufacturers should do
Do not just say “float” or “32-bit value.” Also state how the bytes and words are arranged.
Final note
If the values look wrong but communication is fine, do not only check the register address. Also check byte order and word order.
Consulting
Manufacturers can hire me for help with Modbus device documentation, testing, and troubleshooting.