Ladder Diagram Editor

This is how a POU written in the LD appears in the TwinCAT PLC Control editor:

Ladder Diagram Editor 1:

POU in the Ladder Diagram

All editors for POUs consist of a declaration part and a body. These are separated by a screen divider.

The LD editor is a graphic editor. The most important commands are found in the context menu (right mouse button or <Ctrl>+<F10>).

For information about the elements, see Ladder Diagram (LD).

Cursor Positions in the LD Editors

The following locations can be cursor positions, in which the function block and program accessing can be handled as contacts. POUs with EN inputs and other POUs connected to them are treated the same way as in the Function Block Diagram. Information about editing this network part can be found in the FBD Editor chapter.

1. Every text field (possible cursor positions framed in black)

Ladder Diagram Editor 2:

2. Every Contact or Function Block

Ladder Diagram Editor 3:

3. Every Coil

Ladder Diagram Editor 4:

4. The Connecting Line between the Contacts and the Coils

Ladder Diagram Editor 5:

The Ladder Diagram uses the following menu commands in a special way:

'Insert' 'Contact' Shortcut: <Ctrl>+<O>

Use this command in the LD editor in order to insert a contact in front of the marked location in the network.
If the marked location is a coil (Cursor Position 3) or the connecting line between the contacts and the coils (Cursor Position 4), then the new con-tact will be connected serially to the previous contact connection.
The contact is preset with the text "???". You can click on this text and change it to the desired variable or the desired constant. For this you can also use the Input Assistant.
You can activate the options Comments per Contact and Lines for variable comment in the dialog 'Function Block and Ladder Diagram Options' ('Extras' 'Options') to reserve a certain number of lines for the variable name. This might be useful, if long variable names are used, to keep the network short.
Also regard the option Networks with linebreaks, which you also can activate with the command 'Extras' 'Options' in the dialog 'Function Block and Ladder Diagram Options'.

Ladder Diagram Editor 6:

Ladder Diagram Editor 7:

'Insert' 'Parallel Contact' Shortcut: <Ctrl>+<R>

Use this command in the LD editor to insert a contact parallel to the marked position in the network. If the marked position is a coil (Cursor Position 3) or the connection between the contacts and the coils (Cursor Position 4), then the new contact will be connected in parallel to the entire previous contact connection. The contact is preset with the text "???". You can click on this text and change it to the desired variable or the desired constant. For this you can also use the Input Assistant.

'Insert' 'Function Block' Shortcut: <Ctrl>+<B>

Use this command in order to insert an operator, a function block, a function or a program as a POU. For this, the connection between the contacts and the coils (cursor position 4), or a coil (cursor position 3), must be marked. The new POU at first has the designation AND. If you wish, you can change this designation to another one. For this you can also use the Input Assistant. Both standard and selfdefined POUs are available.

The first input to the POU is placed on the input connection, the first output on the output connection; thus these variables must definitely be of type BOOL. All other in- and outputs of the POU are filled with the text „???“. These prior entries can be changed into other constants, variables or addresses. For this you can also use the Input Assistant.

'Insert' 'Coil' Shortcut: <Ctrl>+<L>

You can use this command in the LD editor to insert a coil in parallel to the previous coils. If the marked position is a connection between the contacts and the coils (Cursor Position 4), then the new coil will be inserted as the last. If the marked position is a coil (Cursor Position 3), then the new coil will be inserted directly above it. The coil is given the text "???" as a default setting. You can click on this text and change it to the desired variable. For this you can also use the Input Assistant.

POUs with EN Inputs

If you want to use your LD network as a PLC for calling up other POUs , then you must merge a POU with an EN input. Such a POU is connected in parallel to the coils. Beyond such a POU you can develop the network further, as in the Function Block Diagram. You can find the commands for insertion at an EN POU under the menu item "Insert" "Insert at Blocks".

An operator, a function block, or a function with EN input performs the same way as the corresponding POU in the Function Block Diagram, except that its execution is controlled on the EN input. This input is annexed at the connecting line between coils and contacts. If this connection carries the information "On", then the POU will be evaluated.

If a POU has been created once already with EN input, then this POU can be used to create a network. This means that data from usual operators, functions, and function blocks can flow in an EN POU and an EN POU can carry data to such usual POUs.

