Object ‘Program’

A program is a POU that supplies one or more values during execution. After execution of the program, all values are retained until the next execution. The order of calling the programs within an application is defined in task objects.

A program is added to the application or the project using the command Project ‣ Add object ‣ POU . In the Device tree and in the POUs view the program POUs have the suffix (PRG).

The editor of a program consists of the declaration part and the implementation part.

The uppermost line of the declaration part contains the following declaration:

PROGRAM <program>

Calling a program

Programs and function blocks can call a program. A program call is not permitted in a function. There are no instances of programs.

If a POU calls a program and values of the program change as a result, these changes are retained until the next program call. The values of the program are also retained even if the repeat call takes place by another POU. This differs from the call of a function block. When calling a function block only the values of the respective instance of the function block change. The changes only need to be observed if a POU calls the same instance again.

You can also set the input or output parameters for a program directly when calling.

Syntax: <program>(<input variable> := <value>, <output value> => <value>):

If you insert a program call via the input assistant and the Insert with arguments option in the input assistant is activated at the same time, CODESYS adds input and/or output parameters to the program call in accordance with the syntax.

Examples

Calls:

IL:

With assignment of the parameters:

ST:

PLC_PRG()
erg := PLC_PRG.out2;

With assignment of the parameters:

PLC_PRG(in1:=2, out1=>erg);

See also