1. Home
  2. Knowledge base

Reading Modbus registers without surprises

Why Modbus values are often shifted by one register, what word order is and how scale and offset get you to real units.

Productielijn in een fabriekshal

Modbus is simple and found everywhere: in frequency drives, energy meters, sensors and simple PLCs. Precisely because of that simplicity, things often go wrong in the details. These are the most common pitfalls.

The four register types

  • Coils: bits you can read and write.
  • Discrete inputs: bits you can only read.
  • Input registers: 16-bit values you can only read.
  • Holding registers: 16-bit values you can read and write.

Shifted by one register

The most common mistake: all values are one place off. The cause is that the manufacturer’s manual counts from 1, or from 40001, while the protocol counts from 0. Lower the address by 1, or drop the 4xxxx prefix.

Absurdly large numbers

A 32-bit value, such as an int32 or a float, takes up two registers. The order of those two words differs per manufacturer. If the order is wrong, you get huge or meaningless numbers. Then swap the word order.

Ten times too large

Many devices deliver tenths or hundredths, so they don’t need a decimal point. A current of 12.4 A then arrives as 124. A scale of 0.1 gets you to the real unit. Sometimes an offset is needed too: value times scale plus offset.

Unit ID behind a gateway to RTU

If there is a gateway between the network and a serial Modbus RTU bus, you have to enter the unit ID of the device behind the gateway. Otherwise you get a timeout.

Start with the register map

Always ask for the manufacturer’s register map before you start. It lists the register type, address, data type and scale for each value.

In FactoryNebula you set the byte and word order per Modbus device and the scale and offset per value. Read more about the Modbus connector.

Further reading

More from the knowledge base

See your own machines in FactoryNebula

In a personal demo we show how the platform works for your production, and what it takes to start with one machine.