Calling a Sub-Program
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
"Structured text"
A high-level language that is block structured and syntactically resembles Pascal, you have to specify
its
name, followed by the input parameters written between parentheses 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 and FFLD Languages
To call a sub-program in FBD"Function block diagram"
A function block diagram describes a function between input variables and output variables. A function is described as a set of elementary blocks or FFLD languages, you
just need to insert the block in the diagram and to connect its inputs and
outputs.
IL Language
To call a sub-program in IL"Instruction list"
This is a low-level language and resembles assembly
language, you must use the CAL instruction with the name of the sub-program, followed by the input
parameters written between parentheses and separated by comas. Alternatively the CALC,
CALCN or CALNC conditional instructions can be used:
CAL Calls the sub-program
CALC Calls the sub-program if the current result is TRUE
CALNC Calls the sub-program if the current result is FALSE
CALCN same as CALNC
Here is an example:
Op1: CAL MySubProg (i1, i2)
FFLD MySubProg.Q1
ST Res1
FFLD MySubProg.Q2
ST Res2