Programming Ladder Diagrams (LD)
Creating a POU in the Ladder Diagram implementation language (LD)
- 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 Ladder Diagram (LD).
- 4. Click on Open.
- TwinCAT adds the POU to the PLC project tree and opens it in the editor. An empty network is added in the implementation part. On the left, the empty network is limited by a vertical line, which represents a busbar. The Toolbox view opens automatically, providing suitable elements, operators and function blocks for LD programming.
Adding a contact and a function block (TON)
- A POU with the implementation language LD is opened in the editor, and an empty network is added.
- 1. Click on the category Ladder elements in the Toolbox view.
- 2. Click the Contact element, drag it into your network and release the mouse button at the insert position Start here.
- The contact is added on the left of the network directly at the vertical line.
- 3. Click on ??? and enter the name of a Boolean variable. The input assistant is available for this purpose.
- 4. In the Toolbox view click on the category function blocks and drag the function block TON to an insert position on the connecting line to the right of the added contact.
- TwinCAT adds the function block TON to the right of the contact. The contact is linked to the input IN of the TON function block.
- 5. Enter a time constant, e.g. T#3s, at the input PT.
- If the variable of your contact becomes TRUE, the input IN of the TON function block also becomes TRUE. The TON function block passes the value TRU to output Q with a switch-on delay of T#3s, for example.
Inserting a closed branch
- A POU with the implementation language LD is opened in the editor, and an empty network is added.
- 1. Click in the empty network and select the command Insert Contact in the menu FBD/LD/IL.
- 2. Select the connecting line to the left of the contact and select the command Set Branch Start Point in the menu FBD/LD/IL.
- The start point on the connecting line is indicated by a red rectangle. TwinCAT indicates all possible end points of the branch with a blue rectangle.
- 3. Click on a blue rectangle to set the end point of your closed line branch.
- TwinCAT adds the line branch between the start and end points. The program will run through both branches up to the end point.
If you insert the line branch at a function block instead of a contact, the function block is only called if none the other branches is TRUE.
See also:
- TC3 User Interface documentation: Command Insert Contact
- TC3 User Interface documentation: Command Set Branch Start Point