Danfoss MCO 305 Design Manual page 169

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

Advertisement

MCO 305 Design Guide
Arithmetic
The compiler offers the following commands and parameters:
Operators
Bit operators
Comparison Operations
Logical Operations
Inform yourself about the type of assignment operation 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.
Operators
Symbol
Meaning
+
plus
++
plus 1
minus
––
minus 1
*
times
%
divided by
^
XOR
mod
Modulo
rnd
Division
abs
Absolute
amount
Post-increment
The compiler supports post increment and decrement
for both long and double variables. So the following
expressions are allowed. (This support depends only
on the compiler version; the compiled program will
run on both new and old firmware versions.)
This also works with arrays as in the following
example.
Here, the value of testarray[5] is copied into var and then the value of testarray[5] is incremented by one.
NB!:
The Post-increment operator is supported starting with MCO 5.00.
__ How to Program __
plus, minus, times, divided by, XOR, Modulo, Division, Absolute amount
and, or, invert, left-shift, right-shift, 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
Syntax / Example
3 + 3
= 6
expr++ = expr + 13
9 – 3 = 6
expr–– = expr – 13
2 * 3 = 6
19 % 3
= 6
expr1 ^ expr2
127 ^ 255 = 128
expr1 mod expr2
250 mod 16 = 10
expr1 rnd expr2
250 rnd 16 = 16
Abs(expr)
abs (-5) = 5
®
MG.33.L5.02 – VLT
is a registered Danfoss trademark
Description
Addition
Post-increment (= Addition + 1)
Subtraction
Post-decrement (= Subtraction – 1)
Multiplication
Division (result is truncated)
Exclusive Or (binary operation)
Mathematic modulo (rest of an integer division)
Division with round-off (opposite to truncating)
Absolute amount of the expression
while(index < 100) do
test[index] = index++
endwhile
value-
DIM testarray[20]
...
var = testarray[5]++
testarray[10]
169

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents