<< Click to Display Table of Contents >> Navigation: Modbus Universal MasterOPC Server > MasterOPC Universal Modbus Server > The Design-Time Mode > The Byte Swapping Editor > Setting the Sequence of Bytes |
Setting the sequence of bytes is very important when working with the Modbus protocol because there are no clear standards in the order of byte transmission, and different manufacturers can form such an order differently. The byte transmission order in the OPC server must correspond to the byte transmission order in the device, otherwise data received are incorrect. For example, let's consider transmission of the number 100 (0x64 in HEX) with the data type int16. Because of the data type is int16 (2-byte integer), two bytes of the number 100 are 00 64. If we set the byte order as "upper byte first", we get a correct result 00 64 (100). But if we set the byte order as "lower byte first", we get an incorrect result 64 00 (25600).
The byte swapping editor defines a byte order in a request sent and in a reply received. A byte sequence can be set at the device level or at the tag level. By default, tags inherit a byte order configured at the device level. That is, the tag setting of byte order is switched off by default. If required, this tag setting can be switched on, and the byte sequence can be configured for the tag individually.
Note. Bytes of STRING-type variables cannot be swapped, and a byte order in strings always correspond to the initial order of bytes received.