93
MG.10.J8.02 – VLT is a registered Danfoss trade mark
Programmable SyncPos motion controller
However, the sequence of definition must always be
the same since the SyncPos option does not store
the names of the arrays but only their position in the
DIM statement. Thus the following program line is
also correct and the xpos array is identical to the
target1 array.
Example
DIM xpos[20], ypos[20], zpos[20], offs[50]
Indexes
The elements of an array are designated by a
corresponding index in square brackets: xpos[5].
Indexes are allowed from 1 to the size of the array
defined. Thus, in the above case for xpos from 1 to
20. If an attempt is made to access elements
before or after this array then an error message is
generated since this could lead to data overrun
and destruction of the array.
Reading and Writing Arrays
Access to the arrays thus defined is made analog
to the use of variables. Thus all of the following
statements are correct:
Example
xpos [1] = 10000
xpos [2] = 20000
xpos [3] = 30000
i = 1
WHILE (i<20) DO
ypos [i] = i*1000
i = i+1
ENDWHILE
zpos [1] = APOS
POSA xpos [1]
offs [1] = (xpos[2]) % 20
Arrays versus Variables
In general arrays can be used everywhere variables
are also permitted. Furthermore, an array only
occupies the location of an internal variable and
thus only reduces the number of maximally permit-
ted variables by one. The maximum number of
variables can be set in the menu "SETTINGS" →
"COMPILER".
■■
■■
■ Arithmetic
The compiler offers the following commands and
parameters:
Operators plus, minus, times, divided
by, XOR, Modulo, Division,
Absolute amount
Bit operators and, or, invert, left shift,
rightshift, bit, byte, word,
long
Comparison Operations greater than, less than,
greater than or equal to,
less than or equal to, the
same as, not equal
Logical Operations and, or, not
Inform yourself about the type of assignment ope-
ration which is structured in accordance with the
Bit/Byte commands and about the priorities of the
operators and the operations.
NB!
All arithmetical operations are integer
number operations.
Programming with SyncPos