Programming in the Ladder Diagram (LD)
Creating a POU in the Ladder Diagram (LD) implementation language
In the device tree, select the application.
Click the
command.The Add POU dialog opens.
Specify a name and select the Ladder Logic Diagram (LD) implementation language.
Click the Add button.
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 ToolBox view is also opened automatically, where the suitable elements, operators, and function blocks are available for LD programming.
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.
In the ToolBox view, click the Ladder Elements category.
Click the Contact element, drag it into your network and drop it at the insertion position Start here.
The contact is added on the left in the network directly at the vertical line.
Click
???
and enter the identifier of a Boolean variable. The Input Assistant is also available for this.In the ToolBox view, click the Function Blocks category and drag the TON function block to an insertion position on the connecting line to the right of the inserted contact.
CODESYS inserts the TON box to the right of the contact. The contact is connected with the input
IN
of theTON
function block.Specify a time constant at the
PT
input (example:T#3s
).If the variable of your contact becomes
TRUE
, then theIN
input of the TON function block also becomesTRUE
. For example, with a on-delay time ofT#3s
theTON
function block forwards the valueTRUE
to theQ
output.
For more information, see the following: Contact
Inserting a closed 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 click
.Select the connecting line to the left of the contact and click
.The start point on the connecting line is indicated by a red rectangle. CODESYS indicates all possible end points of the branch with a blue rectangle.
Click a blue rectangle in order to set the end point of your closed branch.
CODESYS inserts the branch between the start and end points. The program flow will run through both branches until the end point.
If you insert the branch at a box instead of at a contact, then the box will only be called if none of the other branches is
TRUE
.
For more information, see the following: Closed Branch