A Brief Introduction to TwinCAT PLC Control Calling a function block The input and output variables of a function block can be accessed from another POU by setting up an instance of the function block and specifying the desired variable using the following syntax: . If you would like to set the input parameters (thus the value of the inputvariables) when you open the function block, you can do this in the text languages IL and ST by assigning values to the parameters after the instance name of the function block in parentheses (this assignment takes place using ":=" just as with the initialization of variables at the declaration position).
Please note, that the input/output variables (VAR_IN_OUT) of a POU will be turn over as a pionter. Therefore no constants can be assigned to them at a call, and an external read or write access is impossible. Example for the call of a VAR_IN_OUT variable inout1 of the POU fubo in ST: VAR inst:fubo; var1:int; END_VAR var1:=2; inst(inout1:=var1); Not allowed: inst(inout1:=2); or. inst.inout1:=2; Examples for calling function block FUB described above. The multiplication result is saved in the variable ERG, and the result of the comparison is saved in QUAD. An instance of FUB with the name INSTANCE is declared: In IL the function block is called as follows:
In the example below the call is shown in ST. The declaration part is the same as with IL: In FBD it would look as follows (declaration part the same as with IL): TX1200 13 Version: 1.3