Danfoss MCO 305 Design Manual page 166

Programmable motion controller
Hide thumbs Also See for MCO 305:
Table of Contents

Advertisement

MCO 305 Design Guide
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 → Compiler.
Switch Statement
Switch statements are supported starting with MCO
5.00:
The following expressions are valid
Break Statement
Break statements are supported starting with MCO 5.00:
The new break statement is not only useful for switch statements (see above) but also to leave WHILE and
REPEAT loops. If used in such a loop, a break leaves the loop. In nested loops only the inner loop is exited.
Pragmas
At the moment there are only two pragma directives:
#pragma NOIMPLICIT
#pragma IMPLICIT
NOIMPLICIT tells the compiler that no implicit variable declarations are allowed any more. That means that
every variable must be declared before it is used. IMPLICIT tells the compiler that implicit variable
declarations are allowed again. Declaration statements look as follows:
166
__ How to Program __
xpos [1] = 10000
xpos [2] = 20000
xpos [3] = 30000
i = 1
WHILE (i<20) DO
ENDWHILE
zpos [1] = APOS
POSA xpos [1]
offs [1] = (xpos[2]) % 20
#define WITH 1
#define WITHOUT 2
LONG val
val = WITH
switch (val)
endswitch
®
MG.33.L5.02 – VLT
is a registered Danfoss trademark
ypos [i] = i*1000
i = i+1
case
WITH:
var = var + 1
break
case WITHOUT: var = var - 1
// fall through
default :
var = var % 2

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents