Call of function block instance in ST
FB_instance_1(); (* calls of function block instances without parameter list *)
FB_instance_2[n](); (* This function block instance is declared by means of
'ARRAY [x..y] OF'
. *)
FB_instance_2[n, n](); (* This function block instance is declared by means of
'ARRAY [x1..y1, x2..y2] OF'
. *)
FB_instance_3
(input_1:=x1,input_2:=x2,...,input_n:=xn,
output_1=>y1,output_2=>y1,...,output_n=>yn); (* call of a function block instance with parameter list *)
Meaning |
formal call of the →function block instance (= formal function block →call) without or with parameter list This parameter list of a formal →call may contain the following elements:
As alternatives, you can use the following variants for the call:
Enhancement to IEC-standard An enhancement to the →IEC-standard, it is possible to:
The FAQ article "When to use a formal call? When to use a non-formal call?" lists a table when to use formal call vs. non-formal call. |
If you want to call the body of the base function block from within a derived function block, use SUPER(); . See under " Declaration of a function block in ST " for an example.
Inst1();
Inst2a[
5
](); (* call of a function block instance that is declared by means of an one-dimensional array *)
Inst2b[
1
,
3
] (); (* call of a function block instance that is declared by means of a two-dimensional array *)
Inst2c[
2
,
4
,
1
] (); (* call of a function block instance that is declared by means of a three-dimensional array
The call of a function block instance that is declared by means of a four-dimensional array is similar. *)
Inst3 (IN1 :=
10
, IN2 :=
20
, T1 := T#3ms, OUT => result);
(* call of the function block instance
'Inst4'
with assignments to
2
array elements and assignment of a structure element *)
(* Conditions: Input variable
'arrVar'
has been declared as array variable with index subrange [
1
..
2
]. *)
(* Output variable
'out'
has been declared based on a structured data type with structure element
'Elem1'
. *)
Inst4(arrVar[
1
] :=
16
#
01
, arrVar[
2
] :=
16
#
02
, out.Elem1 => result1);
Examples for incomplete parameter list of formal call for a function block instance and accesses defined separately:
Syntax |
Meaning |
Inst1.IN1:=10; |
assigning value 10 to input IN1 of function block instance Inst1 |
Inst2a[5].IN1 := 10; |
assigning value 10 to input IN1 of function block instance Inst2a that has been declared by means of ARRAY OF [1..5] |
Inst1(IN2:=20); |
calling the function block instance Inst1, assigning value 20 to input IN2 while input IN1 keeps value 10 |
result:=Inst1.OUT; |
because of the read output OUT of Inst1: assigning value 30 (under the assumption that Inst1 adds the values) to local variable result
|
Inst1(IN2 := fun2(EN := FALSE)); |
calling the function block instance Inst1, |