An IEC 61131-3 expression is a sequence of:
An IEC 61131-3 expression produces a single result.
You can use an IEC 61131-3 expression in any of these areas:
The simplest possible expression is a literal defining a constant value. For example:
12 'A string' T#5s
See Numeric Literals, Time Literals, Date Literals, or String Literals for more information on supported literals.
A tag reference is a way of referring to a SCADA tag. For example:
Tag Reference | Evaluation Order |
---|---|
%"PumpStation.TotalCurrent" | Returns the value of the tag PumpStation.TotalCurrent |
%"PumpStation.TotalCurrent.Quality" | Returns the quality of the tag PumpStation.TotalCurrent |
See Tag References for other ways to refer to SCADA tags in IEC 61131-3 code.
A unary operator performs an operation on a single value. These unary operators are supported:
Operator | Description | Example |
---|---|---|
- | Negation | - A |
NOT | Complement | NOT B |
@ | Take the address of | @C |
REF_TO | Take the address of | REF_TO C |
A binary operator performs an operation on two values to return a single result. These binary operators are supported:
Operator | Description | Precedence |
---|---|---|
OR | Logical OR | 1 |
XOR | Logical Exclusive OR | 2 |
AND & | Logical AND | 3 |
= <> | Equality | 4 |
> >= < <= | Comparison | 5 |
+ | Addition | 6 |
- | Subtraction | 6 |
* | Multiply | 7 |
/ | Divide | 7 |
MOD | Modulo | 7 |
** | Power | 8 |
When multiple operators are present in an expression, higher precedence operators are evaluated before lower precedence operators. When two operators have equal precedence, the left operator is evaluated before the right operator. For example:
Expression | Evaluation Order |
---|---|
A + B * C | B is multiplied by C, then the result is added to A |
A + B + C | B is added to A, then C is added to the result of A + B |
A * B + C | A is multiplied by B, then C is added to the result of A * B |
Parentheses alter the order of evaluation of operators. An expression inside parentheses is always evaluated first, regardless of operator precedence. For example:
Expression | Evaluation Order |
---|---|
(A + B) * C | B is added to A, then the result of A + B is multiplied by C |
A variable is a value that can change, depending on the actions of the program code.
A variable reference is a way of referring to a variable in an expression.
Expressions can include references to elementary type variables. For example:
A - Reference to variable A.
B[4] - Reference to element number 4 of the array B.
C.M - Reference to the M member variable of structure C.
See Variable References for information on how to reference variable values.
Expressions can include calls to:
Function calls can be Formal or Informal. For example:
LIMIT( EN:=True, MN:=10.5, IN:=Voltage, MX:=13.4 ) - Formal call to the standard function LIMIT.
LIMIT( 10.5, Voltage, 13.4 ) - Informal call to the standard function LIMIT.
Numeric Literals, Time Literals, Date Literals, or String Literals.
To learn about the different types of literals.
To learn about standard and user defined functions.
For the meaning of terms used in Fernhill SCADA.