Function Block Diagram Editor

This is how a POU written in the FBD under the corresponding TwinCAT PLC Control editor looks:

Function Block Diagram Editor 1:

Editor for the Function Block Diagram

The Function Block Diagram editor is a graphic editor. It works with a list of networks, in which every network contains a structure that displays, respectively, a logical or an arithmetical expression, the calling up of a function block, a function, a program, a jump, or a return instruction.The most important commands are found in the context menu (right mouse button).

Cursor positions in FBD

Every text is a possible cursor position. The selected text is on a blue background and can now be changed. You can also recognize the present cursor position by a dotted rectangle. The following is a list of all possible cursor positions with an example:

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

Function Block Diagram Editor 2:

2) Every input:

Function Block Diagram Editor 3:

3) Every operator, function, or function block:

Function Block Diagram Editor 4:

4) Outputs, if an assignment or a jump comes afterward:

Function Block Diagram Editor 5:

5) The lined cross above an assignment, a jump, or a return instruction:

Function Block Diagram Editor 6:

6) Behind the outermost object on the right of every network ("last cursor position," the same cursor position that was used to select a network):

Function Block Diagram Editor 7:

7) The lined cross directly in front of an assignment:

Function Block Diagram Editor 8:

How to set the cursor

The cursor can be set at a certain position by clicking the mouse, or with the help of the keyboard. Using the arrow keys, you can jump to the nearest cursor position in the selected direction at any time. All cursor positions, including the text fields, can be accessed this way. If the last cursor position is selected, then the <up> or <down> arrow keys can be used to select the last cursor position of the previous or subsequent network. An empty network contains only three question marks "???". By clicking behind these, the last cursor position is selected.

'Insert' 'Assignment' Shortcut: <Ctrl>+<A>

This command inserts an assignment. Depending on the selected position, insertion takes place directly in front of the selected input (Cursor Position 2), directly after the selected output (Cursor Position 4), directly before the selected line cross (Cursor Position 5), or at the end of the network (Cursor Position 6). For an inserted assignment, a selection can be made accompanying the entered text "???", and the assignment can be replaced by the variable that is to be assigned. For this you can also use the Input Assistant. In order to insert an additional assignment to an existing assignment, use the "Insert" "Output" command.

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

This command inserts a jump. Depending on the selected position, insertion takes place directly in front of the selected input (Cursor Position 2), directly after the selected output (Cursor Position 4), directly before the selected line cross (Cursor Position 5), or at the end of the network (Cursor Position 6). For an inserted jump, a selection can be made accompanying the entered text "???", and the jump can be replaced by the label to which it is to be assigned.
'Insert' 'Return' Shortcut: <Ctrl>+<R>

This command inserts a RETURN instruction. Depending on the selected position, insertion takes place directly in front of the selected input (Cursor Position 2), directly after the selected output (Cursor Position 4), directly before the selected line cross (Cursor Position 5), or at the end of the network (Cursor Position 6).

'Insert' 'Box' Shortcut: <Ctrl>+<B>

With this command, operators, functions, function blocks and programs can be inserted. First of all, it is always inserted an “AND” operator. This can be converted by Selection and Overwrite of the type text („AND“) into every other operator, into every function, into every function block and every program. You can select the desired POU by using Input Assistant (<F2>). If the new selected block has another minimum number of inputs, these will be attached. If the new block has a smaller highest number of inputs, the last inputs will be deleted.

In functions and function blocks, the formal names of the in- and outputs are displayed.

In function blocks there exists an editable instance field above the box. If another function block that is not known is called by changing the type text, an operator box with two inputs and the given type is displayed. If the instance field is selected, Input Assistant can be obtained via <F2> with the categories for variable selection.

The newest POU is inserted at the selected position (see ):

All POU inputs that could not be linked will receive the text "???". This text must be clicked and changed into the desired constant or variable.

If there is a branch to the right of an inserted POU, then the branch will be assigned to the first POU output. Otherwise the outputs will be unassigned.

'Insert' 'Input' Shortcut: <Ctrl>+<U>

This command inserts an operator input. With many operators, the number of inputs may vary. (For example, ADD can have 2 or more inputs.) In order to extend such an operator by an input, you need to select the input in front of which you wish to insert an additional input (Cursor Position 1); or you must select the operator itself (Cursor Position 3), if a lowest input is to be inserted.

