Data types
Below are the available basic data types:
Type |
Description |
BOOL |
Boolean (bit) - can be FALSE or TRUE - stored on 1 bit. |
SINT (*) |
Small signed integer on 8 bits (from -128 to +127). |
USINT (*) |
Small unsigned integer on 8 bits (from 0 to +255). |
BYTE |
Same as USINT. |
INT (*) |
Signed integer on 16 bits (from -32768 to +32767). |
UINT (*) |
Unsigned integer on 16 bits (from 0 to +65535). |
WORD |
Same as UINT. |
DINT |
Signed integer on 32 bits (from -2147483648 to +2147483647). |
UDINT (*) |
Unsigned integer on 32 bits (from 0 to +4294967295). |
DWORD |
Same as UDINT. |
LINT (*) |
Long signed integer on 64 bits. |
ULINT (*) |
Long unsigned integer on 64 bits. |
LWORD |
Same as ULINT. |
REAL (*) |
Single precision floating point - stored on 32 bits. |
LREAL (*) |
Double precision floating point - stored on 64 bits. |
TIME |
Time of day - less than t#49d17h2m47s295ms - accuracy is 1ms. |
STRING (*) |
Variable length string with declared maximum length. |
WSTRING (*) |
Variable length string of UNICODE characters encoded as UTF16. Unlike STRINGs, these variables are dynamically allocated/reallocated in memory and thus are not declared with a maximum length. However, a WSTRING during execution cannot exceed 32000 characters. IMPORTANT: In order to use WSTRING variables in a project the option Store complex variables in a separate segment must be enabled in the project settings. |
(*) Some of those data types may be not supported by all targets.
Structures
A structure is a complex data type defined as a set of members. Members of a structure may have various data types. A member of a structure may have dimensions or may be an instance of another structure.
When a structure is defined, it may be used as other data types to declare variables.
Members of a structure may have an initial value. In that case, corresponding members of all declared variable having this structure type will be initialized with the initial value of the member.
For specifying a member of a structured variable in languages, use the following notation:
VariableName.MemberName
Enumerated data types
You can define some new data types that are enumaration of named values. For example:
type: LIGHT
values: GREEN, ORANGE, RED
Then in programs, you can use one of the enumerated values, prefixed by the type name:
Light1 := LIGHT#RED;
Variables having enumerated data types can only be used for assignment, comparison, and SEL/MUX functions.
UNIONs
A kind of user defined Data types. As structures, a UNION is defined as a set of data members, each member having a name and a data type.
But unlike for structures, all members of a UNION are implemented at the same location in the memory and thus overlap.
In languages, access to a member of a UNION is done the same way as for structures, using the “.” separator: variable_name.member_name
Hint: The option Store complex variables in a separate segment must be enabled.
Restrictions:
A UNION cannot:
- contain STRING members
- have an initial value
- work with the Soft Scope
"Bit fields" data types
You can define new data types derived from integer data types, that have some readable names for some of their bits. Thus you can use VarName.BitName notations in programs. Such data types cannot be derived from the LINT type.
Arbitrary grouping of bits into evaluable integer values
You can configurate bits groups inside a bit field for the bit field types:
- BYTE
- WORD
- DWORD
- LWORD
The bit fields are shown in the Spylist view too.
When typing the same symbol“ in consecutive lines of the value field, the binary values (sum of the single bits) is displayed on that symbol in the IEC program.
This, essentially, works starting from only 1 single bit to the maximum number of bits of integer values. In this way, the source value can be grouped accordingly into several groups of 1 to n-bits.
Hint: Extended bit filds (more than one bit) are not supported for 64bit datatypes.
Example: An 16 bit integer value is split up into:
- Single Bit (bit 0), with name “AlarmActive”
- Group of 4 Bits (bit 1 to 4), with name “AlarmCode” representing value 0 to 15
- Group of 3 Bits (bit 5 to 7), with name “AlarmLocationID” representing value 0 to 7
Data types |
IEC 61131-3 Automation platform > Programming - Reference guide > Data types |
Created with the Personal Edition of HelpNDoc: Add an Extra Layer of Security to Your PDFs with Encryption