Example for an array with automatic addressing (BOOL variable)

Previous chapterNext chapter Show allShow all    Hide allHide all

We use the same configuration as in the example above, but this time use the standard data type BOOL.

All other settings stay as above and we now create a new array variable.

In the properties of the array variable we set the following values: datablock 50, net address 0, offset 100 and bit address 0.

By pressing OK, the array with all array elements in the variable list is created.

As we kept the S7 driver, the automatic addressing has the following result:

1

Array of BOOL[1] has the address: Net address 0, datablock 50, offset 100, bit number 0

2

Array of BOOL[2] has the address: Net address 0, datablock 50, offset 101, bit number 0

3

Array of BOOL[3] has the address: Net address 0, datablock 50, offset 102, bit number 0

4

Array of BOOL[4] has the address: Net address 0, datablock 50, offset 103, bit number 0

5

Array of BOOL[5] has the address: Net address 0, datablock 50, offset 104, bit number 0

A 1 bit variable has enough room in a 8 bit offset. Because of the activated option "Each data type starts with new offset", each array element starts a new offset.

If we deactivate this property in the array variable, we get the following addressing:

1

Array of BOOL[1] has the address: Net address 0, datablock 50, offset 100, bit number 0

2

Array of BOOL[2] has the address: Net address 0, datablock 50, offset 100, bit number 1

3

Array of BOOL[3] has the address: Net address 0, datablock 50, offset 100, bit number 2

4

Array of BOOL[4] has the address: Net address 0, datablock 50, offset 100, bit number 3

5

Array of BOOL[5] has the address: Net address 0, datablock 50, offset 100, bit number 4

Now the bits are all in one offset. If the offset would not be big enough (e.g. array of 20 BOOL variable), the next bit would be the first of the next offset. An array of 20 BOOL variable would be from offset 100 bit number 0 to offset 102 bit number 3.