SensorCatalog

Modbus register decoder

Turn raw holding or input registers into the number they carry, in every byte and word order, or a value into registers.

Registers

Direction

Register values

Entered as

Every byte order

ABCD · big-endian
1041 20 00 00
CDAB · word swap
2.3362448 × 10⁻⁴¹unlikely reading · 00 00 41 20
BADC · byte swap
1.6347736 × 10⁻¹⁹unlikely reading · 20 41 00 00
DCBA · little-endian
1.1570521 × 10⁻⁴¹unlikely reading · 00 00 20 41

Register address

Protocol address
00x0000 · counted from 0, as sent in the request
Data table
Holding registers (4x)read FC 03 · write FC 06, 16
Reference numbers
40001 · 4000015- and 6-digit notation, counted from 1
Registers read
0 … 12 consecutive registers for this data type
Formulas and standards
ABCD: A B C D   CDAB: C D A B   BADC: B A D C   DCBA: D C B A
Value = raw × Scale factor + Offset

Modbus sends each 16-bit register high byte first. A 32- or 64-bit value spread over several registers has no order fixed by the protocol: many devices send the high register first (ABCD), others the low register first (CDAB), and a few also swap the bytes in each register (BADC, DCBA). Each row decodes the same registers in one of these orders; the letters show which byte of the value arrives where, A being the most significant.

Floating-point values are IEEE 754 binary32 (FLOAT32) or binary64 (FLOAT64). A wrong order usually gives a value that is absurdly large or small, or not a number; those rows are greyed. The engineering value is raw × scale factor + offset. Reference numbers such as 40001 are the Modicon convention: the first digit names the table, the rest counts from 1, while the request carries the address counted from 0.

Need sensors and transmitters with a Modbus RTU or TCP output?

Get pricing from SensorSpan

How the Modbus register decoder works

Modbus moves data in 16-bit registers, and every register travels with its high byte first. That is all the protocol fixes. A temperature sent as a 32-bit float, or an energy counter sent as a 64-bit integer, is spread over two or four registers, and the order of those registers is chosen by the device maker. Most devices send the high register first, some send the low register first, and a few also swap the two bytes inside each register.

The decoder takes the registers exactly as your master, gateway or test tool shows them and decodes them in all four orders at once. Write the order as the letters of the value’s bytes, A being the most significant: ABCD is big-endian, CDAB is the common word swap, BADC swaps the bytes in each register, DCBA is fully little-endian.

Finding the right byte order

Read a register pair while you know roughly what the device should report, and look for the row that makes sense. The registers 0x4120 0x0000 are 10.0 as ABCD. Read as CDAB they give 2.3 × 10⁻⁴¹, a value no sensor reports, and the decoder greys out such rows. If the device sends the low register first you will see 0x0000 0x4120 instead, and the CDAB row shows the 10.

Once you know the order of one value, it is the same for every value of that device and data type. Write it into the master’s configuration rather than swapping bytes in the PLC program.

Scaling and data types

Many devices send integers with an implied scale: a pressure of 1234 that means 12.34 bar, or a temperature in tenths of a degree. Enter the scale factor and offset from the register map and the decoder shows the engineering value next to the raw one; the value is raw × scale factor + offset. The same factor works backwards when you encode a value to write.

INT16 and UINT16 differ only in how the top bit is read: 0xFFFF is 65535 unsigned and −1 signed. Most register maps state the type for every address; when they do not, a value that should never be negative is usually unsigned.

Register numbers and addresses

Device manuals often list registers as 40001, 30001 or 400001. This is the Modicon convention: the first digit names the table (4 for holding registers, 3 for input registers, 0 for coils, 1 for discrete inputs) and the rest counts from 1. The request on the wire carries the address counted from 0, so 40001 is holding register address 0, read with function code 03. Enter the reference to see the protocol address, the function codes and the registers a multi-register value occupies.

An off-by-one error here is the most common reason for a value that is plausible but wrong: the master reads the second half of one value and the first half of the next.

Frequently asked questions

Why does the decoder show NaN for some rows?

A float whose exponent bits are all ones is not a number, or infinity. A wrong byte order often produces this pattern; so does a device that reports a sensor fault with NaN on purpose. Check the device manual for the second case.

Can I enter the registers as one hex string?

Yes. Eight or sixteen hex digits without spaces are split into registers of four digits, so 41200000 is read as 0x4120 0x0000.

What about Modbus TCP?

The register layout is the same over TCP and RTU; only the framing differs. The byte order of multi-register values belongs to the device, not to the transport.

↑ ↓ choose · Enter open · Esc close