|Show all Hide all|
The offsets and the bit numbers are defined in the structure elements in the data type. But there only a relative offset is defined. In the structure variable a start offset is defined and all relative offsets are added to this start offset.
Example: As shown above we create the structure data type Controller, for the single structure elements offsets are defined, e.g. offset 3 for structure element Engine Speed Set..
On creating the structure variable the option Automatic addressing is not activated. Start offset 100 is defined in the properties of the structure variable. zenon now calculates offset 103 for the address of the variable 'Engine Speed Control.Engine Speed.Set'. (100 from the structure + 3 from the structure element).
If the relative offset should be changed lateron the following steps have to be done: First the offset in the structure element in the data type has to be changed. Then the start offset in the structure variable has to be changed (e.g. to 101) and then it can be set back to the original offset (in our example 100). Background: The new address calculation is only done, when the start offset in the structure variable is changed, and not if only the offset in a structure element is changed.