Documentation

Modbus data types and byte order

A Modbus register holds 16 bits. Larger values such as 32-bit integers and floats use two or more registers, and devices differ in the order those bytes are sent.

One value, several registers

A 16-bit integer fits in one holding register. A 32-bit integer or a 32-bit float (IEEE 754) needs two consecutive registers, and a 64-bit value needs four. Strings are packed two characters per register. The Modbus protocol does not say which register comes first or which byte comes first: that is a property of the device, and the manual should say which order it uses.

Byte order in four variants

Take the 32-bit value 0x42F6E979, which is the float 123.456. Its four bytes are 42 F6 E9 79. The usual device orders are:

The same float in the four common byte orders
OrderRegister 1Register 2Decodes as
ABCD (big endian)42F6E979123.456
CDAB (word swap)E97942F6a different number
BADC (byte swap)F64279E9a different number
DCBA (little endian)79E9F642a different number

When a float looks wildly wrong but not random, try the other orders before suspecting the wiring or the polling.

Signed and unsigned values

A register read as unsigned gives 0 to 65535. The same 16 bits read as signed give -32768 to 32767. A temperature of -5.0 degrees stored in tenths is 0xFFCE, which reads as 65486 unsigned and -50 signed. Choose the type the device documents; reading a signed value as unsigned is a common reason for large numbers.

Test it in Busscope

In a Busscope Master poll window each cell has a format and a byte order, so you can read a 32-bit float across two registers in all four orders and pick the one that matches the device. The addressing page covers the register numbers themselves.

Try Busscope

Install Busscope and run it without a license key to see whether it fits your work. Evaluation mode is for trying the tool, not for production or commercial use.

Download the evaluation All documentation