User-defined Data Types
The
IEC 61131-3 provides the possibility to declare own, user-defined data types based on the standardized IEC 61131-3 elementary data types. This way, application programmers can specify their own "data model" with regard to the requirements of the current application. These user-defined data types are also known as derived data types or type definitions.
User-defined data types are declared in the data type worksheet using a TYPE ... END_TYPE declaration block.
Note
Safety-related user-defined data types are not supported. It is not possible to define, for example, a SAFEARRAY or an ARRAY or STRUCT which contains any safety-related elementary data type. Example: ARRAY[5] OF SAFEFINT is not allowed. |
PLCnext Engineer supports the following type definitions:
- Arrays: array data types consist of several elements of the same data type.
- Structures: structured data types include several elements of the same or of different data types.
- Enumerations: a variable can store one of several names specified in the type definition.
- User-defined strings are composed by a number of characters specified in the type definition.
- Arrays, structures, enumerations and strings can be combined forming, e.g., a structure with enumerations or arrays of structures.
Note
The use and (memory) format of user-defined data types depend on your controller type. Please refer to your hardware documentation concerning the use of these data types. |
Note
Uniqueness of user-defined data types: A user-defined data type must only be defined once in the data types worksheets of the project. An identical data type definition (same name) is, however, allowed in included libraries. This means when taking libraries into account, multiple definitions of the same data type are possible. |
Using user-defined data types
Basically, the following steps are required in order to define a new data type, declare and use a variable of this newly declared data type.
- Enter the type definition in the data type worksheet using the TYPE ... END_TYPE declaration keywords.
- Declare a variable of the user-defined data type.
Now you can use the elements contained in the user-defined types in the code.
Note
Members of user-defined data types (ARRAYs and STRUCTs) can easily be initialized using the 'Init Value Configuration' editor. |