Danfoss MCO 305 Design Manual page 168

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

Advertisement

MCO 305 Design Guide
where a is a long variable and y is a double variable, then the a is cast to double before the multiplication is
executed. But you must be careful. If
y = a % 2
Then the integer a is first divided by 2 (integer arithmetic) and then the result is converted to double before
it is assigned to y.
Functions
APOSS supports functions and local variables. Functions can have the type LONG or DOUBLE. A function can
have maximum 100 parameters. Functions must be declared before they are used. This can either be done
by defining them first or by using a declaration statement. (See examples below).
Functions must always have a return type of either LONG or DOUBLE. No VOID functions are supported at
the moment.
The body of the function must be enclosed in braces.
All variables defined inside a function are local. That means they are not visible outside the function.
Local variables are stored temporarily on the stack. So defining a lot of local variables or local arrays may
overflow the stack (see stack size in compiler options).
long test_func (long a, long b, double c) ;
...
wert = test_func(a,b,c)
...
long test_func(long a, long b, double c)
{
long result, tmpval
....
return(result)
}
Functions can handle LONG or DOUBLE variables (or expressions) as parameters. This is done "by value".
This means that inside the functions, those parameters are locally defined.
Arrays can also be passed and this is done "by reference". This allows the original array to be modified
inside the function.
DIM test[100]
long modi(long[] myarray, long index)
{
myarray[index] = myarray[index] * 10
return(index)
}
...
modi(test,2)
// element 2 of test will be multiplied by 10
NB!:
Functions are supported starting with MCO 5.00.
168
__ How to Program __
// declaration statement
// using the function
// function definition
// local variables
// here we return the value of the function
®
MG.33.L5.02 – VLT
is a registered Danfoss trademark

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents