Home / Blog / Protocols
Protocols

Modbus Register Mapping: Addresses, Byte Order and Other Classic Traps

Modbus is simple enough to implement in an afternoon, and loose enough that every manufacturer does it slightly differently. Nearly all integration problems fall into a handful of categories.

Trap 1: the address is off by one

The protocol addresses registers from 0. Many manuals number them from 1. A manual that lists "register 40001" usually means holding register address 0, read with function code 03. If every value looks like its neighbour's, shift the address by one before doing anything else.

Trap 2: the 4xxxx prefix is not part of the address

NotationTableRead function
0xxxxCoils (read/write bits)01
1xxxxDiscrete inputs (read-only bits)02
3xxxxInput registers (read-only, 16-bit)04
4xxxxHolding registers (read/write, 16-bit)03

The leading digit only names the table. "30010" and "40010" are different registers in different tables. Some devices expose the same data in both, many do not.

Trap 3: 32-bit values and word order

A register is 16 bits. A 32-bit integer or float occupies two consecutive registers, and the standard does not say which half comes first. For the four bytes A B C D there are four layouts in the field:

LayoutOften called
A B C DBig-endian
C D A BWord swap (little-endian word order)
B A D CByte swap
D C B ALittle-endian

The symptom of a wrong choice is a value that is wildly wrong, not slightly wrong: a voltage of 1.2e-38 or 4,000,000. Test with a quantity you know, such as line frequency or voltage. 64-bit energy counters have the same problem with four registers.

Trap 4: scaling and sign

Many devices send integers with an implied decimal: 2305 for 230.5 V. The factor is in the manual and may itself be stored in another register. Check signed versus unsigned as well; a temperature of 65,526 is really −10.

Trap 5: block reads across gaps

A single request can read up to 125 holding registers. Reading in blocks is efficient, but if the block spans an address the device has not implemented, many devices reject the whole request with exception 02 (illegal data address). Group registers into contiguous blocks that follow the device map.

Trap 6: timing on serial lines

On Modbus RTU, only one request is in flight per line. One slow or missing device costs a full timeout on every cycle and delays all the others. Set timeouts per device, reduce retries for known-offline devices, and separate slow and fast devices onto different lines where possible. With serial-to-Ethernet gateways, remember that the unit ID still selects the device behind the gateway.

Make it repeatable

The mapping work is worth doing once. Save the verified map as a device template, including word order, scaling and units, and the hundredth analyzer of the same type takes minutes.

Argus handles all byte and word orders, scaling and device templates for Modbus TCP and RTU, and licensing is by tags, not by the number of devices or drivers. See Argus Power and Argus Meter.

Related articles

All articles

Have a project in mind?