You are on page 1of 51

The Fixed Format LD editor − general information

Chapter contents : Editing in LD using the Fixed Format LD editor


The Fixed Format LD editor − general information.......................................................................1
Changing the column width in LD worksheets.....................................................................2
Customizing the representation of the LD worksheet...........................................................2
Converting (standard) non−FF LD code into Fixed Format LD code...................................3
Exporting an FF LD code body using source conversion.....................................................3
Mouse and keyboard operations in the Fixed Format LD editor..........................................4
Rules concerning columns and rows of an LD worksheet....................................................5
Saving an LD code body as template (Copy to... / Insert from...).........................................6
Setting default names for newly created contacts/coils and variables in the current
worksheet............................................................................................................................7
Setting editor defaults in the 'Options' dialog.......................................................................7
Setting the display mode for variables.................................................................................9

General editing operations in the Fixed Format LD editor.........................................................12


Copying objects in LD worksheets.....................................................................................12
Cutting objects in LD worksheets.......................................................................................13
Deleting objects in LD worksheets.....................................................................................13
Marking objects in LD worksheets......................................................................................14
Moving objects in LD worksheets by drag and drop...........................................................15
Moving objects by inserting/deleting rows or columns.......................................................17
Pasting objects in LD worksheets......................................................................................17
Printing LD worksheets......................................................................................................18
Using Undo and Redo in LD worksheets...........................................................................19

Editing LD networks using the Fixed Format LD editor..............................................................20


Changing the properties of existing contacts or coils.........................................................20
Connecting objects in LD worksheets................................................................................22
How to connect objects by drag and drop...................................................................23
How to connect objects using the connection mode...................................................24
Editing program control statements....................................................................................24
Rules and restrictions for program control statements.......................................................25
Inserting and editing program control statements..............................................................26
Available statement types..................................................................................................27
Replacing functions and function blocks............................................................................27
Finding and replacing LD objects.......................................................................................28
Dialog 'Find/Replace LD Objects' (local).....................................................................28
Dialog 'Global Find/Replace LD Objects'....................................................................29
Finding LD objects in all worksheets...........................................................................30
Finding LD objects in the active worksheet.................................................................31
Replacing LD objects in all worksheets.......................................................................32
Replacing LD objects in the active worksheet.............................................................33
Inserting comments while editing in LD..............................................................................33
Inserting connectors while editing in LD.............................................................................34
Inserting functions and function blocks in LD worksheets..................................................35
Inserting jumps and labels while editing in LD...................................................................37
Inserting left power rails (network blocks)..........................................................................38
Inserting parallel LD branches using the branch edit mode...............................................39
Inserting parallel contacts/coils..........................................................................................41
Inserting returns while editing in LD...................................................................................42
Inserting right power rails...................................................................................................42
Inserting serial contacts/coils.............................................................................................42
Inserting variables while editing in LD................................................................................44
Declaring and inserting new variables in LD...............................................................44

i
Chapter contents : Editing in LD using the Fixed Format LD editor
Editing LD networks using the Fixed Format LD editor
Inserting already declared variables in LD..................................................................46
Network blocks (left power rails)........................................................................................47

ii
The Fixed Format LD editor − general information
The topics contained in this help section are specific to the Fixed Format LD editor. Basic editing
and displaying operations which are common to all graphical editors are explained in the general
description of the graphical editor. The same applies to non−specific dialogs.

Editing in the graphical programming language LD is done using the Fixed Format LD editor. This
graphical editor is a cell based editor splitting the LD worksheet into rows and columns building up
the worksheet cells. For that reason all operations you perform are cell−oriented, i.e. operations
such as inserting or moving objects are always done with regard to the cell structure of the
worksheet.

Navigating through the rows and columns in the LD worksheet is done using a cell cursor (see
figure below). Every operation in the LD worksheet, e.g. inserting or connecting objects is
performed by the help of the cell cursor. You can move this cell cursor either by clicking the left
mouse button into a cell or using the arrow keys.

The Fixed Format LD editor provides a powerful auto routing feature which allows you to easily
connect and move objects in your LD worksheet, i.e. the editor determines the routing of any
connection line between two free connection points of two objects automatically.

In addition to the "standard" editing operations used to develop your program, the Fixed Format LD
editor allows you:

• to set the representation of LD worksheets. So it is for example possible to change the


display mode for variables or to change the column width.

• to set the default names for newly created variables.

• to mix the programming languages LD and ST by using program control statements.

• Finding and replacing of LD objects (global or local).

• Saving LD worksheets as templates.

• Exporting LD worksheets (source conversion).

1
Changing the column width in LD worksheets

Changing the column width in LD worksheets


The width of the first column can not be changed. This column is reserved for left power rails.
The set column width is worksheet−dependent, i.e. you can change the column width for each LD
worksheet individually.

The default column width is defined in the tab 'Graphical editor' of the 'Options' dialog. For that
purpose the dialog field 'Ladder grid width' is provided.

How to change the column width:

• Position the mouse cursor on the vertical column separator right of the column head to be
changed (as shown in the following figure). The mouse cursor changes its shape.

• Press the left mouse button and change the column width to the desired size by moving
the mouse.

• Release the mouse button. The changed column width is applied to all columns in the
active worksheet.

Customizing the representation of the LD worksheet


The Fixed Format LD editor provides several possibilities to customize the representation of the LD
worksheet. So you can:

• change the column width.


Note, that the default column width, adjusted after inserting a worksheet, depends on the
grid setting in the 'Options' dialog.

• change the display mode for variables, i.e. specify which information is displayed in the LD
worksheet.

• change the grid representation. Using the entries of the menu item 'Grid' in the submenu
'Layout' you can choose between the grid presentations 'No', i.e. no grid is visible, 'Point',
i.e. grid points are visible or 'Dotted', i.e. dotted lines are visible.

• display the execution order of functions and function blocks in the LD worksheet after
compiling the worksheet. For a description about this procedure refer to the topic Viewing
the execution order of functions and function blocks.

• view feedbacks in the FBD parts of the LD network in online mode. For a description
about this procedure refer to the topic Viewing feedbacks in FBD networks.

• display or hide the column and row headers. This is done by activating/deactivating the
menu item 'Header' in the submenu 'Layout'. Marking this menu item will display the

2
Converting (standard) non−FF LD code into Fixed Format LD code

headers.

Converting (standard) non−FF LD code into Fixed Format LD


code
It is possible to convert older LD code, developed with the standard graphical editor, into Fixed
Format LD code by a click of the mouse. This way, you can view and edit older LD networks using
the Fixed Format Ladder editor.

This conversion is only possible, if the checkbox 'Never Convert to Fixed Format LD editor' in tab
'General' of the 'Options' dialog is not marked. Otherwise the context menu item is not available!

In the project tree:

• Right click on the node icon of the LD POU to be converted. The POU context menu
appears.
• Select the context menu item 'Convert LD to Fixed Format LD'.

After the successful conversion, all worksheets contained in the POU are represented by a FF LD
POU icon in the project tree. The POU name is not changed.

Indirect source conversion from FBD/IL into FF LD:


Using the source conversion feature you can convert FBD and IL worksheets into standard LD
code. Currently it is not possible to cross−compile FBD and IL code directly into Fixed Format
Ladder. However, you may achieve this indirectly by first converting the FBD or IL worksheet into
standard LD code and then into FF LD using the context menu item described above.

Exporting an FF LD code body using source conversion


The Fixed Format LD editor provides an export function based on the source conversion
functionality of the programming system. Using this function you can convert the contents of an
entire POU into the programming languages IL or FBD or suitable for the older LD editor version.

Basically the LD export function means cross compiling a cell oriented LD worksheet into each of
the mentioned languages.

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 graphical language
elements which are visible in the corresponding worksheets, but the intermediate code, generated
while compiling the project.

3
Mouse and keyboard operations in the Fixed Format LD editor

How to proceed:

• Make sure, that the project was already built before.

• In the project tree open the subtree 'Logical POUs' and mark the folder icon of the LD
POU to be converted.

• Right click on the icon in order to open its context menu.

• Select the menu item 'Source conversion'.


The dialog 'Source conversion' appears.

• 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).

• Confirm the dialog.


According to your settings the source POU is converted and the new POU is inserted in
the project tree.

The new POU is not yet compiled after the conversion.

The dialog fields have the following meaning:

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. Note
'FBD', 'LD', 'IL' that the option 'LD' means the older LD editor version.

Mouse and keyboard operations in the Fixed Format LD editor


The fixed format LD editor supports full mouse and keyboard handling, i.e. all important commands
and functions can be executed by mouse and keyboard operations.

The following table contains all important keyboard operations and the corresponding mouse
operations.

