Example for an array with automatic addressing (INT variable) |
Manual -> Variables -> Variables -> Array variables -> Automatic addressing -> Example for an array with automatic addressing (INT variable) |
Show all Hide all |
We will create an array of five integer variables as shown above.
The name is freely definable. As a driver we will use the S7 TCP/IP and as a driver object type "datablock". As a data type we choose INT.
And we set the options: "Automatic addressing" and "Each data type starts with new offset".
At the end we define, that all elements should be activated.
After clicking OK
, the five defined variables are
created in the variable list. Additionally a corresponding array
variable is created in which we can set the array properties.
When selecting the array variable in the detailview, the properties of the whole array can be edited in the properties window. The most important settings are in the group "Addressing". There the datablock, the netddress (= bus address) and the start offset can be changed. As "Automatic addressing" was actiavted, all the addresses of the single array elements depend on this start offset.
In our example, we change the datablock to 50, we leave the net address at 0 and change the offset to 100.
The granularity of the S7 datablocks is 8 bit. So the datablock area is byte-oriented.
Each INT variable needs 16 bits.
This results in the following automatic addressing for our array:
Array of INT[1] has the address: Net address 0, datablock 50, offset 100 |
Array of INT[2] has the address: Net address 0, datablock 50, offset 102 |
Array of INT[3] has the address: Net address 0, datablock 50, offset 104 |
Array of INT[4] has the address: Net address 0, datablock 50, offset 106 |
Array of INT[5] has the address: Net address 0, datablock 50, offset 108 |
Each offset is two higher than the previous, as a 16 bit variable
needs two 8 bit offsets.
Taking a S5 driver instead of the S7 driver changes the addressing. On the S5, the datablock area has a granularity of 16 bits. The datablock area of a S5 PLC is word-oriented.
Identical projecting would lead to the following result:
Array of INT[1] has the address: Net address 0, datablock 50, offset 100NT |
Array of INT[2] has the address: Net address 0, datablock 50, offset 101 |
Array of INT[3] has the address: Net address 0, datablock 50, offset 102 |
Array of INT[4] has the address: Net address 0, datablock 50, offset 103 |
Array of INT[5] has the address: Net address 0, datablock 50, offset 104 |
each offset now is only 1 higher than the previous, as a 16 bit variable needs only one 16 bit offset.