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 function block from the standard library or from the user's library and accesses its return parameters |
Syntax | (* call of the function block *) <blockname> ( <p1>, PLC-2 ... );(* gets its return parameters *) <result> := <blockname>. <ret_param1>; ... <result> := <blockname>. <ret_paramN>; |
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