Memory Allocation for Arrays
The amount of memory that an array uses depends on the data type used to create the array. The minimum allocation within the controller is four bytes, which is the same as 4 SINTs, 2 INTs, or 1 DINT.
The following examples show memory allocation for various arrays:
small_values as SINT[8]
This example is an array with 8 elements, each of data type SINT (1 byte each element).
Bit | 31 24 | 23 16 | 15 8 | 7 0 |
data allocation 1 | small_values[3] | small_values[2] | small_values[1] | small_values[0] |
data allocation 2 | small_values[7] | small_values[6] | small_values[5] | small_values[4] |
small_values as SINT[3]
This example is an array with 3 elements, each of data type SINT (1 byte each element). Because the minimum data allocation is 4 bytes, the last byte is zero.
Bit | 31 24 | 23 16 | 15 8 | 7 0 |
data allocation 1 | 0 | small_values[2] | small_values[1] | small_values[0] |
values as INT[4]
This example is an array with 4 elements, each of data type INT (2 bytes each element).
Bit | 31 16 | 15 0 |
data allocation 1 | values[1] | values[0] |
data allocation 2 | values[3] | values[2] |
big_values as DINT[2]
This example is an array with 2 elements, each of type DINT (4 bytes each element).
Bit | 31 0 |
data allocation 1 | big_values[0] |
data allocation 2 | big_values[1] |
timer_list as TIMER[2]
This example is an array with 2 elements, each element is a TIMER structure (12 bytes each structure).
Bit | 31 0 |
data allocation 1 | timer_list[0] status bits |
data allocation 2 | timer_list[0].pre |
data allocation 3 | timer_list[0].acc |
data allocation 4 | timer_list[1] status bits |
data allocation 5 | timer_list[1].pre |
data allocation 6 | timer_list[1].acc |
small_values as SINT[2,2,2]
This example is a three-dimensional array with 8 elements, each of data type SINT.
Bit | 31 24 | 23 16 | 15 8 | 7 0 |
data allocation 1 | small_values[0,1, 1] | small_values[0,1, 0] | small_values[0,0, 1] | small_values[0,0, 0] |
data allocation 2 | small_values[1,1, 1] | small_values[1,1, 0] | small_values[1,0, 1] | small_values[1,0, 0] |
big_values as DINT[2,2,2]
This example is a three-dimensional array with 8 elements, each of type DINT.
Bit | 31 0 |
data allocation 1 | big_values[0,0,0] |
data allocation 2 | big_values[0,0,1] |
data allocation 3 | big_values[0,1,0] |
data allocation 4 | big_values[0,1,1] |
data allocation 5 | big_values[1,0,0] |
data allocation 6 | big_values[1,0,1] |
data allocation 7 | big_values[1,1,0] |
data allocation 8 | big_values[1,1,1] |
You can modify array dimensions when programming offline without loss of tag data. You cannot modify array dimensions when programming online.
Provide Feedback