← Bit Manipulation

Swap Register Bytes

easy

Reads a 16-bit register from a device that sends its high byte first.

What it teaches

A register is two bytes, and not every device stores them in the same order. A Siemens PLC or a Modbus device that sends the high byte first delivers 4660 (16#1234) as 13330 (16#3412). SWPB puts the bytes back: on an INT every order mode swaps the two bytes. It moves whole bytes, never decimal digits, so look at the value in hex to see what moved. Unlike Combine Two Registers, nothing is combined; one register is reordered.

Parameters

TagDirectionTypeDefaultDescription
In_RawInputINT13330Register as received, high byte first
Out_ValueOutputINT0The register's value in this controller's byte order

Required behavior