Programming Instruction Lists (IL)
If required, IL can be enabled via the TwinCAT options. (Tools > Options > TwinCAT > PLC programming environment > FBD, LD and IL > IL) |
Creating a POU in the Instruction List implementation language (IL)
- 1. Select a folder in the Solution Explorer in the PLC project tree.
- 2. In the context menu select the command Add > POU...
- The Add POU dialog opens.
- 3. Enter a name and select the implementation language Instruction List (IL).
- 4. Click on Open.
- TwinCAT adds the POU to the PLC project tree and opens it in the editor. A network has already been added in the implementation part.
Programming a network (e.g. for an ADD operation)
- A POU (IL) is opened in the editor with an empty network.
- 1. Click in the 1st column of the highlighted row and enter the operator LD.
- 2. Press the [Tab] key.
- The cursor jumps to the 2nd column.
- 3. Enter the first summand of your ADD operation, e.g. “6”.
- 4. Press [Ctrl] + [Enter] or select the command Insert IL line below in the menu FBD/LD/IL.
- TwinCAT adds a new statement line at the bottom. The focus is in the first column of this row.
- 5. Enter ADD and press [Tab].
- 6. Enter the 2nd summand of your ADD operation, e.g. “12”.
- 7. Press [Ctrl] + [Enter]
- 8. Enter the operator ST and press [Tab].
- 9. Enter a variable of data type INT, e.g. “nVar”.
- The result, in the example “16”, is stored in nVar.
See also:
- TC3 User Interface documentation: Command Insert IL line below
Calling a function block
- A POU (IL) is opened in the editor with an empty network. A variable with data type <function block>, is declared in the declaration part, e.g.
fbSample : CTU;.
- 1. Click in the first column of the highlighted row and select the command Insert Box in the menu FBD/LD/IL.
- The Input Assistant opens.
- 2. In the category Function blocks or Module calls select the required function block, for example the counter CTU from the library Tc2_Standard, and click OK.
- 3. TwinCAT adds the selected function block CTU as follows:
- 4. Replace the ??? strings with the variable names and the values or variables for the inputs/outputs of the function block.
- 5. As an alternative to adding the function block via the input assistant, you can enter the call directly in the editor.
See also:
- TC3 User Interface documentation: Command Insert Box