Endianness / Byte Swap Converter
Swap byte and word orders (Little Endian, Big Endian) to resolve register mismatch.
32-Bit Input
Provide exactly 8 hex characters (4 bytes).
Endianness Swaps
Understanding Endianness in Industrial Networks
In the realm of industrial automation, endianness refers to the specific order in which bytes are arranged within multi-byte data types, such as 32-bit integers or floats, during memory storage or network transmission. Recognizing and managing endianness is crucial for seamless communication between disparate systems like PLCs, HMIs, and SCADA servers.
The Modbus Word Order Challenge
The Modbus protocol specification standardizes 16-bit registers using a Big-Endian format, meaning the most significant byte is transmitted first. However, Modbus does not dictate a standard for larger data types (like 32-bit REALs or DINTs). This ambiguity leads to four common byte and word permutations depending on the equipment manufacturer:
- ABCD (Big-Endian): The standard sequential order.
- BADC (Byte Swap): Swaps the bytes within each 16-bit word.
- CDAB (Word Swap): Swaps the two 16-bit words entirely.
- DCBA (Little-Endian): Both bytes and words are swapped.
Correcting Byte Swaps in PLCs
When a PLC reads Modbus data and the values appear erratic or wildly out of scale, a byte or word swap is usually required. Most automation platforms offer native solutions:
- Siemens (TIA Portal): Utilize the
SWAPinstruction for WORD and DWORD manipulation. - Allen-Bradley (Studio 5000): The
SWPB(Swap Byte) instruction easily reorders the data. - Standard IEC 61131-3: Use bitwise shift operations (
SHL,SHR) or rotate commands (ROL) to manually restructure the payload.
Driver Configurations and Troubleshooting
Before writing complex PLC logic, check your SCADA or OPC server configuration. Modern drivers in platforms like Ignition or Kepware allow you to select the exact byte/word order (e.g., “CDAB”) directly in the tag properties, handling the translation automatically. If you must troubleshoot manually, comparing the raw Hexadecimal values from the device manual against the PLC tag will quickly reveal the correct endianness format.