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. Put the low register in output bits 0-15 and the high register in bits 16-31. Register order matters, only the low 16 bits of each input belong to the result, and setting output bit 31 makes the DINT appear negative.
Inputs and outputs
| Tag | Type | Default | Description |
|---|---|---|---|
| In_LowRegister | DINT | 22136 | Low register; only bits 0-15 are used |
| In_HighRegister | DINT | 4660 | High register; only bits 0-15 are used |
| Out_Value | DINT | — | Combined 32-bit value |
Required behavior
- Bits 0-15 of Out_Value follow bits 0-15 of In_LowRegister every scan.
- Bits 16-31 of Out_Value follow bits 0-15 of In_HighRegister every scan.
- Bits 16-31 of each input register are ignored.
- All 32 bits of Out_Value are rebuilt every scan; no previous output bits are retained.
- With the defaults, low register 22136 (16#5678) and high register 4660 (16#1234) produce 305419896 (16#12345678).