meta data for this page
This is an old revision of the document!
BYTE – WORD type variables
There are plenty of variables in the world of automation. They differ in scope (size) and internal structure depending on their use.
The simplest variable types have no internal structure, i.e., they can describe ones and zeros in different scopes:
The longest 64-bit LWord didn't fit in the example above, but I think it's relatively easy to imagine. The byte positions are on the bottom row. If everything works well, this is the byte order for the longer variable types, but sometimes confusion arises in the matrix, and this order gets “tangled”.
This most often happens when we try to transfer long variables via communication to other systems, such as HMI. In such cases, it is definitely worth testing the transfer, for example, with the above trick, because when the specified #deadbeef is on one side. If the destination side shows #beefdead or #efbeadde, we can rightly suspect a conversion discrepancy, which is easiest to correct on the starting side by swapping the structures.
The following types are unsigned (UNSIGNED), meaning their minimum value is always zero.
Let's review the basic variable types and their features:
| Type | Bit | Min. | Max. | Value range HEX | Value range DEC |
|---|---|---|---|---|---|
| BYTE | 8 | 0 | 28-1 | 0 .. FF | 0 .. 255 |
| WORD | 16 | 0 | 216-1 | 0 .. FFFF | 0 .. 65.535 |
| DWORD | 32 | 0 | 232-1 | 0 .. FFFF_FFFF | 0 .. 4.294.967.295 |
| LWORD | 64 | 0 | 264-1 | 0 .. FFFF_FFFF_ FFFF_FFFF | 0 .. 18.446.744.073.709.551.615 |
