Modbus float converter

A Modbus register holds 16 bits, so a float or a 32-bit integer spans two of them, and devices disagree about the order. Enter the two registers and see the value in every order at once; the right one is usually obvious.

Hex (0x41A4) or decimal (16804).

Encode a value

Why the same registers decode four ways

Two registers, four bytes

Call the four bytes A B C D, most significant first, as IEEE 754 defines them. The Modbus standard fixes the byte order inside a register (big-endian) but says nothing about which register comes first, and some devices also swap the bytes.

The four orders

ABCD is big-endian throughout. CDAB swaps the two registers, which is the most common alternative and is often called word swap. BADC swaps the bytes inside each register. DCBA reverses everything.

Finding the right one

Read a value you know, such as room temperature or a setpoint, and pick the order that gives it. Then set that order once in the system reading the device. The datasheet should state it, and often does not.

Frequently asked questions

What does "word swap" or "CDAB" mean?

The device sends the low 16 bits of the value in the first register and the high 16 bits in the second. The bytes inside each register stay in normal order.

Why do I get a huge or tiny number like 1.4e-41?

Almost always the wrong word order. A small float read with its registers swapped lands in the denormal range or far out of scale. Try the other orders.

How are 16-bit signed values decoded?

As two's complement: a register above 32767 is negative, so 0xFF9F is -97. Many sensors send a value multiplied by 10 or 100, so -97 may mean -9.7.

Reading Modbus sensors in the field?

Genesis reads RS485 Modbus sensors, analogue transducers and 1-Wire probes on the same four ports and reports them over cellular. Tell us what you need to read.

Talk to us →