
82
SM-Applications Modules & Motion Processors User Guide
Issue Number: 4
7.3.3
Initialization of Variables
All variables must be given an initial value before they can be used. This is typically
done within the INITIAL task. For example,
7.3.4
Scope and Lifetime of Variables
Variables can either be global or local. All variables declared in DPL programs are
global. i.e. they can be accessed and altered by any task, with the exception of
variables within a User Defined Function Block which are local (i.e. cannot be accessed
from outside the user defined function block).
No DPL variables survive a reset of the Second Processor. Remember that resetting the
drive from a tripped condition will also cause a reset (depending on the value in
Pr
xx.15
).
7.3.5
Fixed-size Variable Arrays
A DPL program may contain arrays of either integer or floating-point variables. Only
fixed-size (single-dimension) arrays are allowed.
An array must first be declared using the DIM statement (usually in the Initial task), and
the number of elements given in square brackets after the variable name, e.g:
The elements in an array are numbered 0 to number_of_elements - 1. So from the
above example, the first element of myarray%[] is:
myarray%[0]
and the last is:
myarray%[19]
Two functions are provided that can be used at run-time to determine the upper and
lower bounds of an array. These are UPPER and LOWER. for myarray%[], UPPER will
return 19 and LOWER will return 0.
7.3.6
Constant Arrays
Constant arrays, as the name suggests, contain fixed pre-defined values. The values of
the constant array are defined within the DPL program by using a special section (see
CONST in the on-line help). Only integer values can be defined.
The advantage of constant arrays is that the size of the array is only limited by the
amount of available program space - and not variable RAM. The program space is
384kb - it is used to store the compiled DPL file, constant array data, and optionally, the
DPL file itself.
7.3.7
Storage Space - Number of variables
All variables, fixed-size variable arrays and PLC registers live in an 80kbytes memory
space. Each integer variable and single-precision floating point variable consumes 4-
bytes (32-bit), and double-precision floating point variables consume 8-bytes (64-bit).
There are other things that consume memory as well, such as parameter accesses.
The DPL compiler will notify you if you reach the limit of available memory.
Initial {
Speed_SP% = 0
Ramp% = 0
}
DIM MyArray%[20]
// Integer array having 20 elements
DIM Array2[30]
// Floating point array having 30 elements
Summary of Contents for Digitax ST Indexer
Page 131: ......
Page 132: ...0471 0062 04...