Principle
In Instruction
List, a user function block is called by a CAL
instruction,
followed by the name of the DFB instance as an operand and a list
of arguments (optional). Arguments are displayed in the list between
brackets and separated by commas.
In Instruction List, there are three possible ways of calling a DFB:
The instruction
CAL DFB_Name
is followed by a list of arguments that are assignments (parameter = value). In this case, the order in which the arguments are entered in the list is not important.The EN input parameter can be used to control the execution of the function block.
The instruction
CAL DFB_Name
is followed by a list of arguments that are values (expression, object or immediate value). In this case, the order in which the arguments are entered in the list must follow the order of the DFB input parameters, including for non-assigned inputs (the argument is an empty field).It is not possible to use EN and ENO parameters.
The instruction CAL DFB_Name is not followed by a list of arguments. In this case, this instruction must be preceded by the assignment of the input parameters, via a register: loading of the value (Load) then assignment to the input parameter (Store). The order of assignment of the parameters (LD/ST) is not important; however, you must assign all the required input parameters before executing the
CAL
command. It is not possible to use EN and ENO parameters.
CAL DFB_Name (argument 1,argument 2,...,argument n)
or
LD Value 1
ST Parameter
1
...
LD Value n
ST Parameter n
CAL DFB_Name
Use of EN\ENO Parameters
Example of a DFB
The following example explains the different calls of a DFB
in Instruction List. This is the instance Cpt_1
of
the Cpt_parts
: type DFB

DFB Call when the Arguments Are Assignments
When the arguments are assignments, the DFB
call Cpt_1
is performed with the following syntax:
CAL Cpt_1 (Reset:=Clear, Presel:=%MD10, Count:=100, Done=>%Q1.2.1)
Where the input parameters assigned by a value (expression, object or immediate value) are entered in the list of arguments, the syntax is:
CAL Cpt_1 (Reset:=Clear, Presel:=%MD10, Count:=100)
...
LD Cpt_1.Done
ST %Q1.2.1
In order to make your application program more legible, you can enter a carriage return after the commas that separate the arguments. The sequence then takes the following syntax:
CAL Cpt_1(
Reset:=Clear,
Presel:=%MD10,
Count:=100,
Done=>%Q1.2.1)
Elements of the DFB Call Program
The following table lists the different elements of the DFB call program.
Element |
Meaning |
---|---|
CAL |
DFB call instruction |
Cpt_1 |
Name of the DFB instance |
Reset, Presel, Count |
Input parameters |
:= |
Assignment symbol of an input |
Clear, %MD10, 100 |
Assignment object or value of the inputs |
Done |
Output parameter |
=> |
Assignment symbol of an output |
%Q1.2.1 |
Assignment object of an output |
, |
Argument separation symbol |
DFB Call when the Arguments Are Values
When the arguments are values, the DFB call Cpt_1
is performed with the following syntax:
CAL Cpt_1 (Clear, %MD10,, 100)
...
LD Cpt_1.Done
ST %Q1.2.1
Elements of the DFB Call Program
The following table lists the different elements of the DFB call program.
Element |
Meaning |
---|---|
CAL |
DFB call instruction |
Cpt_1 |
Name of the DFB instance |
Clear, %MD10, 100 |
Assignment object or value of the inputs |
, |
Argument separation symbol |
DFB Call with no Argument
When there is no argument, the DFB call Cpt_1
is performed with the following syntax:
LD Clear
ST Cpt_1.Reset
LD %MD10
ST Cpt_1.Presel
LD 100
ST Cpt_1.Count
CAL Cpt_1(
...
LD Cpt_1.Done
ST %Q1.2.1
Elements of the DFB Call Program
The following table lists the different elements of the DFB call program.
Element |
Meaning |
---|---|
LD Clear |
Load instruction to load the |
ST Cpt_1.Reset |
Assign instruction to assign the
contents of the register to the input parameter |
CAL Cpt_1( |
Call instruction for the DFB |