Modbus Word Swap Calculator

Visualize and swap word orders for 32-bit values in Modbus registers. Debug word ordering issues.

Modbus word swap endian byte order register float 32-bit

Input values

Enter values and click Calculate to see results here.

Formula

Input: Reg[N] = 0xHHHH, Reg[N+1] = 0xLLLL AB/CD: [HHHH][LLLL] — no swap (standard) CD/AB: [LLLL][HHHH] — word swap AB/BA: [HH][LL][HH][LL] → byte swap within words CD/DC: [LL][HH][LL][HH] — full byte swap

Worked Example

Given: Reg[0] = 0x41C8, Reg[1] = 0x0000

AB/CD: 0x41C80000 = 25.5 (correct)

CD/AB: 0x000041C8 = 3.28e-41 (wrong — looks like a tiny number)

Diagnosis: If you see a very small number, swap the word order. If you see a very large number, swap bytes within words.

Engineering Notes

  • Symptom diagnosis: Very small/large number → word order wrong. Garbled bytes → byte order wrong within words.
  • Common PLC word orders: Siemens S7 = CD/AB (byte-swapped). Allen-Bradley = AB/CD (big-endian). Schneider = AB/CD. ABB = CD/AB.
  • 32-bit integers: The same word swap rules apply to 32-bit integers (DINT/UDINT) stored in two holding registers.
  • Quick test: Write 1.0 (0x3F800000) to the device. Read back the two registers and apply each swap until you get 1.0.

References

  • MODBUS Application Protocol Specification V1.1b3