Programming in Instruction List (IL)
Tip
IL can be enabled in the CODESYS options if required: In the FBD, LD and IL dialog, on the IL tab, select the Enable IL option.
Creating POUs in the Instruction List (IL) implementation language
In the device tree, select the application.
Click the
command.The Add POU dialog opens.
Specify a name and select the Instruction List (IL) implementation language.
Click the Add button.
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 has an empty network.
Click the line indicated in color in the first column and enter the
LD
operator.Press the Tab key.
The cursor jumps to the second column.
Specify the first summand of your
ADD
operation.Example:
6
Press Ctrl + Enter or click the FBD/LD/IL → Insert IL line below command.
CODESYS inserts a new instruction line. The first column of this line has the focus.
Enter
ADD
and press Tab.Specify the second summand of your
ADD
operation (example:12
).Press Ctrl + Enter.
Enter the
ST
operator and press Tab.Specify a variable of the data type
INT
(example:iVar
).The result (
16
in the example) is stored in theiVar
.
Calling a function block
Requirement: A POU (IL) is opened in the editor and has an empty network. A variable with the <function block> data type is declared in the declaration part.
Example: C1:CTU;
Click the highlighted line in the first column and click the Insert Box command.
→The Input Assistant opens.
In the Function Blocks category or POUs category, select the desired function block (for example, the CTU counter from the Standard library) and click OK.
CODESYS inserts the selected CTU function block as follows:
Replace the strings
???
with the variable name and the values or variables for the inputs and outputs of the function block.Alternatively to inserting the function block by means of the Input Assistant, you could also directly enter the call in the editor as shown in the image in Step 4.
For more information, see the following: Modifiers and Operators in IL