C - Program Files Eliwell Free Studio Application Docs AppManual
C - Program Files Eliwell Free Studio Application Docs AppManual
User Manual
II user manual
Contents
1. Introduction 1
2. Overview 3
3.2 Toolbars 9
3.2.1 Showing/hiding toolbars 9
3.2.2 Moving toolbars 9
4. Managing projects 17
5.2 Variables 33
5.2.1 Global variables 33
5.2.2 Local variables 36
5.2.3 Creating multiple 36
5.3 Tasks 37
5.3.1 Assigning a program to a task 37
5.3.2 Task configuration 38
IV user manual
5.5.2 Search with the Find in project command 49
user manual V
6.4.4 Inserting and connecting blocks 65
6.4.5 Editing networks 66
6.4.6 Modifying properties of blocks 66
6.4.7 Getting information on a block 66
6.4.8 Automatic error retrieval 67
7. Compiling 77
8.4 Simulation 87
VI user manual
8.5.4 Hot restart 87
8.5.5 Reboot target 87
9. Debugging 89
9.2 Oscilloscope 96
9.2.1 Opening and closing the oscilloscope 97
9.2.2 Adding items to the oscilloscope 97
9.2.3 Removing a variable 100
9.2.4 Variables sampling 100
9.2.5 Controlling data acquisition and display 100
9.2.6 Changing the polling rate 107
9.2.7 Saving and printing the graph 107
user manual IX
SAFETY INFORMATION
Important Information
Read these instructions carefully, and look at the equipment to become familiar with the
device before trying to install, operate, or maintain it. The following special messages
may appear throughout this documentation or on the equipment to inform of potential
hazards or to call attention to information that clarifies or simplifies a procedure.
The addition of this symbol to a Danger safety label indicates that an electrical hazard
exists, which will result in personal injury if the instructions are not followed.
This is the safety alert symbol. It is used to alert you to potential personal injury
hazards.
Obey all safety messages that follow this symbol to avoid possible injury or death.
DANGER
DANGER indicates an imminently hazardous situation which, if not avoided, results in death
or serious injury.
WARNING
WARNING indicates a potentially hazardous situation which, if not avoided, can result in
death or serious injury.
CAUTION
CAUTION indicates a potentially hazardous situation which, if not avoided, can result in
minor or moderate injury.
NOTICE
NOTICE is used to address practices not related to physical injury.
PLEASE NOTE
Electrical equipment should be installed, operated, serviced, and maintained only by qualified
personnel.
No responsibility is assumed by Eliwell for any consequences arising out of the use of this
material.
You can download these technical publications and other technical information from our website at:
www.eliwell.it
X user manual
PRODUCT RELATED INFORMATION
WARNING
LOSS OF CONTROL
The designer of any control scheme must consider the potential failure modes of control
paths and, for certain critical control functions, provide a means to achieve a safe state
during and after a path failure. Examples of critical control functions are emergency stop and
overtravel stop, power outage and restart.
Separate or redundant control paths must be provided for critical control functions.
System control paths may include communication links. Consideration must be given to the
implications of unanticipated transmission delays or failures of the link.
Observe all accident prevention regulations and local safety guidelines.(1)
Each implementation of this equipment must be individually and thoroughly tested for proper
operation before being placed into service.
Failure to follow these instructions can result in death, serious injury, or equipment
damage.
(1)For additional information, refer to NEMA ICS 1.1 (latest edition), Safety Guidelines for the
Application, Installation, and Maintenance of Solid State Control and to NEMA ICS 7.1 (latest
edition), Safety Standards for Construction and Guide for Selection, Installation and Operation
of Adjustable-Speed Drive Systems or their equivalent governing your particular location.
WARNING
UNINTENDED EQUIPMENT OPERATION
Only use software approved by Eliwell for use with this equipment.
Update your application program every time you change the physical hardware configuration.
Failure to follow these instructions can result in death, serious injury, or equipment damage
user manual XI
1. INTRODUCTION
user manual 1
2 user manual
2. OVERVIEW
3 4
1
5
2
6
1. Workspace window 2. Output window 3. Source code editors 4. Watch window 5. Library window 6. Status
bar 7. Document bar
user manual 3
2.1.1 THE OUTPUT WINDOW
The Output window is the place where Application prints its output messages. This win-
dow contains four tabs: Build, Find in project, Debug, and Resources.
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, Application can
print on this output window every PLC run-time error (for example, division by zero), lo-
cating the exact position where the error occurred.
Resources
The Resources panel displays messages related to the specific target device Application
is interfacing with.
4 user manual
2.1.4 THE WATCH WINDOW
The Watch window is one of the many debugging tools supplied by Application. Among
the other debugging tools, it is worth mentioning the Oscilloscope (see Paragraph 9.2),
triggers, and the live debug mode (see Paragraph 9.2).
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.
user manual 5
2.1.5.3 TARGET BLOCKS
This panel lists all the system functions and function blocks available on the specific target
device.
The panels described in the preceding paragraphs are usually always available in the Li-
brary window. However, other panels may be added to this window, one for each library
included in the current Application project. For example, the picture above was taken from
a Application project having two included libraries, basic.pll and thermmodel.pll (see
Paragraph 4.7).
6 user manual
2.1.6.1 PROJECT
2.1.6.2 DEFINITIONS
The Definitions panel contains the definitions of all user-defined data types, such as
structures or enumerated types.
2.1.6.3 RESOURCES
The contents of the Resources panel depends on the target device Application is interfac-
ing with: it may include configuration elements, schemas, wizards, and so on.
The definition of both global and local variables is supported by specific spreadsheet-like
editors
user manual 7
8 user manual
3. USING THE ENVIRONMENT
This chapter shows you how to deal with the many UI elements Application is composed
of, in order to let you set up the IDE in the way which best suits to your specific develop-
ment 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).
user manual 9
3.3 DOCKING WINDOWS
3.3.1 SHOWING/HIDING TOOL WINDOWS
The View>Tool windows menu allows you to show (or hide) a tool window (for example,
the Output window).
The tool window is then shown (hidden).
Tool windows can be fastened to one side of a frame in Application or within a frame.
10 user manual
3.3.4 AUTO-HIDE TOOL WINDOWS
By the pin button on the top right corner of the window you can switch the window to
auto-hide mode or to regular docking mode.
You can show or hide the Document bar with the menu option of the same name in the
menu View>Toolbars>Document bar .
user manual 11
3.4.2 THE WINDOW MENU
The Window menu is an alternative to the Document bar: it lists all the currently open
editors and allows to switch between them.
Moreover, this menu supplies a few commands to automate some basic tasks, such as
closing all windows.
You can switch on and off the full screen mode with the View>Full screen .
3.6.1 GENERAL
Autosave: if the Enable Autosave box is checked, Application periodically saves the
whole project. You can specify the period of execution of this task by entering the number
of minutes between two automatic savings in the Autosave interval text box.
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.
You can specify the family and the size of the font used for output window.
12 user manual
3.6.1.3 COMMUNICATION
If enabled, the last used port will be set as the default one.
3.6.1.4 TOOLTIP
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 tool windows.
Reset bars positions: the layout of the dock bars in the IDE will be resetted to de-
fault positions and dimensions. In order to take effect Application must be restarted.
3.6.4 LANGUAGE
You can change the language of the environment by selecting a new one from the list
shown in this panel.
After selecting the new language, press the Select button and confirm by clicking OK.
This change will be effective only the next time you start Application.
user manual 13
3.6.5 TOOLS
You can add up to 16 commands to the Tools menu. These commands can be associated
with any program that will run on your operating system. You can also specify arguments
for any command that you add to the Tools menu. The following procedure shows you
how to add a tool to the Tools menu.
1) Type the full path of the executable file of the tool in the Command text box. Other-
wise, you can specify the filename by selecting it from Windows Explorer, which you
open by clicking the Browse button.
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.
14 user manual
-- Press Add. The name you gave to the new tool is now displayed in the list box at the
top of the panel.
user manual 15
3.6.6 MERGE
Here you can set the merge function behavior (see Paragraph 4.8.3.2 for more details).
16 user manual
4. MANAGING PROJECTS
You are required to enter the name of the new project in the Name control. The string you
enter will also be the name of the folder which will contain all the files making up the Ap-
plication project. The pathname in the Directory control 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, Application completes the operation, creating the project direc-
tory 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 the catalog of target devices available to Application.
When 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.
user manual 17
2) From the shown list select the target device from which you want to upload the pro-
ject.
3) Configure Connection with correct parameters (see Paragraph 8.1 for more details).
4) You can test the connection with the target device by Verify Connection button.
Application tries to establish the connection and reports the test result.
5) If the connection is available confirm the operation by clicking on the Upload Sourc-
es button. When the application upload completes successfully, the project is open
and ready for editing.
4.3.3 AUTOSAVE
Application includes an AutoSave feature that periodically saves your project as you work
on it.
AutoSave saves data in a separate folder, called Backup, stored at the same location of
the project folder.
AutoSave protects your project in the event that Application unexpectedly quits. When
Application is started again, if the Backup folder is present, you are asked to restore the
18 user manual
last valid backup file of the project.
When you close Application correctly the Backup folder and its contents are deleted. You
can specify the interval time (in minutes) between saving.
By default AutoSave is running with 1 minute of interval (see Paragraph 3.6 for more
details).
user manual 19
4.4.3 CLOSING THE PROJECT
You can terminate the working session either by explicitly closing the project or by exiting
Application. In both cases, when there are changes not yet persisted to file, Application
asks you to choose between saving and discarding them.
To close the project, select the item File>Close project ; Application shows the Welcome
page, so that you can rapidly start a new working session.
20 user manual
4.6 PROJECT OPTIONS
You can edit some significant project properties choosing Project>Options... .
-- Use new LD editor: the new Ladder Diagram editor is easier to use, by helping you in
common operations working on the diagram will be faster and more efficient. Note that,
by default, this option is active.
-- Use customizable workspace: allows you to manage your project tree in order to
reach a more efficient workspace. Note that, by default, this option is active.
user manual 21
-- Case sensitivity: you can set the project as case-sensitive checking this option. Note
that, by default, this option is not active.
-- Check function and function block external variables: if this option is disabled,
all functions and function blocks can access to global variables without declaring them
as external variables. Note that, by default, this option is enabled respecting the IEC
61131-3 standard.
-- Print debug information: prints on the output window some significant debug info.
-- Allow only integer indexes for arrays: if this option is checked you cannot use
BYTE, WORD or DWORD as array indexes.
-- Run-time check of array bounds: if this option is checked some check code is added
to verify that array indexes are not out of bounds during run-time. This option is set-
table depending on target device.
-- Run-time check of division by zero: if this option is checked some check code is
added to verify that divisions by zero are not performed on arrays during run-time. This
option is settable depending on target device.
-- Run-time check of pointers: if this option is checked the pointers will be test for their
validity before their use, calling a user-defined function checkptr on target. Therefore
this option is settable depending on target device.
-- Enable SFC control flags (extension to standard): if this option is checked, HOLD
and RESET flags for SFC POU are enabled.
-- Enable WAITING statement (extension to standard): if this option is checked the
WAITING construct for the ST language is added as IEC 61131-3 extension (see Para-
graph 11.7.3 for more details).
-- Data copy size warning threshold (bytes, 0=disable): when arrays or structures
are copied, if their dimension exceed the specified threshold, a warning is emitted in
order to inform the possible loss of performance of the PLC. If the threshold is set to 0,
no warnings are emitted.
-- Disable warning emission: if this option is checked warning emissions are not printed
on the output window.
-- Disable warning codes: if this option is checked some specified warning emissions are
not printed on the output window.
22 user manual
Listing section
-- Generate listing file: if this option is checked the compiler will generate a listing
file named as projectname.lst.
-- Include source code (active only if Generate listing file is checked): if this op-
tion is checked the source code will be inserted as visible in the lst file. Otherwise the
source code will be hidden.
4.6.4 DOWNLOAD
Here you can edit some significant properties of the download behavior (see Paragraph
8.3.1 for more information).
4.6.5 DEBUG
Here you can edit some significant properties of the debug behavior.
user manual 23
-- Polling period for debug function (ms): set the active sampling period of the
functionss status.
-- Number of displayed array elements without alert message: specifies the maxi-
mum number of array elements to be added in watch window without being alerted.
-- Polling period between more variables (ms): set the sleep period between sam-
pling 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).
24 user manual
2) Select one of the target devices listed in the combo box.
3) Click Change to confirm your choice, Cancel to abort.
4) If you confirm, Application displays the following dialog box.
The library manager lists all the libraries currently included in a Application 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 Application project, which
results in all the librarys objects becoming available to the current project.
Including a library means that a reference to the librarys .pll file is added to the cur-
rent project, and that a local copy of the library is made. Note that you cannot edit the
elements of an included library, unlike imported objects.
user manual 25
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 Add button, which causes an explorer dialog box to appear, to let you select
the .pll file of the library you want to open.
3) When you have found the .pll file, open it either by double-clicking it or by press-
ing the Open button. The name of the library and its absolute pathname are now
displayed in a new row at the bottom of the list in the white box.
4) Repeat step 1, 2, and 3 for all the libraries you wish to include.
5) When you have finished including libraries, press either OK to confirm, or Cancel to
quit.
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 projects reference to it.
1) Click Project>Library manager menu of the Application 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.
26 user manual
2) Click Project>Export object to library . This causes the following dialog box to appear.
3) Enter the destination library by specifying the location of its .pll 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) 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 .pll file, Application
creates the file, thus establishing a new library.
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.
user manual 27
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.
When you import an object in a Application 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 Application 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)
you can choose the behavior that Application should keep when encountering those prob-
lems.
The possible actions are:
Take from Do
Ask Automatic
library nothing
If different types X X X
Naming If same type but not
X X X
behavior variables
If both variables X X X
If address overlaps X X X
Address
behavior Copy/paste mapped
X X
variable
28 user manual
-- Take from library: the name or the address is taken from the imported object.
-- Do nothing: the name or the address of the objects in the project are not modified.
After importing objects, Application generates a log file in the project folder with detailed
info.
user manual 29
30 user manual
5. MANAGING PROJECT ELEMENTS
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.
user manual 31
5.1.1.1 ASSIGNING A PROGRAM TO A TASK AT CREATION TIME
When creating a new program, Application 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.
Duplicating a POU:
Select a POU from the project tree then choose the appropriate voice of the menu
Project>Duplicate object . Please note that the menu voice may change according to the
type of the selected POU.
Enter the name of the new duplicated POU and confirm the operation.
Deleting POUs
Select a POU from the project tree then choose the appropriate voice of the menu
Project>Delete Object .
Please note that the item of the sub-menu may change according to the type of the POU
you have selected.
Confirm the operation to delete the POU.
Encrypting a POU:
Select a POU from the project tree then choose the [Crypt] voice of the context menu
32 user manual
Double enter the password and confirm the operation.
Application 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.
5.2 VARIABLES
There are two classes of variables in Application: global variables and local variables.
This paragraph shows you how to add to the project, edit, and eventually remove both
global and local variables.
Global variables are organized in special folders of the project tree called Global vari-
ables group. 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 you need to define almost one Global vari-
ables group in your project then select it from the project tree then choose the ap-
propriate voice of the menu Project>New Object>New variable (see Paragraph 5.7.4).
2) Application 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).
user manual 33
3) Specify the type of the variable either by typing it or by selecting it from the list that
Application displays when you click on the Browse button.
4) You may optionally assign the initial value to the variable or to the single elements
of the array.
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.
34 user manual
-- Select from the list that Application 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 choose the appropri-
ate voice of the menu Project>Duplicate variable .
Enter the name of the new duplicated variable and confirm.
Select the variable you want to delete from the project tree then choose the appropriate
voice of the menu Project>Delete variable .
user manual 35
Confirm the operation to delete the variable.
In order to create, edit, and delete local variables, you have to open the Program Organi-
zation Unit for editing and use the local variables editor. The project needs to be saved
in order to update the POU branch structure of the project tree, including the changes
applied to the local variables.
Refer to the corresponding section in this manual for details (see Paragraph 6.6.1.2).
36 user manual
1) Select the type of the variables.
2) Insert the number of the variables you want to create specifying the start index,
the end index and the step value. You can see an example of the generated variable
names at the bottom of the dialog.
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.
user manual 37
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
The following paragraphs show you how to manage Typedefs.
Application can manage Typedefs, Structures, Enumeration and Subranges.
In order to create, edit or delete those data types, use the Definitions section of the
Worskpace window.
In order to create a Typedef select TypeDefs folder item in the Definitions tree then
choose the [New TypeDef] voice of the context menu.
Application will show you a dialog box where you must specify the name of the new type-
def and select the type you are defining an alias for:
38 user manual
(if you want to define an alias for an array type, you shall choose the array size).
Enter a meaningful description (optional) and confirm the operation.
In order to edit an existing typedef you have to double-click it from the Definitions tree.
The associated editor opens and lets you modify its definition.
In order to delete a Typedef select it from the Definitions tree then choose the [Delete]
voice of the context menu.
5.4.2 STRUCTURES
The following paragraphs show you how to manage structures.
user manual 39
5.4.2.1 CREATING A NEW STRUCTURE
In order to create a Structure select Structure folder item in the Definitions tree then
choose the [New Structure] voice of the context menu.
Application 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 delete an existing structure select it from Structures folder item in the Defi-
nitions tree then choose the [Delete] voice of the context menu.
5.4.3 ENUMERATIONS
The following paragraphs show you how to manage enumerations.
40 user manual
5.4.3.2 EDITING AN ENUMERATION
In order to delete an existing enumeration select it from Enumeration folder item in the
Definitions tree then choose the [Delete] voice of the context menu.
5.4.4 SUBRANGES
The following paragraphs show you how to manage subranges.
In order to create a subrange select Subranges folder item in the Definitions tree
then choose the [New Subrange] voice of the context menu.
Application will show you a dialog box where you must specify the name of the new
subrange and select its basic type.
user manual 41
Enter minimum and maximum values of the subrange, a meaningful description (option-
al), and confirm the operation.
In order to delete an existing subrange select it from Subranges folder item in the Defi-
nitions tree then choose the [Delete] voice of the context menu.
42 user manual
within a project: the Object browser and the Find in project feature.
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 com-
mon 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 (ena-
bled) object items.
In this example, Programs, Function Blocks, Functions are selected, so objects of this
type are shown in the object list. Variables and User types objects can be selected
by user but objects of that type are not currently shown in the object list. Operators,
Standard functions, Local variables, and Basic types cannot be checked by user
(because of the context) so cannot be browsed.
user manual 43
User can also click Check all button to select all available objects at one time or can click
Check none button to deselect all objects at one time.
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.
44 user manual
All= Disables this filter.
Project= Objects declared in the Application project.
Target= Firmware objects.
Use
Library= Objects contained in a library. In this case, use
simultaneously also the Library filter, described below.
Aux sources= Shows aux sources only.
Applies to All objects types.
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.
user manual 45
Vars Type
Filters global variables and system variables (also known
Function
as firmware variables) according to their type.
Set of legal values All, Normal, Constant, Retain
All= Shows all the global and system variables.
Normal= Shows normal global variables only.
Use
Constant= Shows constants only.
Retain= Shows retain variables only.
Applies to Variables.
46 user manual
Object list
Object list shows all the filtered objects. List can be ordered in ascending or descend-
ing 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 dese-
lects all objects.
If at least one item is selected on the list operation, buttons are enabled.
Resize
Window can be resized, the cursor changes along the border of the dialog and allows the
user to resize window. When reopened, Object browser dialog takes the same size and
position of the previous usage.
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:
user manual 47
-- 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
Function Exports an object to a library.
Select the objects you want to export, then press the
Use
Export to library button.
Delete objects
Function Allows you to delete an object.
Select the object you want to delete, then press the
Use
Delete 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 choose the ap-
propriate voice of the menu Project>Import object from library .
Available objects
In this mode you can list objects of these types:
-- Programs.
-- Function blocks.
-- Functions.
48 user manual
-- 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 imported so they are unchecked and disabled.
Available operations
Import objects is the only operation supported in this mode. It is possible to import
selected 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.
user manual 49
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 con-
straint on the location of the objects to be inspected.
3) The frame named Filters contains 7 checkboxes, each of which, if ticked, enables
research of the string among the object it refers to.
4) Tick Match whole word only if you want to compare your string to entire word only.
5) Tick Match case if you want your search to be case-sensitive.
6) Press Find to start the search, otherwise click Cancel to abandon.
The results will be printed in the Find in project tab of the Output window.
50 user manual
5.6 WORKING WITH APPLICATION EXTENSIONS
Applications Workspace window may include a section whose contents completely depend
on the target device the IDE is interfacing with: the Resources panel.
If the Resources panel is visible, you can access some additional features related to the
target device (configuration elements, schemas, wizards, and so on).
Information about these features may be found in a separate document: refer to your
hardware supplier for details.
user manual 51
5.7 PROJECT CUSTOM WORKSPACE
The custom workspace functionalities allow you to organize your project tree according to
your needs, in order to obtain more efficiency in the management of the project.
All organizationals units of the custom workspace are logical: creating and editing those
units will no triggers any effects on the PLC code.
52 user manual
5.7.3 CUSTOM WORKSPACE BASIC UNITS
In the new custom workspace you can work using two different main logic units:
-- Folder: this is an optional logical unit that can contain POUs, folders (you can nest fold-
ers into another one) and global variables group.
-- Global variables group: this is a mandatory logical unit that can only contain global
variables. In order to create a global variable you need to have almost one global vari-
ables 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.
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
user manual 53
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).
Tasks Element
You can not move, rename or delete these elements. They are automatically generated by
Application. For more information about SFC language (see Paragraph 5.3).
54 user manual
6. EDITING THE SOURCE CODE
PLC editors
Application includes five source code editors, which support the whole range of IEC 61131-
3 programming languages: Instruction List (IL), Structured Text (ST), Ladder Diagram
(LD), Function Block Diagram (FBD), and Sequential Function Chart (SFC).
Moreover, Application includes a grid-like editor to support the user in the definition of
variables.
All editors, both graphical and text one, support tooltips. By enabling them (see Para-
graph 3.6.1.4), Application will show some information about symbols on which the user
move the mouse.
This chapter focuses on all these editors.
The IL editor allows you to code and modify POUs using IL (i.e., Instruction List), one of
the IEC-compliant languages.
user manual 55
6.1.3 AUTOMATIC ERROR LOCATION
The IL editor also automatically displays the location of compiler errors. To know where
a compiler error occurred, double-click the corresponding error line in the Output bar.
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.
56 user manual
-- Drag-and-drop of selected text.
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.
user manual 57
6.3 LADDER DIAGRAM (LD) EDITOR
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 .
58 user manual
6.3.3 LABELING NETWORKS
You can modify the usual order of execution of networks through a jump statement, which
transfers the program control to a labeled network. To assign a label to a network, double-
click the raised grey button on the left, which bears the network number.
This causes a dialog box to appear, where you can type the label you want to associate
with the selected network.
If you press OK, the label is printed in the top left-hand corner of the selected network.
user manual 59
-- 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.
60 user manual
expressions (that nevertheless can be connected to BOOL pins) to non-BOOL input pins.
-- 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).
user manual 61
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 output
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)
62 user manual
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.
6.3.16 BRANCHES
The main power line can be branched to create sub-networks, that can be further branched
themselves: to add a branch, select the object after you want to create the branch and
then click the Scheme>Object>New>Branch menu command.
The start of the new branch is marked as a big dot on the source line; deleting all objects
on a branch deletes the branch itself.
Selecting an object on a branch effectively selects the branch, so for example selecting a
contact on a branch and then clicking the Scheme>Object>New>Coil adds the coil on the
branch instead of adding it on the main power line.
user manual 63
6.4 FUNCTION BLOCK DIAGRAM (FBD) EDITOR
The FBD editor allows you to code and modify POUs using FBD (i.e. Function Block Dia-
gram), one of the IEC-compliant languages.
64 user manual
You can perform the following operations on networks:
-- To add a new blank network, click Scheme>Network>New .
-- To assign a label to a selected network, give the Scheme>Network>Label command. This
enables jumping to the labeled network.
-- To display a background grid which helps you to align objects, click View>View greed .
-- To add a comment, click Scheme>Object>New>Comment .
This causes a dialog box to appear, which lets you type the label you want to associate
with the selected network.
If you press OK, the label is printed in the top left-hand corner of the selected network.
user manual 65
blocks, drag them close to each other so as to let the corresponding pins coincide. The
FBD editor automatically draws the logical wires.
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.
66 user manual
6.4.8 AUTOMATIC ERROR RETRIEVAL
The FBD editor also automatically displays the location of compiler errors. To reach the
block where a compiler error occurred, double-click the corresponding error line in the
Output bar.
for steps;
for transitions;
for jumps.
To start implementing an action, you need to open an editor. Do it by applying one of the
following procedures:
-- Click Scheme>Code object>New action .
-- Right-click on the name of the SFC POU in the Workspace window [New action] .
user manual 67
In either case, Application displays a dialog box like the one shown below.
Select one of the languages and type the name of the new action in the text box at the
bottom of the dialog box. Then either confirm by pressing OK, or quit by clicking Cancel.
If you press OK, Application opens automatically the editor associated with the language
you selected in the previous dialog box and you are ready to type the code of the new
action.
Note that you are not allowed to declare new local variables, as the module you are now
editing is a component of the original SFC module, which is the POU where local variables
can be declared. The scope of local variables extends to all the actions and transitions
making up the SFC diagram.
When you have finished writing the code, double-click the step you want to assign the
new action to. This 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
if the step is active. You may also choose, from the list shown in the Code P (Pulse) box,
the name of the action you want to execute each time the step becomes active (that is,
the action 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 schema, action to step assignments are represented by letters on the step
block:
-- action N by letter N in the top right corner;
-- action P by letter P in the bottom right corner.
68 user manual
If later you need to edit the source code of the action, you can just double-click these
letters. Alternatively, you can double-click the name of the action in the Actions folder of
the Workspace window.
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 Browse button shown here below.
user manual 69
Note that you can use any language except SFC to code a condition. Select one of the
languages and type the name of the new condition in the text box at the bottom of the
dialog box. Then either confirm by pressing OK, or quit by clicking Cancel.
If you press OK, Application opens automatically the editor associated with the language
you selected in the previous dialog box and you can type the code of the new condition.
Note that you are not allowed to declare new local variables, as the module you are now
editing is a component of the original SFC module, which is the POU where local variables
can be declared. The scope of local variables extends to all the actions and transitions
making up the SFC diagram.
When you have finished writing the code, double-click the transition you want to assign
the new condition to. This causes the following dialog box to appear.
Select the name of the condition you want to assign to this step. Then confirm by press-
ing OK.
If later you need to edit the source code of the condition, you can double-click the name
of the transition in the Transitions folder of the Workspace window.
70 user manual
6.5.7 SPECIFYING THE DESTINATION OF A JUMP
To specify the destination step of a jump, double-click the jump block in the Chart area.
This causes the dialog box shown below to appear, listing the name of all the existing
steps. Select the destination step, then either press OK to confirm or Cancel to quit.
user manual 71
6.6.1 OPENING A VARIABLES EDITOR
6.6.1.1 OPENING THE GLOBAL VARIABLES EDITOR
In order to open the Global variables editor, double-click on Global variables in the
project tree.
To open a local variables editor, just open the Program Organization Unit the variables you
want to edit are local to.
72 user manual
6.6.2 CREATING A NEW VARIABLE
In order to create a new variable, you may click Variables>Insert .
2) Change the variable type, either by editing the type name in the corresponding cell
or by clicking on the button in that cell and select the desired type from the list that
pops up.
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.
user manual 73
4) In the case of global variables, you can assign the variable to a group, by selecting
it from the list which opens when you click on the corresponding cell. This operation
will change the position of the variable in the project tree.
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.
74 user manual
9) Save the project to persist the changes you made to the declaration of the variable.
WARNING
UNINTENDED EQUIPMENT OPERATION
Ensure that all variables are initialized to an appropriate value before their first use as array
indices.
Write programming instructions to test the validity of operands intended to be used as array
indices.
Do not attempt to access an array element outside the defined bounds of the array.
Do not attempt to assign a value to an array name without using an appropriate index into
the array.
Failure to follow these instructions can result in death, serious injury, or equipment damage
user manual 75
6.6.6 COPYING VARIABLES
The variables editor allows you to quickly copy and paste elements. You can either use
keyboard shortcuts or the Edit>Copy , Edit>Paste menu.
Note: overlapping addresses problems may occur by copying mapped variables. Application can
automatically assign new free address to the new pasted variable and fix the overlap. In
order to enable this functionality please refer to paragraph 3.6 and 4.8.3.2 for further
details.
76 user manual
7. COMPILING
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.
user manual 77
Condition Description
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
n=0, m>0
different way from what you expected: you are encouraged to get rid
of these warnings by editing and re-compiling the application until no
warning messages are emitted.
PLC code entirely correct, compilation accomplished. You should
n=m=0
always work with 0 warnings, 0 errors.
78 user manual
You can then fix the problem and re-compile.
user manual 79
7.3 COMMAND-LINE COMPILER
Applications compiler can be used independently from the IDE: in Applications directory,
you can find an executable file, Command-line compiler, which can be invoked (for ex-
ample, in a batch file) with a number of options.
In order to get information about the syntax and the options of this command-line tool,
just launch the executable without parameters.
80 user manual
8. LAUNCHING THE APPLICATION
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 target
and to download the application, while the wide range of Applications 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.
Note: in case the connection is made through a USB cable, using a virtual COM port on your
PC, Modbus protocol is to be activated.
user manual 81
3) Fill in all the protocol-specific settings (e.g., the address or the communication
timeout - that is how long Application must wait for an answer from the target before
displaying a communication error message).
If the selection is on Modbus, with a USB cable connection, only the proper virtual
COM port is to be selected, leaving all the other parameters as default.
82 user manual
8.1.1 SAVING THE LAST USED COMMUNICATION PORT
When you connect to target devices using a serial port (COM port), you usually use the
same port for all devices (many modern PCs have only one COM port). You may save the
last used COM port and let Application use that port to override the project settings: this
feature proves especially useful when you share projects with other developers, which
may use a different COM port to connect to the target device.
In order to save your COM port settings, enable the Use last port option in File>Options...
menu.
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.
-- 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
user manual 83
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.
84 user manual
8.3.1.1 PROTECTING THE SOURCE CODE WITH A PASSWORD
You may want to protect the source code downloaded to the target device with a pass-
word, so that Application will not open the uploaded project unless the correct password
is entered.
Click the Project>Options... menu and set the password.
user manual 85
8.3.1.2 SOURCE CODE AND DEBUG SYMBOLS DOWNLOAD TIME
From the following select menu you can set the Source code download time.
Choosing:
-- 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 disconnec-
tion.
-- Never: the Source code will be never downloaded to the target.
As well as Source code the Debug symbols download time can be set using the following
select menu with the same options.
86 user manual
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 Applications integrated simulation environment:
Simulation.
In order to start the simulation, just click Debug>Simulation mode .
Refer to Simulations manual to gain information on how to control the simulation.
8.5.1 HALT
You can stop the PLC execution by clicking On-line>Halt
user manual 87
88 user manual
9. DEBUGGING
Application 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.
Application 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.
user manual 89
9.1.2.1 ADDING A VARIABLE FROM A TEXTUAL SOURCE CODE EDITOR
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.
90 user manual
The variable name, value, and location are now displayed in a new row of the Watch win-
dow.
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
user manual 91
or press the F8 key.
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).
92 user manual
9.1.4 REFRESHMENT OF VALUES
9.1.4.1 NORMAL OPERATION
The watch window manager reads periodically 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 refreshment process, the values displayed in the window may refer to dif-
ferent execution states of the PLC code.
If the target device is disconnected, the Value column contains three dots.
If the PLC code changes and Application cannot retrieve the memory location of an object
in the Watch window, then the Value column contains three dots.
If you try to add to the Watch window a symbol which has not been allocated, Application
gives the following error message.
user manual 93
9.1.5 CHANGING THE FORMAT OF DATA
When you add a variable to the Watch window, Application automatically recognizes its
type (unsigned integer, signed integer, floating point, hexadecimal), and displays its value
consistently. Also, if the variable is floating point, Application assigns it a default number
of decimal figures.
However, you may need the variable to be printed in a different format.
To impose another format than the one assigned by Application, press the Format value
button in the toolbar.
2) Enter the file name and choose its destination in the file system.
94 user manual
You can load a watch list from file, removing the opened one, following this procedure:
1) Click on the corresponding icon in the Watch window toolbar.
2) Browse the file system and select the watch list file.
The set of symbols in the watch list is added to the Watch window.
You can load a watch list from file, appending to the opened one, following this procedure:
1) Click on the corresponding icon in the Watch window toolbar.
user manual 95
2) Browse the file system and select the watch list file.
The set of symbols in the watch list is added to the Watch window.
You can clear the current opened watch list by clicking on the following icon:
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 Application frame. This is the interface for accessing the debugging functions that
the Oscilloscope makes available. The Oscilloscope consists of three elements, as shown
96 user manual
in the following picture.
The toolbar allows you to better control the Oscilloscope. A detailed description of the
function of each control is given later in this chapter.
The Chart area includes several items:
-- Plot: area containing the curve of the variables.
-- Vertical cursors: cursors identifying two distinct vertical lines. The values of each vari-
able at the intersection with these lines are reported in the corresponding columns.
-- Scroll bar: if the scale of the x-axis is too large to display all the samples in the Plot
area, the scroll bar allows you to slide back and forth along the horizontal axis.
The lower section of the Oscilloscope is a table consisting of a row for each variable.
user manual 97
9.2.2.1 ADDING A VARIABLE FROM A TEXTUAL SOURCE CODE EDITOR
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.
3) 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.
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.
98 user manual
9.2.2.3 ADDING A VARIABLE FROM A VARIABLES EDITOR
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
or press the F10 key and choose Oscilloscope from the list of debug windows which
pops up.
user manual 99
9.2.3 REMOVING A VARIABLE
If you want to remove a variable from the Oscilloscope, select it by clicking on its name
once, then press the Del key.
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.
In this case, when you click on Restart acquisition, the evolution of the value of the
variable is plotted from scratch.
When you open the Oscilloscope, Application applies a default scale to the axes. However,
if you want to set a different scale, you may follow this procedure:
1) Open the graph properties by clicking on the corresponding item in the toolbar.
3) For each variable, you may specify a distinct scale for the vertical axis.
4) Confirm your settings. The graph adapts to reflect the new scale.
Finally, you may also quickly adapt the scale of the horizontal axis, the vertical axis, or
both to include all the samples, by clicking on the corresponding item of the toolbar.
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 Oscillo-
scope toolbar.
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.
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.
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.
4) Choose a file name and a destination directory, then confirm the operation.
Follow this procedure to print a view of the data plotted in the Oscilloscope:
1) Either suspend or stop the acquisition.
2) Move the time slide bar and adjust the zoom, in order to include in the view the ele-
ments you want to print.
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, a step can be assigned to an action, and a
transition can be associated with a condition code. Actions and conditions can be coded in
any of the IEC 61131-3 languages. 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, Ladder Diagram schemes are animated by highlighting the contacts
and coils whose value is true (in the example, i1 and i2).
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).
9.5 TRIGGERS
9.5.1 TRIGGER WINDOW
The Trigger window tool allows you to select 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.
Trigger window icons are part of the Debug toolbar and are enabled only if Application is
in debug mode.
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.
Exact location of the trigger, within module ModuleName.
If ModuleName is in IL, Location has the following format:
N1
Otherwise, if ModuleName is in FBD, it becomes:
N2$BT:BID
Location
where:
N1 = instruction line number
N2 = network number
BT = block type (operand, function, function block, etc.)
BID = block identifier
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 except Ac, the Accumulator display button, are not accessible until at least
one variable is dragged into the debug window.
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.
The value of variables is refreshed every time the window manager is triggered, that is
every time the processor executes the instruction marked by the green arrowhead. How-
ever, you can set controls in order to have variables refreshed only when triggers satisfy
the more limiting conditions you define.
Note that the value of the variables in column Symbol is read from memory just before
the marked instruction (in this case: the instruction at line 5) and immediately after the
previous instruction (the one at line 4) has been performed.
Thus, in the above example the second ST statement has not been executed yet when the
new value of a is read from memory and displayed in the trigger window. Thus the result
of the second ST a is 1.
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 behavior of the window, regard-
less for the type of the module (either IL or FBD) where the related trigger has been
inserted.
All controls except the Accumulator display 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-
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
trigger.
-- For: assuming that you gave the counter limit the value N, the window manager adds
1 to the current value of the counter and refreshes the value of its variables, each time
the debug window is triggered. However, when the counter equals N, the window stops
refreshing the values, and it changes to the Stop state.
-- After: assuming that you gave the counter limit the value N, the window manager re-
sets the counter and adds 1 to its current value each time it is triggered. The window
remains in the Ready state and does not update the value of its variables until the
counter reaches N.
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.
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 variables 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.
Let us also assume that you want to know the values of C, D, and K, just before the ST
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 3, and click the ADD block.
You can click Debug>Set/Remove 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
ADD instruction in network 3 is expanded to:
LD k
ADD 1
ST k
When you add a trigger to an FBD block, you actually place the trigger before the first
statement 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 .
The cursor will become as follows.
Now you can click the block representing the variable you wish to be shown in the trigger
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, also containing the following instructions.
In this case, the same rules apply as to insert a trigger in an FBD module on a contact
or a coil
In this case, follow the SE instructions. Let us also assume that you want to know the
value of some variables every time the processor reaches network number 1.
First you must click one of the items making up network number 1. 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.
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 B in the trigger window, select its reference in the Debug win-
dow column, then press OK.
The name of the variable is now printed in the Symbol column.
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 e, d, and f, just before the in-
struction
f := f+ SHR( d, 16#04 )
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 paragraph deals with trigger windows controls, which allow you to better supervise
the working of this debugging tool to get more information on the code under scope. The
main purpose of trigger window controls is to let you define more limiting conditions, so
that variables in Variables window are refreshed when the processor reaches the trig-
ger location and these conditions are satisfied. If you do not use controls, variables are
refreshed every single time the processor reaches the relative trigger.
Enabling controls
When you set a trigger, all the elements in the Control window look disabled.
As a matter of fact, you cannot access any of the controls, except the Accumulator dis-
play, until at least one variable is dragged into the Debug window. When this happens
triggering automatically starts and the Controls window changes as follows.
Defining a condition
This control enables users to set a condition on the occurrences of a trigger. By default,
this condition is set to TRUE, and the values in the debug window are refreshed every time
the window manager is triggered.
If you want to put a restriction on the refreshment mechanism, you can specify a condi-
tion by clicking on the apposite button.
When you do so, a text window pops up, where you can write the IL code that sets the
condition.
Once you have finished writing the condition code, click the OK button to install it, or press
the Esc button to cancel. If you choose to install it, the values in the debug window are
refreshed every time the window manager is triggered and the user-defined condition is
true.
The text window appears, containing the text you originally wrote, which you can now
edit.
To completely remove a user-defined condition, delete the whole IL code in the text win-
dow, then click OK.
After the execution of the condition code, the accumulator must be of type Boolean (TRUE
or FALSE), otherwise a compiler error occurs.
Only global variables and dragged-in variables can be used in the condition code. Namely,
all variables local to the module where the trigger was originally inserted are out of scope,
if they have not been dragged into the debug window. No new variables can be declared
in the condition window.
This web page deals with what you can do when you finish a debug session with a trigger
window. 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.
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.
1
2
Where
To watch a variable, you need to copy it to the lower section of the Debug window.
1. Variables 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.
Note that you can drag into the graphic 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 controls of the Graphic trigger window. Controls allow you
to specify in detail when Application is supposed to sample the variables added to the
Variables window.
Graphic trigger window controls act in a well-defined way on the behavior 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.
Vertical Zoom In
Vertical Zoom acts only on the vertical axis.
and Zoom Out
Trigger counter
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.
General
Control
Control Description
Tick this control to display a grid in the Chart area
Show grid
background.
Show time The scroll bar at the bottom of the Chart area is
bar available as long as this box is checked.
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.
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 c, d, and k, just before the ST
k 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 3, and click the ADD block.
Now click Debug>Add/Remuve grafic trigger .
This causes the colour of the selected block to turn to green, a white circle with the trig-
ger ID number inside to appear in the middle of the block, and the related trigger window
to 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.
In this case, the same rules apply as to insert the graphic trigger in an FBD module on a
contact
or coil
In this case, follow the instructions. Let us also assume that you want to know the value
of some variables every time the processor reaches network number 1.
Note that unlike the other languages supported by Application, 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 pro-
cessor 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.
In order to plot the curve of variable b, select Graphic trace in the Debug windows col-
umn, then press OK. The name of the variable is now printed in the Track 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.
Once the first variable is dropped into a graphic trace, the Graphic properties window
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 e, d, and f, just before the in-
struction
f := f+ SHR( d, 16#04 )
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 trig-
ger 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.
If you want to remove a variable from the Graphic trigger window, select it by clicking its
name once, then press the Del key.
This paragraph deals with graphic trigger window controls, which allow you to better
supervise the working of this debugging tool, so as to get more information on the code
under scope.
Enabling controls
When you set a trigger, all the elements in the Control bar are enabled. You can start
data acquisition by clicking the Start graphic trace acquisition button.
If you defined a user condition, which is currently false, data acquisition does not start,
even though you press the apposite button.
On the contrary, once the condition becomes true, data acquisition starts and continues
until the Start graphic trace acquisition button is released, regardless for the con-
dition being or not still true.
if you release the Start graphic trace acquisition button before all the required
samples have been acquired, the acquisition process stops and all the collected data get
lost.
Defining a condition
This control enables users to set a condition on when to start acquisition. By default, this
condition is set to true, and acquisition begins as soon as you press the Enable/Disable
acquisition button. From that moment on, the value of the variables in the Debug win-
dow is sampled every time the trigger occurs.
In order to specify a condition, open the Condition tab of the Options dialog box, then
press the relevant button.
A text window pops up, where you can write the IL code that sets the condition.
The text window appears, containing the text you originally wrote, which you can now
edit.
To completely remove a user-defined condition, press again on the above mentioned but-
ton, delete the whole IL code in the text window, then click OK.
After the execution of the condition code, the accumulator must be of type Boolean (TRUE
or FALSE), otherwise a compiler error occurs.
Only global variables and dragged-in variables can be used in the condition code. Namely,
all variables local to the module where the trigger was originally inserted are out of scope,
if they have not been dragged into the Debug window. Also, no new variables can be de-
clared in the condition window.
9.6.2.11 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.
View project
Opens an existing Application project in read-only mode.
(read only)
Saves the current open project specifying new name, location and
Save project As
extension.
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.
Tool windows
PLC run-time
Shows or hides the PLC run-time window.
status
Cross Reference
Not implemented yet.
window
Show comments for Shows or hides comments for individual objects, not only for
objects networks. (Only for LD editor).
New variable
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 Application object to a library.
library
Macros
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 image upload If the target device is connected, lets you upload the img file.
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.
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
Change current in- Changes the current function block instance (live
stance debug mode).
New
Object
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 contact parallel before the selected one into the
Shift+P
before selected network.
Parallel contact Adds a contact parallel after the selected one into the
after selected network.
Serie contact Adds a contact in series before the selected one into
before the selected network.
Set output line Set selected pin as the output line of the block.
New
Modify
Code Object
Ctrl+
Insert Adds a new row to the grid in the currently active editor.
Shift+ins
Opens a dialog box which lets you create and delete groups
Group
of variables.
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.
10.2.3 LD TOOLBAR
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 end by the special character combina-
tions (* and *), respectively. Comments are permitted anywhere in the program,
and they have no syntactic or semantic significance in any of the languages defined in
this standard.
The use of nested comments, e.g., (* (* NESTED *) *), is treated as an error.
Note: the actual implementation of the BOOL data type depends on the processor of the target
device, e.g. it is 1 bit long for devices that have a bit-addressable area.
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
value assigned to the previous identifier augmented by one.
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;
elem3 : INT;
11.1.4 LITERALS
A character string 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
'$'' String of length one containing the single quote character
Two-character combinations beginning with the dollar sign shall be interpreted as shown
in the following table when they occur in character strings.
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 data element with physical or logical locations in the programmable controllers input,
output, or memory structure.
Each program organization unit (POU) (i.e., each program, function, or function block)
contains at its beginning at least one declaration part, consisting of one or more structur-
ing elements, which specify the types (and, if necessary, the physical or logical location)
of the variables used in the organization unit. This declaration part has the textual form of
one of the keywords VAR, VAR_INPUT, or VAR_OUTPUT as defined in the keywords section,
followed in the case of VAR by zero or one occurrence of the qualifiers RETAIN, NON_RE-
TAIN or the qualifier CONSTANT, and in the case of VAR_INPUT or VAR_OUTPUT by zero or
one occurrence of the qualifier RETAIN or NON_RETAIN, followed by one or more decla-
rations separated by semicolons and terminated by the keyword END_VAR. A declaration
may also specify an initialization for the declared variable, when a programmable control-
ler supports the declaration by the user of initial values for variables.
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. 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
declared with the CONSTANT qualifier;
-- a variable declared as VAR_GLOBAL CONSTANT in a configuration element or program or-
ganization unit (the containing element) is used in a VAR_EXTERNAL declaration (with-
out the CONSTANT qualifier) of any element contained within the containing element.
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.
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.
11.1.5.7 LOCATION
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 controllers 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.index
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 Application 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, Application 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
VAR
declaration of local variables (see the relevant section)
END_VAR
Function body
END_FUNCTION
Keyword Description
FunctionName Name of the function being declared.
RetDataType Data type of the value to be returned by the function.
Specifies the operations to be performed upon the
input variables in order to assign values dependent on
the functions 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 Application.
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
declaration of local variables
END_VAR
Function block body
END_FUNCTION_BLOCK
Keyword Description
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 Application.
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_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_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_UINT
Description Conversion to UINT (16-bit unsigned integer)
Number of operands 1
Input data type Any numerical type or STRING
Output data type UINT
out := TO_UINT( 1000.0 ); (* out = 1000 *)
Examples
out := TO_UINT( 16#8000 ); (* out = 32768 *)
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_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_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_DWORD
Description Conversion to DWORD (32-bit string)
Number of operands 1
Input data type Any numerical type or STRING
Output data type DWORD
out := TO_DWORD( 10.0 ); (* out = 16#0000000A *)
Examples
out := TO_DWORD( -1 ); (* out = 16#FFFFFFFF *)
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 *)
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 input #0
Number of operands 1
Input data type Any numerical type
Output data type Same as input
OUT := ABS( -5 );(* OUT = 5 *)
Examples OUT := ABS( -1.618 );(* OUT = 1.618 *)
OUT := ABS( 3.141592 );(* OUT = 3.141592 *)
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 *)
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 *)
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 *)
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 *)
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 *)
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 *)
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 *)
MUL
Description Arithmetic multiplication. Multiplies the two inputs.
Number of operands 2
Input data type Any numerical type, Any numerical type
Output data type Same as Inputs
Examples OUT := MUL( 10, 10 ); (* OUT = 100 *)
SUB
Description Arithmetic subtraction. Subtracts input #1 from input #0
Number of operands 2
Input data type Any numerical type, Any numerical type
Output data type Same as Inputs
Examples OUT := SUB( 10, 3 ); (* OUT = 7 *)
MOD
Description Module. Computes input #0 module input #1
Number of operands 2
Input data type Any numerical type, Any numerical 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 *)
ATAN2*
Arc tangent (with 2 parameters). Computes the principal arc
Description
tangent of Y/X; result is expressed in radians
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 := ATAN2( 0.0, 1.0 ); (* OUT = 0.0 *)
OUT := ATAN2( 1.0, 1.0 ); (* OUT = PI / 4 *)
Examples OUT := ATAN2( -1.0, -1.0 ); (* OUT = ( -3/4 ) * PI
*)
OUT := ATAN2( 1.0, 0.0 ); (* OUT = PI / 2 *)
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 *)
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 *)
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 *)
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 *)
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
OUT := SHL( IN := 16#1000CAFE, 16 );
Examples
(* OUT = 16#CAFE0000 *)
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 *)
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 *)
OR
Logical OR if both Input #0 and Input #1 are BOOL,
Description
otherwise bitwise OR.
Number of operands 2
Input data type Any but STRING, Any but STRING
Output data type Same as Inputs
OUT := TRUE OR FALSE; (* OUT = FALSE *)
Examples
OUT := 16#1234 OR 16#5678;(* OUT = 16#567C *)
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 *)
Selection functions
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 *)
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 *)
MIN
Description Minimum value selection
Number of operands 2, extensible
Any numerical type, Any numerical type, .., Any numerical
Input data type
type
Output data type Same as min Input
Examples OUT := MIN( -8, 120, -1000 ); (* OUT = -1000 *)
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 *)
Comparison functions
Comparison functions can be also used to compare strings if this feature is supported by
target device.
GT
Greater than. Returns TRUE if Input #0 > Input #1,
Description
otherwise FALSE.
Number of operands 2
Input data type Any but BOOL, Any but BOOL
Output data type BOOL
OUT := GT( 0, 20 ); (* OUT = FALSE *)
Examples
OUT := GT( AZ, ABC ); (* OUT = TRUE *)
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 *)
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 *)
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 *)
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 *)
CONCAT
Description Character string concatenation
Number of operands 2
Input data type STRING, STRING
Output data type STRING
Examples OUT := CONCAT( AB, CD ); (* OUT = ABCD *)
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
*)
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_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_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
*)
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-
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 Application blocks,
according to the declarations
EN ENO
VAR_INPUT VAR_OUTPUT
EN: BOOL := 1; ENO: BOOL;
END_VAR END_VAR
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. Application 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)
yields 0.
When an operator has two operands, the leftmost operand is evaluated first. For example,
in the expression
SIN(A)*COS(B)
the expression SIN(A) is evaluated first, followed by COS(B), followed by evaluation of
the product.
Functions are invoked as elements of expressions consisting of the function name fol-
lowed by a parenthesized list of arguments, as defined in the relevant section.
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;
-- Application does not set any constraint on the maximum length of statements.
ST statements can be divided into classes, according to their semantics.
Syntax
An assignment statement consists of a variable reference on the left-hand side, followed
by the assignment operator :=, followed by the expression to be evaluated. For in-
stance, the statement
A := B ;
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
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.
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) ;
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 ;
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.
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)
Application does not set any constraint on the maximum number of steps per SFC.
Step flag
The step flag (active or inactive state of a step) can be represented by the logic value of a
Boolean variable ***_x, where *** is the step name. This Boolean variable has the value
TRUE when the corresponding step is active, and FALSE when it is inactive. The scope of
step names and step flags is local to the program organization unit where the steps ap-
pear.
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.
Application 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.
Application 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)
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.
Example Rule
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.
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.
Application 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.
Application 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
Application implements macros in the same way a C programming language pre-proces-
sor 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:
MACRO MAKEWORD
PAR_MACRO
lobyte;
hibyte;
END_PAR
{ CODE:ST }
lobyte + SHL( TO_UINT( hibyte ), 8 )
END_MACRO
Whenever the macro name appears in the source code, it is replaced (along with the ac-
tual parameter list, in case of function-like macros) with the macro body. For example,
given the definition of the macro MAKEWORD and the following Structured Text code frag-
ment:
w := MAKEWORD( b1, b2 );
the macro pre-processor expands it to
w := b1 + SHL( TO_UINT( b2 ), 8 );
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:
WARNING
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 ++ 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