Operation Keyboard action Mouse action

Moving the cell cursor Pressing the arrow keys

4
Rules concerning columns and rows of an LD worksheet

Clicking the left mouse button


into the desired cell

Moving the mouse cursor Pressing <Ctrl> + arrow keys Moving the mouse

Marking the current object Pressing the space bar Pressing the left mouse
as selected button

Marking several objects Pressing <Shift> + space bar; Pressing <Shift> + left mouse
as selected former selected objects remain button; former selected
selected objects remain selected

Toggling the selection of Pressing <Ctrl> + space bar; all Pressing <Ctrl> + left mouse
the current cell other selections remain button; all other selections
unchanged remain unchanged

Rules concerning columns and rows of an LD worksheet


Please observe the following rules for columns and rows in an LD code body worksheet when
editing LD networks using the Fixed Format LD editor:

• The first column of the worksheet is reserved for the left power rail. There are no other
objects allowed in this column.

• The width of the worksheet columns is identical with the exception of the first column. This
column is smaller than all other columns because it can only contain a left power rail,
representing a network block.

• The width of the column represents the width of a contact/coil.

• The height of rows depends on the content of the highest cell in a row and cannot be
changed. The row height is adjusted automatically to the maximum height of its cells.

• When editing in LD, rows and columns are inserted automatically, e.g. when inserting
objects, connecting objects by auto routing etc.

• There is only one row below the lowermost network block possible, and only one column
right of the most right column, which contains an object.

• Rows are inserted below the row where the cell cursor is positioned and columns are
inserted to the right of the column where the cursor is positioned.

• Specific rows and columns are deleted by positioning the cursor into the desired
row/column, pressing the right mouse button and selecting the desired command from the
context menu (e.g. the menu item 'Delete rows').

5
Saving an LD code body as template (Copy to... / Insert from...)

Saving an LD code body as template


(Copy to... / Insert from...)
The Fixed Format LD editor provides an enhanced copy function which can be used to save the
entire content of a LD code body worksheet in a file. This file can then be inserted into any other
empty LD code body worksheet.

Therefore this external file can be considered as template.

You can insert data from files created with the Fixed Format LD editor (*.lp) as well as files
generated with the older LD editor version (*.gp).

How to copy the LD code body to an external file:

• Ensure that the worksheet to be copied is the active window.

• Select 'Copy To...' in the submenu 'Edit'.


The dialog 'Save As' appears.

• Select a target directory for the template file and enter a file name (*.lp).
Confirm the dialog.
The template file is written.

How to insert data from a template file into an LD code body worksheet:

Importing data from a *.lp or *.gp file overwrites the current content of the worksheet. No undo is
available to restore overwritten data.

• Ensure that the worksheet into which the LD data should be imported is the active
window.

• Select 'Import from...' in the submenu 'Edit'


A message dialog appears, informing you that the current worksheet content will be
overwritten by the inserted data.
Confirm the dialog to continue.
The 'Open' dialog appears.

• Select the desired file type:


− *.lp for a template file created with the Fixed Format LD editor.
− *.gp for a template file created with an older LD editor version.

• Browse for the desired file and confirm the dialog.


The content of the selected file is inserted to the current worksheet.

6
Setting default names for newly created contacts/coils and variables in the current worksheet

Setting default names for newly created contacts/coils and


variables in the current worksheet
The dialog 'Automatically generated variables' is used to set the default variable names applied
when inserting new contacts/coils or variables to the LD worksheet. This way you can define your
own default names or deactivate the automatic insertion of default names.

The dialog is called by selecting the menu item 'Automatically generated variables' in the submenu
'Objects'.

The default settings entered in the dialog fields before changing a value are taken from the tab
'Graphical editor' of the 'Options' dialog.

If the automatic assignment of variable names for contacts/coils is deactivated and you insert a
new contact/coil you first have to insert a variable for the new contact/coil.

The dialog fields have the following meaning:

No variable if this checkbox is marked, new contacts and coils are inserted into the
LD worksheet without a variable name. In this case the new variable is
not inserted automatically to the POU's variable list.
If activated, the 'Prefix' and 'Start index contact' fields are grayed out
and therefore disabled.

Prefix / use these input fields to define the prefix and start index used when
Start index contact inserting new contacts and coils to the LD worksheet and automatically
to the POU's variable list.
Example: With the prefix 'C' and start index '0' new contacts or coils are
inserted to the LD worksheet and the POU's variable list with the default
variable names C???, where ??? is the next free index in the POU's
variable list.

Prefix / use these input fields to define the prefix and start index used when
Start index variable inserting new variables into the LD worksheet.
Example: With the prefix 'V' and start index '0' new variables are
inserted to the LD worksheet and automatically to the POU's variable
list with the default variable names V???, where ??? is the next free
index in the POU's variable list.

Setting editor defaults in the 'Options' dialog


The system provides the possibility of setting some defaults for Fixed Format LD code body
worksheets. This is done on the tab 'Graphical editor' and in the tab 'Graphical editor colors' of the
'Options' dialog. To call this dialog select the menu item 'Options...' in the submenu 'Extras'.

Setting network height, width and variable/object defaults

7
Setting default names for newly created contacts/coils and variables in the current worksheet

The lower area of the tab 'Graphical editor' provides the following LD specific dialog fields:

Network block defines the number of connection points with which a new network block (left
height power rail) is going to be inserted.

sets the horizontal default width of the grid and therefore the default width of
the worksheet columns. The default column width can afterwards be changed
in each worksheet individually.
Ladder grid
width Note: The vertical grid width (row height) depends on the content of the
highest cell in a row and cannot be changed.

Please observe the note below.

defines the prefix and start value used when inserting new contacts and coils
to the LD worksheet and automatically to the POU's variable list.
Example: With the prefix 'C' and start value '0' new contacts or coils are
Prefix inserted to the LD worksheet and the POU's variable list with the default
(Contact/Coil) variable names C???, where ??? is the next free index in the POU's variable
and list.
Start value
These settings can afterwards be changed in each worksheet individually.

Please observe the note below.

defines the prefix and start value used when inserting new variables into the
LD worksheet.
Example: With the prefix 'V' and start value '0' new variables are inserted to
the LD worksheet and automatically to the POU's variable list with the default
Prefix (Variable)
variable names V???, where ??? is the next free index in the POU's variable
and
list.
Start value
These settings can afterwards be changed in each worksheet individually.

Please observe the note below.

The settings 'Ladder grid width', the 'Prefixes' as well as the 'Start values' for contacts and coils are
only applied to new inserted LD code worksheets. Already existing worksheets are not affected.
The steps how to change the settings for existing worksheets are described in the topics Setting
default names for the current worksheet and Customizing the representation of the current LD
worksheet.

Setting Fixed Format LD editor default colors

Beneath the default settings on the tab 'Graphical editor', it is also possible to define default colors
used in FF LD worksheets. For that purpose, the 'Options' dialog tab 'Graphical editor colors' has to
be opened.

The following table describes the FF LD related settings provided in the colors selection box:

8
Setting the display mode for variables

sets the color for Program Control Statements as shown in the sample
Basic PCS
illustration in the dialog.

sets the color for global variables which are defined in the POU using
External
VAR_EXTERNAL. This way, global variables can easily be distinguished from
variables
local variables.

To assign a color, mark the related entry in the selection list and click on 'User defined...' to open
the Windows color pallet. Clicking on 'Reset all colors' resets all user defined color settings to the
predefined manufacturer settings.

Setting the display mode for variables


The Fixed Format LD editor allows to change the display modes for variables in the active LD
worksheet. The following modes are available: Standard, Extended, Full und Extension above.

The set display mode is worksheet−dependent, i.e. you can set the display mode for each LD
worksheet individually.

For printing a single worksheet the current display mode settings are taken. If you use the
command 'Print Project' you can set the display mode for all LD worksheets. For more information
about printing LD worksheets click here.

You can additionally define a different color for external variables. This is done in the 'Options'
dialog.

Changing the display mode is done using the entries of the menu item 'Variables display mode' in
the submenu 'Layout'. The following modes are possible:

Standard
In Standard mode only the variable name is displayed. If the variable has only a direct address or
constant value this value is displayed as shown in the following figure.

Extended
In Extended mode the variable name and, if available, the direct address is displayed. For input

9
Setting the display mode for variables

and output formal parameters the data types are displayed. In addition, activating/deactivating the
entry 'Extension above' of the menu item 'Variables display mode' allows to specify whether the
direct address information is displayed above or below the variable name. The following figure
shows an example for an LD network in Extended display mode.

Full
In Full mode the variable name and, if available, the direct address and variable description,
entered in the properties dialog of the variable is displayed. For input and output formal parameters
the data types are displayed. The following figure shows an example for an LD network in Full
display mode.

