Skip to main content

Guides

When a Modbus value comes in wrong: byte order, multiplier, address offset

When the device answers but the value makes no sense, the cause is usually one of five settings. We show the order to check them in, with numeric examples.

Modbus does not carry what a value means; it carries only 16-bit registers. The device's document says at which address those registers sit, how many of them form one value, in which order they are combined and which multiplier applies. If the definition on the SCADA side does not match the document, the device answers without any error, but the number on screen is wrong.

This guide is for solving that case in order. The examples use the example analyzer from Adding an energy analyzer to SCADA over Modbus TCP. The map is an example made up for these guides; it does not belong to a real product:

MeasurementRegistersRegister content (hex)Correct value
L1 current, 32-bit float40007–400084226 000041.5 A
Total active power, 32-bit float40019–4002046BA 540023,850 W
Active energy counter, 32-bit unsigned40101–401020013 99D71,284,567 (128,456.7 kWh)

The example device numbers its registers from 1 and sends the high word first in 32-bit values.

First tell them apart: wrong value or lost communication?

These are different problems and you look in different places. On the Monitoring > Tag States page, select the device, click Update and look at the Quality column:

QualityMeaningWhere to look
BadThe value cannot be read from the device.Communication: IP address, port, Slave Id, timeout, whether the address is defined in the device.
UncertainThe tag has not been reached yet.Wait if the device was just started; if it stays, treat it like Bad.
Good, value makes no senseThe device answers and the answer is interpreted wrongly.The five checks in this guide.

The Grid View tab of the Monitoring > Device States page shows the same distinction per device: Device Quality is the state of the connection, Tag Quality the state of the queries, and the Error and Error Date columns give the last error.

A hint: if only a few tags of a device are Bad and their addresses are close together, one of the addresses in the block that is read may not be defined in the device. 2Win Scada reads nearby addresses in one request; if the request fails, every tag in that request becomes Bad. Lowering Block Size on the device's Settings tab separates these tags.

If the quality is Good, go through the checks below in order. Change one thing at a time and compare the result with the value on the device's own display.

1. Address offset: from 0 or from 1?

Symptom: The value read belongs to the neighboring register. With 16-bit values the result looks plausible but is the wrong measurement (L2 voltage instead of L1 voltage, for example). With 32-bit values the halves of two different values are combined, so the result makes no sense.

Cause: Some documents number registers from 1 (40001, 40002, …), others give the protocol address from 0 (address 0, 1, …). The difference is exactly one register.

Example: Total active power is in registers 40019–40020. If the definition is shifted one register forward, 40020–40021 are read: the second half of the power, 5400, is combined with the next register. If the next register is 0, the result is 5400 0000, which as a float is about 2.2 × 10¹². The expected value was 23,850.

In the product: The Zero Based option on the device's Settings tab.

Zero BasedAddressProtocol address sent to the device
Selected (default)40001918
Cleared40001919

Keep the option selected if the document numbers registers from 1. Clear it if the document gives addresses from 0. The option applies to every tag of the device.

Device Definition window, Settings tab: Zero Based selected, First Word Low 32 Bit cleared, First DWord Low 64 Bit selected, Block Size 32

Screenshot: 2Win Scada 2.11.5, the Settings tab of a Modbus TCP device; First Word Low 32 Bit is cleared because the example device sends the high word first.

2. Register area: holding or input?

Symptom: The tag stays Bad, or a completely different value arrives.

Cause: Holding registers and input registers are separate areas and are read with separate functions. A holding register and an input register with the same number can hold different values; many devices offer measurements in only one of them.

Example: If the document says "Input registers (function 04), register 7", the address must be 300007. If you write 400007, 2Win Scada asks for the same number as a holding register (function 03).

In the product: The first digit of the tag's Address field.

First digitAreaRead function
0CoilFC01
1Discrete inputFC02
3Input registerFC04
4Holding registerFC03

The address is written with 6 digits (400007); the 5-digit form (40007) points to the same register. If the register number is above 9999, the 6-digit form is required: holding register 12001 becomes 412001.

3. Data type: 16-bit, 32-bit or float?

Symptom: The value is always an integer and seems unrelated to the measurement; or a value that should be negative appears around 65,000.

Cause: The same registers turn into different numbers with different types.

Example: The two power registers 46BA 5400, read with three different types:

