← Bit Manipulation

Combine Two Registers

medium

Combines two 16-bit device registers into one 32-bit word.

What it teaches

Devices and protocols often split one 32-bit value across two 16-bit registers, and a 16-bit register is an INT. Put the low register in output bits 0-15 and the high register in bits 16-31. Register order matters; a register whose top bit is set reads as a negative number, so mask each one to its own 16 bits before combining, or the sign spreads across the bits above it. Setting output bit 31 then makes the DINT itself negative.

Parameters

TagDirectionTypeDefaultDescription
In_LowRegisterInputINT22136Low register from the device
In_HighRegisterInputINT4660High register from the device
Out_ValueOutputDINT0Combined 32-bit value

Required behavior