10
Setting the display mode for variables

Extension above
In addition to the Full mode, activating/deactivating the entry 'Extension above' of the menu item
'Variables display mode' allows to specify whether the direct address and variable description
information is displayed above or below the variable name.

11
General editing operations in the Fixed Format LD
editor
Related topics:

Marking objects in LD worksheets

Moving objects in LD worksheets by drag and drop

Moving objects in LD worksheets by inserting/deleting rows or columns

Copying objects in LD worksheets

Cutting objects in LD worksheets

Pasting objects in LD worksheets

Deleting objects in LD worksheets

Using Undo and Redo in LD worksheets

Printing LD worksheets

Copying objects in LD worksheets


The Fixed Format LD editor provides two possibilities for copying objects:

• copying using the clipboard

• copying by the use of the Drag & Drop method

Copied objects can only be inserted to free and valid positions (cells) in the LD worksheet.

It is for example not possible to insert objects to the cell row containing the network block comment.
A valid or invalid insert operation is displayed by the cursor shape as follows:
inserting the objects at the current cursor position is allowed.
inserting the objects at the current cursor position is not allowed.

How to copy objects using the clipboard:

Elements which are copied to the clipboard can be inserted somewhere in the same or in another
worksheet using the menu item 'Paste'.

• Mark the objects you want to copy to the clipboard. Multi−selection is possible.

• Press <CTRL> + <C> or click on the icon 'Copy' in the toolbar to copy the objects.

12
Cutting objects in LD worksheets

The dialog 'Copy Control' appears if you have not marked a logical assembly of objects.

• If the dialog 'Copy Control' appears, press the button 'Copy' to copy the logical assembly
of objects to the clipboard or press the button 'Show copy' to see which objects are going
to be copied to the clipboard.

How to copy objects using Drag & Drop:

Using this method, it is not possible to copy an object to another worksheet. For that purpose you
have to use the clipboard as described above.

• Mark the objects you want to copy.

• Press the <CTRL> key and keep it pressed.

• Press the left mouse button and drag the object to be copied to a free and valid position
(refer to note above).

• Release the <CTRL> key and the left mouse button in order to drop the copied objects.

Cutting objects in LD worksheets


In the Fixed Format LD editor you can cut objects and move them to the clipboard.

Using 'Cut' the objects are removed from the worksheet and stored to the clipboard. Logical
assemblies of objects which were cut from a worksheet may differ because the LD editor always
tries to handle legal structures without free (i.e. unused) lines. For this reason the dialog 'Cut
Control' allows you to check which objects are going to be removed from the worksheet and what
you get in the clipboard.

How to proceed:

• Mark the objects to be cut. If desired several objects can be selected.

• Press <CTRL> + <X> or click on the icon 'Cut' in the toolbar to move the objects into the
clipboard.

The dialog 'Cut Control' appears if you have not marked a logical assembly of objects.

• If the dialog 'Cut Control' appears, press the button 'Cut' to extend the marking to a logical
assembly of objects and to cut it to the clipboard or press the button 'Show cut' to show
the logical assembly of objects which is going to be deleted in the worksheet.

Deleting objects in LD worksheets


You can delete one or several objects in the LD worksheet. It is not possible to delete objects so
that illegal structures would result. An illegal structure would be for example an LD network
containing unconnected lines.

13
Marking objects in LD worksheets

If you are deleting contacts or coils in an LD network the other contacts or coils remain at their
place connected with a line. Deleting this line the objects remain with connection points.

How to proceed:

• Mark the objects to be deleted.

• Press the key <DEL> to delete the marked object. If you are trying to delete objects which
do not form a logical assembly, the dialog 'Delete control' appears signalizing that the
marked non−legal structure cannot be deleted.

• If the dialog 'Delete control' appears, press the button 'Delete' to extend the marking to a
logical assembly of objects and to delete it or press the button 'OK' to show the logical
assembly of objects which is going to be deleted.

Marking objects in LD worksheets


You can mark only one single object or several distinct objects or a group of objects at the same
time using mouse or keyboard operations.

How to mark one single object using mouse or keyboard:

• Click with the left mouse button on the desired object or press the space bar when the cell
cursor points to the object. The marked object changes its color.

How to mark a function/function block:

• Click with the left mouse button on the upper left or right corner of the FU/FB or use the
arrow keys to move the cell cursor to the upper left or right corner of the FU/FB (see the
following figure) and then press the space bar.

How to mark several distinct objects using mouse or keyboard:

• Click with the left mouse button on the first object or press the space bar when the cell
cursor points to the first object. For selecting FU/FBs refer to the description above.

• When using the mouse press the <SHIFT> key and keep it pressed and then click on the
other objects you want to mark
or
when using the keyboard press the <SHIFT> key and keep it pressed. Then move the cell

14
Moving objects in LD worksheets by drag and drop

cursor to the desired objects and press the space bar.

To deselect an object, press the <CTRL> key and either click on the object or press the space bar.
The markings of all other objects remain.

How to mark a range of objects using the mouse:

• Press the left mouse button and keep it pressed.

• Move the mouse.


A rectangle is displayed indicating the area which is going to be marked.

• Release the mouse button when the rectangle includes all objects to be marked.
The objects are marked.

Some objects are greater than their visible area. That is why you should always draw the rectangle
a bit larger than the visible area of the objects to be marked.

Moving objects in LD worksheets by drag and drop


To organize the structure of an LD POU you can move objects, even if they are connected with
each other. Moving objects is very useful if you have already edited a complex network and you
need more space for inserting new objects. When objects are moved the connections remain after
moving.

Objects can be moved only to free and valid positions (cells) in the LD worksheet.

It is for example not possible to move objects to the cell row containing the network block comment
or to cross connections of an LD network. A valid or invalid move operation is displayed by the
cursor shape as follows:
dropping the objects at the current cursor position is allowed.
dropping the objects at the current cursor position is not allowed.

Connections between moved and not moved objects are routed automatically after dropping. If
dropping is not possible, you get a message and the system stays in the drag mode until dropping
is possible or you cancel the drag and drop operation by pressing the <ESC> key or the right
mouse button.

When moving objects by drag and drop observe the following rules applying to the different LD
objects:

Object To be observed

Contact / Coil Dropping contact/coils on other contacts/coils replace them and


dropping contacts/coils on horizontally lines replace part of the line with
the contact/coil.

Formal parameter Formal parameters can be moved separately. If necessary, the function
/ function block belonging to the formal parameter is extended
automatically to the bottom.

15
Moving objects in LD worksheets by drag and drop

Comment Free comments can be placed at any position in the worksheet.

Network block Network blocks can only be moved by selecting all objects connected to
the network block. It is only possible to move network blocks vertically
and they only can be dropped before or behind an other network block
in the first column of the LD worksheet.

Program control If program control statements are part of the selected objects, moving
statement them is only allowed horizontally or vertically, not diagonally.

How to move objects by dragging and dropping:

• Mark the objects you want to move. In the following figure a contact and function are to be
moved.

• Press the left mouse button and keep it pressed. The selected objects appear as an
outline box.

• Move the cursor to the desired (valid) position (refer to the note above).

• Release the mouse button to drop the objects. Existing connection lines to other objects
are automatically routed in the LD network.

16
Moving objects by inserting/deleting rows or columns

Moving objects by inserting/deleting rows or columns


You can move objects in the LD worksheet by easily inserting/deleting columns or rows.

By inserting/deleting columns or rows it is possible to

• move objects right of the cell cursor to the right or to the left and

• to move objects below the cell cursor to the bottom or to the top.

How to move objects right of the cell cursor to the right or to the left:

• Click in the worksheet to set the cell cursor or use the arrow keys to position the cell
cursor.

• To move all objects right of the cell cursor to the right, open the editor's context menu and
select the menu item 'Insert Columns' or press the default shortcut <CTRL> + 3.

To move all objects right of the cell cursor to the left, open the editor's context menu and
select the menu item 'Delete Columns' or press the default shortcut <CTRL> + 4.

How to move objects below the cell cursor to the bottom or to the top:

• Click in the worksheet to set the cell cursor or use the arrow keys to position the cell
cursor.

• To move all objects below the cell cursor to the bottom, open the editor's context menu
and select the menu item 'Insert Rows' or press the default shortcut <CTRL> + 1.

To move all objects below the insertion mark to the top, open the editor's context menu
and select the menu item 'Delete Rows' or press the default shortcut <CTRL> + 2.

Pasting objects in LD worksheets


If objects have been cut or copied they are stored in the clipboard. You can paste these objects into
any LD worksheet.

Copied or cut objects can only be pasted to free and valid positions (cells) in the LD worksheet.

