EcoStruxure Machine Expert version 1.1 does not support the M258, LMC058 and LMC078 controllers.

Adding and Calling POU Objects

Introduction

You can add Program Organization Unit (POU) objects to your application in the Software catalog > Assets or in the Applications tree.

The different types of POU objects are:

oProgram: It returns one or several values during operation. All values are retained from the last time the program was run until the next. It can be called by another POU object.

oFunction Block: It provides one or more values during the processing of a program. As opposed to a function, the values of the output variables and the necessary internal variables shall persist from one execution of the function block to the next. So invocation of a function block with the same arguments (input parameters) need not always yield the same output values.

oFunction: It yields exactly one data element (which can consist of several elements, such as fields or structures) when it is processed. The call in textual languages can occur as an operator in expressions.

Adding POU Objects to an Application

Step

Action

1

In the Software catalog > Assets > POUs section, select an Application node, click the green plus button, and execute the command POU.... As an alternative, you can right-click the Application node of the controller and choose Add Object > POU.

The two methods are also available in the Applications tree.

Result: The Add POU dialog box opens.

G-SE-0027460.2.gif-high.gif

 

 

2

In the Add POU dialog box, assign a name to your POU object by typing a name in the text field Name.

NOTE: The name must not contain any space characters. If you do not enter a name, a name is given by default.

Assigning a meaningful name to a POU may ease the organization of your project.

3

Select the type of POU object you want:

oProgram

oFunction Block:

a.If you want your function block to extend an already existing function block, select Extends and click the browser to select the function block you want in the Input Assistant.

b.Click the OK button.

c.If you want your function block to implement an interface, select Implements and click the browser to select the interface you want in the Input Assistant.

d.Click the OK button.

e.If your function block implements an interface, in the list box Method implementation language, select the programming language you want for editing the methods and properties defined in the implemented interface.

oFunction:

a.Click the browse button to select the Return type you want in the Input Assistant.

b.Click the OK button.

4

From the list box Implementation Language, select the programming language you want for editing your POU object.

5

Click the Open button.

Already defined POU objects are listed in the Software catalog > Assets > POUs section. You can add them to your application, by dragging them to the Applications tree and dropping them on an Application node. You can also drop a POU object on the logic editor view.

Assigning Programs to a Task

Step

Action

1

Under the node Task Configuration of the controller, double-click the task to which you want to add your program. In the Configuration tab, click Add Call.

Alternatively, in the Applications tree select the task to which you want to assign your program and click the green plus button. Execute the command Program Call... from the list. Click the ... button.

Result: The Input Assistant dialog box is displayed.

2

In the tab Categories of the Input Assistant dialog box, select Programs.

3

Click to clear the check box Structured view.

4

In the Items panel, select the POU you want.

5

Click the OK button.

Calling POUs

POUs can call other POUs. Recursion however is not allowed (a POU that calls itself).

When a POU assigned to an application calls another POU just by its name (without any namespace added), consider the following order of browsing the project for the POU to be called:

1.

current application

2.

Library Manager of the current application in the Tools tree

3.

Global node of the Applications tree

4.

Library Manager in the Global node of the Tools tree

If a POU with the name specified in the call is available in a library of the Library Manager of the application as well as an object in the Global node of the Applications tree, there is no syntax for explicitly calling the POU in the Global node of the Applications tree, just by using its name. In this case move the respective library from the Library Manager of the application to the Library Manager of the Global node of the Applications tree. Then you can call the POU from the Global node of the Applications tree just by its name (and, if needed, that from the library by preceding the library namespace).

Also refer to the chapter POUs for Implicit Checks.