Operators
The built-in standard functions that represent a subset of the standard IEC functions are called operators. User-defined functions cannot be created in the safety programming.
The operators have the same semantics as in CODESYS Standard.
They can be connected to both SAFExxx
and Data types Standard.
Insertion of operators
The operators are inserted using the Insert Box or Insert Empty Box command.
The operators can also be added from the toolbox in the ToolBox view. The toolbox in the Safety FBD Editor contains the following categories:
Boolean operators
Mathematical operators
Other operators
Input Assistant
The following categories are displayed for operators in the Input Assistant:
Operators
Conversions (not in the Basic Level)
Extendable operators
AND
OR
ADD
(only in the Extended Level)MUL
(only in the Extended Level)MUX
(only in the Extended Level)
The EQ
, LT
, LE
, GT
, and GE
operators, which are likewise extendable in accordance with IEC, can be used only with two inputs (as in the case of standard ).
The Insert Input command adds a further input to an extendable operator box.
Operators in the Basic Level
AND
(2 inputs)AND
(3 inputs)OR
(2 inputs)OR
(3 inputs)
All operands of the OR
must be SAFEBOOL
.
Operators in the Extended Level
AND
(2 inputs)AND
(3 inputs)OR
(2 inputs)OR
(3 inputs)XOR
NOT
Important
The careless use of the XOR
and NOT
operators can lead to the loss of the fail-safe property of SAFExxx
variables. No warning is generated by the safety checker for such constructs.
The XOR
and NOT
operators can negate the fail-safe property of a SAFExxx
variable, so that the SAFE
variable loses its fail-safe property, i.e. it becomes "non-fail-safe". This can lead to unintentional starting of the plant.
Programming rule: The SAFExxx
outputs of NOT
and XOR
must be determined. Subsequently, it must be ensured that these NOT
/XOR
outputs are not connected through to outputs (I/Os).
ADD
(2 inputs): ArithmeticADD
operatorADD
(3 inputs): Addition with three inputsSUB
: SubtractionMUL
: MultiplicationDIV
: DivisionEQ
: Comparison for equalityNE
: Comparison for inequalityLT
: Comparison for "less than"LE
: Comparison for "less than" or "equal to"GT
: Comparison for "greater than"GE
: Comparison for "greater than" or "equal to"
SEL
MUX
BOOL_TO_INT
BOOL_TO_DINT
BOOL_TO_TIME
BOOL_TO_WORD
BYTE_TO_INT
BYTE_TO_DINT
BYTE_TO_TIME
BYTE_TO_WORD
DINT_TO_BOOL
DINT_TO_BYTE
DINT_TO_INT
DINT_TO_TIME
DINT_TO_WORD
DINT_TO_DWORD
DWORD_TO_DINT
DWORD_TO_TIME
INT_TO_BOOL
INT_TO_BYTE
INT_TO_DINT
INT_TO_DWORD
INT_TO_TIME
INT_TO_WORD
TIME_TO_BOOL
TIME_TO_BYTE
TIME_TO_INT
TIME_TO_DINT
TIME_TO_WORD
TIME_TO_DWORD
WORD_TO_BOOL
WORD_TO_BYTE
WORD_TO_DINT
WORD_TO_INT
WORD_TO_TIME
WORD_TO_DWORD
Operators with Safety characteristics
The characteristics of some operators specific to are described in the following sections
Runtime error in case of operator overrange in the Extended Level
Runtime error in case of operator overrange in the Extended Level
Important
It is the developers responsibility to design the program logic such that no runtime errors occur.
Reacts to the following overranges with a runtime error, as a result of which the application is stopped and a log entry is generated.
Level | Language element | Runtime error in case of |
---|---|---|
Extended |
| Division by 0 |
Extended |
| Call with first input with a negative value or with a value N that is greater than the number of inputs minus 1. Example: |
Extended |
| Output value is not in the value range of the target type: When converting between two
likewise
|
Tip
The standard behavior of SEL
/MUX
(i.e. the maximum value is selected if the input value is too large and 0 is selected if the input value is negative) must be programmed in the safety application.
SEL
: for k<0
SEL
: for k>max, n...maximum value
MUX
for k<0
MUX
for k>0