It is for example not possible to insert objects to the cell row containing the network block comment.
A valid or invalid insert operation is displayed by the cursor shape as follows:
inserting the objects at the current cursor position is allowed.
inserting the objects at the current cursor position is not allowed.

How to proceed:

• Press <CTRL> + <V> to insert the objects from the clipboard or click on the icon 'Paste'.

The objects to be inserted are displayed as an outline box, i.e. the objects are not
automatically dropped.

17
Printing LD worksheets

• Move the outline box to a valid position in the worksheet using the arrow keys or mouse
and click with the left mouse button or press <RETURN> to drop them.

The objects are placed with the upper left corner of the surrounding rectangle at the cell, marked
with the cursor.

If a collision occurs when dropping the object to a position which is not free, the system cancels the
paste operation automatically. In this case you have to paste the object again and drop it at a free
worksheet position.

Printing LD worksheets
When printing LD worksheets or the complete project it is possible to define the display mode for
variables, i.e. which variable information is printed. These display modes are equal to the modes
available in the menu item 'Variables display mode' in the submenu 'Layout'.

For printing a single worksheet the display mode selected while editing the LD worksheet is taken
for printing.

When printing the complete project you can define the display mode to be used for printing all LD
worksheets of your project. This is done in the 'Print Project' dialog.

Global variables are printed with an underlined font. This way, they can easily be distinguished
from local variables.

How to set the display mode when printing the project:

• Choose the menu item 'Print Project' in the submenu 'File'.


The dialog 'Print Project' appears.

• In the 'Variables display mode (LD)' group box activate the radio button

'Standard' − to print only the variable name in LD worksheets. In this print mode the
checkbox 'Extension above' has no effect.

'Extended' − to print the variable name and, if available, the direct address of the variable.
Activate/deactivate the checkbox 'Extension above' to print the direct address information
above/below.

'Full' − to print variable name and, if available, the direct address and variable description.
Activate/deactivate the checkbox 'Extension above' to print the direct address and variable
description information above/below the variable name.

• To print the project, confirm the dialog.

For detailed information about printing the project or single worksheets refer to the topic Printing
and preview.

18
Using Undo and Redo in LD worksheets

Using Undo and Redo in LD worksheets


The Undo command

You can use undo in the LD editor to restore the last performed actions.

How to undo the last action:

• Press the shortcut <CTRL> + <Z> or click on the icon 'Undo' in the toolbar.

The Redo command

You can use redo in the LD editor to do the steps again, which you have undone using the
command 'Undo'.

How to proceed:

• Press the shortcut <CTRL> + <Y> or click on the icon 'Redo' in the toolbar.

After storing the LD worksheet, no undo or redo is possible in this worksheet.

19
Editing LD networks using the Fixed Format LD
editor
Related topics:

Inserting left power rails (network blocks)

Inserting right power rails

Inserting serial contacts/coils

Inserting parallel contacts/coils (branches)

Inserting variables while editing in LD

Connecting objects in LD worksheets

Inserting connectors while editing in LD

Inserting jumps and labels while editing in LD

Inserting returns while editing in LD

Inserting comments while editing in LD

Inserting functions and function blocks in LD worksheets using the Edit Wizard

Changing the properties of existing contacts or coils

Editing program control statements

Finding and replacing LD objects

Finding and replacing functions and function blocks

Changing the properties of existing contacts or coils


You can change the properties of inserted contacts and coils in LD networks. For example, it is
possible to change a normally open contact into a negative transition−sensing contact. It is also
possible to change the variable properties of an object, for example to define an initial value for a
contact.

How to change variable properties of a contact/coil:

• Double click on the contact or coil to be changed.


The dialog 'Contact/Coil Properties' appears.

20
Editing LD networks using the Fixed Format LD editor

• Use the radio buttons 'Contact' and 'Coil' and the list box 'Type' to change the object type.
The table at the end of this topic shows the symbols representing the different object
types.

• For replacing the current variable by an already declared variable, select the desired
variable in the variables combo box 'Name'. If required, select a variables group either in
the list box 'Local Variable Groups' or in the selection tree 'Global Variable Groups'. For
the further steps proceed as described in the topic How to insert a variable in LD which
has been declared before.

For replacing the current variable by a new variable, enter a new name in the 'Name'
input field and then proceed as described in the topic How to insert and declare a new
variable.

For changing the properties of the current variable perform the required changes.

• Confirm the dialog 'Contact/Coil Properties' with 'OK'.

How to change the type of several contacts/coils:

You can also change the type of several objects at the same time. If you have e.g. five coils which
you want to change into SET coils, you have to mark all coils and change them in one step using
the appropriate icons in the toolbar.

If the icons shown below are not visible in the toolbar, you can assign them to an existing toolbar or
create your own toolbar.

• Mark one or several objects for which the type should be changed.

• Change the type of the marked object(s) by clicking on one of the toolbar icons shown in
the following table.

You can toggle through all available contact and coil types by clicking on the icon 'Toggle
properties of contact/coil' in the toolbar.

The editor additionally provides a Find & Replace functionality which can be used to search for
particular LD objects and replace them by other objects (global and local).

Symbols/icons for the different contact/coil types

The following symbols are used in the list box 'Type' of the dialog 'Contact/Coil Properties' as well
as in the toolbar.

LD Symbol
object

normally opened
contact

21
Connecting objects in LD worksheets

normally closed
contact

coil

negated coil

SET coil

RESET coil

Connecting objects in LD worksheets


The Fixed Format LD editor provides three possibilities to connect objects in an LD network:

• connecting objects using the connection mode

• connecting objects by drag and drop

• inserting contacts/coils automatically connected to left power rails, contact/coils or


input/output formal parameters of functions and function blocks.

The Fixed Format LD editor provides a powerful auto routing feature. Auto routing means that the
editor will determine the routing of the connection line between two free connection points
automatically.

When connecting objects, observe the following:

• Connection lines are only allowed within the same network block, i.e. if the worksheet
contains several network blocks and you want to connect objects between these network
blocks, an error message is displayed. The same applies to connectors.

• In case of an illegal connection, i.e. if you try to connect an output to another output, an
error message is displayed.

• Connection lines are allowed to cross each other.

• Links between two or three lines are marked with soldering points.

• Connections crossing a program control statement are not allowed.

22
How to connect objects by drag and drop

How to connect objects by drag and drop

The following procedure describes how to connect the input formal parameter 'CU' of the function
block 'CTU' to the output of contact 'C001'. In the same way connecting other objects by drag and
drop is done.

• Mark the function block 'CTU' by clicking in the upper left corner of the function block or
setting the cell cursor to the upper left cell and pressing the space bar.

• While positioning the mouse cursor on the function block 'CTU', press the left mouse
button and keep it pressed.

• Move the function block to the contact so that the green connection point of the contact
and the connection point of the function block's formal input parameter 'CU' overlap as
shown in the following figure. While moving the mouse the outline box of the function
block is visible showing the position where the object would be dropped when releasing
the mouse button.

• Release the mouse button.


The function block is dropped and the connection is set automatically.

23
How to connect objects using the connection mode

How to connect objects using the connection mode

• Set the cell cursor to the cell which contains the object or connection point (in case of
input/output formal parameters) from which the connection line should start.

• Activate the connection mode by pressing <CTRL> + <L> or click on the icon 'Connect
objects' in the toolbar.

A symbol for a connection is added to the mouse cursor.

• Press the <RETURN> key or left mouse button (while the mouse cursor is set on the
object from which the connection line should start).

• Move the cell cursor to the cell containing the destination object and press <RETURN> or
click with the left mouse button on the desired connection point of the destination object.

Editing program control statements


The LD editor allows to combine structured text elements like 'IF', 'CASE', 'WHILE' etc. with LD
objects. This way you can for example control the execution of other objects in LD worksheets,
either other control statements, LD objects or functions/function blocks.

In LD, the structured text elements are inserted as program control statements.

Program control statements are always represented by a seven columns wide bar, called statement
bar (see the figure below). The most left column of the statement bar contains the list box where
the type of statement is chosen. The remaining columns are either automatically filled with static
texts belonging to the selected statement type or contain user input fields for entering the
expressions or remain empty depending on the selected type.

User input fields and read−only fields of statement bars are displayed in different background
colors. As shown in the following figure for the statement type 'FOR', the read−only fields ('TO', 'BY'
and 'DO') are displayed in another background color than the user−input fields. These colors can
be customized on the tab 'Graphical editor colors' of the 'Options' dialog.

24
Rules and restrictions for program control statements

