Programming – Lenze E94P PositionServo with MVOB User Manual

Page 38

Advertising
background image

36

L

PM94H201B_13xxxxxx_EN

Programming

2.3

Arithmetic Expressions

Table 7 lists the four arithmetic functions supported by the Indexer program. Constants as well as User and System
variables can be part of the arithmetic expressions.

Examples.
V1 = V1+V2

;Add two user variables

V1 = V1-1

;Subtract constant from variable

V2 = V1+APOS

;Add User and System (actual position) variables

APOS = 20

;Set System variable

V5 = V1*(V2+V3*5/3)

;Complicated expression

Table 7: Supported Arithmetic Expressions

Operator

Symbol

Addition

+

Subtraction

-

Multiplication

*

Division

/

Register (variable) overflow for “*” and “/” operations will cause arithmetic overflow fault F_19. Register (variable)
overflow/underflow for “+” and “-” operations does not cause an arithmetic fault.

2.4

Logical Expressions and Operators

Bitwise, Boolean, and comparison operators are referred to as Logical Operators. Bitwise operators are used to change
individual bits within an operand (variable). Bitwise operation works at the binary level of the variables, changing
specified bits or bit patterns within those variables.
Boolean operators are used to combine simple or complex expressions within a single logic statement. They are used
to define a condition that ultimately equates to either True or False.
Comparison operators are used to perform a test between two values and to return a result indicating whether or not the
test (Comparison) evaluates to true or false.

2.4.1 Bitwise Operators

Table 8 lists the bitwise operators supported by the Indexer program.

Table 8: Supported Bitwise Operators

Operator

Symbol

AND

&

OR

|

XOR

^

NOT

!

Both User or System variables can be used with these operators. In order to perform a bitwise (Boolean) operation,
the value often easier in entered in hexadecimal format. To enter a number in hexadecimal use the characters ‘0x’
immediately prior to the hexadecimal number. Example: bit 22 alone would be referenced as 0x400000.
Examples:
V1 = V2 & 0xF

;clear all bits but lowest 4

IF (INPUTS & 0x3)

;check inputs 0 and 1

V1 = V1 | 0xff

;set lowest 8 bits

V1 = INPUTS ^ 0xF

;invert inputs 0-3

V1 = !IN_A1

;invert input A1

Advertising