A sub-program is called by another program. Unlike function blocks, local variables of a sub-program are not instantiated, and thus you do not need to declare instances. A call to a sub-program processes the block algorithm using the specified input parameters. Output parameters can then be accessed.

ST Language

To call a sub-program in ST, you have to specify its name, followed by the input parameters written between parenthesis and separated by comas. To have access to an output parameter, use the name of the sub-program followed by a dot '.' and the name of the wished parameter:

MySubProg (i1, i2); (* calls the sub-program *)
Res1 := MySubProg.Q1;
Res2 := MySubProg.Q2;

Alternatively, if a sub-program has one and only one output parameter, it can be called as a function in ST language:

Res := MySubProg (i1, i2);

FBD Language and LD Language

To call a sub-program in FBD or LD languages, you just need to insert the block in the diagram and to connect its inputs and outputs.

Calling a sub-program

IEC 61131-3 Automation platform > Programming - Reference guide > Basic Operations > Calling a sub-program

Previous chapterNext chapter


Created with the Personal Edition of HelpNDoc: Experience the Power and Simplicity of HelpNDoc's User Interface