The behavior and syntax of program control statements is identical to the statements used in the
programming language ST. This means, for example, that a selection statement such as 'IF' always
requires the terminating statement 'END_IF' to form a legal structure of statements. For detailed
information refer to the topic Statements in ST. A table listing the available statement types can be
found at the end of this topic.

Selecting the type of program control statement is done in the most left column of the statement bar
(see section Inserting and editing below).

The following figure shows an example for an LD network consisting of program control statements
and LD objects. In this example the program control statements 'IF' and 'FOR' are nested.

Rules and restrictions for program control statements


When inserting program control statements, the following rules and restrictions must be observed:

• Program control statements are only allowed in rows with a connection point of the left
power rail.
• In a row containing a program control statement no other elements are allowed, except
the right power rail.
• No line or connector connections are allowed between networks which are divided by
program control statements.
• Nesting of program control statements is possible. When compiling the LD worksheet, it is
checked for the correct nesting of program control statements and also the order of
statement sequences, the data types of expressions, variables and CASE values.

25
Inserting and editing program control statements

Inserting and editing program control statements

How to insert a program control statement:

• Move the cell cursor to a cell of an empty row, i.e. there are no other objects than the left
power rail
or
position the cell cursor in a row where a new row below can be inserted.

• Click on the toolbar icon 'Program Control statement'.

• If the cell cursor is set to an empty row, the program control statement with right power rail
is inserted in this row.
If the cell cursor is set to a row containing LD objects, a new row with the program control
statement and right power rail is inserted below, if allowed.
In both cases the new program control statement is automatically connected to the left
power rail.

How to edit a program control statement:

Once you have inserted the program control statement in the LD worksheet, you can edit the
statement bar, i.e. you can choose the program statement type and enter the required expressions,
variables, constants, etc.

• To choose the program statement type, double click on the first cell of the statement bar
containing the type of statement. The list box containing the available program statement
types is displayed.

• Open the list box by clicking on the arrow button and select the statement type. The table
below lists the available statement types.

• Confirm the selected type by pressing <RETURN> or clicking in an empty cell of the
worksheet.
The statement bar is automatically updated, i.e. the "elements" belonging to the selected
statement type are automatically displayed. For example, if you have selected the type
'CASE', the relating element 'OF' is automatically displayed in the statement bar.
Note: Editing fields and non−editing fields of statement bars are displayed in different
colors. As shown in the figure above for the static text 'THEN' another background color is
used than for the editing field left to this static text.

• Enter the values (variables, constants, etc.) for the selected statement type by double
clicking on an editable field as shown in the following example.

26
Available statement types

• Confirm the entered value by clicking with the left mouse button to an empty cell of the
worksheet.

Available statement types


The following table details the available statement types where the group of statements belonging
to each other are listed in one table cell.

Statement types Remark

IF Expression THEN Expression must have the data type 'BOOL'


ELSEIF Expression THEN
(ELSEIF optional)
.
ELSEIF Expression THEN
ELSE
END_IF

CASE Variable OF Variable must have the data type 'INT'. Case list
VALUE case list : represents integer constants.
.
VALUE case list :
ELSE
END_CASE

FOR Expression TO Variable BY Expression and variables must have the data type
Variable DO 'ANY_INT'.
END_FOR

WHILE Expression DO Expression must have the data type 'BOOL'.


END_WHILE

REPEAT Expression must have the data type 'BOOL'.


UNTIL Expression
END_REPEAT

EXIT Used to abort the execution of a statement.

Replacing functions and function blocks


Like in FBD worksheets you can either replace one particular function/FB using the Edit Wizard or
you can replace several functions or function blocks of one type using the dialog 'Local Replace

27
Finding and replacing LD objects

FB/FU'.

This topic describes the second method using the replace dialog.

• Choose the menu item 'Replace FB/FU' in the submenu 'Edit'.


The dialog 'Local Replace FB/FU' appears.

• In the field 'Find what:' select the function or function block type to search for.

• In the field 'Replace with:' select the function or function block for replacing.

• Click 'Find Next' to go to the first function or function block to be replaced.

• Click 'Replace all' if you want to replace all functions or function blocks of this type without
having a look at them
or
click 'Replace' if you want to replace them step by step.

Finding and replacing LD objects


When working with the Fixed Format LD editor, the system provides the possibility to search and
replace LD objects. The procedure is similar to the well−known text search/replace. Objects can be
searched either local (in the current active LD worksheet) or global (within the entire project).

For that purpose, the 'Find/Replace' dialogs are extended by new tabs:

• Tab 'Find LD Objects'


• Tab 'Replace LD Objects'
• Tab 'Global Find LD Objects'
• Tab 'Global Replace LD Objects'

While the global tabs are accessible from each worksheet, it is necessary that a FF LD worksheet
is active for calling the local find/replace tabs.

Dialog 'Find/Replace LD Objects' (local)

The tabs 'Find LD Objects' and 'Replace LD Objects' are only available in the dialog 'Find/Replace'
if you are working with the Fixed Format LD editor. This means that an FF LD worksheet must be
active when selecting one of the menu items 'Find...' or 'Replace...' in the submenu 'Edit'.

These tabs are used for searching and replacing LD objects in the active Fixed Format LD
worksheet.

The following table describes the fields and buttons in both LD specific tabs.

Tab 'Find LD Objects'

28
Dialog 'Global Find/Replace LD Objects'

Find what:Text specifies the name of the LD object to search for.

Find what:Object specifies the object type to search for. Use the list box to select a
type.

Match Case it is searched only for words with same capital and small letters.

Direction: specifies the direction of searching in the worksheet.


'Up' or 'Down'

Find Next goes to the next LD object.

Additional fields and buttons in the tab 'Replace LD Objects'

Replace with: Text specifies the name of the new object.

Replace with: Object specifies the type of the new object.

Replace replaces the first match (text or object).

Replace All replaces all matches (text or object).

Dialog 'Global Find/Replace LD Objects'

The tabs 'Global Find LD Objects' and 'Global Replace LD Objects' of the dialog 'Find/Replace' are
used for searching and replacing LD objects in all Fixed Format LD worksheets of the project or in
all FF LD worksheets which are marked in the project tree. The dialog is called by selecting one of
the menu items 'Global Find...' or 'Global Replace...' in the submenu 'Edit'.

The following table describes the fields and buttons in both LD specific tabs.

Tab 'Global Find LD Objects'

Find what:Text specifies the name of the LD object to search for.

Find what:Object specifies the object type to search for. Use the list box to select a
type.

Match Case it is searched only for words with same capital and small letters.

Range: specifies the range in which the worksheets are searched for the
'All' or 'Marked' specified object. The radio buttons have the following meaning:

All − If this option is selected, all FF LD worksheets are


searched through. If some object icons are marked in the project

29
Finding LD objects in all worksheets

tree, these markings are not considered.

Marked − When activating this option, the system only considers


the FF LD worksheets which are marked in the project tree (or
which are contained in marked POUs).

Direction: specifies the direction of searching in the worksheet.


'Up' or 'Down'

Find Next goes to the next LD object.

Additional fields and buttons in the tab 'Global Replace LD Objects'

Replace with: Text specifies the name of the new object.

Replace with: Object specifies the type of the new object.

Replace replaces the first match (text or object).

Replace All replaces all matches (text or object).

Finding LD objects in all worksheets

The system provides two possibilities for searching LD objects in the Fixed Format LD worksheets
of a project: The local and the global object search.

Finding LD objects global, as it is described in this topic, is done using the tab 'Global Find LD
Objects' of the dialog 'Find/Replace' and considers all worksheets in the project. It does not matter,
whether the worksheets are opened or not.

The second possibility for searching LD objects is called local search and considers only the active
worksheet. This search engine is described in the topic Finding LD objects in the active worksheet.

How to proceed:

• If you want to search only in some worksheets or POUs within the current project, mark
the related icons in the project tree. To mark several icons, hold the <Ctrl> key pressed
while left clicking on the desired symbols.

• Select the menu item 'Global Find...' in the submenu 'Edit'.


The dialog 'Find/Replace' appears.

• Open the tab 'Global Find LD Objects'.

• In the fields 'Find what: Text/Object' enter the name and select the type of the object you
want to search for.

30
Finding LD objects in the active worksheet

• Mark one or several of the search options.

• Change the searching direction if desired.

• If you want to search in a range of marked icons (see step 1 in this procedure) activate the
radio button 'Marked'. If the radio button 'All' is activated, the selection you have made in
the project tree is not considered.

• Click on the button 'Find Next' to start the search operation.

How to use the menu items 'Find next (global)' and 'Find Previous (global)':

