← Bit Manipulation

REAL From Two Registers

medium

Reads a REAL that a Modbus device sends in two registers, high word first.

What it teaches

A REAL is 32 bits, which device manuals call a float, and Modbus carries it in two 16-bit registers. COP copies bits without converting them, so copying the two registers into a DINT and then into a REAL rebuilds the value, but it puts register 0 in the low half. When the device sends the high word first, SWPB with WORD swaps the halves back before the bits become a REAL. A wrong order is easy to spot: 24.0 reads as a tiny number near 2.36e-41. Builds on Combine Two Registers and Swap Register Bytes.

Parameters

TagDirectionTypeDefaultDescription
Out_ValueOutputREAL0The device's REAL value
Ref_RegistersInOutINT[2]—Two registers as received; register 0 holds the high word

Required behavior