If necessary, IL can be activated in the CODESYS options.
Creating POUs in the instruction list (IL) implementation language
-
Select the application in the device tree.
-
Click “Project Add Object POU”.
The “Add POU” dialog opens.
-
Enter a name and select the implementation language “Instruction List (IL)”.
Click “Add”.
CODESYS adds the POU to the device tree and opens it in the editor. A network is already inserted in the implementation part.
Programming networks (example: ADD operation)
Requirement: A POU (IL) is opened in the editor and possesses an empty network.
-
Click the line marked in color in the 1st column and enter the operator
LD
. -
Press the [Tab] key.
The cursor jumps to the 2nd column
-
Enter the first summand of your ADD operation, for example
6
. -
Press [Ctrl]+[Enter] or select the command “FBD/LD/IL Insert IL Line After”.
CODESYS inserts a new instruction line. The first column of this line has the focus.
-
Enter
ADD
and press [Tab]. -
Enter the second summand of your ADD operation, for example
12
. -
Press [Ctrl]+[Enter]
-
Enter the operator
ST
and press [Tab]. -
Specify a variable of the data type
INT
, for exampleiVar
.The result –
16
in the example – is stored in theiVar
.
Calling function blocks
Requirement: A POU (IL) is opened in the editor and possesses an empty network. A
variable of the data type <function block> is declared in the declaration part (example:
C1:CTU;
).
-
Click the line marked in color in the 1st column and select the command “FBD/LD/IL Insert Box”.
The input assistant opens.
-
Select the desired function block in the category “Function Blocks” or “Boxes”, for example the “CTU” counter from the “Standard” library, and click “OK”.
CODESYS inserts the selected function block “CTU” as follows:
-
Replace the strings
???
with the variable name and the values or variables for the inputs/outputs of the function block. -
As an alternative to inserting the function block via the input assistant, you can directly enter the call in the editor as shown in the picture at step 4.
See also