Danfoss MCO 305 Design Manual page 167

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

Advertisement

MCO 305 Design Guide
long a,b,c,d
double u,v,y,z
// x is not allowed, because it is used for axes notification x(n)
It is recommended that NOIMPLICIT be used since this avoids the creation of unwanted definitions of new
LONG variables by mistake (e.g. a misspelled variable name).
NB!:
Pragmas are supported starting with MCO 5.00.
Variable Types
Variable types are available starting with MCO 5.00.
APOSS supports variables of type LONG and DOUBLE. LONG variables can be defined implicitly by just using
them (unless the NOIMPLICIT pragma is used). DOUBLE variables must be declared before they are used.
Declaration of those variables looks like:
long a,b,c,d
double u,v,y,z
// x is not allowed, because it is used for axes notification x(n)
Implementation of DOUBLE variables is hardware and firmware dependent. MCO305 (firmware > 5.00) –
uses 64 bit precision (some double functions like sqrt, sin, cos .. are only 32 bit precision).
Additionally, the following DOUBLE functions are supported:
sqrt, sin, cos, tan, acos, asin, atan, grad, rad, ln, exp, as well as the constant PI. These functions are only
32-bit precision for some hardware (MCO305). They can be used as follows:
y = sqrt(x) // returns the square root of x
y = sin(x)
// returns the sine of x (this also works for cos, tan, acos, asin, atan)
y = grad(x) // converts x (radians) into degrees (0..360)
y = rad(x)
// converts degrees into radians (0.. 2 *pi)
x = pi * 0.5 // Pi is 3.1415....
y = ln (x)
// returns the natural logarithm of x
y = x exp u // returns x raised to u (x
The double functions can be used: FABS returns the floating point absolute value of a floating point
argument.
double dx, dy
dy = -100.00 % 15.0 // this will be -6.6666..
dx = fabs(dx) // this gives back 6.6666..
ROUND rounds the floating point argument to the closest integer. This function still returns a double.
dx = round(dy) // this will be -7.0000
The RND command for integers also works for negative numbers.
a = -100
b = a rnd 15 // now correctly delivers –7
Furthermore, a cast operator is supported. So you can explicit cast expressions like:
a = ((long) y) – 4
y = (double) a
If necessary, the compiler will internally cast expressions. If
y = a * 2.0
__ How to Program __
u
)
®
MG.33.L5.02 – VLT
is a registered Danfoss trademark
167

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents