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
ANDORADD(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)XORNOT
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): ArithmeticADDoperatorADD(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"
SELMUX
BOOL_TO_INTBOOL_TO_DINTBOOL_TO_TIMEBOOL_TO_WORDBYTE_TO_INTBYTE_TO_DINTBYTE_TO_TIMEBYTE_TO_WORDDINT_TO_BOOLDINT_TO_BYTEDINT_TO_INTDINT_TO_TIMEDINT_TO_WORDDINT_TO_DWORDDWORD_TO_DINTDWORD_TO_TIMEINT_TO_BOOLINT_TO_BYTEINT_TO_DINTINT_TO_DWORDINT_TO_TIMEINT_TO_WORDTIME_TO_BOOLTIME_TO_BYTETIME_TO_INTTIME_TO_DINTTIME_TO_WORDTIME_TO_DWORDWORD_TO_BOOLWORD_TO_BYTEWORD_TO_DINTWORD_TO_INTWORD_TO_TIMEWORD_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