-

Structures

Structured data types include several elements of the same or of different data types. Therefore, structures are especially suitable to reflect and handle several different properties of an object, e.g., characteristics of a machine.

In the following example, the structured data type 'machine' consists of the components x_pos, y_pos, depth and rpm. All components describe the characteristics of the machine.

The following simple example specifies a drilling machine which has to process several holes. For each hole to be drilled, the following information is required: position (x/y coordinates), depth and machine revolutions per minutes. The actual values vary for each hole but the used variables are always the same. A 'ready' flag indicates whether the machine is ready for operation.

Data type definition
Variable declaration
('Variables'/Data List)
Use in code

Initializing structures

Structures, or to be more precise, the individual members contained in a structure, are initialized using the following syntax. The initialization value can be either a literal (fixed value) or a local or global constant (local = constant declared in the data type worksheet by a VAR CONSTANT...END_VAR declaration block; global = 'Constant' attribute selected for variable in variables table or data list).

Further Info

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.