Skip to main content
Search

Programming in Instruction List (IL)

Note

If needed, IL can be enabled in the CODESYS options.

Creating POUs in the Instruction List (IL) implementation language

  1. Select the application in the device tree.

  2. Click Project → Add Object → POU.

    The Add POU dialog opens.

  3. Specify a name and select the Instruction List (IL) implementation language.

    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.

  1. Click the line marked in color in the 1st column and enter the operator LD.

  2. Press the Tab key.

    The cursor jumps to the 2nd column.

  3. Specify the first summand of your ADD operation.

    Example: 6

  4. Press Ctrl+Enter or click FBD/LD/IL → Insert IL Line After.

    CODESYS inserts a new instruction line. The first column of this line has the focus.

  5. Enter ADD and press Tab.

  6. Specify the second summand of your ADD operation, for example 12.

  7. Press Ctrl+Enter.

  8. Enter the ST operator and press Tab.

  9. Specify a variable of the data type INT, for example iVar.

    The result – 16 in the example – is stored in the iVar.

Calling function blocks

Requirement: A POU (IL) is opened in the editor and possesses an empty network. A variable with the <function block> data type is declared in the declaration part.

Example: C1:CTU;

  1. Click the line marked in color in the first column and click FBD/LD/IL → Insert Box.

    The Input Assistant opens.

  2. Select the desired function block in the Function Blocks category or Boxes category (for example, the CTU counter from the Standard library) and click OK.

    CODESYS inserts the selected function block CTU as follows:

    _cds_img_il_fb_call.png
  3. Replace the strings ??? with the variable name and the values or variables for the inputs/outputs of the function block.

  4. 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.

For more information, see: Modifiers and Operators in IL