Data TypeValue readExplanation
Real23,850Correct: 32-bit float
DInt1,186,616,320The same 32 bits, interpreted as an integer
Word18,106Only the first register (46BA) was read

The quality is Good in all three rows; the device answered all three queries correctly.

Tag States page, TipDenemesi device: three tags reading the same address; Guc_Real 23850, Guc_DInt 1186616320, Guc_Word 18106; all three with quality Good

Screenshot: 2Win Scada 2.11.5, Tag States; all three tags read address 400019, only the Data Type differs. The values come from the Modbus simulator prepared for this guide.

The sign is the same kind of error: a 16-bit register that holds −150 reads −150 as Int and 65,386 as Word.

In the product: The tag's Data Type field. How the names in documents map:

In the documentData TypeRegisters
INT16, signed 16-bitInt1
UINT16, unsigned 16-bitWord1
INT32DInt2
UINT32DWord2
FLOAT32, IEEE 754 singleReal2
INT64LInt4
UINT64ULInt or LWord4
FLOAT64, doubleLReal4

Length is always 1 for Modbus tags; also for a type that occupies several registers, the tag takes only the address of the first register.

4. Word order and byte order

Symptom: The type is right, the address is right, but the 32-bit value is a very large number or a number very close to zero.

Cause: A 32-bit value is split across two registers. Some devices send the high word first (big-endian, "ABCD"), others the low word ("word swap", "CDAB").

Example: The example device sends the high word first. If the setting is left the other way round:

MeasurementCorrect orderRead in the reversed order
Power (46BA 5400)23,8505400 46BA → about 2.2 × 10¹²
Current (4226 0000)41.50000 4226 → a number very close to 0
Counter (0013 99D7)1,284,56799D7 0013 → 2,581,004,307

In the product: The First Word Low 32 Bit option on the device's Settings tab.

First Word Low 32 BitFirst registerCommon name
Selected (default)Low wordWord swap / CDAB
ClearedHigh wordBig-endian / ABCD

Clear the option if the document says "high word first" or "big-endian". For 64-bit values there is also the First DWord Low 64 Bit option; the table in the manual shows all four combinations.

Two limits:

  • These options apply to every tag of the device. If one device uses two different word orders, read one of the values as two separate Word tags and combine them with an advanced tag expression.
  • The byte order inside each register is fixed by the Modbus standard (high byte first), and 2Win Scada has no setting that changes it. A device that sends the bytes inside a register reversed is handled the same way: read the register as Word and correct the value with an expression.

5. Multiplier and unit

Symptom: The value resembles the right measurement but is 10, 100 or 1000 times too large or too small; or current and power are too small by the current transformer ratio.

Cause: Many devices send a decimal value as an integer and give the multiplier in the document ("0.1 A", for example). Some analyzers also leave the current and voltage transformer ratios out of the value and send the secondary value.

Example:

CaseRaw valueScale Min Raw – Scale Max RawScale Min – Scale MaxResult
Current in steps of 0.1 A4150 – 100 – 141.5 A
Power in W, kW wanted on screen23,8500 – 10000 – 123.85 kW
Secondary current, transformer ratio 200/51.040 – 10 – 4041.6 A

In the product: The Scale fields in the tag row: Scale Active, Scale Min Raw, Scale Max Raw, Scale Min, Scale Max. Scaling is linear; values outside the range are converted with the same ratio. If Scale Min Clamp Active and Scale Max Clamp Active are selected, the result is held at Scale Min and Scale Max.

The Unit field is only a label; it does not convert the value. When you change the scaling, update the unit as well.

The consumption calculation has a multiplier of its own: Factor and Divisor in the log definition convert the calculated consumption; they do not change the tag's current value.

Quick checklist

What you seeWhere to look first
Quality BadCommunication: Device States, IP address, port, Slave Id, Block Size
The value of a neighboring measurementZero Based
An unexpected value, or Bad only at some addressesThe first digit of the address (3 or 4)
A meaningless integer, a value around 65,000Data Type
A 32-bit value that is very large or close to zeroFirst Word Low 32 Bit
A difference of 10, 100 or 1000 timesScale

After changing the device settings or the tag list, remember to reinitialize the device: the Reinitialize Device button next to the device in the Tag Management tree.

Related pages in the manual:

If you would like to go through your own device's map together, we can do that in a demo meeting.

All guides