-

User-defined Data Types

This topic contains the following sections:

General information on 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. (Arrays and user-defined strings can also be defined in the 'Variables' and 'Data List' tables; see below).

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:

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.

Note
To avoid naming collisions between user-defined data types, PLCnext Engineer supports namespaces (see the following section).

Namespaces for user-defined data types

PLCnext Engineer supports namespaces for user-defined data types. Namespaces allow you to organize and group data types to make them unique within the project. They help you to ensure that the data type definitions do not collide with other definitions within the PLCnext Engineer project.

Refer to the help topic "Defining Namespaces for User-defined Data Types" for details.

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.

  1. Enter the type definition in the data type worksheet using the TYPE ... END_TYPE declaration keywords.
  2. 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
Elements and members of user-defined data types (ARRAYs and STRUCTs) can easily be initialized using the 'Init Value Configuration' editor.