Download Introduction

Transcript
Chapter 3
Address Data
Guidelines for Arrays
Guideline
Description
You can create arrays of most data types,
except for ALARM, AXIS,
COORDINATE_SYSTEM, MOTION_GROUP,
and MESSAGE data types.
A subscript identifies an individual element within the array. A subscript starts at 0 and
extends to the number of elements minus 1 (zero based).
• Single-dimension arrays take less memory and execute faster than two-dimension
or three-dimension arrays.
• Direct references to array elements execute faster than indexed references.
• An array can be as large as 2 MB.
• If you create an array of structures, the memory for each element is allocated based
on the structure definition.
Type of Array
Single (1) dimension
Benefit
• Better support by native file
instructions
• Fully supported in user-defined
structures and arrays
• Smallest impact (execution time and
memory) for indexed references
• Can create new arrays when
programming online
Double (2) dimension
and
Triple (3) dimension
Considerations
• Multiple arrays cannot be indirectly
referenced like in PLC or SLC
processors (such as, N[N7:0]:5)
• BOOL arrays not directly supported
by file instructions
• Can be changed only when
programming offline
• Can provide a more accurate data
representation for a physical system
• Larger impact (execution time and
memory) for indexed references
• Can emulate PLC file/word
indirection with a two-dimension
array
• File manipulation requires extra code
in addition to file instructions
• Can create new arrays when
programming online
• Can only be changed when
programming offline
Nest arrays.
The file instructions offer limited support for arrays. To work with array data, create a
user-defined structure with one array as a member of the structure. Then create an array tag
by using the user-defined structure as its data type.
Select the data type of the array based on
the data, as well as the instructions that
manipulate that data.
While SINT and INT arrays can compact more values into a given memory area, they require
additional memory and execution time for each instruction that references the array.
Limit arrays to 2 MB of data.
The maximum array size is 2 MB. The software displays a warning if you try to create an
array that is too large. The software also displays a warning if an array is 1.5...2 MB in size,
even though these sizes are valid.
Edit arrays online and offline.
You can create new arrays when online or offline. However, you can modify only the size or
data type of an existing array when offline.
44
Publication 1756-RM094C-EN-P - June 2007