3 arithmetic expressions, 4 logical expressions and operators, 1 bitwise operators – Lenze PM94P01C User Manual

Page 38: Programming

Advertising
background image

PM94P01C

36

Programming

2.3

Arithmetic Expressions

Table 8 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/2+1)

;Complicated expression

Table 8: Supported Arithmetic Expressions

Operator

Symbol

Addition

+

Subtraction

-

Multiplication

*

Division

/

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

2.4

Logical Expressions and Operators

Bitwise, Boolean, and comparison operators are considered as Logical Operators. They operate on logical values of the
operands. There are two possible values for logical operand: TRUE and FALSE. Any value contained in a User variable,
System variable or flag is treated as TRUE or FALSE with these types of the operators. If a variable value equals “0”, it
is considered FALSE. All other values (non-0) including negative numbers are considered TRUE.

2.4.1 Bitwise Operators

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

Table 9: 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 must be referenced in hexadecimal format. 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