IEC 61131-3 Expressions

Help Contents


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:

Constant Values (Literals)

The simplest possible expression is a literal defining a constant value. For example:

'A string'

See Numeric Literals, Time Literals, Date Literals, or String Literals for more information on supported literals.

Tag References

A tag reference is a way of referring to a SCADA tag. For example:

Tag ReferenceEvaluation 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.

Unary Operator

A unary operator performs an operation on a single value. These unary operators are supported:

-Negation- A
NOTComplementNOT B
@Take the address of@C
REF_TOTake the address ofREF_TO C

Binary Operator

A binary operator performs an operation on two values to return a single result. These binary operators are supported:

ORLogical OR1
XORLogical Exclusive OR2
AND &Logical AND3
= <>Equality4
> >= < <=Comparison5

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:

ExpressionEvaluation Order
A + B * CB is multiplied by C, then the result is added to A
A + B + CB is added to A, then C is added to the result of A + B
A * B + CA 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:

ExpressionEvaluation Order
(A + B) * CB is added to A, then the result of A + B is multiplied by C

Variable References

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.

Function Calls

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.

Type Information Functions

These type information functions can be used in expressions:

Sizeof Returns the size, in bytes, of a type. For example:
IsTypeOf Tests whether a value is an Elementary Type, or a Generic Type. For example:
IsTypeOf( Value, ANY_INT )

Further Information

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.