TECHNICAL GUIDE

Decode 32-bit Modbus floats without guessing word order

Modbus defines 16-bit registers. It does not standardize how a vendor spreads a 32-bit float across two registers. A plausible number is therefore evidence of nothing until the source words and a known operating point agree.

Two Modbus registers decoded into the IEEE 754 float value 230.0
Prove byte and word order from the raw register words before adding scaling or units.
01

Capture the original words

Read two consecutive registers and write down their hexadecimal values in address order. Keep those values visible while trying interpretations. If the tag starts at the second register or the view omits a continuation word, no byte-order setting can repair the input.

02

Treat word and byte order independently

The common variants are ABCD, CDAB, BADC, and DCBA when the four bytes are named in significance order. Vendors may describe only a “word swap,” but adapters and gateways can also introduce byte-level conventions.

  • ABCD: high word, then low word
  • CDAB: low word, then high word
  • BADC: bytes swapped within each word
  • DCBA: reversed words and bytes
03

Use a second operating point

Choose a value you can move safely—temperature simulator, setpoint, or known counter—and observe both raw words again. The correct interpretation should change in the right direction and magnitude. Only then apply an additional engineering scale or offset specified by the manual.

Reject interpretations that merely look plausible once. A swapped float can land inside a believable range by accident; direction, magnitude, and repeatability are the useful checks.

04

Eliminate the wrong data type before swapping bytes

Two registers are not automatically a float. They may hold a signed or unsigned 32-bit integer, two independent uint16 values, a fixed-point number, a counter, or a bit field. Compare the manual's type, width, scale, and valid range before testing byte permutations. If an integer interpretation follows the physical process while every float is unstable, the problem is probably the assumed type rather than endianness.

Watch for IEEE 754 warning signs. NaN, infinity, extreme exponents, and values that jump many orders of magnitude after a small process change usually indicate the wrong word pair or ordering. Zero is a poor test value because several layouts can decode it identically; choose a stable non-zero value with a known approximate magnitude.

05

Use raw hexadecimal as the common language

Screenshots of a formatted decimal value are not enough to reproduce a decoding issue. Preserve both 16-bit words in address order, the start offset, function code, and response byte sequence. With those bytes another engineer can test ABCD, CDAB, BADC, and DCBA without access to the device. This also exposes accidental reads that begin on the second half of a value.

Gateways normally forward Modbus register bytes without inventing a new floating-point convention, but application layers can still reorder words when they build tags. Compare the bytes at the wire with the words shown by the client before blaming the device or gateway.

06

Separate representation from engineering conversion

Word order reconstructs the 32-bit payload. Scaling and offset are later engineering operations. If the manual says the register is float32 in volts, applying an additional factor of 0.1 is usually wrong. If it says signed int32 with a resolution of 0.1 V, the integer must be reconstructed first and scaled second.

Commission the tag with at least two points and, where practical, one value on each side of zero. Confirm direction, magnitude, sign, and unit. Save the original words beside the decoded tag so future firmware or mapping changes can be checked without repeating the entire investigation.

QUESTIONS

Before you connect.

Can a plausible float still be wrong?+

Yes. Random bit patterns can decode into ordinary-looking numbers. Verify the same interpretation at a second controlled operating point and preserve the source words.

KEEP THE EVIDENCE

Use the reference beside the live protocol.

Browse documentation→