If, therefore, you want to program a network in the LD editor, as in FBD, you only need first to insert an EN operator in a new network. Subsequently, from this POU, you can continue to construct from your network, as in the FBD editor. A network thus formed will perform like the corresponding network in FBD.

'Insert' 'Box with EN'

Use this command to insert a function block, an operator, a function or a program with EN input into a LD network. The marked position must be the connection between the contacts and the coils (Cursor Position 4) or a coil (Cursor Position 3).

The new function block is inserted in parallel to the coils and underneath them; it contains initially the designation AND. If you wish, you can change this designation to another one. From the Input Assistant dialog box that appears, you can select whether to insert a user-defined, or a standard (default) function block.

‘Insert’ ’Insert at blocks

With this command you can insert additional elements into a POU that has already been inserted (also a POU with EN input). The commands below this menu item can be executed at the same cursor positions as the corresponding commands in the Function Block Diagram (See Chapter 5.7).

With Input you can add a new input to the POU.

With Output you can add a new output to the POU.

With POU, you insert a new POU. The procedure is similar to that described under 'Insert' 'POU'.

With Assign you can insert an assignment to a variable. At first, this is shown by three question marks „???“, which you edit and replace with the desired variable. Input assistance is available for this purpose.

'Insert' 'Jump'

With this command you can insert a parallel jump in the selected LD editor, in parallel, at the end of the previous coils. If the incoming line delivers the value "On", then the jump will be executed to the indicated label.

The marked position must be the connection between the contacts and the coils (Cursor Position 4) or a coil (Cursor Position 3). The jump is present with the text "???". You can click on this text and make a change in the desired label.

'Insert' 'Return'

In the LD editor, you can use this command to insert a Return instruction in parallel at the end of the previous coils. If the incoming line delivers the value "On," then the processing of the POU in this network is broken off. The marked position must be the connection between the contacts and the coils(Cursor Position 4) or a coil (Cursor Position 3).

'Extras' 'Paste after'

Use this command in the LD editor to insert the contents of the clipboard as a serial contact after the marked position. This command is only possible if the contents of the clipboard and the marked position are networks comprised of contacts.

'Extras' 'Paste below' Shortcut <Ctrl>+<U>

Use this command in the LD editor to insert the contents of the clipboard as parallel contact below the marked position. This command is only possible if the contents of the clipboard and the marked position are networks comprised of contacts.

'Extras' 'Paste above'

Use this command in the LD editor to insert the contents of the clipboard as parallel contact above the marked position. This command is only possible if the contents of the clipboard and the marked position are networks comprised of contacts.

'Extras' 'Negate' Shortcut: <Ctrl>+<N>

Use this command to negate a contact, a coil, a jump or return instruction, or an input or output of EN POUs at the present cursor position (Cursor Position 2 and 3).

^Between the parentheses of the coil or between the straight lines of the contact, a slash will appear ((/) or |/|). If there are jumps, returns, or inputs or outputs of EN POUs , a small circle will appear at the connection, just as in the FBD editor.

The coil now writes the negated value of the input connection in the respective Boolean variable. Right at this moment, a negated contact switches the status of the input to the output, if the respective Boolean variable carries the value FALSE.

If a jump or a return is marked, then the input of this jump or return will be negated. A negation can be canceled through renewed negation.

'Extras' 'Set/Reset'

If you execute this command on a coil, then you will receive a Set Coil. Such a coil never overwrites the value TRUE in the respective Boolean variable. This means that once you have set the value of this variable to TRUE, it will always remain at TRUE. A Set Coil is designated with an "S" in the coil symbol.

If you execute this command once again, then you will be given a Reset Coil. Such a coil never overwrites the value FALSE in the respective Boolean variable. This means that once you have set the value of this variable to FALSE, it will always remain at FALSE. A Reset Coil is designated with an "R" in the coil symbol.

If you execute this command repeatedly, the coil will alternate between set, reset and normal coil.

‘Extras’ ‘Open instance’

This command corresponds to the 'Project' 'Open instance' command.

The Ladder Diagram in the Online Mode

In Online mode, the contacts and coils in the Ladder Diagram that are in the "On" state are colored blue. Likewise, all lines over which the "On" is carried are also colored blue. At the inputs and outputs of function blocks, the values of the corresponding variables are indicated.

Breakpoints can only be set on networks; by using stepping, you can jump from network to network.

If you place the mouse pointer briefly above a variable, then the type and the comment about the variable will be displayed in a Tooltip.