31 August 2012

Byte and Word swap when dealing with 32 bits (4 Bytes) Modbus data


Note 1 – Article used as reference


Note 2 - Software used as reference

FPconverter from http://www.61131.com

Modbus protocol was designed based on devices with a 16-bit register length. Consequently, special considerations were required when implementing 32-bit data elements. This implementation settled on using two consecutive 16-bit registers to represent 32 bits of data or essentially 4 bytes of data.

Big-Endian is the most commonly used format for network protocols – so common, in fact, that it is also referred to as ‘network order’.

As a rule of thumb, the family of a device’s microprocessor determines its endianness. Typically, the big-Endian style (the high-order byte is stored first, followed by the low-order byte) is generally found in CPUs designed with a Motorola processor. The little-Endian style (the low-order byte is stored first, followed by the high-order byte) is generally found in CPUs using the Intel architecture.

System integrator has to be very careful when dealing with 32 bits Modbus data. Various manufacturers may implement various data swapping techniques as described in table below:

Swap Mode
Source Bytes
Target Bytes
None
AB
CD
AB
CD
Byte and Word swap
AB
CD
DC
BA
Byte swap
AB
CD
BA
DC
Word swap
AB
CD
CD
AB


No comments:

Post a Comment