Arrays

An array tag holds several values of one type under one name, numbered from 0. Levels, a DINT array of 5, holds Levels[0] to Levels[4].

One name, numbered values

A DINT array of 5 called Levels, after a few readings:

ElementValue
Levels[0]12
Levels[1]15
Levels[2]19
Levels[3]0
Levels[4]0

The first element is 0, so an array of 5 ends at 4. There is no Levels[5].

Create an array tag

  1. Stop the PLC. In the Tags table, click + Tag.
  2. Type a name, such as Levels, and choose ARRAY under Array in Type.
  3. Choose the Element type: BOOL, DINT or REAL.
  4. Type the Dimensions: 5 for a list of 5, or 4, 3 for a grid of 4 rows and 3 columns.
  5. Click Create. The Tags table shows the type as DINT[5] or DINT[4×3]. Expand the row to see every element.

Dimensions

DimensionsTypeElementsFirst and last
5DINT[5]5Levels[0] … Levels[4]
4, 3REAL[4×3]12Grid[0,0] … Grid[3,2]
2, 3, 4BOOL[2×3×4]24Bits[0,0,0] … Bits[1,2,3]

An array has one to three dimensions and 1 to 256 elements in all. In Grid[1,2] the first number is the row and the second the column.

Use one element

Where an instruction accepts an element, choose the array tag in the Inspector, then type each index. MOV SpeedSet Levels[2] writes one element and leaves the others as they are. Each index is a fixed number.

Work on a whole line

Copy array and Fill array work on a line of elements. In a list the line is the whole array; in a grid you choose which row or column.

RungLevels beforeLevels after
FILL Value 0, Dest Levels, Dest start 0, Count 512 15 19 0 00 0 0 0 0
COPY Source Levels, Source start 0, Dest Levels, Dest start 1, Count 412 15 19 7 012 12 15 19 7

The second rung shifts every reading one place along, ready for a new one in Levels[0]. Copy array reads every source element before it writes, so a copy inside one array works even when the ranges overlap.

Good to know

  • An array tag is always a Global tag.
  • The element type and dimensions are fixed once the tag is made. To change them, make a new tag.
  • A range past the end of the array is a fault, and nothing is written. Check Start plus Count against the size.
  • Tag export to a CSV file leaves array tags out. Save the project file to keep them.
  • Arena export does not accept Copy array or Fill array.

Related