-

POUs

This topic contains the following sections:

POUs (Program Organization Units) in your project are managed in the COMPONENTS area on the right. In the 'Local' folder of the 'Programming' category, you can add, delete, rename and move POUs and open POUs for editing.

According to the IEC 61131-3 standard, the following three POU types Function (FU), Function Block (FB), and Program are available (click the hyperlinks for details):

The program and function block types are to be defined in the COMPONENTS area. The illustration in the topic "Instantiation: Program and FB Instances" explains the relation between types and instances and shows where instances of these types are possible.

 Instantiation of programs and function blocks

Uniqueness and order of precedence (hierarchy) of POUs

Uniqueness of POUs: A user-defined POU must only be defined once within a project. A POU type with the same name is, however, allowed in included libraries. This means when taking libraries into account, multiple types with the same POU name are possible.

Note
To avoid naming collisions between user-defined standard POUs, PLCnext Engineer supports namespaces. Namespaces allow you to organize and group POUs to make them unique within the project. For further details, see the topic "Namespaces".

Precedence of POUs: If POUs with the same name are defined in the project and provided in libraries, they are subject to a type hierarchy. By including libraries, various hierarchical levels result, especially if libraries contain further included libraries (nested references).

The following precedence rules apply:

Components of a POU in PLCnext Engineer

Each POU consists of a declaration part (variables table) containing the variable declarations used within the POU and a code part (one or more code worksheets) containing the instructions to be processed.

Double-clicking a POU in the 'Programming' category in the COMPONENTS area opens the editors (see list below) for declaring variables and developing the code.

Note
When editing the code or variables of a safety-related POU (you have to be logged on to the Safety-related Area for that purpose), the editor title bar with hatched background indicates the safety-related context. The consistency of safety-related data is verified continuously by the corresponding editor to detect possible data corruption.

Details on the editor handling can be found in the help topic "Editors area".

'Settings' editor

'Variables' editor

'Code' editor

'Description' editor

'Safety Information' editor (for safety-related POUs only)

Management of POUs in the COMPONENTS area

In the 'Programming' category of the COMPONENTS area, Program POUs and Function and Function Block POUs are represented and grouped in separate folders. Right-clicking a node (folder or individual POU) opens a context menu. The context menu contains only commands which can be applied to the selected node. In addition to the standard editing commands such as 'Cut', 'Copy', 'Paste', etc. the context menu provides the commands to add new POUs (see descriptions below).

Structure of POU subcategories
The 'Local' folder in the 'Programming' category contains user-defined programs and functions/function blocks. To organize user-defined POUs, you can add a maximum of 3 subfolders via context menu. The digit behind the folder name indicates the number of contained POUs. POUs can be simply moved via drag & drop between the user-defined folders.

For adding, managing and editing safety-related parts of the project, you have to be logged on to the Safety-related Area which is an area of responsibility restricted to authorized members.

Note
Non-safety-related elements that have been deleted in the COMPONENTS area are added to the RECYCLE BIN (if enabled in the 'Extras > Options' dialog under the 'Tool | Recycle Bin' category). You can restore the deleted non-safety-related elements using the 'Restore' command in the context menu of a deleted element in the RECYCLE BIN. This does not apply to safety-related elements. They are deleted permanently.

Execution order of code worksheets in a POU

The execution order of the code worksheets in a POU is defined by their arrangement in the editor group. The read-only number in square brackets assigned to the worksheet name (title) indicates the execution order of the worksheet relative to the other worksheets.

To change the execution order of the code worksheets in a POU, drag the desired worksheet and drop it on the worksheet before which it is to be executed (the number in square brackets indicating the execution order is automatically adapted).

Example

Operations on POUs

Add a POU

Add a transition or action to an SFC function block POU

Add a method to a user-defined FB POU

Add/delete code worksheets in a POU

Define a namespace for a POU

Import POUs from another project or from a PLCopen XML file

Switch between editors