This part explains how to implement a function and a function block in IL language.
Functions IsFirstMastCycle
and SetRTCDrift
and Function Block TON
are used as examples to show implementations.
This procedure describes how to insert a function in IL language:
Step |
Action |
---|---|
1 |
Open or create a new POU in Instruction List language.
NOTE: The procedure to create a POU is not detailed here. For more information, refer to Adding and Calling POUs.
|
2 |
Create the variables that the function requires. |
3 |
If the function has 1 or more inputs, start loading the first input using LD instruction. |
4 |
Insert a new line below and:
|
5 |
If the function has more than 1 input and when Input Assistant is used, the necessary number of lines is automatically created with |
6 |
Insert a new line to store the result of the function into the appropriate variable: type ST instruction in the operator column (left field) and the variable name in the field on the right. |
To illustrate the procedure, consider the Functions IsFirstMastCycle
(without input parameter) and SetRTCDrift
(with input parameters) graphically presented below:
Function |
Graphical Representation |
---|---|
without input parameter:
|
![]() |
with input parameters:
|
![]() |
In IL language, the function name is used directly in the operator column:
Function |
Representation in POU IL Editor |
---|---|
IL example of a function without input parameter:
|
![]() |
IL example of a function with input parameters:
|
![]() |
This procedure describes how to insert a function block in IL language:
Step |
Action |
---|---|
1 |
Open or create a new POU in Instruction List language.
NOTE: The procedure to create a POU is not detailed here. For more information, refer to Adding and Calling POUs.
|
2 |
Create the variables that the function block requires, including the instance name. |
3 |
Function Blocks are called using a
Each parameter (I/O) is an instruction:
|
4 |
In the |
5 |
Replace other |
To illustrate the procedure, consider this example with the TON
Function Block graphically presented below:
Function Block |
Graphical Representation |
---|---|
|
![]() |
In IL language, the function block name is used directly in the operator column:
Function Block |
Representation in POU IL Editor |
---|---|
|
![]() |