FBD Editor
FBD Editor
FBD Editor
General information about editing in FBD.....................................................................................1
Inserting functions or function blocks in the graphic editor using the Edit Wizard................1
Changing the properties of functions and function blocks....................................................3
Replacing functions or function blocks.................................................................................3
How to replace one function or function block using the Edit Wizard....................3
How to replace several functions or function blocks of one type...........................4
Dialog 'Local Replace FB/FU'................................................................................4
Inserting variables while editing FBD...................................................................................4
How to insert a variable in FBD which has been declared before.........................4
How to declare and insert a new variable in FBD..................................................5
Changing variables while editing FBD..................................................................................6
Negation of inputs and outputs of functions and function blocks.........................................7
Duplicating inputs of functions..............................................................................................7
Deleting inputs of functions..................................................................................................8
Inserting connectors while editing FBD................................................................................8
Inserting jumps and labels while editing FBD.......................................................................9
Inserting returns while editing FBD....................................................................................10
Changing the flag type using the dialog 'Flag Type Properties'.........................................10
Viewing the execution order of functions and function blocks............................................10
Viewing feedbacks in FBD networks..................................................................................11
Source conversion for IL, FBD and LD...............................................................................11
i
General information about editing in FBD
In the graphic editor you can edit in the programming language FBD using different features of the
program.
In order to edit an FBD code body worksheet you first have to open the corresponding worksheet in
the project tree by double clicking on the desired icon.
The graphical programming language FBD provides many additional features, which facilitate the
creation of a program, FB or function code body, e.g.:
• Functions and function blocks can be inserted using the Edit Wizard and edited using the
dialog 'Variables Properties'.
• The graphic editor provides simple keyboard operations for insertion and scrolling (Cursor
keys /CTRL Cursor keys for object mode and SHIFT/SHIFT CTRL Cursor keys for mouse
cursor mode).
• Duplication of inputs can be done directly via keyboard, toolbar and menu.
• Negation of Inputs, Outputs, Contacts and Coils can be done directly via keyboard, toolbar
and menu.
• Items can be inserted directly on a line or can be connected to the inputs or outputs of
present items.
• Double clicking on user functions and function blocks opens the contents of the
corresponding POU.
The most comfortable way to perform this is to use the Edit Wizard.
If you have inserted a new function or function block POU and you want to use it in a worksheet,
compile the variables worksheet of the new POU with 'Compile Worksheet'. You can insert the new
element immediately in your new worksheet having done this compilation.
1
General information about editing in FBD General information about editing in FBD
The command 'Compile Worksheet' of the submenu 'Build' can be used to compile only one
worksheet for detecting syntax errors while developing a project. It is only available if the worksheet
is the active window. Using Compile Worksheet no code is generated.
How to proceed:
• If the Edit Wizard is not visible, click on the icon 'Edit Wizard' in the toolbar.
The Edit Wizard is activated by clicking in the Edit Wizard or pressing <ALT> + <3>.
• Locate the code body position in your worksheet, where the new function or function block
has to be inserted.
• If desired activate the grid by selecting the menu item 'Grid' in the submenu 'Layout'.
• Open the Edit Wizard list box 'Group' and select the desired group of functions or function
blocks.
• Determine the desired function or function block in the Edit Wizard selection area.
• In the dialog 'Variables Properties' an instance name for the inserted FB is proposed in the
field 'Name' on the dialog page 'Variables'.
The field 'Name' displays the default instance name (e.g. for a CTU the name 'CTU_n' is
proposed, where n is the first available number which is free for this instance name).
To define the name of the new FB you have the following possibilities:
* Enter a new instance name in the field.
* Accept the proposed name.
* Select an already existing name in the instance name list box below the text field.
• If desired enter a comment concerning the new function block on the dialog tab 'Common'.
• On the tab 'Local Scope' of the dialog 'Variables Properties' mark the group of the local
variables grid worksheet into which you want to insert the new instance declaration. For
that purpose click on the desired group name with the left mouse button.
2
General information about editing in FBD Changing the properties of functions and function blocks
By using different colors for functions and function blocks the origin of the related object is
indicated. IEC FIRMWARE FUs/FBs and FUs/FBs from FIRMWARE libraries are displayed in red.
USER FUs/FBs from the same project are displayed in green and USER FUs/FBs from an user
library are displayed in blue.
Please note, that the colors described above are system default colors. If you have changed the
colors using the dialog 'Options', your display may differ from the help information.
How to proceed:
• In the FBD worksheet click with the right mouse button on the function or function block to
be edited to open the context menu for this object.
• Replacing several functions or function blocks of one type within the worksheet
Functions and function blocks can be replaced maintaining the connection lines if they have the
same formal parameters. If not, the lines will be deleted.
How to replace one function or function block using the Edit Wizard
• Click on the function or function block you want to replace. The marked object changes its
color.
3
General information about editing in FBD How to replace several functions or function blocks of one type
• Press the button 'Find Next' to go to the first function or function block to be replaced.
• Press the button 'Replace all' if you want to replace all functions or function blocks of this
type without having a look at them.
• Press the button 'Replace' if you want to replace them step by step.
The dialog 'Local Replace FB/FU' appears if you choose the menu item 'Replace FB/FU' in the
submenu 'Edit'. It can be used to replace functions and function blocks.
• Inserting variables which have already been declared in the variables grid worksheet
• Inserting variables which have not been declared in the variables grid worksheet before
Variables can be inserted anywhere in the FBD worksheet or directly connected to an input/output
(formal parameter) of functions or function blocks.
• If you want to insert a variable not connected to a function or function block, click in the
worksheet to set an insertion mark.
If you want to insert a variable already connected to a function or function block, mark the
formal parameter of the object.
4
General information about editing in FBD How to declare and insert a new variable in FBD
Example:
• On the page 'Variables' of the dialog 'Variable Properties' activate the radio button 'Local
scope' if you want to insert a local variable. Activate 'Global scope' if you want to insert a
global variable.
Depending on the selected scope, the variables list box below the field 'Name' now
contains all local or global variables which are declared in the corresponding local or
global variables worksheet. It does not matter in which group a variable is declared, the
list box shows the content of all groups in the variables worksheet.
• Click on the desired variable in the variables list box. The marked name is entered into the
text field.
• If you want to insert a variable not connected to a function or function block, click in the
worksheet to set an insertion mark.
If you want to insert a variable already connected to a function or function block, mark the
formal parameter of the object.
Example:
• On the page 'Variables' of the dialog 'Variables Properties' enter the new name in the field
'Name' and click on the button 'Apply'. The dialog page 'Common' is opened automatically.
• On the dialog page 'Common' select the appropriate settings for the variable and click on
'Apply' to confirm the settings.
5
General information about editing in FBD Changing variables while editing FBD
Note: By selecting the usage, you define, whether you are declaring a local or a global
variable.
• Now you have to define the scope of the new variable, i.e. the variables group into which
the new declaration should be inserted. For that purpose open the dialog page 'Local
scope' if you are declaring a local variable or 'Global scope' in the case of a global
variable.
In the subtree on the dialog page browse for the variables group into which you want to
insert the new variable declaration and mark it with a left mouse click.
Note: If you are declaring a global variable (i.e. usage VAR_EXTERNAL or
VAR_EXTERNAL_PG), you have to select both, a local and a global scope.
The autoinsertion of the variable declaration is not done if the variable has the same name as the
POU, an action or transition code body or if it is a structure or an array.
If the variables grid worksheet is opened while declaring a new variable in the code body
worksheet, the grid is updated (i.e. the new declaration is inserted into the specified variables
group) automatically without closing the variables worksheet.
It is possible to change the variable into a variable which has been declared before in the variable
worksheet. It is also possible to enter a name for a new variable and thus declare a new variable
while changing.
How to proceed:
• For replacing the current variable by an already declared variable, select the desired
variable in the variables list box on the dialog page 'Variables'. If required mark the radio
button 'Local scope' or 'Global scope'. Proceed as described in the topic How to insert a
variable which is already declared.
For replacing the current variable by a new variable, enter a new name and then
proceed as described in the topic How to insert and declare a new variable.
For changing the properties of the current variable open the dialog page 'Common' and
do the required changes.
6
General information about editing in FBD Negation of inputs and outputs of functions and function blocks
To negate an FP (Formal Parameter) you can either perform the procedure described below or you
can use the dialog 'FB/FU Properties' which is called by double clicking on the function or function
block.
How to proceed:
• Click on the input or output you want to negate. The marked FP changes its color.
Example:
To duplicate function inputs you can either perform the procedure described below or you can use
the dialog 'FB/FU Properties' which is called by double clicking on the function.
How to proceed:
• Click on the last input of the function you want to duplicate. The marked input changes its
color.
Example:
7
General information about editing in FBD Deleting inputs of functions
It is also possible to delete inputs of extensible functions which have been duplicated before.
To delete inputs of functions you can either perform the procedure described below or you can use
the dialog 'FB/FU Properties' which is called by double clicking on the function.
How to proceed:
• Press <DEL>.
How to proceed:
• Mark the input or output of an object in your worksheet where you want to insert the
connector.
8
General information about editing in FBD Inserting jumps and labels while editing FBD
It is also possible to insert a connector somewhere in the worksheet by setting an insertion mark
and then clicking on the icon 'Connector/Jump or Label' in the toolbar.
• Mark the output of an object in your worksheet where you want to insert the jump.
It is also possible to insert a jump somewhere in the worksheet by setting an insertion mark and
then clicking on the icon 'Connector/Jump or Label' in the toolbar.
• Click in the worksheet to set an insertion mark where you want to insert the label.
• Enter a name for the label. The label name must be identical with the name of the related
jump.
9
General information about editing in FBD Inserting returns while editing FBD
How to proceed:
• Mark the output of an object in your worksheet where you want to insert the return.
It is also possible to insert a return somewhere in the worksheet by setting an insertion mark and
then double clicking on the icon 'Return' in the toolbar.
Changing the flag type using the dialog 'Flag Type Properties'
If functions are connected directly with each other by a line (i.e. a direct line from connection point
to connection point) the program sometimes needs an internal temporary flag for compilation.
In those cases where the data type of an internal flag is not determined by the structure of the
network you have do it manually by using the dialog 'Flag Type Properties'. This dialog only
contains a list box for specifying the data type of the current flag.
Normally you will get a compilation error in the message window. Double clicking on the error
message will go directly to the point where the flag is needed.
How to proceed:
• Double click on a line or choose the menu item 'Object Properties...' in the context menu
of a line used to connect functions.
The dialog 'Flag Type Properties' appears.
• Change the data type of the flag and confirm the dialog 'Flag Type Properties'.
The execution order corresponds to the intermediate PLC code which is created while compiling. It
may differ from the execution order of the PLC.
The execution order can only be seen if you have already compiled the worksheet using the menu
item 'Compile Worksheet' in the submenu 'Build'.
This command can be used to compile only one worksheet for detecting syntax errors while
developing a project. It is only available if the worksheet is the active window. Using Compile
Worksheet no code is generated.
Using the menu item 'Compile Worksheet' you cannot detect programming errors such as using a
variable in a code body which has not been declared in a variable declaration. In those cases you
should use the menu item 'Make' or the menu item 'Rebuild Project'.
10
General information about editing in FBD Viewing feedbacks in FBD networks
How to proceed:
• If the worksheet is not already compiled, choose the menu item 'Compile Worksheet' in
the submenu 'Build' or click on the icon 'Compile Worksheet' in the toolbar to compile the
worksheet.
The execution order corresponds to the intermediate PLC code which is created while compiling. It
may differ from the execution order and feedbacks of the PLC.
Feedbacks can only be seen if you have already compiled the worksheet using the menu item
'Compile worksheet' in the submenu 'Build'.
This command can be used to compile only one worksheet for detecting syntax errors while
developing a project. It is only available if the worksheet is the active window. Using Compile
Worksheet no code is generated.
Using the menu item 'Compile Worksheet' you cannot detect programming errors such as using a
variable in a code body which has not been declared in a variable declaration. In those cases you
should use the menu item 'Make' or the menu item 'Rebuild Project'.
How to proceed:
• If the worksheet is not already compiled, choose the menu item 'Compile Worksheet' in
the submenu 'Build' or click on the icon 'Compile Worksheet' in the toolbar to compile the
worksheet.
Feedbacks are represented with green lines if you have done changes in your worksheet since last
compilation. In those cases compile the worksheet using 'Compile Worksheet'.
11
General information about editing in FBD Viewing feedbacks in FBD networks
IL FBD, LD
FBD IL, LD
LD IL, FBD
Prerequisite for each source conversion is that the project which contains the POU to be
converted was already built before (using one of the commands 'Make' or 'Rebuild Project' in the
submenu 'Build'). This is necessary, because the system does not convert the textual or graphical
language elements which are visible in the corresponding worksheets, but the intermediate code,
generated while compiling the project.
How to proceed:
• In the project tree open the subtree 'Logical POUs' and mark the folder icon of the POU to
be converted.
Example:
• Click with the right mouse button on the icon in order to open its context menu.
• In the dialog mark the checkbox 'Overwrite source POU' if desired, determine the name of
the target POU and mark the desired target language (please refer to the table shown
below).
• Note, that the new POU is not yet compiled after the conversion.
Overwrite source POU if this checkbox is marked, the source POU is going to be overwritten
by the converted POU. Otherwise the source POU is not changed
and is available for future use.
Text field this field is used to define a name for the new POU. After opening the
dialog, the system automatically proposes a name. You can either
leave this name unchanged or enter a new name.
Convert to these radio buttons are used to determine the target language. Of
'FBD', 'LD', 'IL' course the source language is displayed in grey.
12