Ll Manual
Ll Manual
2. Overview 3
3.2 Toolbars 9
3.2.1 Showing/hiding toolbars 9
3.2.2 Moving toolbars 9
4. Managing projects 19
5.2 Variables 40
5.2.1 Global variables 40
5.2.2 Local variables 42
5.2.3 Creating multiple VARIABLES 43
5.2.4 Textual editor for variables 44
5.3 Tasks 44
5.3.1 Assigning a program to a task 44
5.3.2 Task configuration 45
7. Compiling 101
9. Debugging 119
1. Workspace window 2. Output window 3. Source code editors 4. Watch window 5. Library tree 6. Status bar
7. Document bar 8. Toolbars
Build
The Build panel displays the output of the following activities:
- opening a project;
- compiling a project;
- downloading code to a target.
Find in project
This panel shows the result of the Find in project activity.
Debug
The Debug panel displays information about advanced debugging activities (for example,
breakpoints). Depending on the target device you are interfacing with, LogicLab can print
on this output window every PLC run-time error (for example, division by zero), locating
the exact position where the error occurred.
Resources
The Resources panel displays messages related to the specific target device LogicLab is
interfacing with.
This panel lists basic language elements, such as operators and functions defined by the
IEC 61131-3 standard.
This panel lists all the system variables, also called target variables, which are the inter-
face between firmware and PLC application code.
This panel lists all the system functions and function blocks available on the specific target
device.
The Project panel contains all the elements of the project, visualized in a tree-like organi-
zation; custom folders can be added to the project tree in order to reorganize the ele-
ments accordingly to the user preferences.
Among the other elements, there’s also the task list, which represent the available tasks
and the relative assigned programs (see Paragraph 5.3).
2.1.6.2 RESOURCES
The contents of the Resources panel depends on how the target device is interfacing with
LogicLab: it may include configuration elements, schemes, wizards, and so on.
This chapter shows you how to deal with the many UI elements LogicLab is composed of,
in order to let you set up the IDE in the way which best suits to your specific development
process.
3.2 TOOLBARS
3.2.1 SHOWING/HIDING TOOLBARS
In details, in order to show (or hide) a toolbar, open the View>Toolbars menu and select
the desired toolbar (for example, the FBD bar).
The toolbar is then shown (hidden).
Take back a window to its most recent docked location simply double-click the title bar of
the window.
Moreover, this menu supplies a few commands to automate some basic tasks, such as
closing all windows.
Colour Theme: allows you to turn LogicLab to dark theme mode (or return to standard
mode), in order to have an environment that best suits your preferences.
Max previous version to keep: if set greater than 0 indicates the maximum number of
copies of the project that must be zipped and stored in the PreviousVersions folder.
3.6.1.3 COMMUNICATION
Use last port: if enabled, the last used port will be set as the default one.
3.6.1.4 TOOLTIP
Enable tooltip on editors: if enabled, small information boxes will appear when user places
the cursor over a symbol in the editors.
You can specify the family and the size of the font used for the output window.
You can specify the family and the size of the font used for the other tool windows.
Reset bars positions: the layout of the dock bars in the IDE will be resetted to default
positions and dimensions. In order to take effect LogicLab must be restarted.
ST-LD: auto declaration of variables: allows the creation of new variables in the moment
they’re first used in the code. In LD programs, when you name a variable block, that
name is suggested as a new variable. In ST program, upon entering a new code line, that
line is parsed to look for new variables to suggest.
Track active object in project tree: if this option is checked, when using the Go to symbol
(shift+F12) function, also the project tree will track the selected object.
Automatically restore last open editors: if this option is checked, LogicLab will save open
editors when closing the project. When reopening the project, also the same editors will
be restored.
2) In the Arguments text box, type the arguments - if any - to be passed to the execut-
able command mentioned at step 1. They must be separated by a space.
3) Enter in Menu string the name you want to give to the tool you are adding. This is the
string that will be displayed in the Tools menu.
4) Press Add to effectively insert the new command into the suitable menu.
5) Press OK to confirm, or Cancel to quit.
For example, let us assume that you want to add Windows calculator to the Tools menu:
- Fill the fields of the dialog box as displayed.
3.6.6 MERGE
Here you can set the merge function behaviour (see Paragraph 4.8.3.2 for more details).
You are required to enter the name of the new project in the Name text area. The string
you enter will also be the name of the folder which will contain all the files making up the
LogicLab project. The path name in the Directory area indicates the default location of
this folder.
Target selection allows you to specify the target device which will run the project.
Finally, you can make the project case-sensitive by activating the related option. Note
that, by default, this option is not active, in compliance with IEC 61131-3 standard: when
you choose to create a case-sensitive project, it will not be standard-compliant.
When you confirm your decision to create a new project and the whole required informa-
tion has been provided, LogicLab completes the operation, creating the project directory
and all project files; then, the project is opened.
The list of devices, from which you can select the target for the project you are creating,
depends on the contents of LogicLab catalog, which contains the list of available target
devices
If the desired target is missing, either you have run the wrong setup executable or you
have to run a separate setup which is responsible to update the catalog to include the
target device. In both cases, you should contact your hardware supplier for support.
To close the project, select the item File>Close project ; LogicLab shows the Welcome
page, so that you can rapidly start a new working session.
4.6.1 GENERAL
Here you can set some basic properties related to the project, such as its application
name and version.
- Case sensitivity: you can set the project as case-sensitive checking this option. Note
- PLC application (active only if Create downloadable target files is checked): this field
specifies the name of the PLC application binary file. By default projectname.bin.
- Source code (active only if Create downloadable target files is checked): this field
specifies the name of the Source code binary file. By default projectname._source.bin.
- Debug (active only if Create downloadable target files is checked): this field specifies
the name of the Debug symbol binary file. By default projectname._debug.bin
4.6.4 DOWNLOAD
Here you can edit some significant properties of the download behaviour (see Paragraph
8.3.1 for more information).
- Polling period for debug function (ms): set the active sampling period of the functions’s
status.
- Number of displayed array elements without alert message: specifies the maximum
number of array elements to be added in watch window without being alerted.
- Polling period between more variables (ms): set the sleep period between sampling
two variables.
- Autosave watch list: if checked (not by default) the watch list status will be saved into
a file, when the project is closed (see Paragraph 9.1.7 for more details).
- Enable memory dump: advanced debug feature, allows the user to put in watch directly
physical memory addresses (with format %MW without subindexes)
- Watch internal variables of function block: when putting a function block instance in
watch you’ll see also the internal variable values; with this option disabled, only the
input and output variables of that function block will be displayed in the watch.
- Automatically dereference pointers and references in watch:if this option is checked,
when adding the pointer variable in the watch window, the pointed value will be directly
shown; if it is disabled, the watch window will show the content of the pointer which
need to be expanded to see the pointed value.
- Print debug informations: when compiling, additional information are shown in the out-
put window.
Once the cross reference has been enabled, open the relative window selecting
View > Tool window > Cross reference ; the following window should be opened:
From the menu labeled Context: you can filter the result.
By double clicking one of the occurrences in the result list, the relative POU window will
be opened and the element (code line or block) where the symbol is used will be high-
lighted.
4.6.9 ADVANCED
These options allow the user to specify specific behaviors, suggested only for expert us-
ers:
The library manager lists all the libraries currently included in a LogicLab project. It also
allows you to include or remove libraries.
To access the library manager, click Project>Library manager .
The following procedure shows you how to include a library in a LogicLab project, which
results in all the library’s objects becoming available to the current project.
Including a library means that a reference to the library’s .pll file is added to the current
project, and that a local copy of the library is made. Note that you cannot edit the ele-
ments of an included library, unlike imported objects.
If you want to copy or move a project which includes one or more libraries, make sure
that references to those libraries are still valid in the new location.
1) Click Project>Library manager , which opens the Library manager dialog box.
2) Press the upper Add button, which causes an explorer dialog box to appear, to let you
select the library you want to open.
3) When you have found the library file, open it either by double-clicking it or by press-
The following procedure shows you how to remove an included library from the current
project. Remember that removing a library does not mean erasing the library itself, but
the project’s reference to it.
1) Click Project>Library manager menu of the LogicLab main window, which opens the
Library manager dialog box.
Select the library you wish to remove by clicking its name once. The Remove button
is now enabled.
2) Click the Remove button, which causes the reference to the selected library to disap-
pear from the Project library list.
3) Repeat for all the libraries you wish to remove. Alternatively, if you want to remove
all the libraries, you can press the Remove all button.
4) When you have finished removing libraries, press either OK to confirm, or Cancel not
to apply changes.
Alternatively, you can remove a whole library folder; doing it will remove ALL the library
contained in that folder. To do so, select the folder in the Folder directories area; then
press the Remove button and then OK to confirm and close, making the changes effective.
3) Enter the destination library by specifying the location of its file (it can be a .pll ora
a .plclib file). You can do this by:
- typing the full pathname in the white text box;
- clicking the Browse button , in order to open an explorer dialog box which allows
you to browse your disk and the network.
4) You may optionally choose to encrypt the source code of the POU you are exporting,
in order to protect your intellectual property.
5) If you chose and already existing library file, you can enter a version number in the
version field in order to keep track of library changes.
6) Click OK to confirm the operation, otherwise press Cancel to quit.
If at Step 3 of this procedure you enter the name of a non-existing library file, LogicLab
creates the file, thus establishing a new library.
The .pll was the old library format used by LogicLab; even if .pll format is still supported
by LogicLab, we strongly recommend to use .plclib format.
The .plclib format is the new library format used by LogicLab; it can handle all the newest
feature of LogicLab: for example you can export blocks with images associated, or you
can export entire folder to a library in order to better organize your objects, when import-
ing you will import the library non just a list of objects.
So far, it is not possible to undo export to a library. The only possibility to remove an ob-
ject is to create another library containing all the objects of the current one, except the
one you wish to delete.
3) Select the tab of the type of the object(s) you want to import. You can also make
simple queries on the objects in each tab by using Filters. However, note that only the
Name filter actually applies to libraries. To use it, select a tab, then enter the name
of the desired object(s), even using the * wildcard, if necessary.
4) Select the object(s) you want to import, then press the Import object button.
5) When you have finished importing objects, press indifferently OK or Cancel to close
the Library browser.
Intead of importing single objects, you can import the whole content of a library as project
elements; to do so: select the root element of the project tree, open its context menu and
choose Import whole library.
A file browser will appear to allow you to select the library file; once you have done, you’ll
find a new folder inside the project tree, with the same name of the library, and the whole
content of the library will be inside that folder.
When you import an object in a LogicLab project, you actually make a local copy of that
object. Therefore, you just need to delete the local object in order to undo import.
When you import objects in a LogicLab project or insert a copied mapped variable, you
may encounter an overlapping address or duplicate naming warning.
By setting the corresponding environment options (see Paragraph 3.6 for more details)
Take from Do
Ask Automatic
library nothing
If different types X X X
Naming If same type but not
X X X
behaviour variables
If both variables X X X
If address overlaps X X X
Address
behaviour Copy/paste mapped X X
variable
This chapter shows you how to deal with the elements which compose a project, namely:
Program Organization Units (briefly, POUs), tasks, derived data types, and variables.
This alert icon indicates that the program is not yet associated to a task. Refer to para-
graph 5.3.1 to assign the program to the desired task.
When creating a new program, LogicLab gives you the chance to assign that program to
a task at the same time: select the task you want the program to be assigned to from the
list shown in the Task section of the New program window.
Deleting POUs
Select a POU from the project tree then choose the appropriate voice of the menu
Project>Delete Object .
Confirm the operation to delete the POU.
Editing POU properties
Select a POU from the project tree then open its context menu by right-clicking on its
icon, choose Edit Program Properties .
Encrypting a POU:
Select a POU from the project tree then choose the [Crypt] voice of the context menu
Double enter the password and confirm the operation.
LogicLab shows in the project tree a special marker icon that overlays the standard POU
icon in order to inform the user that the POU is crypted.
Decrypting a POU:
Select a POU from the project tree then choose the [Decrypt] voice of the context menu
Select the root element from the project tree then choose the [Decrypt all objects] voice
of the context menu.
Global variables are organized in special folders of the project tree called Global_vars.
Those variables are classified according to their properties as:
- Automatics: the compiler automatically allocates them to an appropriate location in the
target device memory.
- Mapped: they have an assigned address in the target device logical addressing system,
which shall be specified by the developer.
- Constants: are declared having the CONSTANT attribute; They cannot be written.
- Retains: they are declared having the RETAIN attribute; Their values are stored in a
persistent memory area of the target device.
1) In order to create a new global variable select a Global variables group from the project
tree then choose the appropriate voice from the menu Project>New Object>New variable
(see Paragraph 5.7.4).
2) LogicLab will show you a dialog box where you must enter the name of the variable
(remember that some characters, such as ‘?’, ‘.’, ‘/’, and so on, cannot be used: the
variable name must be a valid IEC 61131-3 identifier).
3) Specify the type of the variable either by typing it or by selecting it from the list that
LogicLab displays when you click on the Browse button.
If you create a new mapped variable, you are required to specify the address of the vari-
able during its definition. In order to do so, you may do one of the following actions:
- Click on the button to open the editor of the address, then enter the desired value.
- Select from the list that LogicLab shows you the memory area you want to use: the tool
automatically calculates the address of the first free memory location of that area.
To edit the definition of an existing global variable, open it by double-clicking it, or the
folder that it belongs to, from the project tree. The global variables editor opens and lets
you modify its definition.
Duplicating a variable:
Select the variable you want to duplicate from the project tree then right-click on it and
choose Duplicate Variable from the context menu.
Enter the name of the new duplicated variable and confirm.
Deleting a variable:
Select the variable you want to delete from the project tree then right-click on it and
choose Delete Variable from the context menu.
Confirm the operation to delete the variable.
Refactoring a variable:
Refactoring will allow you to change the name of a global variable and consequently
adjust all of its occurrences in the project.
Select the desired variable from the project tree, then right-click on it and choose
Refactoring from the context menu.
A window will appear allowing you to insert a new variable name and showing you all
the occurrences found for this symbol; if you change the name and press OK, all the
shown occurrences will be modified.
Refer to the corresponding section in this manual for details (see Paragraph 6.6.1.2).
5.3 TASKS
5.3.1 ASSIGNING A PROGRAM TO A TASK
1) Select the task where you want to add the program from the project tree then choose
the [Add program] voice of the context menu.
2) Select the program you want to be executed by the task from the list which shows up
and confirm your choice.
3) The program has been assigned to the task, as you can see in the project tree.
Note that you can assign more than a program to a task. From the contextual menu you
can sort and, eventually, remove program assignments to tasks.
5.4.1 TYPEDEFS
In order to create a Typedef select Typedef voice when creating a new definition.
LogicLab will show you a dialog box where you must specify the name of the new typedef
and select the type you are defining an alias for:
In order to edit an existing typedef you have to double-click it from the Project tree. The
associated editor opens and lets you modify its definition.
If you open the context menu of a Typedef, by selecting it from the project tree and right-
clicking it, you will see different actions that can be done with Typedefs:
Deleting a Typedef:
In order to delete a Typedef, select it from the Project tree then choose the Delete
voice of the context menu.
Duplicating a Typedef:
In order to duplicate a Typedef, select it from the Project tree then choose the Duplicate
voice of the context menu.
A window will appear asking you a new name for the duplicated Typedef.
Refactoring a Typedef:
Refactoring will allow you to change the name of a Typedef and consequently adjust all
of its occurrences in the project.
Select the desired typedef from the project tree, then right-click on it and choose the
Refactoring voice from the context menu.
A window will appear allowing you to insert a new name and showing you all the oc-
currences found for this symbol; if you change the name and press OK, all the shown
occurrences will be modified.
Typedef properties:
In order to edit the properties of a Typedef, select it from the Project tree then choose
Edit properties . A window will open allowing you to insert or modify information such
as version number and description.
To view the properties of a Typedef, select it form the project tree then choose
View properties .
In order to create a structure select Structure voice when creating a new definition.
LogicLab will show you a dialog box where you must specify the name of the new struc-
ture and a meaningful description, then confirm the operation.
In order to edit an existing structure, open it by double-clicking it from the Project tree.
The associated editor opens and lets you modify its definition and fields.
If you open the context menu of a Structure, by selecting it from the project tree and
right-clicking it, you will see different actions that can be done with Structures:
Deleting a Structure:
In order to delete a Structure, select it from the Project tree then choose the Delete
voice of the context menu.
Duplicating a Structure:
In order to duplicate a Structure, select it from the Project tree then choose the
Duplicate voice of the context menu.
A window will appear asking you a new name for the duplicated Structure.
Refactoring a Structure:
Refactoring will allow you to change the name of a Structure and consequently adjust all
of its occurrences in the project.
Select the desired Structure from the project tree, then right-click on it and choose the
Refactoring voice from the context menu.
A window will appear allowing you to insert a new name and showing you all the oc-
currences found for this symbol; if you change the name and press OK, all the shown
occurrences will be modified.
Structure properties:
In order to edit the properties of a Structure, select it from the Project tree then choose
5.4.3 ENUMERATIONS
In order to create a new Enumerations select Enumeration voice when creating a new
definition.
LogicLab will show you a dialog box where you must specify the name of the new enu-
meration, its type and a meaningful description, then confirm the operation.
In order to edit an existing structure, open it by double-clicking it from the Project tree.
The associated editor opens and lets you modify its definition and the initialization values
of its elements.
If you open the context menu of an enumeration, by selecting it from the project tree and
right-clicking it, you will see different actions that can be done with enumerations:
Deleting an Enumeration:
In order to delete an enumeration, select it from the Project tree then choose the
Delete voice of the context menu.
Duplicating an Enumeration:
In order to duplicate an enumeration, select it from the Project tree then choose the
Duplicate voice of the context menu.
A window will appear asking you a new name for the duplicated enumeration.
Refactoring an Enumeration:
Refactoring will allow you to change the name of an enumeration and consequently ad-
just all of its occurrences in the project.
Select the desired enumeration from the project tree, then right-click on it and choose
Enumeration properties:
In order to edit the properties of an enumeration, select it from the Project tree then
choose Edit properties . A window will open allowing you to insert or modify information
such as name, title, type, version number and description.
To view the properties of an enumeration, select it form the project tree then choose
View properties .
5.4.4 SUBRANGES
In order to create a new subrange select Subrange voice when creating a new definition.
LogicLab will show you a dialog box where you must specify the name of the new sub-
range, select its basic type and enter the minimum and the maximum values for the
subrage; optionally you can enter a meaningful description.
In order to edit an existing subrange, open it by double-clicking it from the Project tree.
The associated editor opens and lets you modify its definition.
If you open the context menu of a subrange, by selecting it from the project tree and
right-clicking it, you will see different actions that can be done with subranges:
Duplicating a Subrange:
In order to duplicate a subrange, select it from the Project tree then choose the
Duplicate voice of the context menu.
A window will appear asking you a new name for the duplicated subrange.
Refactoring a Subrange:
Refactoring will allow you to change the name of a subrange and consequently adjust all
of its occurrences in the project.
Select the desired subrange from the project tree, then right-click on it and choose the
Refactoring voice from the context menu.
A window will appear allowing you to insert a new name and showing you all the oc-
currences found for this symbol; if you change the name and press OK, all the shown
occurrences will be modified.
Subrange properties:
In order to edit the properties of a subrange, select it from the Project tree then choose
Edit properties . A window will open allowing you to insert or modify information such
as version number and description.
To view the properties of a subrange, select it form the project tree then choose
View properties .
5.4.5 MACROS
In order to create a new macro select Macro voice when creating a new definition.
LogicLab will show you a dialog box where you must specify the name of the new macro
and its language, only IL and ST are allowed (see chapter 11.7.1 for further details).
In order to edit an existing macro, open it by double-clicking it from the Project tree. The
associated editor opens and lets you modify its definition, the parameters and its code.
If you open the context menu of a macro, by selecting it from the project tree and right-
clicking it, you will see different actions that can be done with macros:
Deleting a macro:
In order to delete a macro, select it from the Project tree then choose the Delete voice
of the context menu.
Duplicating a macro:
In order to duplicate a macro, select it from the Project tree then choose the Duplicate
voice of the context menu.
A window will appear asking you a new name for the duplicated macro.
Refactoring a macro:
Refactoring will allow you to change the name of a macro and consequently adjust all of
its occurrences in the project.
Select the desired macro from the project tree, then right-click on it and choose the
Refactoring voice from the context menu.
A window will appear allowing you to insert a new name and showing you all the oc-
currences found for this symbol; if you change the name and press OK, all the shown
occurrences will be modified.
Macro properties:
In order to edit the properties of a macro, select it from the Project tree then choose
Edit properties . A window will open allowing you to insert or modify information such
as version number and description.
To view the properties of a macro, select it form the project tree then choose
View properties .
5.4.6 INTERFACES
In order to create a new interface select Interface voice when creating a new definition;
note that interfaces can be created only if Object Oriented Programming is enabled (see
paragraph 4.6.1), and that depends on target implementation.
LogicLab will show you a dialog box where you must specify the name of the new macro
and its language, only IL and ST are allowed (see chapter 11.7.1 for further details).
Interfaces cannot be edited, but you can add method to an interface and edit the method.
To add a new method, open the context menu of the interface, by selecting it in the Pro-
ject tree and right-clicking on it, then choose Add method prototype ; a window will appear
asking you to insert name and description of the method prototype.
The method prototype will be added to the Project tree; now double-clicking it will open
its editor, allowing you to modify the method prototype.
If you open the context menu of an interface, by selecting it from the project tree and
right-clicking it, you will see different actions that can be done with interfaces; same
things can be done with the method prototypes in the same way
This tool is context dependent, this implies that the kind of objects that can be selected
and that the available operations on the objects in the different contexts are not the same.
Object browser can be opened in these three main ways:
- Browser mode.
- Import object mode.
- Select object mode.
User interaction with Object browser is mainly the same for all the three modes and is
described in the next paragraph.
This section describes the features and the usage of the Object browser that are common
to every mode in which Object browser can be used.
Objects filter
This is the main filter of the Object browser. User can check one of the available (enabled)
object items.
In this example, Programs, Function Blocks, Functions are selected, so objects of this
Other filters
Selected objects can be also filtered by name, symbol location, specific library and var
type.
Filters are all additive and are immediately applied after setting.
Name
Function Filters objects on the base of their name.
Set of legal values All the strings of characters.
Type a string to display the specific object whose name
matches the string. Use the * wildcard if you want to
display all the objects whose name contains the string in
Use the Name text box. Type * if you want to disable this filter.
Press Enter when edit box is focused or click on the OK
button near the edit box to apply the filter.
Applies to All object types.
Symbol location
Function Filters objects on the base of their location.
Set of legal values All, Project, Target, Library, Aux. Sources.
Library
Completes the specification of a query on objects contained
Function in libraries. The value of this control is relevant only if the
Symbol location filter is set to Library.
Set of legal values All, libraryname1, libraryname2, ...
All= Shows objects contained in whatever library.
Use LibrarynameN= Shows only the objects contained in the
library named librarynameN.
Applies to All objects types.
Vars Group
Function Filters objects on the base of their group.
Set of legal values Every group known to the project
Use Shows only variables belonging to the selected group.
Applies to Variables.
Object list shows all the filtered objects. List can be ordered in ascending or descending
way by clicking on the header of the column. So it is possible to order items by Name,
Type, or Description.
Double-clicking on an item allows the user to perform the default associated operation
(the action is the same of the OK, Import object, or Open source button actions).
When item multiselection is allowed, Select all and Select none buttons are visible.
It is possible to select all objects by clicking on Select all button. Select none deselects
all objects.
If at least one item is selected on the list operation, buttons are enabled.
In order to use the object browser to simply look over through the element of the project
choose the appropriate voice of the menu Project > Object Browser .
Available objects
In this mode you can list objects of these types:
- Programs.
- Function Blocks.
- Functions.
- Variables.
- User types.
These items can be checked or unchecked in Objects filter section to show or to hide the
objects of the chosen type in the list.
Other types of objects (Operators, Standard functions, Local variables, Basic types) can-
not be browsed in this context so they are unchecked and disabled).
Available operations
Allowed operations in this mode are:
Export to library
Delete objects
Function Allows you to delete an object.
Select the object you want to delete, then press the Delete
Use
object button.
Multi selection
Multi selection is allowed for this mode, Select all and Select none buttons are visible.
Object browser is also used to support objects importation in the project from a desired
external library.
In order to use the object browser to import external library to the project, select
Project>Import object , then an explorer dialog will be prompted to allow you to choose
the source library; once selected a library, an Object Borwser Window will appear, allowing
you to select the objects you wish to import.
Available objects
In this mode you can list objects of these types:
- Programs.
- Function blocks.
- Functions.
- Variables.
- User types.
These items can be checked or unchecked in Objects filter section to show or to hide the
objects of the chosen type in the list.
Available operations
Import objects is the only operation supported in this mode. It is possible to import se-
lected objects by clicking on Import objects button or by double-clicking on one of the
objects in the list.
Multi selection
Multi selection is allowed for this mode, Select all and Select none buttons are visible.
Object browser dialog is useful for many operations that requires the selection of a single
PLC object. So Object browser can be used to select the program to add to a task, to se-
lect the type of a variable, to select an item to find in the project, etc..
Available objects
Available objects are strictly dependent on the context, for example in the program as-
signment to a task operation the only available objects are programs objects.
It is possible that not all available objects are selected by default.
Available operations
In this mode it is possible to select a single object by double-clicking on the list or by click-
ing on the OK button, then the dialog is automatically closed.
Multi selection
Multi selection is not allowed for this mode, Select all and Select none buttons are not
visible.
1) In the Find what text box, type the name of the object you want to search.
Otherwise, click the Browse button to the right of the text box, and select the name
of the object from the list of all the existing items.
2) Select one of the values listed in the Location combo box, so as to specify a constraint
3) The frame named Object type contains a set of checkboxes, each of which, if ticked,
enables research of the string among the object it refers to.
4) The frame named Find options contains a set of checkboxes, each of which, if ticked,
modify the way the research is done. For example, check Match case if you want your
research to be case-sensitive.
5) Press Find (or Find & close) to start the search, otherwise click Cancel to abandon.
The results will be printed in the Find in project tab of the Output window.
Information about these features may be found in a separate document: refer to your
hardware supplier for details.
- Global variables group: this logical unit can only contain global variables. In order to
create a global variable you need to have at least one global variables group defined
into your custom workspace.
Creating a folder
In order to create a folder select the root item of the project tree or, if you want to nest
it, an existing folder then choose the [Add>New folder] voice of the context menu.
This operation adds a new customizable folder (by default named New folder) unit ready
to be renamed.
You can edit the folder properties choosing Edit folder properties from its context menu.
Once inside the folder properties window, you can choose to mark the folder as read
only; doing so you’ll be asked to set a password. The content of the folder is now not
modifiable until someone remove the read only attribute by inserting the correct pass-
word.
Still from the folder properties window, you can mark the folder as a library folder
(select Enable from the Library generation options section). Doing so you’ll be allowed
to set other informations about the library folder (like the version number or a descrip-
tion).
If your folder is a library folder, it’ll be represented with a different icon in the tree:
In the context menu of the folder, now, you’ll find a new voice: Generate library ; select-
ing it will create a new .plcprj library in the project folder (inside AutoGeneratedLibraries
sub folder) with the name of the library folder and all of its content.
This is an easy and efficient way to create complex libraries.
Moving Unit
You can simply drag&drop units to a different location of the tree in order to organize
your project workspace. All children are moved if the parent item is moved, following the
original structure.
Moving variables is also possible both from project tree (single selection) and from the
variable grid (single and multiple selections) (see Paragraph 6.6 for more information
about variables editor).
Sorting folder
It is possible to manually sort the folder order to better organize the project tree (by
default folder are sorted alphabetically). To do so you have to enable the Custom sort of
project folder, in the project options; then, from the context menu of a folder, you can
choose Move Up or Move Down to move the folder.
Tasks Element
You can not move, rename or delete these elements. They are automatically generated by
LogicLab. For more information about SFC language (see Paragraph 5.3).
The IL editor allows you to code and modify POUs using IL (Instruction List), one of the
IEC-compliant languages.
6.1.4 BOOKMARKS
You can set bookmarks to mark frequently accessed lines in your source file. Once a book-
mark is set, you can use a keyboard command to move to it. You can remove a bookmark
when you no longer need it.
Move the insertion point to the line where you want to set a bookmark, then press Ctrl+F2.
The line is marked in the margin by a light-blue circle.
Move the cursor to anywhere on the line containing the bookmark, then press Ctrl+ F2.
The ST editor allows you to code and modify POUs using ST (i.e. Structured Text), one of
the IEC-compliant languages.
6.2.5 BOOKMARKS
You can set bookmarks to mark frequently accessed lines in your source file. Once a book-
mark is set, you can use a keyboard command to move to it. You can remove a bookmark
when you no longer need it.
Move the insertion point to the line where you want to set a bookmark, then press Ctrl+F2.
The line is marked in the margin by a light-blue circle.
Move the cursor to anywhere on the line containing the bookmark, then press Ctrl+F2.
The LD editor allows you to code and modify POUs using LD (i.e. Ladder Diagram), one of
the IEC-compliant languages.
On each LD network the right and the left power rail are represented, according to the LD
language indication.
On the new LD network a horizontal line links the two power rails. It is called the “power
link”. On this link, all the LD elements (contacts, coils and blocks) have to be placed.
You can perform the following operations on networks:
- To add a new blank network, click Scheme>Network>New , or press one of the equivalent
buttons in the Network toolbar.
- To assign a label to a selected network, give the Scheme>Network>Label . This enables
jumping to the labeled network.
- To display a background grid which helps you to align objects, click View>Grid .
- To add a comment, click Scheme>Object>New>Comment .
If you press OK, the label is printed in the top left-hand corner of the selected network.
- Drag a boolean variable to the desired place over an object. For example, global vari-
ables can be taken from the Workspace window, whereas local variables can be selected
from the local variables editor. Contacts inserted with drag and drop will always be in-
serted in series after the destination object.
- Drag a boolean variable on the network, over an existing output of the network (coil,
return, jump). For example, global variables can be taken from the Workspace window,
whereas local variables can be selected from the local variables editor.
- Click Scheme>Enable EN/ENO pins , to display the enable input and output pins.
EN/ENO pins can be removed only if the selected block has at least one BOOL input and
one BOOL output; otherwise, they will be automatically added when creating the block
and it will not be possible to remove them (the Enable EN/ENO pins command will be
disabled).
If a block has more than one BOOL output pin, it is possible to choose which pin will
bring the signal out of the block and so continue the power link: select the desired out-
put pin and click the Scheme>Set output line menu command.
- Click Scheme>Object>Instance name , to change the name of an instance of a function
block.
TO_INT(n)
ADR(x)
6.3.15 COMMENTS
It is possible to insert two types of comments:
- network comments: activate the network by clicking on the header on the left or inside the
grid (but without selecting any object), and then click the Scheme>Object>New>Comment
menu command. The network comment will be displayed at the top of the network, and
if necessary will be expanded to show all the text lines of the comment.
- Object comments: they are activated with the apposite menu command in
View>Show comments for objects ; above any contact, function block or coil the descrip-
tion of the associated PLC variable (if present) will be initially shown, but with the Com-
ment command you can modify it to enter a specific object comment that will override
the PLC variable description.
The FBD editor allows you to code and modify POUs using FBD (Function Block Diagram),
one of the IEC-compliant languages.
This causes a dialog box to appear, which lets you type the label you want to associate
with the selected network.
If you delete a block, its connections are not removed automatically, but they become
invalid and they are redrawn red. Click Scheme>Delete invalid connection .
- Click Scheme>Enable EN/ENO pins , to display the enable input and output pins.
Alternatively you can move the curso over the pin until it changes to the green square,
then double-click it to open a dialog; in that dialog you can enter the name o a valid vari-
able (even using the object browser) or you can directly enter a constant value.
for steps;
for transitions;
for jumps.
To create a new action: choose Scheme>Code object>New action or select the Actions
folder in the workspace and choose [New action] from its context menu.
In either case, LogicLab displays a dialog box like the one shown below.
To modify the code of and action you can double-click it on the project tree or select it and
choose Edit source from its context menu.
Note that you are not allowed to declare new local variables, as the action that you are
now editing is a component of the original SFC module, which is the POU where local vari-
ables can be declared. The scope of local variables extends to all the actions and transi-
tions making up the SFC diagram.
You can assign or change the action associated to a step by opening its properties win-
dow; to do so, double-click the step in the SFC editor.
Be careful, if the step has already one or two action associated, they will be shown on the
block as a white square with a specific letter written inside, if you click the letter you will
open directly the action editor, not the step properties window.
Opening the step properties window will causes the following dialog box to appear.
From the list shown in the Code N box, select the name of the action you want to execute
when the step is active.
From the list shown in the Code P (Pulse) box, you may optionally choose the name of
the action you want to execute each time the step becomes active (which means the ac-
tion is executed only once per step activation, regardless of the number of cycles the step
remains active).
Confirm the assignments by pressing OK.
In the SFC editor, the actions assigned to a step are represented by white square with a
specific letter inside: action P with letter P in the top right corner; action N with letter N
in the bottom right corner.
As stated in the relevant section of the language reference, a transition condition can be
assigned through a constant, a variable, or a piece of code. This paragraph explains how
to use the first two means, while conditional code is discussed in the next paragraph.
First of all double-click the transition you want to assign a condition to. This causes the
following dialog box to appear.
Select True if you want this transition to be constantly cleared, False if you want the PLC
program to keep executing the preceding block.
Instead, if you select Variable the transition will depend on the value of a Boolean vari-
able. Click the corresponding bullet, to make the text box to its right available, and to
specify the name of the variable.
To this purpose, you can also make use of the objects browser, that you can invoke by
pressing the button its right side.
Click OK to confirm, or Cancel to quit without applying changes.
This paragraph explains how to specify a condition through a piece of code, and how to
assign it to a transition.
Start by creating a transition code: select Scheme>Code object>New transition code ; or
select [New transition] from the context menu of the SFC POU in the Workspace
In either case, LogicLab displays a dialog box similar the one shown in the following pic-
ture.
Note that you can use any language except SFC to code a condition. Select one of the
Select Code, and then choose the name of the condition you want to assign to this transi-
tion from the list. Then confirm by pressing OK.
Select the destination step, then either press OK to confirm or Cancel to quit.
The name of the target step will be shown inside the jump element.
Alternatively, LogicLab includes also a textual editor for both global and local variables;
using this editor will allow you to declare and edit the source code of the variables.
In order to open the Global variables editor, expand the Global variables folder and any
subfolder until you reach the desired Global variables group, then double-click on it.
To open a local variables editor, just open the relative Program Organization Unit.
For both global and local variables, when you open their graphic editor, you’ll see on the
far right border three tabs:
The first, selected by default, is the graphic variables editor; this editor provides a user-
friendly interface.
The second is the textual variables editor; this editor allows the user to declare and edit
variables by modifying directly the source code. The textual editor can be really useful if
you need to paste some variables declaration code, taken from another source.
Switching from the graphic editor to the textual editor, will show you the actual source
code of the defined variables:
The third tab is the watch editor, refer to the appropriate chapter of this manual for de-
tails (see Paragraph 9.1.1.1).
2) Change the variable type, either by editing the type name in the corresponding cell
or by clicking on the button in its right and select the desired type from the object
browser.
3) Edit the address of the variable by clicking on the button in the corresponding cell
and entering the required information in the window that shows up. Note that, in the
case of global variables, this operation may change the position of the variable in the
project tree.
4) In the case of global variables, you can assign the variable to a group. You have three
ways to do so:
- First create the group and then create the variable from inside the group.
- You can drag&drop existing variable into a new group.
5) Choose whether a variable is an array or not; if it is, edit the size of the variable.
6) Edit the initial values of the variable: click on the button in the corresponding cell and
enter the values in the window that pops up.
8) Type a description for the variable in the corresponding cell. Note that, in the case of
global variables, this operation may change the position of the variable in the project
tree.
9) Save the project to persist the changes you made to the declaration of the variable.
String
When selecting the type string, you’ll see also the field array is valorized with [32]; that
is the number of character allowed inside the variables, exceeding character will be trun-
cated.
To initialize a sting, just enter the desired character within single quotes.
The string terminator character will be added automatically, so you don’t need to insert
it; also the string terminator is not counted within the specified size: that means that if
the specified size is 32, you can enter 32 chars and the terminator will be the 33th, the
string length will be 33.
The single quotes are not counted among the other characters, they are ignored.
WString
When selecting the type wstring, you’ll see also the field array is valorized with [32]; that
is the number of wide character allowed inside the variables, exceeding character will be
truncated.
To initialize a wsting, just enter the desired character within double quotes.
The string terminator character will be added automatically, so you don’t need to insert
it; also the string terminator is not counted within the specified size: that means that if
the specified size is 32, you can enter 32 wide chars and the terminator will be the 33th,
the wstring length will be 66.
The double quotes are not counted among the other characters, they are ignored.
Array
Before inserting the initial values, you must specify that the desired variable is an array;
to do so, click the button inside the Array field, and use the pop up dialog to specify the
array size.
Now you can enter the initial values: for the matrix, write the values within square brack-
ets and separate each value with a comma. Write all the value inline, the indexes will be
automatically applied.
The initial value of a structure is written within round brackets, each field is separated
with a comma, and you must also specify the field you are valorizing since you are not
required to valorize every field of the structure nor you’re required to respect the order
of the fields.
Array of structures
An array can be of different types, even of complex data types; to make an example, let’s
suppose we have an array of structures, where the structure has these fields:
To initialize the array we will write the values within square brackets, each value will be
separated with a comma, and every value will be the initial value of a structure; the result
will be something like this:
The initial value of a function block is written within round brackets, each field is sepa-
rated with a comma, and you must also specify the field you are valorizing since you are
not required to valorize every field of the function block nor you’re required to respect the
order of the fields.
Now the dialog that shows up when creating a new Function Block (as well as the Object
Properties dialog), will show addittional content:
6.7.2 METHODS
If the Object Oriented feature is enabled, you can consider a Function Block as a class;
in order to create a new method: open the context menu of the Function Block by right-
clicking on it’s instance in the project tree, then choose New Methods.
You can define any number of methods for the same class, but you cannot define more
methods with the same name (even if their prototype is different).
Methods work like functions, except that they have access to the class context (which
means, for example, the Input variables of the function block).
Methods can be invoked in a POU (for example in a program), like extensions to the Func-
tion Block instance:
Methods can be called also from inside the relative Function Block body, but the Function
Block body cannot be called from inside a method.
If in the Extends field, when creating a new Function Block, or inside it’s Object properties
window, you specify the name of another Function Block, the current one will inherit all
of it’s methods.
Inherited methods are always considered as virtual methods, which means that if the
children Function Block implements a method with the same protorype of a method im-
plemented by the father, no error is raised, as the children method will override the father
method.
If you wish to explicitly call the father method, you can do it by using the super. specifier:
You can also call the father Function Block body, instead of a specific method, using
super(); alone.
You can see if a Function Block extends another function block, by looking at its prop-
erty window.
LogicLab can handle polimorphysm with classes, to do so you’ll have to use the reference
data type (see paragraph 11.1.2.1).
Create a variable of type reference to the father class; now valorize it usign the reference
of a child class; now you can use the reference variable to call a method (or to access the
class properties), LogicLab will be able to recognize which is the correct method to call.
6.7.3 INTERFACES
In order to create a new interface, after having enabled the Object Oriented program-
ming, select Project > New object > New definition > Interface . A dialog will be shown ask-
ing you to specify the name of the interface and (optionally) a description.
After creation, the interface will appear as a new element in the project tree.
Now you can add a method prototype: from the interface context menu, select Add meth-
od prototype; a dialog will appear asking you to insert the name of the method and (op-
After creation, the method prototype will appear in the project tree as a subelement of
the interface element.
By double clicking on the method prototype element, a new editor will be opened in the
editor window, allowing you specify the method prototype (which means the required
input variables).
An interface can extend another interface (only one), in a father-child hierarchy; doing so,
the children interface will inherit all the method prototypes of the father interface.
To extend an interface select Edit properties from the interface context menu, a new di-
alog will be shown allowing you to modify several properties, included the extend field.
In the example of the above picture, fb_class_2 implements intf_1; and intf_1 extends
intf_2.
In order to implement a method prototype of an interface, you need to create a method
which has the same prototype (name and input variables) of the method prototype you
wish to implement. Compiling a project with method prototypes not correctly implement-
ed, will raise errors.
To implement a method prototype you can create a new method (see paragraph 6.7.2.1)
which has the same prototype of the method you wish to implement, or you can right-click
on the method prototype and select Implement method; this way a new method will be
created, already with the correct prototype.
Method prototypes can have different icons, with different meaning:
there is a method with the same name but different prototype from the one you wish
to implement.
no method has been found with the same name of the method prototype you wish to
implement.
the previous icons can also have a blue arrow on their right side, that means the
method prototype is inherited from a different interface
LogicLab can handle polimorphysm with interfaces, create a variable of type interface and
valorize it usign the instance of a class that implements the method prototypes of that
interface; now you can use the interface variable to call methods, LogicLab will be able
In the baove example: the interface intf_1 extends the interface intf_2; the interface
intf_1 is implemented by both fb_class_1 and fb_class_2.
i1, variable of type intf_1, is valorized using myClass_2, an instance of fb_class_2, which
is a Function Block that implements intf_1; now calling i1.method_201 will correctly call
method_201 of fb_class_2.
i2, variable of type intf_2, which is an interface extended by intf_1, is valorized with i1
using the IMOVE operator; thanks to this operator there’s no error even if i1 and i2 are
not of the same type (because LogicLab understand that i1 extends i2) and i2 is valor-
ized with a reference to the instance of myClass_2; so if around your project you call
i2.method201, you will be calling method_201 of fb_class_2.
Compilation consists of taking the PLC source code and automatically translating it into
binary code, which can be executed by the processor on the target device.
When this pre-condition does not hold, compilation aborts with a meaningful error mes-
sage.
Condition Description
Compiler error(s). The PLC code contains one or more serious errors,
n>0 which cannot be worked around by the compiler; the binary output
file is not generated, the project cannot be downloaded.
Emission of warning(s). The PLC code contains one or more minor
errors, which the compiler automatically spotted and worked around.
However, you are informed that the PLC program may act in a
different way from what you expected: you are encouraged to get rid
m>0 of these warnings by editing and re-compiling the application until no
warning messages are emitted.
Even if you do not correct the warnings, the binary output file is
generated and you can download the project.
PLC code entirely correct, compilation accomplished. You should
n=m=0 always work with 0 warnings, 0 errors.
The binary output file is generated and you can download the project.
From the properties window you can also specify a condition (global symbol existance) to
determine if the POU should be compiled or not.
Remember that the exclusion is recursive, so if you choose to exclude from compilation a
folder or a global variables group, all the sub-elements will be excluded too.
To remark this, the context menu voice will also change into Exclude all contents from
This feature will exclude from compilation the selected code only if a specified symbol has
not been defined; the symbol to be specified can be any symbol or POU (program, frun-
tion, function block, global variable...) but it must be GLOBALLY VISIBLE.
Inside an ST program, you can disable a portion of code including it inside the IFDEF
syntax.
Inside an LD program, you can put under IFDEF condition every single network, but not
just a portion of a network.
Open the network properties window, and insert the specific symbol to be checked.
Like LD language, also with FBD you can put under IFDEF condition every single network,
but not just a portion of a network.
Open the network properties window, and insert the specific symbol to be checked.
The condition of a valid IFDEF syntax can be more complex thag just a globally visible
symbol; here’s some example of valid IFDEF syntax:
- {IFDEF: symbol_1}
- {IFDEF: symbol_1 AND symbol_2}
- {IFDEF: symbol_1 OR symbol_2}
- {IFDEF: symbol_1 AND (symbol_2 OR symbol3)}
- {IFDEF: symbol_1 AND NOT symbol_2}
- {IFDEF: symbol_1 OR NOT symbol_2}
Be aware that currently, due to an implementation limit, the negation of an expression is
not supported; that means that the following syntax is NOT supported:
- {IFDEF: symbol_1 AND NOT (symbol_2 AND symbol_3}
The NOT statement must be used with a symbol, not with an expression.
SOURCE DESTINATION
L U U U L D
R L D S U W B B
R I L D S W W
E I I I I O Y O
E N I I I O O
A N N N N R T O
A T N N N R R
L T T T T D E L
L T T T D D
LREAL = E E E E E E E E E E I I I E
REAL I = E E E E E E E E E E I I E
LINT E E = E E E E E E E E E E E E
DINT I E I = E E E E E E E E E E E
INT I I I I = E E E E E E E E E E
SINT I I I I I = E E E E E E E E E
ULINT E E E E E E = E E E E E E E E
UDINT I E I E E E I = E E E E E E E
UINT I I I I E E I I = E E E E E E
USINT I I I I I E I I I = E E E E E
LWORD E E E E E E E E E E = E E E E
DWORD I E E E E E E E E E I = E E E
WORD I I E E E E E E E E I I = E E
BYTE I I E E E E E E E E I I I = E
BOOL E E E E E E E E E E I I I I =
LTIME E E E E E E E E E E E E E E E
TIME E E E E E E E E E E E E E E E
LDT - - E E E E E E E E E E E E -
DT - - E E E E E E E E E E E E -
LDATE - - - - - - - - - - - - - - -
DATE - - - - - - - - - - - - - - -
LTOD - - - - - - - - - - - - - - -
L U U U L D
R L D S U W B B
R I L D S W W
E I I I I O Y O
E N I I I O O
A N N N N R T O
A T N N N R R
L T T T T D E L
L T T T D D
TOD - - - - - - - - - - - - - - -
WSTRING E E E E E E E E E E E E E E -
STRING E E E E E E E E E E E E E E -
SOURCE DESTINATION
W
S
L L S
T D L T
T L D T T
I D A T R
I D A O R
M T T O I
M T T D I
E E D N
E E N
G
G
LREAL - - - - - - - - E E
REAL - - - - - - - - E E
LINT E E E E - - - - E E
DINT E E E E - - - - E E
INT E E E E - - - - E E
SINT E E E E - - - - E E
ULINT E E E E - - - - E E
UDINT E E E E - - - - E E
UINT E E E E - - - - E E
USINT E E E E - - - - E E
LWORD E E E E - - - - E E
DWORD E E E E - - - - E E
WORD E E E E - - - - E E
BYTE E E E E - - - - E E
BOOL E E E E - - - - E E
LTIME = E - - - - - - - -
TIME I = - - - - - - - -
LDT - - = E E E E E - -
DT - - I = E E E E - -
LDATE - - - - = E - - - -
DATE - - - - I = - - - -
LTOD - - - - - - = E - -
TOD - - - - - - I = - -
WSTRING - - - - - - - - = E
STRING - - - - - - - - E =
In case of arithmetic or logic operations, between differently typed operand, the standard
requires that they must be converted to the same type, before the operation take place,
accordingly to the convertion table.
In case of operation between variables with different sign, LogicLab automatically makes
an explicit convertion (if explicit cast between them is allowed) to the singed counterpart
of the unsigned type; then it makes the implicit cast on the smaller type, to make the two
types identical.
For example: USINT + DINT will be resolved as follow
- First USINT will be casted to SINT (the signed counterpart of USINT), which should be
an explicit cast.
- Then SINT is casted to DINT, which is an implicit cast.
- Now that both variables are of type DINT, the operation can take place.
In order to download and debug the application, you have to establish a connection with
the target device. This chapter focuses on the operations required to connect to the tar-
get and to download the application, while the wide range of LogicLab’s debugging tools
deserves a separate chapter (see Chapter 9).
The elements in the list of communication protocols you can select from depend on
the setup executable(s) you have run on your PC (refer to your hardware provider if
a protocol you expect to appear in the list is missing).
2) Choose the appropriate protocol and make it the active protocol by clicking on the
activate button.
4) Apply the changes you made to the communication settings by pressing the OK but-
ton; otherwise, if you press the Cancel button, all changes will be undone.
Now you can establish a communication by clicking On-line>Connect menu.
- Diff. code: the application currently executing on the target device is not the same as
the one currently open in the IDE; moreover, no debug information consistent with the
running application is available: thus, the values shown in the watch window or in the
oscilloscope are not reliable and the debug mode cannot be activated.
- Diff. code, Symbols OK: the application currently executing on the target device is
not the same as the one currently open in the IDE; however, some debug information
consistent with the running application is available (for example, because that applica-
tion has been previously downloaded to the target device from the same PC): the values
shown in the watch window or in the oscilloscope are reliable, but the debug mode still
cannot be activated.
- Source OK: the application currently executing on the target device is the same as the
one currently open in the IDE: the debug mode can be activated.
When you try to connect to the target device, the state of communication becomes one
of the following:
- Error: the communication cannot be established. You should check both the physical
link and the communication settings.
You may want to protect the source code downloaded to the target device with a pass-
word, so that LogicLab will not open the uploaded project unless the correct password is
entered.
Click the Project>Options... menu and set the password.
As stated before, LogicLab allows you to download also the source code on the target
device; this way you can retrieve the source code in a later time having the certainty to
work with the exact project that is running on the target device.
The availability of this feature depends on the device implementation.
LogicLab allows you to choose when the download of the source code must be done; from
the menu Project > Options > Download you can choose one of the following voices:
- On PLC application download: the Source code will be downloaded to the target to-
gether with PLC application.
- Before disconnection: the Source code will be downloaded before target disconnection.
- Never: the Source code will be never downloaded to the target.
As well as the Source code, also the Debug symbols download time can be set using the
following select menu with the same options.
8.4 SIMULATION
Depending on the target device you are interfacing with, you may be able to simulate
the execution of the PLC application with LogicLab’s integrated simulation environment:
LogicLab.
In order to start the simulation, just click Debug>Simulation mode .
Refer to Quickstart manual to gain information on how to control the simulation.
LogicLab provides several debugging tools, which help the developer to check whether the
application behaves as expected or not.
All these debugging tools basically allow the developer to watch the value of selected vari-
ables while the PLC application is running.
LogicLab debugging tools can be gathered in two classes:
- Asynchronous debuggers. They read the values of the variables selected by the devel-
oper with successive queries issued to the target device. Both the manager of the de-
bugging tool (that runs on the PC) and, potentially, the task which is responsible to an-
swer those queries (on the target device) run independently from the PLC application.
Thus, there is no guarantee about the values of two distinct variables being sampled in
the same moment, with respect to the PLC application execution (one or more cycles
may have occurred); for the same reason, the evolution of the value of a single variable
is not reliable, especially when it changes fast.
- Synchronous debuggers. They require the definition of a trigger in the PLC code. They
refresh simultaneously all the variables they have been assigned every time the proces-
sor reaches the trigger, as no further instruction can be executed until the value of all
the variables is refreshed. As a result, synchronous debuggers obviate the limitations
affecting asynchronous ones.
This chapter shows you how to debug your application using both asynchronous and syn-
chronous tools.
A particular implementation of the watch window is available from the variables editor
(both global and local); on the right side of the variables editor you’ll see three tabs:
The third one, when pressed, will turn the variables editor into a watch window, where
all the variables of the editor are already added to the list and their values are shown:
No other variables can be added to this list and the variables in this list cannot be re-
moved.
Follow this procedure to add a variable to the Watch window from a textual (that is, IL
or ST) source code editor: select a variable, by double-clicking on it, and then drag it into
the watch window.
The same procedure applies to all the variables you wish to inspect.
Follow this procedure to add a variable to the Watch window from a graphical (that is, LD,
FBD, or SFC) source code editor:
1) Click Edit>Watch mode .
2) Click on the block representing the variable you wish to be shown in the Watch win-
dow.
A dialog box appears listing all the currently existing instances of debug windows, and
asking you which one is to receive the object you have just clicked on.
In order to display the variable in the Watch window, select Watch, then press OK.
The variable name, value, and location are now displayed in a new row of the Watch win-
The same procedure applies to all the variables you wish to inspect.
Once you have added to the Watch window all the variables you want to observe, you
should click Edit>Insert/Move mode : the mouse cursor turns to its original shape.
In order to add a variable to the Watch window, you can select the corresponding record
in the variables editor and then either drag-and-drop it in the Watch window
In order to add a variable to the Watch window, you can select it in the project tree and
then either drag-and-drop it in the Watch window
You can also click on the appropriate item of the Watch window inner toolbar, in order to
add a variable to it.
You shall type (or select by browsing the project symbols) the name of the variable and
its location (where it has been declared).
The watch window manager reads periodically from memory the value of the variables.
However, this action is carried out asynchronously, so it may happen that a higher-priority
task modifies the value of some of the variables while they are being read. Thus, at the
end of a refreshment process, the values displayed in the window may refer to different
execution states of the PLC code.
If the target device is disconnected, the Value column contains three dots.
If the PLC code changes and LogicLab cannot retrieve the memory location of an object in
the Watch window, then the Value column contains three dots.
LogicLab does not allow you to add to the Watch window a symbol which has not been
allocated, any attempt will be ignored.
2) Enter the file name and choose its destination in the file system.
When loading a watch list from file, you have two options: you can load the items from
file and append them to the items currently shown in the watch window; or you can auto-
matically clear the watch window and display only the items loaded from file. Either way,
follow this procedure and choose the desired option:
1) Click on the corresponding icon in the Watch window toolbar. The one labeled Load
(no appends) watch list will remove all currently displayed elements and show only
the ones loaded from file; the icon labeled Load watch list will append them instead.
2) Browse the file system and select the watch list file.
9.2 OSCILLOSCOPE
The Oscilloscope allows you to plot the evolution of the values of a set of variables. Be-
ing an asynchronous tool, the Oscilloscope cannot guarantee synchronization of samples.
Opening the Oscilloscope causes a new window to appear next to the right-hand border
of the LogicLab frame. This is the interface for accessing the debugging functions that the
Oscilloscope makes available. The Oscilloscope consists of three elements, as shown in
the following picture.
The toolbar allows you to better control the Oscilloscope. A detailed description of the
Follow this procedure to add a variable to the Oscilloscope from a textual (that is, IL or
ST) source code editor: select a variable by double-clicking on it, and then drag it into the
Oscilloscope window.
The same procedure applies to all the variables you wish to inspect.
Follow this procedure to add a variable to the Oscilloscope from a graphical (that is, LD,
FBD, or SFC) source code editor:
1) Click Edit>Watch mode .
2) Click on the block representing the variable you wish to be shown in the Oscilloscope.
Select Oscilloscope, the press OK. The name of the variable is now displayed in the
Track column.
The same procedure applies to all the variables you wish to inspect.
Once you have added to the Oscilloscope all the variables you want to observe, you should
click Edit>Insert/Move mode : the mouse cursor turns to its original shape.
In order to add a variable to the Oscilloscope, you can select the corresponding record in
the variables editor and then either drag-and-drop it in the Oscilloscope
or press the F10 key and choose Oscilloscope from the list of debug windows which pops
up.
In order to add a variable to the Oscilloscope, you can select it in the project tree and then
either drag-and-drop it in the Oscilloscope
The Oscilloscope manager periodically reads from memory the value of the variables.
However, this action is carried out asynchronously, that is it may happen that a higher-
priority task modifies the value of some of the variables while they are being read. Thus,
at the end of a sampling process, data associated with the same value of the x-axis may
actually refer to different execution states of the PLC code.
If the target device is disconnected, the curves of the dragged-in variables get frozen,
until communication is restored.
When you add a variable to the Oscilloscope, data acquisition begins immediately.
However, you can suspend the acquisition by clicking on Pause acquisition.
The curve freezes (while the process of data acquisition is still running in background),
until you click on Restart acquisition.
In this case, when you click on Restart acquisition, the evolution of the value of the vari-
able is plotted from scratch.
When you open the Oscilloscope, LogicLab applies a default scale to the axes. However, if
you want to set a different scale, you can do that by opening the graph properties clicking
on the corresponding icon in the toolbar:
The graph settings window will open, allowing you to change both the vertical and the
horizontal axis.
The vertical scale can be different for every variable, you can specify the desired scale in
the edit box labeled Value/div.
In the Oscilloscope toolbar you can also find icons for zoom in and out, and also to force
the Oscilloscope to display all the sample.
These options are axis-related, so you can zoom in, zoom out and show all samples for
the horizontal axis alone:
as well as you can zoom in, zoom out and show all samples for the vertical axis alone:
You can also quickly force the oscilloscope to display all samples for both horizontal and
vertical axis (which means show all values) with a specific icon:
When you are watching the evolution of two or more variables, you may want to split
the respective tracks. For this purpose, click on the Vertical split item in the Oscilloscope
toolbar.
To separate traces you can also manually move them; to do so grab the corresponding
coloured flag on the left of the chart and drag it to the desired location.
If you click on the Show samples item in the Oscilloscope toolbar, the tool highlights the
single values detected during data acquisition.
You can click on the same item again, in order to go back to the default view mode.
The Oscilloscope includes two measure bars, which can be exploited to take some meas-
ures on the chart; in order to show and hide them, click on the Show measure bars item
in the Oscilloscope toolbar.
If you want to measure a time interval between two events, you just have to move one
bar to the point in the graph that corresponds to the first event and the other to the point
that corresponds to the second one.
The time interval between the two bars is shown in the top left corner of the chart.
You can use a measure bar also to read the value of all the variables in the Oscilloscope
at a particular moment: move the bar to the point in the graph which corresponds to the
instant you want to observe.
In the table below the chart, you can now read the values of all the variables at that par-
ticular moment.
You can further customize the appearance of the Oscilloscope by clicking on the Graph
properties item in the toolbar.
In the window that pops up you can choose whether to display or not the Background
grid, the Time slide bar, and the Track list.
LogicLab periodically sends queries to the target device, in order to read the data to be
plotted in the Oscilloscope.
The polling rate can be configured by modifying the Sample polling rate voice in the Oscil-
loscope settings window.
Note that the actual rate depends on the performance of the target device, in particular
on the performance of its communication task.
You can save the samples acquired by the Oscilloscope to a file, in order to further analyze
the data with other tools.
1) You may want to stop acquisition before saving data to a file.
2) Click on the Save tracks data into file in the Oscilloscope toolbar.
3) Choose between the available output file format: OSC is a simple plain-text file, con-
taining time and value of each sample; OSCX is an XML file, that includes more
complete information, which can be further analyzed with another tool, provided
separately from LogicLab.
4) Choose a file name and a destination directory, then confirm the operation.
The oscilloscope allows you to restore data previously saved on file; you have two option
to do so: Load and append graph data or Load (no append) graph data.
In both cases you’ll have to select the OSC (or OSCX) file to load; then if you’ve choose
to load and append, the data taken from the file will be added to the list of those al-
ready inside the oscilloscope; if you’ve choose to load without append, the variables list
of the oscilloscope will be cleared before adding the data taken from the file.
Follow this procedure to print a view of the data plotted in the Oscilloscope:
1) Either suspend or stop the acquisition.
2) Only the elements included in the view will be printed, so move the time slide bar
and adjust the zoom, in order to include in the view the elements you want to print.
3) Click on the Print graph item.
Note that you cannot enter the debug mode if the connection status differs from Con-
nected.
Animation ON in hold
Animation OFF Animation ON
status
As explained in the SFC language reference, an action can be assigned to a step, and
a transition can be associated with a transition code (condition). Actions and transition
codes can be coded in any of the IEC 61131-3 languages (except SFC for transition code).
General-purpose debugging tools can be used within each action/condition, as if it was a
stand-alone POU.
9.4.2 LD ANIMATION
In live debug mode, LogicLab displays the values of all the visible variables directly in the
graphical source code editor.
Note that the LD animation manager tests periodically the state of all the elements. It
may happen that an element remains true for a slot of time too short to be displayed
on the video. The fact that an element is never highlighted does not imply that its value
never becomes true (the sampling rate may be too slow).
Note that the LD animation manager tests periodically the state of all the elements. It
9.5 TRIGGERS
9.5.1 TRIGGER WINDOW
The Trigger window tool allows you to watch the value of a set of variables and to have
them updated synchronously in a special pop-up window.
Memory availability
A trigger window takes a segment in the application code sector, having a well-defined
length. Obviously, in order to start up a trigger window, it is necessary that a sufficient
amount of memory is available, otherwise an error message appears.
From the Debug menu you can select the appropriate voice for work with triggers.
Triggers can be palced only if a valid connection is established and the PLC is currently
executing.
From the Debug menu you can choose the following voices:
Each record refers to a trigger window, either graphic or textual. The following table ex-
plains the meaning of each field.
Field Description
T: trigger window.
Type
G: graphic trigger window.
Name of the program, function, or function block where
the trigger is placed. If the module is a function block, this
Module
field contains its name, not the name of its instance where
you actually put the trigger.
For the textual languages (IL, ST) indicates the line in
Line which the trigger is placed. For the other languages the
value is always -1.
Setting a trigger causes a pop-up window to appear, which is called Interface window:
this is the interface to access the debugging functions that the trigger window makes
available. It consists of three elements, as shown below.
Caption bar
The Caption bar of the pop-up window shows information on the location of the trigger
which causes the refresh of the Variables window, when reached by the processor.
The text in the Caption bar has the following format:
Trigger n° X at ModuleName#Location
where
X Trigger identifier.
Name of the program, function, or function block where
ModuleName
the trigger was placed.
Controls section
This dialog box allows the user to better control the refresh of the trigger window to get
more information on the code under scope. A detailed description of the function of each
control is given in the Trigger window controls section (see Paragraph 9.5.2.11).
All controls are not accessible until at least one variable is dragged into the debug window.
The Variables section
This lower section of the Debug window is a table consisting of a row for each variable
that you dragged in. Each row has four fields: the name of the variable, its value, its type,
and its location (@task:ModuleName) read from memory during the last refresh.
To watch a variable, you need to copy it to the lower section of the Debug window.
This section is a table consisting of a row for each variable you dragged in. You can drag
into the trigger window only variables local to the module where you placed the relative
trigger, or global variables, or parameters. You cannot drag variables declared in another
program, or function, or function block.
This paragraph deals with the trigger window controls, which allows you to better super-
vise the working of this debugging tool, to get more information on the code under scope.
Trigger window controls act in a well-defined way on the behaviour of the window, re-
gardless for the type of the module (either IL or FBD) where the related trigger has been
inserted.
All controls are not accessible until at least one variable is dragged into the Variables
window.
Window controls are made accessible to users through the grey top half of the debug
window.
Trigger counter
This read-only control counts how many times the debug window manager has been trig-
gered, since the window was installed.
The window manager automatically resets this counter every time a new triggering ses-
sion is started.
Trigger state
This read-only control shows the user the state of the Debug window. It can assume the
following values.
The trigger has not occurred during the current task execution.
User-defined condition
If you define a condition by using this control, the values in the Debug window are re-
freshed every time the window manager is triggered and the user-defined condition is
true.
After you have entered a condition, the control displays its simplified expression.
Counters
These controls allow the user to define conditions on the trigger counter.
The trigger window can be in one of the following three states.
- None: no counter has been started up, thus no condition has been specified upon the
The trigger window tool allows the user to select a set of variables and to have their val-
ues displayed and updated synchronously in a pop-up window. Unlike the Watch window,
trigger windows refresh simultaneously all the variables they contain, every time they are
triggered.
Let us assume that you have an IL module, also containing the following instructions.
Let us also assume that you want to know the value of b, d, and k, just before
the ST k instruction is executed. To do so, move the cursor to line 12, then click
Debug>Add/Remove text trigger .
A green arrowhead appears next to the line number, and the related trigger window pops
up.
In order to watch the value of a variable, you need to add it to the trigger window. To this
purpose, select a variable by double-clicking it, and then drag it into the Variables win-
dow, that is the lower white box in the pop-up window. The variable’s name now appears
in the Symbol column.
The same procedure applies to all the variables you wish to inspect.
Let us assume that you have an FBD module, also containing the following instructions.
you must select the first available block preceding the selected variable. In the example
of the above figure, you must move the cursor to network 8, and click the ADD block.
You can click Debug>Add/Remove text trigger .
Else, you can also insert trigger on the whole line; this means you’ll hit the trigger just
before the first instruction of that line is executed. To do so, select the row by clicking the
gray button on the left (the one with the row number inside) and add the trigger.
In both cases, the color of the selected block turns to green, a white circle with a number
inside appears in the middle of the block, and the related trigger window pops up.
When preprocessing FBD source code, the compiler translates it into IL instructions. The
instruction in the selected network will be expanded to:
LD k
ADD 1
ST k
When you add a trigger to an FBD block, you actually place the trigger on the first state-
ment of its IL equivalent code.
In order to watch the value of a variable, you need to add it to the trigger window. Let
us assume that you want to inspect the value of variable k of the FBD code in the figure
below.
To this purpose, click Edit>Watch mode .
Now you can click the block representing the variable you wish to be shown in the trigger
window.
Now select the element you wish to inspect, in our example let’s suppose the variable K.
A dialog box appears listing all the currently existing instances of debug windows, and
asking you which one is to receive the object you have just clicked.
In order to display the variable k in the trigger window, select its reference in the Debug
windows column, then press OK. The name of the variable is now printed in the Symbol
column.
The same procedure applies to all the variables you wish to inspect.
Once you have added to the Graphic watch window all the variables you want to observe,
you can click Edit>Insert/Move mode , so as to let the cursor take back its original shape.
Let us assume that you have an LD module containing the following instructions:
You can place a trigger directly on a block, a contact, a coil or the entire row.
Let us assume that you want to know the value of some variables every time the pro-
cessor reaches network number 1. First select the network number 1 by clicking on
the grey area on its left, the one containing the network number. Now you can click
Debug>Add/Remove text trigger .
In both cases, the grey raised button containing the network number turns to green, and
a white circle with the number of the trigger inside appears in the middle of the button,
while the related trigger window pops up.
Unlike the other languages supported by LogicLab, LD does not allow you to insert a
trigger into a single contact or coil, as it lets you select only an entire network. Thus the
variables in the trigger window will be refreshed every time the processor reaches the
beginning of the selected network.
In order to watch the value of a variable, you need to add it to the trigger window. Let
us assume that you want to inspect the value of variable b in the LD code represented in
the figure below.
To this purpose, click Edit>Watch mode .
The cursor will become as follows.
Now you can click the item representing the variable you wish to be shown in the trigger
window.
A dialog box appears listing all the currently existing instances of debug windows, and
asking you which one is to receive the object you have just clicked.
In order to display variable parPulseWidth in the trigger window, select its reference in the
Debug window column, then press OK.
The name of the variable is now printed in the Symbol column.
The same procedure applies to all the variables you wish to inspect.
Once you have added to the Graphic watch window all the variables you want to observe,
you can click Edit>Insert/Move mode , so as to restore the original shape of the cursor.
Let us assume that you have an ST module containing the following instructions.
Not all the ST instructions support triggers. For example, it is not possible to place a trig-
ger on a line containing a terminator such as END_IF, END_FOR, END_WHILE, etc..
In order to watch the value of a variable, you need to add it to the trigger window. To this
purpose, select a variable, by double clicking it, and then drag it into the Variables win-
dow, that is the lower white box in the pop-up window. The variable name now appears
in the Symbol column.
The same procedure applies to all the variables you wish to inspect.
If you want a variable not to be displayed any more in the trigger window, select it by
clicking its name once, then press the Del key.
This page deals with what you can do when you finish a debug session with a trigger win-
dow. You can choose between the following options.
- Closing the trigger window.
- Removing the trigger.
- Removing all the triggers.
Notice that the actions listed above produce very different results.
The interface window appears with value of variables and trigger counter updated, as if it
had not been closed.
Removing a trigger
If you choose this option, you completely remove the code both of the window manager
and of its trigger. To this purpose, just open the Trigger list window, select the record
referred to the trigger window you want to eliminate, and click the Remove button.
Alternatively, you can move the cursor to the line (if the module is in IL or ST), or
click the block (if the module is in FBD or LD) where you placed the trigger. Now press
Debug>Add/Remove trigger .
Memory availability
A graphic trigger window takes all the free memory space in the application code sector.
Obviously, in order to start up a trigger window, it is necessary that a sufficient amount
of memory is available, otherwise an error message appears.
Setting a graphic trigger causes a pop-up window to appear, which is called Interface
window. This is the main interface for accessing the debugging functions that the graphic
trigger window makes available. It consists of several elements, as shown below.
Where
To watch a variable, you need to copy it to the lower section of the Debug window.
This lower section of the Debug window is a table consisting of a row for each variable
that you dragged in. Each row has several fields, as shown in the picture below.
Field Description
Track Name of the variable.
Um Unit of measurement.
Min value Minimum value in the record set.
Max value Maximum value in the record set.
Cur value Current value of the variable.
How many engineering units are represented by a unit
v/div of the y-axis (i.e. the space between two ticks on the
vertical axis).
Value of the variable at the intersection with the line
V Blue cursor
identified by the vertical blue cursor.
Value of the variable at the intersection with the line
V Red cursor
identified by the vertical red cursor.
Value of the variable at the intersection with the line
H Red cursor
identified by the horizontal red cursor.
Value of the variable at the intersection with the line
H Blue cursor
identified by the horizontal red cursor.
Information about the variable in watch, like its parent
Description
POU and the execution task
Note that you can drag into the graphic trigger window only variables local to the module
This paragraph deals with controls of the Graphic trigger window. Controls allow you to
specify in detail when LogicLab is supposed to sample the variables added to the Variables
window.
Graphic trigger window controls act in a well-defined way on the behaviour of the window,
regardless for the type of the module (IL, ST, FBD or LD) where the related trigger has
been inserted.
Window controls are made accessible to users through the Controls bar of the debug
window.
Trigger counter
This read-only control displays two numbers with the following format: X/Y.
X indicates how many times the debug window manager has been triggered, since the
graphic trigger was installed.
Y represents the number of samples the graphic window has to collect before stopping
data acquisition and drawing the curves.
Trigger state
This read-only control shows you the state of the Debug window. It can assume the fol-
lowing values.
In order to open the options tab, you must click the Properties button in the Controls bar.
When you do this, the following dialog box appears.
Control
Control Description
Tick this control to display a grid in the Chart area
Show grid
background.
The scroll bar at the bottom of the Chart area is
Show time bar
available as long as this box is checked.
The Variables window is shown as long as this box
Show tracks
is checked, otherwise the Chart area extends to the
list
bottom of the graphic trigger window.
Values
Control Description
Horizontal
Number of samples per unit of the x-axis. By unit of the
scale
x-axis the space is meant between two vertical lines of
the background grid.
Tracks
This tab allows you to define some graphic properties of the plot of each variable. To select
a variable, click its name in the Track list column.
Control Description
Unit of measurement, printed in the table of the
Unit
Variables window.
Δ value per unit of the y-axis. By unit of the y-axis is
Value/div meant the space between two horizontal lines of the
background grid.
Hide Check this flag to hide selected track on the graph.
Push Apply to make your changes effective, or push OK to apply your changes and to
close the options tab.
User-defined condition
If you define a condition by using this control, the sampling process does not start until
that condition is satisfied. Note that, unlike trigger windows, once data acquisition begins,
samples are taken every time the window manager is triggered, regardless of the user
condition being still true or not.
After you enter a condition, the control displays its simplified expression.
Let us assume that you have an IL module, also containing the following instructions.
Not all the IL instructions support triggers. For example, it is not possible to place a trig-
ger at the beginning of a line containing a JMP statement.
In order to get the diagram of a variable plotted, you need to add it to the graphic trigger
window. To this purpose, select a variable, by double clicking it, and then drag it into the
Variables window. The variable now appears in the Track column.
The same procedure applies to all the variables you wish to inspect.
Once the first variable is dropped into a graphic trace, the Graphic properties window is
automatically shown and allows the user to setup sampling and visualization properties.
Let us assume that you have an FBD module, also containing the following instructions.
Let us also assume that you want to know the values of a, c, and k, just before the last
instruction is executed.
Provided that you can never place a trigger in a block representing a variable such as
you must select the first available block preceding the selected variable. In the example
of the above figure, you must move the cursor to network 8, and click the ADD block.
Now click Debug>Add/Remove graphic trigger .
Else, you can also insert trigger on the whole line; this means you’ll hit the trigger just
before the first instruction of that line is executed. To do so, select the row by clicking the
gray button on the left (the one with the row number inside) and add the trigger.
In both cases the colour of the selected block will turn to green, a white circle with the
trigger ID number inside will appear in the middle of the block, and the related trigger
interface window will pop up.
In order to watch the diagram of a variable, you need to add it to the trigger window. Let
us assume that you want to see the plot of the variable k of the FBD code in the figure
below.
To this purpose, click Edit>Watch mode .
The cursor will become as follows.
Now you can click the block representing the variable you wish to be shown in the graphic
trigger window.
In the example we are considering, click the button block.
A dialog box appears listing all the currently existing instances of debug windows, and
asking you which one is to receive the object you have just clicked.
In order to plot the curve of variable k, select Graphic Trace in the Debug windows col-
umn, then press OK. The name of the variable is now printed in the Track column.
Let us assume that you have an LD module, also containing the following instructions.
You can place a graphic trigger directly on a block, a contact, a coil or the entire row.
Let us assume that you want to know the value of some variables every time the pro-
cessor reaches network number 1. First select the network number 1 by clicking on
the grey area on its left, the one containing the network number. Now you can click
Debug>Add/Remove graphic trigger .
Note that unlike the other languages supported by LogicLab, LD does not allow you to
insert a trigger before a single contact or coil, as it lets you select only an entire network.
Thus the variables in the Graphic trigger window will be sampled every time the processor
reaches the beginning of the selected network.
In order to watch the diagram of a variable, you need to add it to the Graphic trigger
window. Let us assume that you want to see the plot of the variable b in the LD code
represented in the figure below.
To this purpose, click Edit>Watch mode .
The cursor will become as follows.
Now you can click the item representing the variable you wish to be shown in the Graphic
trigger window.
A dialog box appears listing all the currently existing instances of debug windows, and
asking you which one is to receive the object you have just clicked.
The same procedure applies to all the variables you wish to inspect.
Once you have added to the Graphic watch window all the variables you want to observe,
you can click Edit>Insert/Move mode , so as to restore the original shape of the cursor.
Once the first variable is dropped into a graphic trace, the Graphic properties window is
automatically shown and allows the user to setup sampling and visualization properties.
Let us assume that you have an ST module, also containing the following instructions.
Let us also assume that you want to know the value of x and y, just before the for cycle is
Not all the ST instructions support triggers. For example, it is not possible to place a trig-
ger on a line containing a terminator such as END_IF, END_FOR, END_WHILE, etc.
In order to get the diagram of a variable plotted, you need to add it to the Graphic trigger
window. To this purpose, select a variable, by double clicking it, and then drag it into the
Variables window, that is the lower white box in the pop-up window. The variable now
appears in the Track column.
The same procedure applies to all the variables you wish to inspect.
Once the first variable is dropped into a graphic trace, the Graphic properties window is
automatically shown and allows the user to setup sampling and visualization properties.
If you want to remove a variable from the Graphic trigger window, select it by clicking its
name once, then press the Del key.
9.6.2.10 CLOSING THE GRAPHIC TRIGGER WINDOW AND REMOVING THE TRIGGER
At the end of a debug session with the graphic trigger window you can choose between
the following options:
- Closing the Graphic trigger window.
- Removing the trigger.
- Removing all the triggers.
Alternatively, you can move the cursor to the line (if the module is in IL or ST), or
click the block (if the module is in FBD or LD) where you placed the trigger. Now select
Debug>Add/Remove graphic trigger
Removing all the triggers
This way you’ll remove all the existing triggers at once, regardless for which records are
selected. To do so: open the Trigger list window and click on the Remove all button.
9.7 BREAKPOINTS
9.7.1 THE BREAKPOINT TOOL
The Breakpoint tool allows you to halt the program execution when it reaches a certain
location. When a breakpoint is hit you can take all the time you want to watch other vari-
ables values or check every condition you need t verify before resuming the program ex-
ecution; with breakpoints you also have the option of executing only the next instruction,
running your program step by step.
Breakpoints cannot be used with SFC modules.
Memory availability
Icon in
Command debug Description
toolbar
In order to actually set a breakpoint, select the
point of the PLC code where to insert the relative
Set/Remove breakpoint breakpoint and then select this voice or use the
shortcut pressing F12.
Do the same to remove the breakpoint.
One a breakpoint is hit, the program execution
will be stopped and its state will become HALTED;
Run
in order to resume the normal program execution
select this voice.
Once a breakpoint is hit, the program execution
will be stopped and its state will become HALTED;
Step
select this voice to execute only the next
instruction.
Selecting this voice will cause all the existing
Remove all breakpoints
breakpoints to be removed simultaneously.
Select this voice to open a dialog listing all the
Breakpoint list
existing breakpoints.
If you have set several breakpoint, you may want to keep control over them using the
Breakpoints list window. Selecting the Breakpoints list voice the following window will be
opened:
Breakpoints work the same way in both IL and ST languages; in order to set a new break-
point, move to the code line where you want to halt the program execution, then choose
Debug>Set/Remove breakpoint .
At the far left side of the code line, left to the line number, a red circle will appear, mean-
ing that there’s a breakpoint on that line.
Note that you cannot set breakpoints on every instruction, for example you cannot set a
breakpoint on an end_if statement and similar.
When a breakpoint is hit (which means that the code execution has reached the line
where the breakpoint is set), the whole line is highlighted and a yellow arrow appears
inside the red circle, to indicate that the program is waiting to execute that instruction.
Also the program execution state will change, in the far bottom-right corner, it will change
from running to halted.
Selecting Debug > Run the program execution will be resumed until another break-
point is hit, or the same breakpoint will be hit again after an entire cicle has took place.
Selecting Debug > Step the code line where the program execution has halted, will
be executed, but the program will halt on the very next instruction. In other words, the
result is the same as setting a new virtual breakpoint to the next instruction and then
resume the execution.
Breakpoints work the same way in both LD and FBD languages; in order to set a new
breakpoint, move to the line where you want to halt the program execution, then choose
Debug > Set/remove breakpoint .
On the header of the line, the gray raised button with the line number on it, will now ap-
pera a red circle, meaning that there’s a breakpoint on that line.
When a breakpoint is hit (which means that the code execution has reached the line
where the breakpoint is set), the header is highlighted to indicate that the program is
waiting to execute that instruction.
Also the program execution state will change, in the far bottom-right corner, it will change
from running to halted.
Selecting Debug > Run the program execution will be resumed until another break-
point is hit, or the same breakpoint will be hit again after an entire cicle has took place.
Selecting Debug > Step the line where the program execution has halted, will be ex-
ecuted, but the program will halt on the very next instruction. In other words, the result
is the same as setting a new virtual breakpoint to the next instruction and then resume
the execution.
Saves the current open project specifying new name, location and
Save project As
extension.
Shift
Go to symbol Allows you to move through the results of a symbol search
+F12
Ctrl+
Find in project Opens the Find in project dialog box.
Shift+F
Bookmarks...
Asks you to type a string and searches for its first instance
Find Ctrl+F within the active document from the current location of the
cursor.
Ctrl +
Zoom in mouse Increase zoom level inside the active POU.
wheel
Ctrl +
Zoom out mouse Decrease zoom level inside the active POU.
wheel
Tool windows
Local variables Shows or hides the local variables window for the active POU.
PLC run-time
Shows or hides the PLC run-time window.
status
New variable
New definition
View PLC object Shows properties and description of the currently selected
Alt+Enter
properties object.
Ctrl+
Recompile all Recompiles the project.
Alt+F7
Generate
redistributable Generates an RSM file.
source module
Export object to
Lets you export a LogicLab object to a library.
library
Select target... Lets you to select a new target for the project.
Refresh current Lets you update the target file for the same version of the
target target.
Force debug symbols If the target device is connected, lets you upload the debug
upload symbols file.
Hot restart Restarts the PLC execution without any reset on variables.
Read all logs again Reloads all remote logs from target.
Simulation mode
Open/close the integrated simulation environment allowing
(workspace selec-
the user to create and choose different workspace.
tion)
Add/remove text
F9 Adds/removes a text trigger.
trigger
Add/remove
Shift+F9 Adds/removes a graphic trigger.
graphic trigger
Add/Remove
F12 Adds or removes a breakpoint.
breakpoint
Remove all
Removes all the active breakpoints.
breakpoints
New
New
Jump to
shift+J Adds a jump statement into the selected network.
label
Opens the editor by which the selected object was created, and
displays the relevant source code:
- if the object is a program, or a function, or a function block,
this command opens its source code;
Open source
- if the object is a variable or a parameter, this command opens
the corresponding variable editor;
- if the object is a standard function or an operator, this
command has no functionality.
Delete invalid Removes all invalid connections, represented by a red line in the
Ctrl+M
connection active scheme.
Decrement pins Ctrl+’-’ Removes pins added by the Increment pins command.
Object proper-
Shows some properties of the selected block.
ties
New
Object
New
Parallel contact
Adds a parallel contact before the selected one.
before
Parallel contact
Shift+P Adds a parallel contact after the selected one.
after
Serie contact
Adds a contact in series and before the selected one.
before
Serie contact after Shift+C Adds a contact in series and after the selected one.
Set output line Set selected pin as the output line of the block.
New
Modify
Code Object
The PLC editors area is split into frames having the same
dimensions, depending on the number of currently open
Tile
documents. Each frame is automatically assigned to one of
such documents.
Textual documents and textual elements of graphic languages are written by using the
standard ASCII character set.
11.1.1.2 COMMENTS
User comments are delimited at the beginning and at the end by special character com-
binations. For the textual languages (IL and ST) are allowed this format of comments:
- (* multi-lines comment *)
- // single line comment
- /* multi-line comment */
For graphic languages, comments are inserted using dedicated commands; they are then
translated, into the project file, using the first comment format (* comment *).
Comments are permitted anywhere in the program, and they have no syntactic or seman-
tic significance in any of the languages defined in this standard.
TIME#-24d_20h_31m_
Time expressed in
23s_648ms
milliseconds represented
TIME 32 to
with format TIME#dd_hh_
TIME#24d_20h_31m_
mm_ss_ms
23s_647ms
11.1.2.1 REFERENCES
References are a standard IEC type that act as a pointer to another variable (the refer-
enced variable). Reference type works like the pointer type (see paragraph 11.7.2), but
the pointer type is not a standard IEC type and has several less restricion, which make the
pointer type more flexible but also more dangerous than the reference type.
The value of the reference is the address of the referenced variable; in order to access the
data stored at the referenced address, a reference can be dereferenced.
Reference declaration requires the same syntax used in variable declaration, where the
type name is the type name of the referenced variable with ^ sign after:
VAR
<reference_var_name> : <referenced_var_type>^;
END_VAR
For example, the declaration of a reference to an INT shall be as follows:
Reference can be assigned with another reference or with an address; the special operator REF is
available to retrieve the reference address of a variable.
rx := ry; (* where rx and ry are reference of the same type *)
rx := REF(x); (* where rx is a reference to the same type of x *)
Accessing to the reference variable followed by the ^ sign, will dereference the variable:
rx := REF(x); (* rx i a reference to x *)
rx^ := 10; (* x vaule is now 10 *)
rx^ := rx^ + 1; (* x value now is 11 *)
y := rx^; (* y value now is 11, y is of the same type of x *)
For further information about references, please refer to IEC standard reference.
11.1.3.1 TYPEDEFS
The purpose of typedefs is to assign alternative names to existing types. There are not
any differences between a typedef and its parent type, except the name.
Typedefs can be declared using the following syntax:
TYPE
<enumerated data type name> : <parent type name>;
END_TYPE
For example, consider the following declaration, mapping the name LONGWORD to the IEC
61131-3 standard type DWORD:
TYPE
longword : DWORD;
END_TYPE
An enumerated data type declaration specifies that the value of any data element of that
type can only be one of the values given in the associated list of identifiers. The enumera-
tion list defines an ordered set of enumerated values, starting with the first identifier of
the list, and ending with the last.
Enumerated data types can be declared using the following syntax:
TYPE
<enumerated data type name> : ( <enumeration list> );
END_TYPE
For example, consider the following declaration of two enumerated data types. Note that,
when no explicit value is given to an identifier in the enumeration list, its value equals the
11.1.3.3 SUBRANGES
A subrange declaration specifies that the value of any data element of that type is re-
stricted between and including the specified upper and lower limits.
Subranges can be declared using the following syntax:
TYPE
<subrange name> : <parent type name> ( <lower limit>..<upper limit>
);
END_TYPE
For a concrete example consider the following declaration:
TYPE
int_0_to_100 : INT (0..100);
END_TYPE
11.1.3.4 STRUCTURES
A STRUCT declaration specifies that data elements of that type shall contain sub-elements
of specified types which can be accessed by the specified names.
Structures can be declared using the following syntax:
TYPE
<structured type name> : STRUCT
<declaration of structurestructure elements>
END_STRUCT;
END_TYPE
For example, consider the following declaration:
TYPE
structure1 : STRUCT
elem1 : USINT;
elem2 : USINT;
11.1.4 LITERALS
A string character literal is a sequence of zero or more characters prefixed and terminated
by the single quote character (').
The three-character combination of the dollar sign ($) followed by two hexadecimal digits
shall be interpreted as the hexadecimal representation of the eight-bit character code.
Example Explanation
'' Empty string (length zero)
'A' String of length one containing the single character A
' ' String of length one containing the space character
Two-character combinations beginning with the dollar sign shall be interpreted as shown
in the following table when they occur in character strings.
A wide string character literal is a sequence of zero or more characters prefixed and ter-
minated by the double quote character (“).
The three-character combination of the dollar sign ($) followed by two hexadecimal digits
shall be interpreted as the hexadecimal representation of the eight-bit character code.
Example Explanation
““ Empty wide string (length zero)
“A” Wide string of length one containing the single character A
“ “ Wide string of length one containing the space character
“'” Wide string of length one containing the single quote character
'$”' Wide string of length one containing the double quote character
“$R$L” Wide string of length two containing CR and LF characters
“$0A” Wide string of length one containing the LF character
Two-character combinations beginning with the dollar sign shall be interpreted as shown
in the following table when they occur in wide character strings.
Date and time literals are defined by specifing the type name, the sharp character and
the desired value; the value format depends on the specific data type, as shown in the
table below:
11.1.5 VARIABLES
11.1.5.1 FOREWORD
Variables provide a means of identifying data objects whose contents may change, e.g.,
data associated with the inputs, outputs, or memory of the programmable controller. A
variable must be declared to be one of the elementary types. Variables can be represent-
ed symbolically, or alternatively in a manner which directly represents the association of
The declaration of a variable must be performed within the following program structuring
element:
KEYWORD [RETAIN] [CONSTANT]
Declaration 1
Declaration 2
...
Declaration N
END_VAR
The scope (range of validity) of the declarations contained in structuring elements is local
to the program organization unit (POU) in which the declaration part is contained. That
is, the declared variables are accessible to other program organization units except by
explicit argument passing via variables which have been declared as inputs or outputs of
those units. The one exception to this rule is the case of variables which have been de-
clared to be global.
Such variables are accessible to programs in any case, or via a VAR_EXTERNAL declaration
to function blocks and functions. The type of a variable declared in a VAR_EXTERNAL must
agree with the type declared in the VAR_GLOBAL block.
To give access to this variables to all type of POU, without using any keyword, you must
enable this option in the code generation tab of the project options (see Paragraph 4.6.2).
There is an error if:
- any program organization unit attempts to modify the value of a variable that has been
11.1.5.4 QUALIFIERS
Qualifier Description
The attribute CONST indicates that the variables within
the structuring elements are constants, i.e. they have
CONST
a constant value, which cannot be modified once the
PLC project has been compiled.
The attribute RETAIN indicates that the variables
within the structuring elements are retentive, i.e. they
RETAIN
keep their value even after the target device is reset
or switched off.
A single-element variable represents a single data element of either one of the elemen-
tary types or one of the derived data types.
An array is a collection of data elements of the same data type; in order to access a single
element of the array, a subscript (or index) enclosed in square brackets has to be used.
Subscripts can be either integer literals or single-element variables.
To easily represent data matrices, arrays can be multi-dimensional; in this case, a com-
posite subscript is required, one index per dimension, separated by commas. The maxi-
mum number of dimensions allowed in the definition of an array is three.
Variables must be declared within structuring elements, using the following syntax:
VarName1 : Typename1 [ := InitialVal1 ];
VarName2 AT Location2 : Typename2 [ := InitialVal2 ];
VarName3 : ARRAY [ 0..N ] OF Typename3;
where:
Keyword Description
Variable identifier, consisting of a string of
VarNameX alphanumeric characters, of length 1 or more. It is
used for symbolic representation of variables.
Data type of the variable, selected from elementary
TypenameX
data types.
The value the variable assumes after reset of the
InitialValX
target.
LocationX See the next paragraph.
Index of the last element, the array having length
N
N + 1.
Variables can be represented symbolically, i.e. accessed through their identifier, or alter-
natively in a manner which directly represents the association of the data element with
physical or logical locations in the programmable controller’s input, output, or memory
structure.
Direct representation of a single-element variable is provided by a special symbol formed
by the concatenation of the percent sign “%” , a location prefix and a size prefix, and one
or two unsigned integers, separated by periods (.).
%location size index.subindex
1) location
The location prefix may be one of the following:
2) size
The size prefix may be one of the following:
3) index.index
This sequence of unsigned integers, separated by dots, specifies the actual position
of the variable in the area specified by the location prefix.
Example:
Note that the absolute position depends on the size of the datablock elements, not on the
size prefix. As a matter of fact, %MW4.6 and %MD4.6 begin from the same byte in memory,
but the former points to an area which is 16 bits shorter than the latter.
For advanced users only: if the index consists of one integer only (no dots), then it loses
any reference to data blocks, and it points directly to the byte in memory having the index
value as its absolute address.
Example
VAR [RETAIN] [CONSTANT]
XQuote : DINT; Enabling : BOOL := FALSE;
TorqueCurrent AT %MW4.32 : INT;
Counters : ARRAY [ 0 .. 9 ] OF UINT;
Limits: ARRAY [0..3, 0..9]
END_VAR
- Variable XQuote is 32 bits long, and it is automatically allocated by the LogicLab com-
piler.
- Variable Enabling is initialized to FALSE after target reset.
- Variable TorqueCurrent is allocated in the memory area of the target device, and it
takes 16 bits starting from the first byte of the 33rd element of datablock 4.
- Variable Counters is an array of 10 independent variables of type unsigned integer.
Whatever the PLC language you are using, LogicLab allows you to disregard the syntax
above, as it supplies the Local variables editor, the Global variables editor, and the Param-
eters editor, which provide a friendly interface to declare all kinds of variables.
11.1.6.1 FUNCTIONS
Introduction
For the purposes of programmable controller programming languages, a function is de-
fined as a program organization unit (POU) which, when executed, yields exactly one data
element, which is considered to be the function result.
Functions contain no internal state information, i.e., invocation of a function with the
same arguments (input variables VAR_INPUT and in-out variables VAR_IN_OUT) always
yields the same values (output variables VAR_OUTPUT, in-out variables VAR_IN_OUT and
function result).
Declaration syntax
The declaration of a function must be performed as follows:
FUNCTION FunctionName : RetDataType
VAR_INPUT
declaration of input variables (see the relevant section)
END_VAR
Keyword Description
FunctionName Name of the function being declared.
RetDataType Data type of the value to be returned by the function.
A function can access global variables only if they are
VAR_EXTERNAL .. listed in a VAR_EXTERNAL structuring element. Variables
END_VAR passed to the FB via a VAR_EXTERNAL construct can be
modified from within the FB.
Specifies the operations to be performed upon the
input variables in order to assign values dependent on
the function’s semantics to a variable with the same
Function body
name as the function, which represents the function
result. It can be written in any of the languages
supported by LogicLab.
Declaration syntax
The declaration of a function must be performed as follows:
FUNCTION_BLOCK FunctionBlockName
VAR_INPUT
declaration of input variables (see the relevant section)
END_VAR
VAR_OUTPUT
declaration of output variables
END_VAR
VAR_EXTERNAL
declaration of external variables
END_VAR
VAR_IN_OUT
declaration of in_out variables
END_VAR
VAR
declaration of local variables
END_VAR
Function block body
END_FUNCTION_BLOCK
Keyword Description
11.1.6.3 PROGRAMS
Introduction
A program is defined in IEC 61131-1 as a “logical assembly of all the programming lan-
guage elements and constructs necessary for the intended signal processing required for
the control of a machine or process by a programmable controller system”.
Declaration syntax
The declaration of a program must be performed as follows:
PROGRAM < program name>
Declaration of variables (see the relevant section)
Program body
END_PROGRAM
Keyword Description
Program Name Name of the program being declared.
Specifies the operations to be performed to get the
Program body intended signal processing. It can be written in any of
the languages supported by LogicLab.
TO_BOOL
Description Conversion to BOOL (boolean)
Number of operands 1
Input data type Any numerical type
Output data type BOOL
out := TO_BOOL( 0 ); (* out = FALSE *)
Examples out := TO_BOOL( 1 ); (* out = TRUE *)
out := TO_BOOL( 1000 ); (* out = TRUE *)
TO_BYTE
Description Conversion to BYTE (8-bit string)
Number of operands 1
Input data type Any numerical type or STRING
Output data type BYTE
out := TO_BYTE( -1 ); (* out = 16#FF *)
Examples
out := TO_BYTE( 16#100 ); (* out = 16#00 *)
TO_DATE
Description Conversion to DATE (32-bit signed integer)
Number of operands 1
Input data type DATE_AND_TIME, LDATE_AND_TIME, LDATE
Output data type DATE
Examples
TO_DATE_AND_TIME
Description Conversion to DATE_AND_TIME (32-bit signed integer)
Number of operands 1
Input data type LDATE_AND_TIME
Output data type DATE_AND_TIME
Examples
TO_DINT
Description Conversion to DINT (32-bit signed integer)
Number of operands 1
Input data type Any numerical type or STRING
Output data type DINT
out := TO_DINT( 10.0 ); (* out = 10 *)
Examples
out := TO_DINT( 16#FFFFFFFF ); (* out = -1 *)
TO_INT
Description Conversion to INT (16-bit signed integer)
Number of operands 1
Input data type Any numerical type or STRING
Output data type INT
out := TO_INT( -1000.0 ); (* out = -1000 *)
Examples
out := TO_INT( 16#8000 ); (* out = -32768 *)
TO_LDATE
Description Conversion to LDATE (64-bit signed integer)
Number of operands 1
Input data type DATE_AND_TIME, LDATE_AND_TIME, DATE
Output data type LDATE
Examples
TO_LDATE_AND_TIME
Description Conversion to LDATE_AND_TIME (64-bit signed integer)
Number of operands 1
Input data type DATE_AND_TIME
Output data type LDATE_AND_TIME
Examples
TO_LINT
Description Conversion to LINT (64-bit signed integer)
Number of operands 1
Input data type Any numerical type or STRING
Output data type LINT
out := TO_LINT( -1 ); (* out = -1 *)
Examples
out := TO_LINT(16#FFFFFFFFFFFFFFFF); (* out = -1 *)
TO_LREAL
Description Conversion to LREAL (64-bit floating point)
Number of operands 1
Input data type Any numerical type or STRING
Output data type LREAL
TO_LTIME
Description Conversion to LTIME (64-bit signed integer)
Number of operands 1
Input data type TIME
Output data type LTIME
Examples
TO_LTIME_OF_DAY
Description Conversion to LTIME_OF_DAY (64-bit signed integer)
Number of operands 1
Input data type TIME_OF_DAY, DATE_AND_TIME, LDATE_AND_TIME
Output data type LTIME_OF_DAY
Examples
TO_LWORD
Description Conversion to LWORD (64-bit unsigned integer)
Number of operands 1
Input data type Any numerical type or STRING
Output data type LWORD
out := TO_LWORD( 10.0 ); (* out =
16#000000000000000A *)
Examples
out := TO_LWORD( -1 ); (* out = 16#FFFFFFFFFFFFFFFF
*)
TO_POINTER
Description Conversion to pointer
Number of operands 1
Input data type Any numerical type
Output data type UNDEFINED
Examples out := TO_POINTER( example_var );
TO_REAL
Description Conversion to REAL (32-bit floating point)
Number of operands 1
Input data type Any numerical type or STRING
Output data type REAL
out := TO_REAL( -1000 ); (* out = -1000.0 *)
Examples
out := TO_REAL( 16#8000 ); (* out = -32768.0 *)
TO_STRING
Description Conversion to STRING
Number of operands 1
Input data type Any numerical type
Output data type STRING
str := TO_STRING( 10.0 ); (* str = ‘10,0’ *)
Examples
str := TO_STRING( -1 ); (* str = ‘-1’ *)
TO_TIME
Description Conversion to LTIME (32-bit signed integer)
Number of operands 1
Input data type LTIME
Output data type TIME
Examples
TO_TIME_OF_DAY
Description Conversion to TIME_OF_DAY (32-bit signed integer)
Number of operands 1
Input data type LTIME_OF_DAY, DATE_AND_TIME, LDATE_AND_TIME
Output data type TIME_OF_DAY
Examples
TO_UDINT
Description Conversion to UDINT (32-bit unsigned integer)
Number of operands 1
Input data type Any numerical type or STRING
Output data type UDINT
out := TO_UDINT( 10.0 ); (* out = 10 *)
Examples out := TO_UDINT( 16#FFFFFFFF ); (* out = 4294967295
*)
TO_UINT
Description Conversion to UINT (16-bit unsigned integer)
Number of operands 1
Input data type Any numerical type or STRING
TO_ULINT
Description Conversion to ULINT (64-bit unsigned integer)
Number of operands 1
Input data type Any numerical type or STRING
Output data type ULINT
out := TO_ULINT( 10.0 ); (* out = 10 *)
Examples out := TO_ULINT( 16#FFFFFFFFFFFFFFFF ); (* out =
18446744073709551615 *)
TO_USINT
Description Conversion to USINT (8-bit unsigned integer)
Number of operands 1
Input data type Any numerical type or STRING
Output data type USINT
out := TO_USINT( -1 ); (* out = 255 *)
Examples
out := TO_USINT( 16#100 ); (* out = 0 *)
TO_WORD
Description Conversion to WORD (16-bit string)
Number of operands 1
Input data type Any numerical type or STRING
Output data type WORD
out := TO_WORD( 1000.0 ); (* out = 16#03E8 *)
Examples
out := TO_WORD( -32768 ); (* out = 16#8000 *)
TO_WSTRING
Description Conversion to WSTRING
Number of operands 1
Input data type Any numerical type
Output data type WSTRING
wstr := TO_STRING( 10.0 ); (* wstr = “10,0” *)
Examples
wstr := TO_STRING( -1 ); (* wstr = “-1” *)
Numerical functions
The availability of the following functions depends on the target device. Please refer to
your hardware supplier for details.
ABS
Description Absolute value. Computes the absolute value of the input
ACOS
Arc cosine. Computes the principal arc cosine of input #0;
Description
result is expressed in radians
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
OUT := ACOS( 1.0 ); (* OUT = 0.0 *)
Examples
OUT := ACOS( -1.0 ); (* OUT = PI *)
ADD
Description Arithmetic addition. Computes the sum of the two inputs.
Number of operands 2
Input data type Any numerical type, Any numerical type
Output data type Same as Inputs
Examples OUT := ADD( 20, 40 ); (* OUT = 60 *)
ASIN
Arc sine. Computes the principal arc sine of input #0; result
Description
is expressed in radians
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
OUT := ASIN( 0.0 ); (* OUT = 0.0 *)
Examples
OUT := ASIN( 1.0 ); (* OUT = PI / 2 *)
ATAN
Arc tangent. Computes the principal arc tangent of input
Description
#0; result is expressed in radians
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
OUT := ATAN( 0.0 ); (* OUT = 0.0 *)
Examples
OUT := ATAN( 1.0 ); (* OUT = PI / 4 *)
CEIL*
Rounding up to integer. Returns the smallest integer that is
Description
greater than or equal to input #0
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
OUT := CEIL( 1.95 ); (* OUT = 2.0 *)
Examples
OUT := CEIL( -1.27 ); (* OUT = -1.0 *)
COS
Cosine. Computes the cosine function of input #0 expressed
Description
in radians
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
OUT := COS( 0.0 ); (* OUT = 1.0 *)
Examples
OUT := COS( -3.141592 ); (* OUT ~ -1.0 *)
COSH*
Hyperbolic cosine. Computes the hyperbolic cosine function
Description
of input #0
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
Examples OUT := COSH( 0.0 ); (* OUT = 1.0 *)
DIV
Description Arithmetic division. Divides input #0 by input #1
Number of operands 2
Input data type Any numerical type, Any numerical type
Output data type Same as Inputs
EXP
Natural exponential. Computes the exponential function of
Description
input #0
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
Examples OUT := EXP( 1.0 ); (* OUT ~ 2.718281 *)
FLOOR*
Rounding down to integer. Returns the largest integer that is
Description
less than or equal to input #0
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
OUT := FLOOR( 1.95 ); (* OUT = 1.0 *)
Examples
OUT := FLOOR( -1.27 ); (* OUT = -2.0 *)
LN
Natural logarithm. Computes the logarithm with base e of
Description
input #0
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
Examples OUT := LN( 2.718281 ); (* OUT = 1.0 *)
LOG
Common logarithm. Computes the logarithm with base 10 of
Description
input #0
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
Examples OUT := LOG( 100.0 );(* OUT = 2.0 *)
MOD
Description Module. Computes input #0 module input #1
Number of operands 2
Input data type Integer type, integer type
Output data type Same as Inputs
Examples OUT := MOD( 10, 3 ); (* OUT = 1 *)
POW
Description Exponentiation. Raises Base to the power Expo
Number of operands 2
LREAL where available, REAL otherwise;
Input data type
LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
OUT := POW( 2.0, 3.0 ); (* OUT = 8.0 *)
Examples
OUT := POW( -1.0, 5.0 ); (* OUT = -1.0 *)
SIN
Sine. Computes the sine function of input #0 expressed in
Description
radians
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
OUT := SIN( 0.0 ); (* OUT = 0.0 *)
Examples
OUT := SIN( 2.5 * 3.141592 ); (* OUT ~ 1.0 *)
SINH*
Hyperbolic sine. Computes the hyperbolic sine function of
Description
input #0
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
Examples OUT := SINH( 0.0 ); (* OUT = 0.0 *)
SQRT
Description Square root. Computes the square root of input #0
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
Examples OUT := SQRT( 4.0 ); (* OUT = 2.0 *)
SUB
Description Arithmetic subtraction. Subtracts input #1 from input #0
Number of operands 2
TAN
Tangent. Computes the tangent function of input #0
Description
expressed in radians
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
OUT := TAN( 0.0 ); (* OUT = 0.0 *)
Examples
OUT := TAN( 3.141592 / 4.0 ); (* OUT ~ 1.0 *)
TANH*
Hyperbolic tangent. Computes the hyperbolic tangent
Description
function of input #0
Number of operands 1
Input data type LREAL where available, REAL otherwise
Output data type LREAL where available, REAL otherwise
Examples OUT := TANH( 0.0 ); (* OUT = 0.0 *)
AND
Logical AND if both Input #0 and Input #1 are BOOL,
Description
otherwise bitwise AND.
Number of operands 2
Input data type Any but STRING, Any but STRING
Output data type Same as Inputs
OUT := TRUE AND FALSE; (* OUT = FALSE *)
Examples
OUT := 16#1234 AND 16#5678; (* OUT = 16#1230 *)
NOT
Description Logical NOT if Input is BOOL, otherwise bitwise NOT.
Number of operands 1
Input data type Any but STRING
Output data type Same as Inputs
OUT := NOT FALSE; (* OUT = TRUE *)
Examples
OUT := NOT 16#1234;(* OUT = 16#EDCB *)
R
Description Reset operator: reset input to 0
Number of operands 1
Input data type BOOL
Output data type Same as Input #0
Examples
ROL
Description Input #0 left-shifted of Input #1 bits, circular.
Number of operands 2
Input data type Any numerical type, Any numerical type
Output data type Same as Input #0
OUT := ROL( IN := 16#1000CAFE, 4 );
Examples
(* OUT = 16#000CAFE1 *)
ROR
Description Input #0 right-shifted of Input #1 bits, circular.
Number of operands 2
Input data type Any numerical type, Any numerical type
Output data type Same as Input #0
OUT := ROR( IN := 16#1000CAFE, 16 );
Examples
(* OUT = 16#CAFE1000 *)
S
Description Set operator: set input to 1
Number of operands 1
Input data type BOOL
Output data type Same as Input #0
Examples
SHL
Description Input#0 left-shifted of Input #1 bits, zero filled on the right.
Number of operands 2
Input data type Any numerical type, Any numerical type
Output data type Same as Input #0
SHR
Input #0 right-shifted of Input #1 bits, zero filled on the
Description
left.
Number of operands 2
Input data type Any numerical type, Any numerical type
Output data type Same as Input #0
OUT := SHR( IN := 16#1000CAFE, 24 );
Examples
(* OUT = 16#00000010 *)
XOR
Logical XOR if both Input #0 and Input #1 are BOOL,
Description
otherwise bitwise XOR.
Number of operands 2
Input data type Any but STRING, Any but STRING
Output data type Same as Inputs
OUT := TRUE OR FALSE; (* OUT = TRUE *)
Examples
OUT := 16#1234 OR 16#5678; (* OUT = 16#444C *)
Selection functions
LIMIT
Limits Input #0 to be equal or more than Input#1, and
Description
equal or less than Input #2.
Number of operands 3
Input data type Any numerical type, Any numerical type, Any numerical type
Output data type Same as Inputs
OUT := LIMIT( IN := 4, MN := 0, MX := 5 ); (* OUT =
4 *)
OUT := LIMIT( IN := 88, MN := 0, MX := 5 );(* OUT =
Examples
5 *)
OUT := LIMIT( IN := -1, MN := 0, MX := 5 );(* OUT =
0 *)
MAX
Description Maximum value selection
Number of operands 2, extensible
Any numerical type, Any numerical type, .., Any numerical
Input data type
type
Output data type Same as max Input
Examples OUT := MAX( -8, 120, -1000 ); (* OUT = 120 *)
MUX
Description Multiplexer. Selects one of N inputs depending on input K
Number of operands 3, extensible
Any numerical type, Any numerical type, ..., Any numerical
Input data type
type
Output data type Same as selected Input
Examples OUT := MUX( 0, A, B, C ); (* OUT = A *)
SEL
Description Binary selection
Number of operands 3
Input data type BOOL, Any, Any
Output data type Same as selected Input
OUT := SEL( G := FALSE, IN0 := X, IN1 := 5 );
Examples
(* OUT = X *)
Comparison functions
Comparison functions can be also used to compare strings if this feature is supported by
target device.
EQ
Equal to. Returns TRUE if Input #0 = Input #1, otherwise
Description
FALSE.
Number of operands 2
Input data type Any, Any
Output data type BOOL
OUT := EQ( TRUE, FALSE ); (* OUT = FALSE *)
Examples
OUT := EQ( ‘AZ’, ‘ABC’ ); (* OUT = FALSE *)
GE
Greater than or equal to. Returns TRUE if Input #0 >=
Description
Input #1, otherwise FALSE.
Number of operands 2
Input data type Any but BOOL, Any but BOOL
Output data type BOOL
OUT := GE( 20, 20 ); (* OUT = TRUE *)
Examples
OUT := GE( ‘AZ’, ‘ABC’ ); (* OUT = FALSE *)
LE
Less than or equal to. Returns TRUE if Input #0 <= Input
Description
#1, otherwise FALSE.
Number of operands 2
Input data type Any but BOOL, Any but BOOL
Output data type BOOL
OUT := LE( 20, 20 ); (* OUT = TRUE *)
Examples
OUT := LE( ‘AZ’, ‘ABC’ ); (* OUT = FALSE *)
LT
Less than. Returns TRUE if Input #0 < Input #1, otherwise
Description
FALSE.
Number of operands 2
Input data type Any but BOOL, Any but BOOL
Output data type BOOL
OUT := LT( 0, 20 ); (* OUT = TRUE *)
Examples
OUT := LT( ‘AZ’, ‘ABC’ ); (* OUT = FALSE *)
NE
Not equal to. Returns TRUE if Input #0 != Input #1,
Description
otherwise FALSE.
Number of operands 2
Input data type Any, Any
Output data type BOOL
OUT := NE( TRUE, FALSE ); (* OUT = TRUE *)
Examples
OUT := NE( ‘AZ’, ‘ABC’ ); (* OUT = TRUE *)
String functions
The availability of the following functions depends on the target device. Please refer to
your hardware supplier for details.
CONCAT
Description Character string concatenation
Number of operands 2
Input data type STRING, STRING
Output data type STRING
DELETE
Delete L characters of IN, beginning at the P-th character
Description
position
Number of operands 3
Input data type STRING, UINT, UINT
Output data type STRING
OUT := DELETE( IN := ‘ABXYC’, L := 2, P := 3 );
Examples
(* OUT = ‘ABC’ *)
FIND
Find the character position of the beginning of the first
Description occurrence of IN2 in IN1. If no occurrence of IN2 is found,
then OUT := 0.
Number of operands 2
Input data type STRING, STRING
Output data type UINT
OUT := FIND( IN1 := ‘ABCBC’, IN2 := ‘BC’ ); (* OUT
Examples
= 2 *)
INSERT
Description Insert IN2 into IN1 after the P-th character position
Number of operands 3
Input data type STRING, STRING, UINT
Output data type STRING
OUT := INSERT( IN1 := ‘ABC’, IN2 := ‘XY’, P := 2 );
Examples
(* OUT = ‘ABXYC’ *)
LEFT
Description Leftmost L characters of IN
Number of operands 2
Input data type STRING, UINT
Output data type STRING
OUT := LEFT( IN := ‘ASTR’, L := 3 ); (* OUT = ‘AST’
Examples
*)
LEN
Description Return the length of a string
Number of operands 1
Input data type STRING
Output data type UINT
Examples OUT := LEN( ‘ASTRING’ ); (* OUT = 7 *)
REPLACE
Replace L characters of IN1 by IN2, starting at the P-th
Description
character position
Number of operands 4
Input data type STRING, STRING, UINT, UINT
Output data type STRING
OUT := REPLACE( IN1 := ‘ABCDE’, IN2 := ‘X’, L := 2,
Examples
P := 3 ); (* OUT = ‘ABXE’ *)
RIGHT
Description Rightmost L characters of IN
Number of operands 2
Input data type STRING, UINT
Output data type STRING
OUT := RIGHT( IN := ‘ASTR’, L := 3 ); (* OUT =
Examples
‘STR’ *)
TO_STRINGFORMAT
Description Conversion to STRING, with format specifier
Number of operands 2
Input data type Any numerical type, STRING
Output data type STRING
str := TO_STRINGFORMAT(10, ‘%04d’); (* str = ‘0010’
Examples
*)
TO_WSTRINGFORMAT
Description Conversion to WSTRING, with format specifier
Number of operands 2
Input data type Any numerical type, WSTRING
Output data type WSTRING
wstr := TO_WSTRINGFORMAT(10, ‘%04d’); (* wstr =
Examples
“0010” *)
Standard operators
IMOVE
Valorize an interface using another interface and executing
a query interface; checking if the class that implement
Description
the source interface is also implementing the destination
interface
Number of operands 1
Input data type Interface instance
Output data type NULL if error, any if ok
Examples
JMP
Description Jump to a specific label
Number of operands 1
Input data type STRING
Output data type
Examples
MOVE
Description Assign a value to a variable, equivalent of LD and ST
Number of operands 2
Input data type Any, Any
Output data type
Examples
REF
Description Return the reference to a variable
Number of operands 1
Input data type Any
Output data type Reference to the input variable
Examples
RET
Description Return
Number of operands 0
Input data type
Output data type
Examples
Date functions
CONCAT_DATE
Create a valid DATE value given its single components (year,
Description
month and day).
Number of operands 3
Input data type INT, INT, INT
Output data type DATE
out := CONCAT_DATE(2020, 6, 17); (* out = 2020-06-
Examples
17 *)
CONCAT_DATE_LTOD
Concatenate a DATE and a LTIME_OF_DAY into a LDATE_
Description
AND_TIME
Number of operands 2
Input data type DATE, LTIME_OF_DAY
Output data type LDATE_AND_TIME
out := CONCAT_DATE_LTOD(2020-06-17,
Examples 13:40:55.123456789); (* out = 2020-06-17-
13:40:55.123456789 *)
CONCAT_DATE_TOD
Concatenate a DATE and a TIME_OF_DAY into a DATE_AND_
Description
TIME
Number of operands 2
Input data type DATE, TIME_OF_DAY
Output data type DATE_AND_TIME
out := CONCAT_DATE_TOD(2020-06-17, 13:40:55.123);
Examples
(* out = 2020-06-17-13:40:55.123 *)
CONCAT_DT
Create a valid DATE_AND_TIME value given its single
Description
components (year, month, day, hours, minutes, seconds).
Number of operands 2
Input data type INT, INT, INT, INT, INT, INT
Output data type DATE_AND_TIME
out := CONCAT_DT(2020, 6, 17, 13, 40, 55); (* out =
Examples
2020-06-17-13:40:55 *)
CONCAT_LDT
Create a valid LDATE_AND_TIME value given its single
Description components (year, month, day, hours, minutes, seconds,
milliseconds, microseconds, nanoseconds).
Number of operands 9
Input data type INT, INT, INT, INT, INT, INT, INT, INT, INT
Output data type LDATE_AND_TIME
out := CONCAT_LDATE_AND_TIME(2020, 6, 17, 13, 40,
Examples 55, 123, 456, 789);
(* out = 2020-06-17-13:40:55.123456789 *)
CONCAT_LTOD
Create a valid LTIME_OF_DAY value given its single
Description components (hours, minutes, seconds, milliseconds,
microseconds and nanoseconds).
Number of operands 6
Input data type INT, INT, INT, INT, INT, INT
Output data type LTIME_OF_DAY
out := CONCAT_LTOD(13, 40, 55, 123, 456, 789); (*
Examples
out = 13:40:55.123456789 *)
CONCAT_TOD
Create a valid TIME_OF_DAY value given its single
Description
components (hours, minutes, seconds, milliseconds).
Number of operands 4
Input data type INT, INT, INT, INT
Output data type TIME_OF_DAY
out := CONCAT_TOD(13, 40, 55, 123); (* out =
Examples
13:40:55.123 *)
DAY_OF_WEEK
Get the day of week.
Description It returns the day of the week represented in a range from 0
(Sunday) to 6 (Saturday).
Number of operands 1
Input data type LDATE
Output data type SINT
Examples out := DAY_OF_WEEK(2020-06-17); (* out = 3 *)
SPLIT_DT
Split a DATE_AND_TIME into year, month, day, hours,
Description minutes and seconds integer pointer vabiables. The function
returns TRUE in case of no errors.
Number of operands 7
Input data type DATE_AND_TIME, @INT, @INT, @INT, @INT, @INT, @INT
Output data type BOOL
Examples
SPLIT_LDT
Split a LDATE_AND_TIME into year, month, day, hours,
minutes, seconds, milliseconds, microseconds and
Description
nanosecods integer pointer vabiables. The function returns
TRUE in case of no errors.
Number of operands 10
DATE_AND_TIME, @INT, @INT, @INT, @INT, @INT, @INT, @
Input data type
INT, @INT, @INT
Output data type BOOL
Examples
SPLIT_LTOD
Split a LTIME_OF_DAY into hours, minutes, seconds,
Description milliseconds, microseconds and nanoseconds integer pointer
vabiables. The function returns TRUE in case of no errors.
Number of operands 7
Input data type LTIME_OF_DAY, @INT, @INT, @INT, @INT, @INT, @INT
Output data type BOOL
Examples
SPLIT_TOD
Split a TIME_OF_DAY into hours, minutes, seconds,
Description milliseconds integer pointer vabiables. The function returns
TRUE in case of no errors.
Number of operands 5
Input data type TIME_OF_DAY, @INT, @INT, @INT, @INT
Output data type BOOL
Examples
Example
Let us parse a small piece of code:
START:
LD %IX1 (* Push button *)
ANDN %MX5.4 (* Not inhibited *)
ST %QX2 (* Fan out *)
The elements making up each instruction are classified as follows:
Operator
Label Operand Comment
[+ modifier]
START: LD %IX1 (* Push button *)
ANDN %MX5.4 (* Not inhibited *)
ST %QX2 (* Fan out *)
Semantics of IL instructions
- Accumulator
By accumulator a register is meant containing the value of the currently evaluated re-
sult.
- Operators
Unless otherwise specified, the semantics of the operators is
accumulator := accumulator OP operand
That is, the value of the accumulator is replaced by the result yielded by operation OP
applied to the current value of the accumulator itself, with respect to the operand. For
instance, the instruction “AND %IX1” is interpreted as
accumulator := accumulator AND %IX1
and the instruction “GT %IW10” will have the Boolean result TRUE if the current value
of the accumulator is greater than the value of input word 10, and the Boolean result
FALSE otherwise:
accumulator := accumulator GT %IW10
- Modifiers
The modifier “N” indicates bitwise negation of the operand.
The left parenthesis modifier “(” indicates that evaluation of the operator must be de-
ferred until a right parenthesis operator “)” is encountered. The form of a parenthesized
sequence of instructions is shown below, referred to the instruction
accumulator := accumulator AND (%MX1.3 OR %MX1.4)
Supported operand
Operator Modifiers types: Acc_type, Semantics
Op_type
Sets the accumulator equal to
LD N Any, Any
operand.
Stores the accumulator into
ST N Any, Any
operand location.
Sets operand to TRUE if
S BOOL, BOOL
accumulator is TRUE.
Sets operand to FALSE if
R BOOL, BOOL
accumulator is TRUE.
Any but REAL, Any but
AND N, ( Logical or bitwise AND
REAL
Any but REAL, Any but
OR N, ( Logical or bitwise OR
REAL
Any but REAL, Any but
XOR N, ( Logical or bitwise XOR
REAL
NOT Any but REAL Logical or bitwise NOT
ADD ( Any but BOOL Addition
SUB ( Any but BOOL Subtraction
MUL ( Any but BOOL Multiplication
DIV ( Any but BOOL Division
MOD ( Any but BOOL Modulo-division
GT ( Any but BOOL Comparison:
GE ( Any but BOOL Comparison: =
EQ ( Any but BOOL Comparison: =
NE ( Any but BOOL Comparison:
LE ( Any but BOOL Comparison:
LT ( Any but BOOL Comparison:
JMP C, N Label Jumps to label
CAL C, N FB instance name Calls function block
Returns from called program,
RET C, N
function, or function block.
) Evaluates deferred operation.
Functions (as defined in the relevant section) are invoked by placing the function name in
the operator field. This invocation takes the following form:
LD 1
MUX 5, var0, -6.5, 3.14
ST vRES
Note that the first argument is not contained in the input list, but the accumulator is used
as the first argument of the function. Additional arguments (starting with the 2nd), if re-
quired, are given in the operand field, separated by commas, in the order of their decla-
ration. For example, operator MUX in the table above takes 5 operands, the first of which
is loaded into the accumulator, whereas the remaining 4 arguments are orderly reported
after the function name.
Keyword Description
FBInstanceName Name of the instance to be invoked.
IO_var Input or output variable to be written / read.
Feature Example
Lines
The order in which networks and their elements are evaluated is not necessarily the same
as the order in which they are labeled or displayed. When the body of a program organiza-
tion unit (POU) consists of one or more networks, the results of network evaluation within
the aforesaid body are functionally equivalent to the observance of the following rules:
1) No element of a network is evaluated until the states of all of its inputs have been
evaluated.
2) The evaluation of a network element is not complete until the states of all of its out-
puts have been evaluated.
3) As stated when describing the FBD editor, a network number is automatically as-
signed to every network. Within a program organization unit (POU), networks are
evaluated according to the sequence of their number: network N is evaluated before
network N+1, unless otherwise specified by means of the execution control elements.
Feedback
A feedback path is said to exist in a network when the output of a function or function
block is used as the input to a function or function block which precedes it in the network;
the associated variable is called a feedback variable.
Feedback paths can be utilized subject to the following rules:
1) Feedback variables must be initialized, and the initial value is used during the first
evaluation of the network. Look at the Global variables editor, the Local variables
editor, or the Parameters editor to know how to initialize the respective item.
2) Once the element with a feedback variable as output has been evaluated, the new
value of the feedback variable is used until the next evaluation of the element.
For instance, the Boolean variable RUN is the feedback variable in the example shown
below.
Explicit loop
Implicit loop
Additional Boolean EN (Enable) input and ENO (Enable Out) characterize LogicLab blocks,
according to the declarations
See the Modifying properties of blocks section to know how to add these pins to a block.
When these variables are used, the execution of the operations defined by the block are
controlled according to the following rules:
1) If the value of EN is FALSE when the block is invoked, the operations defined by the
function body are not executed and the value of ENO is reset to FALSE by the program-
mable controller system.
2) Otherwise, the value of ENO is set to TRUE by the programmable controller system,
and the operations defined by the block body are executed.
11.3.4.2 JUMPS
Jumps are represented by a Boolean signal line terminated in a double arrowhead. The
signal line for a jump condition originates at a Boolean variable, or at a Boolean output of
a function or function block. A transfer of program control to the designated network label
occurs when the Boolean value of the signal line is TRUE; thus, the unconditional jump is
a special case of the conditional jump.
The target of a jump is a network label within the program organization unit within which
the jump occurs.
Unconditional Jump
Conditional Jump
- Conditional returns from functions and function blocks are implemented using a RETURN
construction as shown in the table below. Program execution is transferred back to the
invoking entity when the Boolean input is TRUE, and continues in the normal fashion
when the Boolean input is FALSE.
- Unconditional returns are provided by the physical end of the function or function block.
Conditional Return
Description Symbol
Description Symbol
11.4.3 CONTACTS
A contact is an element which imparts a state to the horizontal link on its right side which
is equal to the Boolean AND of the state of the horizontal link at its left side with an ap-
propriate function of an associated Boolean input, output, or memory variable.
A contact does not modify the value of the associated Boolean variable. Standard contact
symbols are given in the following table.
11.4.4 COILS
A coil copies the state of the link on its left side to the link on its right side without modi-
fication, and stores an appropriate function of the state or transition of the left link into
the associated Boolean variable.
Standard coil symbols are shown in the following table.
11.5.1 EXPRESSIONS
An expression is a construct which, when evaluated, yields a value corresponding to one
of the data types listed in the elementary data types table. LogicLab does not set any
constraint on the maximum length of expressions.
Expressions are composed of operators and operands.
11.5.1.1 OPERANDS
11.5.1.2 OPERATORS
Open the table of operators to see the list of all the operators supported by ST. The evalu-
ation of an expression consists of applying the operators to the operands in a sequence
defined by the operator precedence rules.
Operators have different levels of precedence, as specified in the table of operators. The
operator with highest precedence in an expression is applied first, followed by the opera-
tor of next lower precedence, etc., until evaluation is complete. Operators of equal prec-
edence are applied as written in the expression from left to right.
For example if A, B, C, and D are of type INT with values 1, 2, 3, and 4, respectively, then:
A+B-C*ABS(D)
yields -9, and:
(A+B-C)*ABS(D)
11.5.2 STATEMENTS IN ST
All statements comply with the following rules:
- they are terminated by semicolons;
- unlike IL, a carriage return or new line character is treated the same as a space char-
acter;
- LogicLab does not set any constraint on the maximum length of statements.
ST statements can be divided into classes, according to their semantics.
11.5.2.1 ASSIGNMENTS
Semantics
The assignment statement replaces the current value of a single or multi-element variable
by the result of evaluating an expression.
The assignment statement is also used to assign the value to be returned by a function,
by placing the function name to the left of an assignment operator in the body of the
function declaration. The value returned by the function is the result of the most recent
evaluation of such an assignment.
would be used to replace the single data value of variable A by the current value of vari-
able B if both were of type INT.
Examples
a := b ;
assignment
pCV := pCV + 1 ;
assignment
c := SIN( x );
assignment with function invocation
FUNCTION SIMPLE_FUN : REAL
variables declaration
...
function body
...
SIMPLE_FUN := a * b - c ;
END_FUNCTION
assigning the output value to a function
Syntax
1) Function:
dst_var := function_name( arg1, arg2 , ... , argN );
Examples
CMD_TMR( IN := %IX5,
PT:= 300 ) ;
FB invocation with formal argument list:
IN := %IX5 ;
PT:= 300 ;
CMD_TMR() ;
FB invocation with assignment of arguments:
a := CMD_TMR.Q;
FB output usage:
RETURN ;
early exit from function or function block.
Syntax
Note that square brackets include optional code, while braces include repeatable portions
of code.
1) IF:
IF expression1 THEN
stat_list
[ { ELSIF expression2 THEN
stat_list } ]
ELSE
stat_list
END_IF ;
2) CASE:
Examples
IF statement:
IF d 0.0 THEN
nRoots := 0 ;
ELSIF d = 0.0 THEN
nRoots := 1 ;
x1 := -b / (2.0 * a) ;
ELSE
nRoots := 2 ;
x1 := (-b + SQRT(d)) / (2.0 * a) ;
x2 := (-b - SQRT(d)) / (2.0 * a) ;
END_IF ;
CASE statement:
CASE tw OF
1, 5:
display := oven_temp ;
2:
display := motor_speed ;
3:
display := gross_tare;
4, 6..10:
display := status(tw - 4) ;
ELSE
display := 0;
tw_error := 1;
END_CASE ;
Syntax
Note that square brackets include optional code, while braces include repeatable portions
of code.
1) FOR:
FOR control_var := init_val TO end_val [ BY increm_val ] DO
stat_list
END_FOR ;
2) WHILE:
WHILE expression DO
stat_list
END_WHILE ;
3) REPEAT:
REPEAT
stat_list
UNTIL expression
END_REPEAT ;
Examples
FOR statement:
j := 101 ;
FOR i := 1 TO 100 BY 2 DO
IF arrvals[i] = 57 THEN
j := i ;
EXIT ;
END_IF ;
END_FOR ;
WHILE statement:
j := 1 ;
REPEAT statement:
j := -1 ;
REPEAT
j := j + 2 ;
UNTIL j = 101 AND arrvals[i] = 57
END_REPEAT ;
SFC elements
The SFC elements provide a means of partitioning a PLC program organization unit into a
set of steps and transitions interconnected by directed links. Associated with each step is
a set of actions, and with each transition is associated a transition condition.
11.6.1 STEPS
11.6.1.1 DEFINITION
A step represents a situation where the behavior of a program organization unit (POU)
with respect to its inputs and outputs follows a set of rules defined by the associated ac-
tions of the step. A step is either active or inactive. At any given moment, the state of
the program organization unit is defined by the set of active steps and the values of its
internal and output variables.
A step is represented graphically by a block containing a step name in the form of an iden-
tifier. The directed link(s) into the step can be represented graphically by a vertical line
attached to the top of the step. The directed link(s) out of the step can be represented by
a vertical line attached to the bottom of the step.
Representation Description
Step
(graphical representation with
direct links)
LogicLab does not set any constraint on the maximum number of steps per SFC.
Representation Description
Step flag
Step Name_x = TRUE when Step Name_x is active
= FALSE otherwise
The initial state of the program organization unit is represented by the initial values of
its internal and output variables, and by its set of initial steps, i.e., the steps which are
initially active. Each SFC network, or its textual equivalent, has exactly one initial step.
An initial step can be drawn graphically with double lines for the borders, as shown below.
For system initialization, the default initial state is FALSE for ordinary steps and TRUE for
initial steps.
LogicLab cannot compile an SFC network not containing exactly one initial step.
Representation Description
Initial step
(graphical representation with
direct links)
11.6.1.3 ACTIONS
Such a structuring element exists in the lsc file for every step having at least one associ-
ated action.
The time when an action associated to a step is executed depends on its action qualifier.
LogicLab implements the following action qualifiers.
If a step has zero associated actions, then it is considered as having a WAIT function, that
is, waiting for a successor transition condition to become true.
11.6.1.5 JUMPS
Direct links flow only downwards. Therefore, if you want to return to a upper step from a
lower one, you cannot draw a logical wire from the latter to the former. A special type of
block exists, called Jump, which lets you implement such a transition.
A Jump block is logically equivalent to a step, as they have to always be separated by a
transition. The only effect of a Jump is to activate the step flag of the preceding step and
to activate the flag of the step it points to.
Representation Description
Jump
(logical link to the destination step)
11.6.2 TRANSITIONS
11.6.2.1 DEFINITION
A transition represents the condition whereby control passes from one or more steps
preceding the transition to one or more successor steps along the corresponding directed
link. The transition is represented by a small grey square across the vertical directed link.
The direction of evolution following the directed links is from the bottom of the predeces-
sor step(s) to the top of the successor step(s).
Each transition has an associated transition condition which is the result of the evaluation
of a single Boolean expression. A transition condition which is always true is represented
by the keyword TRUE, whereas a transition condition always false is symbolized by the
keyword FALSE.
A transition condition can be associated with a transition by one of the following means:
Representation Description
The scope of a transition name is local to the program organization unit (POU) where the
transition is located.
Normal transition
An evolution from step S3 to step S4
takes place if and only if step S3 is
in the active state and the transition
condition c is TRUE.
Divergent transition
An evolution takes place from S5 to
S6 if and only if S5 is active and the
transition condition e is TRUE, or from
S5 to S8 only if S5 is active and f is
TRUE and e is FALSE.
Convergent transition
An evolution takes place from S7
to S10 only if S7 is active and the
transition condition h is TRUE, or from
S9 to S10 only if S9 is active and j is
TRUE.
Examples
Expected behavior: an
evolution takes place
from S30 to S33 if a is
FALSE and d is TRUE.
The scheme in the
leftmost column
is invalid because
conditions d and TRUE
are directly linked.
Expected behavior: an
evolution takes place
from S32 to S31 if c is
FALSE and d is TRUE.
The scheme in the
leftmost column
is invalid because
direct links flow only
downwards. Upward
transitions can be
performed via jump
blocks.
The <POU name>_HOLD_SFC and <POU name>_RESET_SFC flags are automatically gener-
ated from the code compiler and they belongs to the local variables of the POU which are
referred to.
LogicLab does not show this flags in the variables list of the POU; they are hidden but in
any case they can be used everywhere within the code.
Example
FUNCTION_BLOCK test
VAR_INPUT
…
test_RESET_SFC : BOOL; (* Control flag explicitly declared *)
END_VAR
…
END_FUNCTION_BLOCK
PROGRAM Main
VAR
…
LogicLab makes available to user a library, called SFCControl.pll, to allow the manage
of the SFC states trough commands instead of variable settings.
This library is composed by macros usable only in ST language.
Following are some example of control flags usage, assuming the SFC POU is named Main:
- Hold (freeze):
Main_HOLD_SFC := TRUE;
- Restart from hold state:
Main_HOLD_SFC := FALSE;
- Restart form initial state of a SFC block in hold state:
Main_RESET_SFC := TRUE;
Main_HOLD_SFC := FALSE;
- Reset to initial state and instant restart of SFC block:
Main_RESET_SFC := TRUE; (* automatic reset from compiler *).
11.7.1 MACROS
LogicLab implements macros in the same way a C programming language pre-processor
does.
Macros can be defined using the following syntax:
MACRO <macro name>
PAR_MACRO
<parameter list>
END_PAR
<macro body>
END_MACRO
Note that the parameter list may eventually be empty, thus distinguishing between ob-
ject-like macros, which do not take parameters, and function-like macros, which do take
parameters.
A concrete example of macro definition is the following, which takes two bytes and com-
poses a 16-bit word:
11.7.2 POINTERS
Pointers are a special kind of variables which act as a reference to another variable (the
pointed variable). The value of a pointer is, in fact, the address of the pointed variable; in
order to access the data stored at the address pointed to, pointers can be dereferenced.
Pointer declaration requires the same syntax used in variable declaration, where the type
name is the type name of the pointed variable preceded by a @ sign:
VAR
<pointer name> : @<pointed variable type name>;
END_VAR
For example, the declaration of a pointer to a REAL variable shall be as follows:
VAR
px : @REAL;
END_VAR
A pointer can be assigned with another pointer or with an address. A special operator, ADR,
is available to retrieve the address of a variable.
px := py; (* px and py are pointers to REAL (that is, vari-
ables of type @REAL) *)
px := ADR( x ) (* x is a variable of type REAL *)
px := ?x (* ? is an alternative notation for ADR *)
The @ operator is used to dereference a pointer, hence to access the pointed variable.
px := ADR( x );
@px := 3.141592; (* the approximate value of pi is assigned to x *)
pn := ADR( n );
n := @pn + 1; (* n is incremented by 1 *)
Beware that careless use of pointers is potentially dangerous: indeed, pointers can point
to any arbitrary location, which can cause undesirable effects.
Using of PVOID type
Beware that the pointer type and the pointed variable type must be of the same type; else
an error message is raised when compiling. To avoid type mismatching you can use PVOID
type as pointer type, this way the pointed type will be always accepted.
ERROR
SHORT DESCRIPTION EXPLANATION
CODE
The object indicated (variable or function block) has not
A4097 Object not found
been defined in the application.
The size (in bits) requested by the indicated data type
A4098 Unsupported data type
isn't supported by the target system.
The total allocation space requested by all local variables
A4099 Auto vars space exhausted
exceeds the space available on the target system.
The total allocation space requested by all local retentive
A4100 Retentive vars space exhausted variables exceeds the space available on the target
system.
The total allocation space requested by all local bit
A4101 Bit vars space exhausted (boolean) variables exceeds the space available on the
target system.
The variable indicated is associated with an index that is
A4102 Invalid index in data block
not available in the relative data block.
The variable indicated is associated with a data block
A4103 Data block not found
that doesn't exist (isn't defined) in the target system.
The total size of code used for POU (programs, functions
A4104 Code space exhausted and function blocks) exceed the space available on the
target system.
The variable indicated is associated with a bit index that
A4105 Invalid bit offset
is not available in the relative data block.
A4106 Image variable requested Error code superseded.
The function indicated isn't available on the target
A4107 Target function not found
system.
The indicated instance refers to a function block
A4108 Base object not found
definition non defined.
The indicated variable is associated with a data type
A4109 Invalid base object type
(including function block definition) that isn't defined.
The data type used in the variable definition doesn't
A4110 Invalid data type
exist.
A4111 Invalid operand type The operand type is not allowed for the current operator.
The indicated function block is called by more than one
Function block shares global data task but uses global variables with process image. For
A4112
and is used by more tasks this reason the compiler isn't able to refer to the proper
image variable for each instance of the function block.
Temporary variables allocation
A4113 Internal compiler error.
error
Embedded functions do not
A4114
support arrays as input variables
Too many parameters input to
A4115
embedded function
Incremental build failed, perform
A4116
a full build command
A4117 Less then 10% of free data
A4118 Less then 10% of free retain data