BMS Logic Academy – Building Logic One Block At A Time
Menu

← Modbus training series

Modbus training / Part 5 of 6

Modbus Data Types and Byte Order

Understand signed and unsigned numbers, scaling, 32-bit registers and byte order.

See where the four bytes go

A 32-bit value occupies two consecutive registers. Each letter below stands for one byte. Read each pair as one register.

High word firstA B │ C DRegister 1 = AB · Register 2 = CD
Words swappedC D │ A BRegister 1 = CD · Register 2 = AB
Why data types matter

Working communication and the correct address do not guarantee a correct displayed value. The BMS needs the correct width, signedness, scaling, word order and engineering units.

Unsigned 16-bit

One register (16 bits, two bytes). Range: 0–65,535. Suitable for positive counters and scaled values.

Signed 16-bit

One register. Range: −32,768 to 32,767. Uses two’s-complement representation to support negative numbers such as temperature offsets.

One raw value, two interpretations

Scaling and units

Apply exactly the factor specified by the manufacturer. Examples: 750 × 0.1 = 75.0% and 215 × 0.1 = 21.5 °C. The factor may instead call for division, and some registers use offsets. Always verify against the device display.

Bits, bytes and words

8 bits make a byte. A 16-bit Modbus register contains 2 bytes; a 32-bit value uses 4 bytes across two consecutive 16-bit registers. One word may represent a packed group of 16 alarm/status bits.

Decimal status word 13 = binary 0000 0000 0000 1101. Bits 0, 2 and 3 are set. Interpret them using the manufacturer's bit definitions, not generic assumptions.

32-bit integers and floating-point values

A 32-bit unsigned integer can range from 0 to 4,294,967,295. A 32-bit IEEE 754 floating-point number is encoded differently from an integer even though both occupy four bytes.

Word and byte order

Normal high-word first: B1 B2 | B3 B4.

Swapped words: B3 B4 | B1 B2.

Other devices may reverse bytes within words. Use the order explicitly given in the register map.

Trend IQ and Niagara integration

Trend IQ SET Modbus byte order choices include Big Endian (B1 B2 B3 B4), Little Endian (B4 B3 B2 B1), Big Endian/Word Swap (B3 B4 B1 B2) and Little Endian/Word Swap (B2 B1 B4 B3).

Niagara drivers may label byte orders numerically, such as 0123, 1032 or 3210. Verify what each driver's labels mean before assigning the matching configuration. Do not assume equivalent names across platforms.

Worked example: a 32-bit integer

Decimal 65,538 = hexadecimal 0x00010002.

High word first: register 1 = 0x0001, register 2 = 0x0002. Calculation: (1 × 65,536) + 2 = 65,538.

Low word first: register 1 = 0x0002, register 2 = 0x0001. The value remains 65,538 only when decoded in the correct order; decoding these swapped registers as high-word-first gives 131,073.

Four common byte layouts
LayoutRegister 1Register 2
ABCD – no swap12 3456 78
CDAB – word swap56 7812 34
BADC – byte swap34 1278 56
DCBA – both swaps78 5634 12

The examples show hexadecimal bytes, not separate 16-bit integers. Verify each driver’s exact mapping.

Toolkit example

For Float32 21.0, the standard IEEE 754 bytes are 41 A8 00 00. For UInt32 21, the bytes are 00 00 00 15. The same engineering number uses different binary encodings.

A misleading success case

An incorrectly offset and word-swapped 32-bit unsigned integer can appear correct while its value fits within 16 bits: reading the second word as the first word can mask an addressing error. This is not a general rule for floating-point values. Always verify the true starting register and byte/word arrangement from the manufacturer, including a meaningful changing value.

Explore the Modbus Toolkit to inspect raw bits and 32-bit word order.

Check your understanding

How many registers store a 32-bit value, and why can the reading still be wrong?

Reveal answer

Two consecutive 16-bit registers. The type, signedness, scaling, starting address and byte/word order must all match.

Reference: Modbus protocol specifications. Always consult the equipment manufacturer’s register map.