Download Print this page

Danfoss MCO 305 Design Manual page 86

Hide thumbs Also See for MCO 305:

Advertisement

MCO 305 Design Guide
The DIM statement specifies the arrays to be subsequently used. If no arrays have been previously created
then they will be created now. If arrays had been previously defined then it is important that the
information corresponds with the original definition.
Program sample
DIM target1[20], target2[20], target3[20], plant_offset[50]
DIM parameter[10]
With these commands a total of 5 arrays have been defined with their corresponding sizes. If this program
is executed once then the arrays listed above will be created in the option board. If, when the program is
re-started, it is determined that the definition of the arrays differs from the arrays in the option board then
this is indicated as an error. However, it is correct if a second program only contains the following line:
Program sample
DIM target1[20], target2[20], target3[20]
However, the sequence of definition must always be the same since the option board 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.
Program sample
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 in the program sample are correct:
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 permitted variables by
one. The maximum number of variables can be set in the menu Settings
Arithmetic, Operators
The compiler offers the following commands and parameters:
Operators
Bit operators
Comparison Operations
Logical Operations
86
__ How to Program __
plus, minus, times, divided by, XOR, Modulo, Division, Absolute amount
and, or, invert, left shift, rightshift, bit, byte, word, long
greater than, less than, greater than or equal to, less than or equal to, the
same as, not equal
and, or, not
®
MG.33.L4.02 – VLT
is a registered Danfoss trademark
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
Compiler.

Advertisement

loading