If you want to search for the same LD object again (either in the search direction 'Up' or 'Down'),
but the dialog 'Find/Replace' is already closed, you don't have to open the dialog again. Just select
one of the menu items 'Find Previous (global)' or 'Find Next (global') in the submenu 'Edit'. The
object specified in the dialog fields 'Find What: Text/Object' is searched again and marked in the
active worksheet.

Finding LD objects in the active worksheet

The system provides two possibilities for searching LD objects in the Fixed Format LD worksheets
of a project: The local and the global object search.

Finding objects local, as it is described in this topic, is done using the tab 'Find LD Objects' of the
dialog 'Find/Replace' and considers only the active worksheet. This means that the FF LD
worksheet must be opened and must be the active window.

The second possibility for searching LD objects is called global search and considers all FF LD
worksheets contained in the project (except in the announced libraries). This search engine is
described in the topic Finding LD objects in all worksheets.

How to proceed:

• Click in the worksheet, where you want to search for an LD object.

• Select the menu item 'Find...' in the submenu 'Edit'.


The dialog 'Find/Replace' appears.

• Open the tab 'Find LD Objects'.

• In the fields 'Find what: Text/Object' enter the name and select the type of the object you
want to search for.

• Mark one or several of the search options.

• Change the searching direction if desired.

• Click on the button 'Find Next' to start the search operation within the worksheet.

31
Replacing LD objects in all worksheets

How to use the menu items 'Find next (local)' and 'Find Previous (local)':

If you want to search for the same LD object again (either in the search direction 'Up' or 'Down'),
but the dialog 'Find/Replace' is already closed, you don't have to open the dialog again. Just select
one of the menu items 'Find Previous (local)' or 'Find Next (local') in the submenu 'Edit'. The object
specified in the dialog fields 'Find What: Text/Object' is searched again and marked in the active
worksheet.

Replacing LD objects in all worksheets

Replacing LD objects means, that you search for an LD object and replace it automatically by
another LD object. Using the tab 'Global Replace LD Objects' of the dialog 'Find/Replace' this can
be done in all Fixed Format LD worksheets of the project.

Local object replacement (i. e. only the active worksheet is considered) is described in the topic
Replacing LD objects in the active worksheets.

How to proceed:

• If you want to replace LD objects only in some worksheets or POUs within the current
project, mark the related icons in the project tree. To mark several icons, hold the <Ctrl>
key pressed while left clicking on the desired symbols.

• Select the menu item 'Global Replace...' in the submenu 'Edit'.


The dialog 'Find/Replace' appears.

• Open the tab 'Global Replace LD Objects'.

• In the fields 'Find what: Text/Object' enter the name and select the type of the object to be
replaced.

• In the fields 'Replace with: Text/Object' enter the name and select the type of the new
object.

• Mark one or several of the search options.

• Change the searching direction if desired.

• If you want to search in a range of marked icons (see step 1 in this procedure) activate the
radio button 'Marked'. If the radio button 'All' is activated, the selection you have made in
the project tree is not considered.

• Press the button 'Find Next'.


The first match of this LD object is marked.

• Press the button 'Replace' if you want to replace this match and to go to the next match.

• Press the button 'Replace All' if you want to replace all matches.

32
Replacing LD objects in the active worksheet

Replacing LD objects in the active worksheet

Replacing objects means, that you search for an LD object and replace it automatically by another
LD object. Using the tab 'Replace LD Objects' of the dialog 'Find/Replace' this is done in the
worksheet which is currently active. Global object replacement (i.e. the object is searched and
replaced in all worksheets of the project) is described in the topic Replacing LD objects in all
worksheets.

The tab 'Replace LD Objects' is only available in the dialog 'Find/Replace' if you are working with
the Fixed Format LD editor. This means that an FF LD worksheet must be active when selecting
the menu item 'Replace...' in the submenu 'Edit'.

How to proceed:

• Click in the worksheet, where an LD object is to be replaced.

• Select the menu item 'Replace...' in the submenu 'Edit'.


The dialog 'Find/Replace' appears.

• Open the tab 'Replace LD Objects'.

• In the fields 'Find what: Text/Object' enter the name and select the type of the object to be
replaced.

• In the fields 'Replace with: Text/Object' enter the name and select the type of the new
object.

• Activate the desired search options.

• Press the button 'Find Next'.


The first match of this LD object is marked.

• Press the button 'Replace' if you want to replace this match and to go to the next match.

• Press the button 'Replace All' if you want to replace all matches.

Inserting comments while editing in LD


In LD worksheets, it is possible to insert:

• free comments at any position in the worksheet, i.e. comments can be placed independent
of the cell structure in the LD worksheet.

• comments automatically fixed to the network block of an LD network.

Comments can overlap with other objects and consist of one or several lines. They are inserted
using the dialog 'Comment' where additionally the font settings can be chosen.

How to proceed:

33
Inserting connectors while editing in LD

• To insert a free comment at any position in the LD worksheet, move the cell cursor to the
desired position and click on the toolbar icon 'Insert comment'.

To insert a comment for a network block, double click on the network block.
The dialog 'Comment' appears.

• Enter a comment and change, if required, the font settings.

• Confirm the dialog.


A free comment is inserted with its upper left corner at the upper left corner of the cell the
cursor points to as shown in the following figure.

Comments for network blocks are always inserted right of the network block number.

Inserting connectors while editing in LD


You can insert connectors instead of connection lines if you have long distances between objects.
When executing the program it goes automatically from the output connector to the input connector
with the same name. It is possible to have one output connector and several input connectors with
the same name.

Connectors can only be used within one worksheet and within one network block, i.e. it is not
allowed to link different network blocks or link variables to contacts / coils with connectors. This is
checked when compiling the worksheet.

How to proceed:

• Move the cell cursor to the cell right or left of an object or a formal parameter (input or
output of a function/function block) in the LD worksheet where you want to insert the
connector.

• Click on the icon 'Connector/Jump or Label' in the toolbar.

The dialog 'Connector/Jump' appears.

• Enter a name for the connector.

• Activate the radio button 'Connector'.

• Confirm the dialog.


The connector is inserted connected to the marked object or to the formal parameter.

It is also possible to insert a connector to a cell with no objects in the right or left neighbor cells by
moving the cell cursor to the desired position and then clicking on the icon 'Connector/Jump or
Label' in the toolbar.

34
Inserting functions and function blocks in LD worksheets

Inserting functions and function blocks in LD worksheets


In an LD network also functions and function blocks can be called.

Functions and function blocks are represented as FBD elements, i.e. LD and FBD elements are
mixed in LD code body worksheets.

You can insert a function or a function block

• anywhere in the worksheet to an empty cell and connect it later. In this case, the object is
inserted at the cell cursor position with its upper left corner in the cursor cell as shown in
the following figure:

• directly into an existing line of the LD network. In this case the topmost input and output of
the function/function block will be directly connected to the line.

• directly connected to a formal parameter (input or output) of an already existing


function/function block. In this case the topmost input or output of the new inserted
function/function block will directly be connected to the marked formal parameter of the
existing function/FB. If an input was marked before inserting, the new Fu/FB is connected
at its topmost output and vice versa.

While inserting functions/function blocks the space needed for the objects will be automatically
generated by moving related objects to the left and to the bottom or by inserting rows and columns.

The most comfortable way to insert an FBD function or function block into the LD worksheet is to
use the Edit Wizard, where the method of inserting either a function or a function block is the same.

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.
The command 'Compile Worksheet' of the submenu 'Build' can be used to compile only one

35
Inserting functions and function blocks in LD worksheets

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, press <SHIFT> + <F2> or 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
should be inserted and move the cell cursor to this position.
If you want to insert the function/function block directly in an exisiting LD network, select
the connection line between the objects where the new function/function block should be
inserted. You can also mark a formal parameter (input or output) of an already existing
function/function block. Please refer to the list at the beginning of this topic.

• 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.

• Double click on the desired function or function block.


When inserting a function, it is inserted at the corresponding position without displaying
any further dialogs.
If you are inserting a function block, the dialog 'Variables Properties' appears. In this case
continue with the next item of this procedure.

• In the dialog 'Variables Properties' select the group of the local variables grid worksheet
into which you want to insert the new instance declaration.

• An instance name for the inserted FB is proposed in the combo box 'Name'.
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 'Name' combo box.
Note: The 'Name' combo box shows only these variables which are available in the
selected variables group (see item above). If you want to display all variables contained in
the variables grid, you have to mark the checkbox 'Show all variables of worksheet'.

• If desired, enter a comment concerning the new function block in the 'Description' input
field.

• 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.

• Confirm the dialog 'Variables Properties'.


The new function block is inserted automatically in the LD worksheet at the previously
selected cell cursor position with its upper left corner in the cursor cell. Its declaration is

36
Inserting jumps and labels while editing in LD

