Commands and functions
P.
170 of 349
Commands and
functions
Logical operators
AND-links
OR-links
Note:
For all arguments or functions, the group addresses can also be used directly instead of
variables.
To create AND-links, the
and
instruction is provided. This statement is constructed as follows:
Definition
●
A
and
B
[
and
C
... etc.]
Arguments
●
All arguments (
A, B, C
... ) are of the same data type. But otherwise, the data types are
arbitrary.
●
Any number of links
Effect
●
The variable
A
is bitwise "ANDed" with the variable
B
(and the variable
C
etc.). The result
of the operation
and
is zero (all bits), if one of the variables is zero (all bits). In the other
case the result is a bitwise "ANDing", i.e. the n-th bit of the result is zero, once one of the
bits of the input is zero. Otherwise, the n-th bit of the result is 1, i.e. each n-th bit of the two
(or more) input variables is 1.
Data type result (Return)
●
Data type of the arguments
Example: AND-Link
LightActuatorOn is the result of the AND operation of variable ButtonOn and variable
LightRelease.
The implementation of the user program is then:
LightActuatorON = ButtonOn and LightRelease
If
ButtonOn
is 1b01 and
LightRelease
is 1b01, then LightActuatorOn
is 1b01, otherwise it is 0b01.
Example: And-Link with different variables
If the variable ButtonOn is '1' and the variable wind speed is exactly 2.9 m/s, the variable
LightActuatorOn has to be set to '1'.
For the implementation, we need the
if
statement and the comparison
==
. (here, the whole if-query is
to be set in parentheses). The implementation is then:
if ((ButtonOn==1u08) and (WindSpeed==2.9f16)) then LightActuatorOn=1u08 endif
To create OR-links, the
or
statement is provided. This statement is organized as follows:
Definition
●
A
or
B
[
or
C
... etc.]
Arguments
●
All arguments (
A, B, C
... ) are of the same data type. But otherwise, the data types are
arbitrary.
●
Any number of links
Effect
●
The variable
A
is bitwise "ORed" with the variable
B
(and the variable
C
etc.), which
means: The result of the operation
or
is zero, if both of the variables are zero. In the other
case the result is a bitwise "ORing", i.e. the n-th bit of the result is one, once one of the bits
of the input is one.
Data type result (Return)
●
Data type of the arguments
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]