Calling Function Blocks
The Structured Text (ST) programming language enables calling function blocks. Function block calls can be used in any expression.
Function Block calls | |
---|---|
Name | Name of the function block instance |
Meaning | Calls a ST, LD, or FBD function block or a "C" function block and gets its return parameters |
Syntax |
|
Operands | Parameters are expressions which match the type of the parameters specified for that function block |
Return value | See Syntax to get the return parameters. |
When setting the value of the return parameter in the body of a function block, assign the return parameter using its name concatenated with the function block name:
FunctionBlockName.OutputParaName := <expression>;
Example
(* ST program calling a function block *) (* declare the instance of the block in the dictionary: *) (* trigb1 : block R_TRIG - rising edge detection *) (* Function block activation from ST language *) trigb1 (b1); (* return parameters access *) If (trigb1.Q) Then nb_edge := nb_edge + 1; End_if;
Provide Feedback