-

Literals according to IEC 61131-3

Where constant numeric values, character strings or time data values are to be used in the code, for example, for connecting them to a formal parameter of a function/function block, literals can be used instead of constant variables. Literals are directly entered "hard-coded" constant values or strings. The IEC 61131-3 standard designates literals as "external representation of data". Literals can directly be entered in the code. It is not necessary to specify a declaration.

The IEC 61131-3 standard describes different literal types, according to the basic data types.

Furthermore, safety-related literals can be used according to the safety-related data types.

This topic contains the following sections:

Numeric literals

TypeExamples
Integer literals-12 0 123_456 +986

Note
For SAFEINT literals, always the data type must be entered (SAFEINT#).

Real literals-12.0 0.0 0.4560 3.14159_26
Real literals with exponent-1.34E-12 -1.34e-12 1.0E+6
Long Real literalsLREAL#-12.0

Observe the 2nd note below this table.
Long Real literals with exponentLREAL#2.3E-89

Observe the 2nd note below this table.
Base 2 literalsINT#2#1111_1111
Base 8 literalsINT#8#377
Base 16 literalsINT#16#FF SINT#16#ff
Boolean FALSE and TRUEFALSE, TRUE

SAFEFALSE, SAFETRUE
Boolean 0 and 10, 1

For SAFEBOOL literals, always SAFEFALSE, SAFETRUE has to be used.

Note
INT literals can be used without keyword. Example: for INT#16#ff, you can use 16#ff.
BOOL/SAFEBOOL literals can also be used without keyword. Examples: for BOOL#FALSE, you can use FALSE and for SAFEBOOL#FALSE, you can use SAFEFALSE.

Note
If you are using PLCnext Engineer in another user interface language and/or with another Windows system locale than English you must enter numeric values with a '.' as decimal separator (always according to the English standard). This applies, for example, when entering initial values in variables tables or REAL/LREAL literals in the code.

Character string literals

Character string literals include single-byte or double-byte encoded characters.

A single-byte character string literal is a sequence of zero or more characters enclosed in single quote characters (''). A double-byte character string literal is a sequence of zero or more characters enclosed in double quote characters ("").

TypeExamples
Single-byte character strings
Empty string ''
String with one space character' '
Not empty string'this is a text'
Double-byte character strings
Empty string""
String with one space character" "
Not empty string"this is a text"

Date and time literals

Duration data can be represented in hours, minutes, seconds, milliseconds and in combination of these formats.

TypeExamples
Short prefixTIME data type: T#14ms t#14ms t#12m18s3.5ms T#25h_15m t#25h_15m

Note
The short prefix representation is not allowed for SAFETIME literals.

LTIME data type: LT#14ms t#14ms t#12m18s3.5ms T#25h_15m t#25h_15m
Long prefixTIME data type: TIME#14 ms time#14ms TIME#25h_15m time#25h_15m

SAFETIME data type: SAFETIME#14 ms safetime#14ms SAFETIME#25h_15m safetime#25h_15m

LTIME data type: LTIME#14 ms time#14ms TIME#25h_15m time#25h_15m

Further Info
See the section "Constant (Literal)" for information how to edit literals in the programming languages FBD/LD/SFC.