autoinserted into the group of the local variables worksheet, which you have selected in
the 'Local Variable Groups' list box of the properties dialog.

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.

The unconnected formal parameters of the function or function block can be connected to other
contacts, coils or variables.

Inserting jumps and labels while editing in LD


While editing in LD jumps can be used. For realizing jumps two objects have to be inserted in your
worksheet: a jump and a label. The label is the target for the jump.

Jump and label belonging together must have the same name and must be placed in worksheets of
the same POU.

Labels are only allowed in empty rows and at the beginning of a network block, i.e. no other objects
are allowed in a row except the left power rail.

How to insert a jump:

• Move the cell cursor to the cell right of the object or the function/function block output in
the LD worksheet where you want to insert the jump.

• Click on the icon 'Connector/Jump or Label' in the toolbar.

The dialog 'Connector/Jump' appears.

• Enter a name for the jump.

• Activate the radio button 'Jump'.

• Confirm the dialog.


The jump is inserted connected to the object or function/function block output.

It is also possible to insert a jump to a cell with no objects in the right or left neighbor cells by
moving the cell cursor to the desired position and then clicking on the icon 'Connector/Jump or
Label' in the toolbar.

How to insert a label:

• Move the cell cursor to any cell of an empty row of a network block where you want to
insert the label.

• Click on the icon 'Connector/Jump or Label' in the toolbar.

37
Inserting left power rails (network blocks)

The dialog 'Connector/Jump' appears.

• Enter the same name as used for the jump.

• Activate the radio button 'Label'.

• Confirm the dialog.


The label is inserted to the adjacent cell right of the left power rail.

Inserting left power rails (network blocks)


Inserting left power rails (network blocks) is only possible in the first column of the LD worksheet
and between, above or below existing network blocks.

Click here for a detailed description of network blocks.

In the following description there is made a difference between:

• Inserting a network block to an empty worksheet.

• Inserting further network blocks to an LD worksheet already containing network blocks.

• Extending an existing network block by additional connection points.

How to insert a network block into an empty worksheet:

• Press <F6> or select the menu item 'Insert a network block' in the editor's context menu or
click on the toolbar icon 'Contact network'.

The first network block with five connection points (fixed number) is inserted to the first
row of the empty LD worksheet.

How to insert further network blocks:

• Move the cell cursor to one of the empty rows between, above or below an existing
network block as shown in the figure above for the first cell row. Only in these rows new
network blocks can be inserted.

38
Inserting parallel LD branches using the branch edit mode

• Press <F6> or select the menu item 'Insert a network block' in the editor's context menu or
click on the toolbar icon 'Contact network'.

The new network block is inserted to the worksheet below the already existing network
block(s). The new network block number at the top is automatically incremented.

How to extend an existing network block by additional connection points:

• Move the cell cursor to a cell which row contains a connection point of the network block
to be extended.

• Click on the toolbar icon 'Left power rail' to insert an additional connection point.

If you want to assign a comment to a network block, double click on the network block to open the
dialog 'Comment' and enter the desired text.

Inserting parallel LD branches using the branch edit mode


Parallel objects (i.e. branches) in LD can either be inserted using the appropriate icons or using the
Fixed Format LD editor branch edit mode.

The LD branch edit mode cannot be used if your worksheet is empty. You first have to insert a
network with at least one contact or coil.

How to use the branch edit mode of the Fixed Format LD editor:

• Click on the icon 'Insert LD branch' in the toolbar.

• Move the mouse cursor to the cell where you want to start the branch. If a branch is
possible in the cell under cursor, a symbol for an LD branch is added to the cursor:

Otherwise the following symbol is displayed:

• Left click on the cell where you want to start your parallel branch and keep the mouse
button pressed.
A symbolic contact appears in the appropriate cell as shown below.

• Drag the mouse cursor up or downwards to a free cell while keeping the left mouse button
still pressed.

39
Inserting parallel LD branches using the branch edit mode

• Release the mouse button in the desired cell to drop the new object. The object is inserted
with an already drawn left connection line.

The system now automatically changes to the connection mode so that you can draw the
right connection line.

• Move the mouse cursor to the object where the parallel branch should end. Click into the
left half of the appropriate cell to complete the branch.
Note: When clicking into the right half of a cell (means on the output side of a contact/coil)
the system can not establish the connection, because it seems that you want to connect
two outputs.

• The contact is now inserted and connected at both sides.

40
Inserting parallel contacts/coils

The new contact appears either with or without an assigned default variable
name. This depends on the setting made in the dialog 'Automatically generated
variables'.
If the assignment of default variable names for contacts/coils is enabled, the
dialog 'Contact/Coil Properties' appears where you can define the properties of
the new object.
If the assignment is disabled, the new object is automatically inserted at the
desired position with no contact/coil name. In this case a variable must be
inserted manually for the contact/coil.

• After inserting an object you can change its properties or assign a different variable.

Inserting parallel contacts/coils


Programming in LD allows to insert parallel contacts/coils. So it is possible to insert an object below
or above an already existing one.

The program inserts automatically the object type which you have selected before i.e. if you mark a
contact a new contact is inserted or if you mark a coil a new coil is inserted.

How to insert another parallel object:

• Mark either an existing contact or an existing coil.

• To insert a new object


− below the selected one, click on the icon 'Add contact/coil below'.

− above the selected one, click on the icon 'Add contact/coil above'.

• The contact/coil is inserted connected at both sides either with an assigned default
variable name or without a variable name. This depends on the setting made in the dialog
'Automatically generated variables'.
If the assignment of default variable names for contacts/coils is enabled, the dialog
'Contact/Coil Properties' appears where you can define the properties of the new object.
If the assignment is disabled, the new object is automatically inserted at the desired
position with no contact/coil name. In this case a variable must be inserted manually for
the contact/coil.

41
Inserting returns while editing in LD

Alternatively you can insert parallel branches using the LD branch edit mode.

After inserting an object you can change its properties or assign a different variable.

Inserting returns while editing in LD


In LD worksheets returns can be inserted for returning back to the calling POU if the Boolean
variable is TRUE. If the variable is FALSE the execution of the current network continues.

How to proceed:

• Move the cell cursor to the cell right of the object in the LD worksheet where you want to
insert the return.

• Click on the icon 'Return' in the toolbar to insert the Return.

It is also possible to insert a return to a cell with no objects in the right or left neighbor cells by
moving the cell cursor to the desired position and then clicking on the icon 'Return' in the toolbar.

Inserting right power rails


Right power rails are optional objects which are used to terminate a network block. They are not
required for compiling the LD worksheet.

It is only possible to insert right power rails connected to a contact or coil which has no connected
objects to the right.

Right power rails are automatically added when inserting a program control statement or a specific
statement box.

How to insert a right power rail:

• Move the cell cursor on the contact or coil to which the right power rail is to be assigned.

• Click on the toolbar icon 'Right power rail' to insert the power rail.

The right power rail is inserted and automatically connected to the contact/coil selected
before.

Inserting serial contacts/coils


In the Fixed Format LD editor, you have several possibilities to insert contacts and coils. If you
select an already existing object in the LD worksheet and a new contact/coil is to be inserted, the
new object is automatically connected to the object selected before. The editor allows to:

• insert contacts/coils to cells in the LD worksheet with no objects in the neighbor cells to
the right and to the left.

42
Inserting returns while editing in LD

• insert contacts/coils automatically connected to existing contacts/coils.

• insert contacts/coils automatically connected to a free connection point of the left power
rail.

• insert contacts/coils automatically connected to input/output formal parameters.

How to insert a contact/coil:

• To insert a contact/coil to a cell with no objects in the neighbor cells to the right and to
the left, move the cell cursor to a valid position.

To insert a contact/coil automatically connected to existing contacts/coils, mark an


existing contact/coil.

To insert a contact/coil automatically connected to the left power rail, position the cell
cursor in the cell right to the free connection point of the left power rail as shown as
follows:

To insert a contact/coil automatically connected to input/output formal parameters,


position the cell cursor in the horizontal neighbor cell of the input or output formal
parameter as shown as follows:

• In the toolbar, click on the respective icon.


'Add contact right' or
'Add contact left' or
'Add coil right'

Note: Depending on the marked cell/object only the toolbar icons are available which
ensure the valid insertion of an LD object. For example, if the cell cursor is positioned in
the cell right to a free connection point of the left power rail, only the icons 'Add contact
right' and 'Add coil right' can be selected.

• The contact/coil is inserted either with an assigned default variable name or without a
variable name. This depends on the setting made in the dialog 'Automatically generated
variables'.
If the assignment of default variable names for contacts/coils is enabled, the dialog
'Contact/Coil Properties' appears where you can define the properties of the new object.
If the assignment is disabled, the new object is automatically inserted at the desired

