Programming Ladder Diagrams (LD)¶
Creating a POU in the ladder diagram (LD) implementation language
Select the application in the Device tree.
Select the command
.- ⇒
The dialog box Add POU opens.
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)
Click on the category Ladder elements in the view ToolBox
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.
Click on
???
and enter the identifier of a boolean variable. The input assistant is also available to you for this.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.
Enter a time constant at the input
PT
, for exampleT#3s
.- ⇒
If the variable of your contact goes
TRUE
, then the inputIN
of the TON box also goesTRUE
. The TON box forwards the valueTRUE
to the outputQ
with a switch-on delay ofT#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.
Click inside the empty network and select the command
.Select the connecting line to the left of the contact and select the command
.- ⇒
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.
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