What is Arrays data structure in PLC?| Array Data type.

Published on May20, 2023 | Category: Introduction

Share this Page:

An array is a data structure that can store multiple values of the same data type under a single variable or single tag. array are useful for large amounts of data complex sets of data. Arrays are useful for storing large amounts of data in a single variable or tag. DINT water_level_pre[12].water_level_pre[12] alloocated space for the 12 element array water_level_pre and the element of array are of DINT data type, these element accessed as water_level_pre[0],water_level_pre[1], water_level_pre[2]....water_level_pre[11].Each element in an array is accessed by an index, which represents the position of the element in the array. The index or subscript of an array always starts at 0.Arrays are easy to implement and use, since most programming languages support them as a built-in type or a library. Arrays have fast access time, since we can access any element in an array by using its index in constant time. Arrays have fixed size, which means they cannot grow or shrink dynamically according to the data needs. We have to allocate enough memory for an array at the time of its creation, and we cannot add more elements than its capacity.

how to declare array data type in plc

in a plc an array is declared by specifying its data type, name of array structure (variable name or tag name) and size of array. For example, `real plc1[100]` declares an array of 100 real values name of array is PLC1. Below is example of studio 5000 array declarations of bool and real data type. In array declarations uses square brackets, the number inside the brackets is the index of the element we want to access.

following are common properties of array data structure required for decalration of arra data type.

img/array/how to declare array data type in plc.webp

types of array in plc

types of array is depend on plc manufacturer some of the plc support single dimensional array but some plc support multidimensional array. Arrays can be classified based on their dimensions, which refer to the number of indices required to access an element in the array.

img/array/types of array in plc.webp

One-dimensional Array

Mostly in our plc we use single dimensional array, single dimensional array is linear array and it is a very simple array. Element of one dimensional array are accessed by The index value. Index value starts from 0 and goes up to the size of the array minus one. for example real motor_current[12]. array name is motor_current current so we stored 12 motor current in single variable motor_current. and each elements of this array is accessed as motor_current[index name].index name range from 0 to 11 (size of array-1).

img/array/One-dimensional Array.webp

example of array single dimensional array in plc

below is the declaration of array data type in studio 5000. in this example we use single dimensional array bool data type.

img/array/example of array single dimensional array in plc.webp

example of two dimensional array in plc

in a two dimensional array has two index, index are separated by comma (,) in this example we compare temperature value to previous temperature value of process.

img/array/example of two dimensional array in plc.webp

example of three dimensional array in plc

below is the example of three dimensional array in studio 5000 plc. This is program for storing motor current here we use a move instructions to move motot_current[0,0,1] to report_data[0,0,2]. in a three dimensional array have three index separated by comma (,).

img/array/example of three dimensional array in plc.webp

example of array in Structured Text

img/array/example of array in Structured Text.webp

above is the example of array in Structured Text we use if else conditional statement. First example is single dimensional array and second example is two dimensional array example.

Use of array in plc