43
Inserting variables while editing in LD

position with no contact/coil name. In this case a variable must be inserted manually for
the contact/coil.

Inserting variables while editing in LD


There are two possibilities to insert variables using the Fixed Format LD editor:

• Inserting variables which have already been declared in the variables worksheet

• Inserting variables which have not been declared in the variables worksheet before

Declaring and inserting new variables in LD

There are two possibilities to insert a new variable in an LD code body:

• either you can insert a variable for an existing contact/coil. This means, that you have
to change the contact/coil properties and assign it to a new variable. In this case, the
dialog 'Contact/Coil Properties' is used to insert the variable.

• or you can insert a variable which is not a contact/coil. So it is for example possible to
insert a variable into an empty worksheet cell or to insert a variable automatically
connected to an input or output formal parameter of a function/function block. In this case
the dialog 'Variable Properties' is used.

How to insert and declare a new variable for a contact or coil:

• Double click on the contact or coil for which you want to insert a new variable.
The dialog 'Contact/Coil Properties' appears.

• For inserting a local variable select the scope 'Local' by marking the related radio button
within the 'Scope' area.
If you want to insert a global variable mark the radio button 'Global'.

• Select the local or global variables group where the variable to be declared should be
stored. For a local group, select the desired group in the list box 'Local Variable Groups'
list box. For a global group, mark the desired group in the selection tree 'Global Variable
Groups'.
Note: If you are declaring a global variable (i.e. usage VAR_GLOBAL), you have to select
both, a local and a global variables group.

• Enter the name for the new variable in the 'Name' combo box.
Note: The combo box 'Name' shows only these variables which are available in the
selected variables group (see item above). If you want to display all variables contained in
the variables grid, you have to mark the checkbox 'Show all variables of worksheet'.
Additionally an internal data type filter makes sure that only variables with a suitable data
type are displayed.

• If required, define the remaining variable properties.

44
Inserting variables while editing in LD

• Click on 'OK'.
The variable appears in the graphical worksheet as contact/coil name and its declaration
is automatically inserted into the selected group of the corresponding variables grid
worksheet.
In the case of a global variable, the declaration is inserted into the local variables grid
using the keyword 'VAR_EXTERNAL' and into the global variables worksheet using
'VAR_GLOBAL'.

Please observe the note at the end of this topic.

How to insert and declare a new variable which is not a contact or coil:

• Move the cell cursor to the desired position in the LD worksheet, for example to an empty
cell. To insert a new variable automatically connected to an input or output formal
parameter of a function/function block set the cell cursor to the left neighbor cell (for an
input formal parameter) or the right neighbor cell (for an output formal parameter).

• Click on the icon 'Variable' in the toolbar.

The dialog 'Variable Properties' appears.

• For inserting a local variable select the scope 'Local' by marking the related radio button
in the 'Scope' area.
If you want to insert a global variable mark the radio button 'Global'.

• Select the local or global variables group where the variable to be declared should be
stored. For a local group, select the desired group in the list box 'Local Variable Groups'
list box. For a global group, mark the desired group in the selection tree 'Global Variable
Groups'.
Note: If you are declaring a global variable (i.e. usage VAR_GLOBAL), you have to select
both, a local and a global variables group.

• Enter the name for the new variable in the 'Name' combo box.
Note: The combo box 'Name' shows only these variables which are available in the
selected variables group (see item above). If you want to display all variables contained in
the variables grid, you have to mark the checkbox 'Show all variables of worksheet'.
Additionally an internal data type filter makes sure that only variables with a suitable data
type are displayed.

• Select a data type for the new variable from the 'Data Type' list box.

• If required, define the remaining variable properties.

• Click on 'OK'.
The variable appears in the graphical worksheet and its declaration is automatically
inserted into the selected group of the corresponding variables grid worksheet.
In the case of a global variable, the declaration is inserted into the local variables grid
using the keyword 'VAR_EXTERNAL' and into the global variables worksheet using
'VAR_GLOBAL'.

45
Inserting already declared variables in LD

When inserting a variable into an LD worksheet and an LD object already exists in the right or left
neighbor cell next to the selected cell, the new variable is automatically connected to the object in
the neighbor cell.

If the variables grid worksheet is opened while declaring a new variable in the code body
worksheet, the grid is updated automatically without closing the variables worksheet (i.e. the new
declaration is inserted into the specified variables group).

Inserting already declared variables in LD

There are two possibilities to insert an already declared variable in an LD code body:

• either you can insert a variable for an existing contact/coil. This means, that you have
to change the contact/coil properties and assign it to a variable which already exists in the
variables worksheet. In this case, the dialog 'Contact/Coil Properties' is used to insert the
variable.

• or you can insert a variable which is not a contact/coil. So it is for example possible to
insert a variable into an empty worksheet cell or to insert a variable automatically
connected to an input or output formal parameter of a function/function block. In this case
the dialog 'Variable Properties' is used.

How to insert an already declared variable for a contact or coil:

• Double click on the contact or coil for which you want to insert a variable which is already
declared.
The dialog 'Contact/Coil Properties' appears.

• For inserting a local variable select the scope 'Local' by marking the related radio button
in the 'Scope' area.
If you want to insert a global variable mark the radio button 'Global'.

• Select the local or global variables group where the variable to be inserted is located. For
a local group, select the desired group in the list box 'Local Variable Groups' list box. For a
global group, mark the desired group in the selection tree 'Global Variable Groups'.
Note: If you are inserting a global variable (i.e. usage VAR_GLOBAL), you have to select
both, a local and a global variables group.

• Select the variable to be inserted from the 'Name' combo box by clicking on the
corresponding name.
Note: The combo box 'Name' shows only these variables which are available in the
selected variables group (see item above). If you want to display all variables contained in
the variables grid, you have to mark the checkbox 'Show all variables of worksheet'. In
both cases (checkbox activated or not) an internal data type filter makes sure that only
variables with a suitable data type are displayed.

• Confirm the dialog.


The variable name appears in the graphical worksheet as contact/coil name, i.e. the LD
element is considered as this variable.

46
Network blocks (left power rails)

How to insert an already declared variable which is not a contact or coil:

• If you want to insert a variable into the code worksheet which is not a contact or coil,
move the cell cursor to the desired position, e.g. to an empty cell. To insert a variable
automatically connected to an input or output formal parameter of a function/function block
set the cell cursor to the left neighbor cell (for an input formal parameter) or the right
neighbor cell (for an output formal parameter).

• Click on the icon 'Variable' in the toolbar.

The dialog 'Variable Properties' appears.

• For inserting a local variable select the scope 'Local' by marking the related radio button
in the 'Scope' area.
If you want to insert a global variable mark the radio button 'Global'.

• Select the local or global variables group where the variable to be inserted is located. For
a local group, select the desired group in the list box 'Local Variable Groups' list box. For a
global group, mark the desired group in the selection tree 'Global Variable Groups'.
Note: If you are inserting a global variable (i.e. usage VAR_GLOBAL), you have to select
both, a local and a global variables group.

• Select the variable to be inserted in the 'Name' combo box by clicking on the
corresponding name.
Note: The combo box 'Name' shows only these variables which are available in the
selected variables group (see item above). If you want to display all variables contained in
the variables grid, you have to mark the checkbox 'Show all variables of worksheet'. In
both cases (checkbox activated or not) an internal data type filter makes sure that only
variables with a suitable data type are displayed.

• Confirm the dialog.


The variable is inserted in the LD worksheet at the desired cell cursor position.

When inserting a variable into an LD worksheet and an LD object already exists in the right or left
neighbor cell next to the selected cell, the new variable is automatically connected to the object in
the neighbor cell.

Network blocks (left power rails)


A left power rail represents a network block. Network blocks "terminate" the LD network on the left
side. In contrast to right power rails, which are optional objects, network blocks are absolutely
necessary for building up a legal LD network and for an error−free compilation.

When working with network blocks, note the following rules:

• In LD worksheets, network blocks are only allowed in the first column of a worksheet.

• Several network blocks are allowed in an LD worksheet.

• By default, network blocks contain five connection points. This default value can be
changed. Free connection points are allowed.

47
Network blocks (left power rails)

• Extending of network blocks by additional connection points is possible.

• The first cell row belonging to a network block is reserved for the network block number
and network block comment. No other objects are allowed in this row. The network block
number is automatically assigned to the network block and can not be edited. The network
block comment is inserted or edited (in the dialog 'Comment') by double clicking on the
network block.

• LD objects are only allowed in rows with a connection point of the network block.

• Connections between objects in different network blocks are illegal.

• The state of the left power rail in each network block is always to be considered to be ON.

48

You might also like