Glossary · PLC and control programming
Array
Also known as: ARRAY data type, Field (array)
German: Array
In IEC 61131-3 programming, an array is a derived data type that holds a fixed number of elements of the same data type, addressed by one or more integer indices within declared bounds.
- PLC programming
- Standards
In one sentence
An array in IEC 61131-3 holds a fixed number of same-type elements addressed by index, such as ARRAY[1..10] OF INT.
Example
A palletizer program declares ARRAY[1..24] OF BOOL to track which of the 24 positions on a pallet layer are already filled.
How it applies
- Engineering: Arrays group repeated values, such as the temperatures of eight heating zones or the states of 24 pallet positions. Loops in Structured text (ST) iterate over them instead of repeating code. Arrays can also hold structures, for example an array of recipe steps.
- Commissioning: Index errors are a classic source of faults. Many runtimes stop the controller or raise an exception when an index leaves the declared bounds, so bounds checks belong in the code and in the test cases.
- Maintenance: Changing array bounds changes the memory layout. On many controllers this cannot be done as an Online change without reinitializing data.
- Documentation: Document what each index means (zone 1 = infeed, zone 8 = outfeed) and the valid range. A table in the software reference that maps indices to physical positions saves service technicians a lot of guessing.
Array vs. structure
An array holds many elements of the same type, addressed by number. A Structure (data type) holds named elements of different types. Real programs often combine both: an array of structures describing identical machine modules.