The inserted input is allocated with the text "???". This text must be clicked and changed into the desired constant or variable. For this you can also use the Input Assistant.
'Insert' 'Output'

This command inserts an additional assignment into an existing assignment. This capability serves the placement of so-called assignment combs; i.e., the assignment of the value presently located at the line to several variables.

If you select the lined cross above an assignment (Cursor Position 5) or the output directly in front of it (Cursor Position 4), then there will be another assignment inserted after the ones already there.

If the line cross directly in front of an assignment is selected (Cursor Position 4), then another assignment will be inserted in front of this one.

The inserted output is allocated with the text "???". This text must be clicked and changed into the desired variable. For this you can also use the Input Assistant

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

With this command you can negate the inputs, outputs, jumps, or RETURN instructions. The symbol for the negation is a small circle at a connection.

If an input is selected (Cursor Position 2), then this input will be negated.

If an output is selected (Cursor Position 4), then this output will be negated.

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'

With this command you can define outputs as Set or Reset Outputs. A grid with Set Output is displayed with [S], and a grid with Reset Output is displayed with [R].

Function Block Diagram Editor 9:

Set/Reset Outputs in FBD

An Output Set is set to TRUE, if the grid belonging to it returns TRUE. The output now maintains this value, even if the grid jumps back to FALSE. An Output Reset is set to FALSE, if the grid belonging to it returns FALSE. The output maintains its value, even if the grid jumps back to FALSE. With multiple executions of the command, the output will alternate between set, reset, and normal output.

'Extras' 'Zoom' Shortcut: <Alt>+<Enter>

With this command a selected POU is loaded into its editor (Cursor Position 3). If you are dealing with a POU from a library, then the library manager is called up, and the corresponding POU is displayed.

‘Extras’ ‘Open instance’

This command corresponds to the 'Project' 'Open instance' command.
Cutting, Copying, Pasting, and Deleting in FBD

The commands used to "Cut", "Copy", "Paste", and "Delete" are found under the "Edit" menu item.

If a line cross is selected (Cursor Position 5), then the assignments, jumps, or RETURNS located below the crossed line will be cut, deleted, or copied.

If an operator, a function, or a function block is selected (Cursor Position 3), then the selected object itself, will be cut, deleted, or copied, along with all of the branches dependent on the inputs, with the exception of the first branch. Otherwise, the entire branch located in front of the cursor position will be cut, deleted, or copied.

After copying or cutting, the deleted or copied part is located on the clipboard and can now be pasted, as desired. In order to do so, you must first select the pasting point.

Valid pasting points include inputs and outputs. If an operator, a function, or a function block has been loaded onto the clipboard (As a reminder: in this case all connected branches except the first are located together on the clipboard), the first input is connected with the branch before the pasting point. Otherwise, the entire branch located in front of the pasting point will be replaced by the contents of the clipboard. In each case, the last element pasted is connected to the branch located in front of the pasting point.

The following problem is solved by cutting and pasting: A new operator is pasted in the middle of a network. The branch located on the right of the operator is now connected with the first input, but must be connected with the second input. You can now select the first input and perform the command "Edit" "Cut". Following this, you can select the second input and perform the command "Edit" "Paste". This way, the branch is dependent on the second input.

The Function Block Diagram in the Online Mode

In the Function Block Diagram, breakpoints can only be set to networks. If a breakpoint has been set to a network, then the network numbers field will be displayed in blue. The processing then stops in front of the network where the breakpoint is located. In this case, the network numbers field will become red. Using stepping (single step), you can jump from network to network.

Exception: The current value is displayed for each variable.

Doubleclicking on a variable opens the dialog box for writing a variable. Here it is possible to change the present value of the variable. In the case of Boolean variables, no dialog box appears; these variables are toggled. The new value will turn red and will remain unchanged. If the "Online" "Write values" command is given, then all variables are placed in the selected list and are once again displayed in black. The flow control is run with the "Online" "Flow control" command. Using the flow control, you can view the present values that are being carried in the networks over the connecting lines. If the connecting lines do not carry Boolean values, then the value will be displayed in a specially inserted field. If the lines carry Boolean values, then they will be shaded blue in the event that they carry TRUE. By this means, you can accompany the flow of information while the PLC is running.

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.