Programming Ladder Diagrams (LD)

Creating a POU in the ladder diagram (LD) implementation language

  1. Select the application in the Device tree.

  2. Select the command Project ‣ Add Object ‣ POU .

    ⇒ The dialog box Add POU opens.

  3. Enter a name and select the implementation language Ladder Diagram (LD).

    Click on Add.

    ⇒ CODESYS adds the POU to the Device tree and opens it in the editor. An empty network is inserted in the implementation part. The empty network is bounded on the left by a vertical line, which represents a bus bar. The view ToolBox is also automatically opened, in which the suitable elements, operators and function blocks for LD programming are available.

Adding a contact and a function block (TON)

Requirement: a POU with the implementation language LD is opened in the editor and an empty network is inserted.

  1. Click on the category Ladder Elements in the view ToolBox

  2. Click on the Contact element, drag it into your network and release the mouse button at the insertion position Start here.

    ⇒ The contact is added on the left in the network directly against the vertical line.

  3. Click on ??? and enter the identifier of a boolean variable. The input assistant is also available to you for this.

  4. Click on the category Function Blocks in the view ToolBox and drag the function block TON onto an insertion position on the connecting line to the right of the inserted contact.

    ⇒ CODESYS inserts the box TON to the right of the contact. The contact is connected with the input IN of the TON box.

  5. Enter a time constant at the input PT, for example T#3s.

    ⇒ If the variable of your contact goes TRUE, then the input IN of the TON box also goes TRUE. The TON box forwards the value TRUE to the output Q with a switch-on delay of T#3s, for example.

Inserting a closed line branch

Requirement: a POU with the implementation language LD is opened in the editor and an empty network is inserted.

  1. Click inside the empty network and select the command FBD/LD/IL ‣ Insert Contact .

  2. Select the connecting line to the left of the contact and select the command FBD/LD/IL ‣ Set Branch Start Point .

    ⇒ The starting point on the connecting line is marked by a red rectangle. CODESYS marks all possible end points of the branch with a blue rectangle.

  3. Click on a blue rectangle in order to set the end point of your closed line branch.

    ⇒ CODESYS inserts the line branch between the starting and end points. The program flow will go through both branches up to the end point.

    If you insert the line branch at a box instead of at a contact, the box will only be called if none of the other branches is TRUE.

See also