Unity Pro Programming
Unity Pro Programming
35006144 07/2012
Unity Pro
Program Languages and Structure
Reference Manual
35006144.12
07/2012
www.schneider-electric.com
35006144 07/2012
Table of Contents
Safety Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
About the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
13
15
17
18
23
25
27
33
38
46
49
51
53
57
58
59
60
61
62
69
70
73
75
35006144 07/2012
75
77
78
79
80
81
83
84
85
87
88
89
90
92
93
94
95
97
98
100
102
105
107
108
112
113
115
4.1 Memory Structure of the Premium, Atrium and Modicon M340 PLCs . . .
Memory Structure of Modicon M340 PLCs . . . . . . . . . . . . . . . . . . . . . . .
Memory Structure of Premium and Atrium PLCs. . . . . . . . . . . . . . . . . . .
Detailed Description of the Memory Zones . . . . . . . . . . . . . . . . . . . . . . .
4.2 Memory Structure of Quantum PLCs. . . . . . . . . . . . . . . . . . . . . . . . . . . .
Memory Structure of Quantum PLCs . . . . . . . . . . . . . . . . . . . . . . . . . . .
Detailed Description of the Memory Zones . . . . . . . . . . . . . . . . . . . . . . .
116
117
121
123
124
125
128
131
132
133
135
139
142
143
144
145
147
152
155
156
156
35006144 07/2012
157
158
159
160
162
164
167
170
174
177
179
180
184
189
191
193
205
206
208
209
213
214
216
217
219
220
221
222
227
228
231
238
241
35006144 07/2012
238
243
244
245
247
249
250
251
252
253
255
260
262
263
264
266
267
268
269
269
274
274
277
278
279
281
282
285
286
288
291
293
294
295
297
299
302
302
304
304
306
306
311
312
316
319
327
328
330
333
337
35006144 07/2012
Chapter 13
341
342
344
354
355
356
358
359
362
367
369
376
387
388
390
393
394
403
405
407
413
339
370
373
374
414
415
419
420
421
424
428
429
431
432
435
436
438
440
440
441
441
7
13.7
442
443
445
447
447
448
449
450
451
454
456
459
460
462
465
469
470
475
14.1
500
501
506
518
527
14.2
15.1
15.2
476
477
481
484
486
496
497
499
528
529
532
534
539
540
541
544
545
546
547
548
551
35006144 07/2012
559
560
566
574
581
552
553
554
555
556
557
558
583
584
586
589
590
592
596
598
601
602
603
604
607
608
611
614
616
619
623
625
625
Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
627
629
35006144 07/2012
630
632
633
637
644
651
653
660
661
B.1
662
662
664
665
677
679
680
681
682
685
687
687
689
689
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
691
719
B.2
B.3
B.4
10
35006144 07/2012
Safety Information
Important Information
NOTICE
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 warn
of potential hazards or to call attention to information that clarifies or simplifies a
procedure.
35006144 07/2012
11
PLEASE NOTE
Electrical equipment should be installed, operated, serviced, and maintained only by
qualified personnel. No responsibility is assumed by Schneider Electric for any
consequences arising out of the use of this material.
A qualified person is one who has skills and knowledge related to the construction
and operation of electrical equipment and its installation, and has received safety
training to recognize and avoid the hazards involved.
12
35006144 07/2012
At a Glance
Document Scope
This manual describes the elements necessary for the programming of Premium,
Atrium and Quantum PLCs using the Unity Pro programming workshop.
Validity Note
This documentation is valid from Unity Pro V7.0.
Product Related Information
WARNING
UNINTENDED EQUIPMENT OPERATION
The application of this product requires expertise in the design and programming
of control systems. Only persons with such expertise should be allowed to
program, install, alter, and apply this product.
Follow all local and national safety codes and standards.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
User Comments
We welcome your comments about this document. You can reach us by e-mail at
techcomm@schneider-electric.com.
35006144 07/2012
13
14
35006144 07/2012
Unity Pro
General Presentation
35006144 07/2012
35006144 07/2012
15
General Presentation
16
35006144 07/2012
Unity Pro
Presentation
35006144 07/2012
Presentation
1
Overview
This chapter describes the general design and behavior of a project created with
Unity Pro.
What Is in This Chapter?
This chapter contains the following topics:
Topic
Capabilities of Unity Pro
35006144 07/2012
Page
18
User Interface
23
Project Browser
25
27
Configurator
33
Data Editor
38
Program Editor
46
49
51
53
Instruction List IL
57
Structured Text ST
58
PLC Simulator
59
Export/Import
60
User Documentation
61
Debug Services
62
Diagnostic Viewer
69
Operator Screen
70
17
Presentation
Programming Languages
Unity Pro provides the following programming languages for creating the user
program:
Function Block Diagram FBD
Ladder Diagram (LD) language
Instruction List IL
Structured Text ST
Sequential Control SFC
Ladder Logic 984 (LL984)
All of these programming languages can be used together in the same project.
All these languages conform to IEC 61131-3.
Block Libraries
The blocks that are included in the delivery of Unity Pro extensive block libraries
extend from blocks for simple Boolean operations, through blocks for strings and
array operations to blocks for controlling complex control loops.
For a better overview the different blocks are arranged in libraries, which are then
broken down into families.
The blocks can be used in the programming languages FBD, LD, IL and ST.
Elements of a Program
A program can be constructed from:
a Master task (MAST)
a Fast task (FAST)
one to four AUX Tasks (not available for Modicon M340)
sections, which are assigned one of the defined tasks
sections for processing time controlled events (Timerx)
sections for processing hardware controlled events (EVTx)
subroutine sections (SR)
18
35006144 07/2012
Presentation
Software Packages
The following software packages are available:
Unity Pro S
Unity Pro M
Unity Pro L
Unity Pro XL
Unity Pro XLS
Performance Scope
The following table shows the main characteristics of the individual software
packages:
Unity Pro S
Unity Pro M
Unity Pro L
Unity Pro XL
Function Block +
Diagram FBD
Ladder
Diagram (LD)
language
Instruction
List IL
+(2)
Structured
Text ST
+(2)
Sequential
Language
SFC
+(2)
Standard
library
+(2)
Control library
+(2)
Communication library
+(2)
Diagnostics
library
+(2)
I/O
Management
library
+(2)
System library
+(2)
Motion control
drive library
+(2)
TCP Open
library
optional
optional
optional
optional (2)
Programming languages
Libraries (1)
35006144 07/2012
19
Presentation
Obsolete
library
Unity Pro S
Unity Pro M
Unity Pro L
Unity Pro XL
+(2)
MFB library
+(2)
Safety library
Memory card
file
management
library
+(2)
General information
Create and
use data
structures
(DDTs)
+(2)
Create and
use Derived
Function
Blocks (DFBs)
+
Project
browser with
structural
and/or
functional view
Managing
access rights
Operator
screen
Diagnostic
viewer
System
diagnostics
Project
diagnostics
+(2)
Application
converter
PL7 converter
PL7 converter
Concept Converter
PL7 converter
Concept
Converter
PL7 converter
Concept
Converter
Managing
multi-stations
Supported platforms
Modicon M340 BMX P34 1000 BMX P34 1000
BMX P34 20 BMX P34 20
20
35006144 07/2012
Presentation
Unity Pro S
Unity Pro M
Unity Pro L
Unity Pro XL
Premium
P57 0244M
P57 CA 0244M
P57 CD 0244M
P57 104M
P57 154M
P57 1634M
P57 204M
P57 254M
P57 2634M
H57 24M
All CPUs
All CPUs
Quantum
CPU 311 10
CPU 434 12 U/A
CPU 534 14 U/A
CPU 651 50
CPU 651 60
CPU 652 60
CPU 670 60
CPU 671 60
CPU 672 60
CPU 672 61
CPU 311 10
CPU 434 12 U/A
CPU 534 14 U/A
CPU 651 50
CPU 651 60
CPU 652 60
CPU 670 60
CPU 671 60
CPU 672 60
CPU 672 61
CPU 651 60 S
CPU 671 60 S
Atrium
PCI 57 204
All CPUs
All CPUs
All CPUs
Simulator
Hyperlinks
Unity Pro
Server (for
OFS, UAG)
Openess
OS Loader tool +
+ HW
Firmware
Unity loader
Documentation as context
help and PDF
Legend:
+ = available
+ (1) = Availability of the blocks depends on the hardware platforms (see Unity Pro,
Standard, Block Library).
+ (2) = Available on all PLC except platforms CPU 651 60 S, CPU 671 60 S.
- = not available
35006144 07/2012
21
Presentation
Naming Convention
In the following documentation, "Unity Pro" is used as general term for "Unity Pro S",
"Unity Pro M", "Unity Pro L", "Unity Pro XL" and "Unity Pro XLS".
22
35006144 07/2012
Presentation
User Interface
Overview
The user interface consists of several, configurable windows and toolbars.
User interface:
35006144 07/2012
23
Presentation
Legend:
24
Number
Description
35006144 07/2012
Presentation
Project Browser
Introduction
The Project Browser displays all project parameters. The view can be shown as
structural (topological) and/or functional view.
Structural View
The project browser offers the following features in the structural view:
Creation and deletion of elements
The section symbol shows the section programming language and if it is
protected (in case of an empty section the symbol is grey)
View the element properties
Creation of user directories
Launching the different editors
Start the import/export function
35006144 07/2012
25
Presentation
Functional View
The project browser offers the following features in functional view:
Creation of functional modules
Insertion of sections, animation tables etc. using Drag and Drop from the
structural view
Creation of sections
View the element properties
Launching the different editors
The section symbol shows the section programming language and other
attributes
26
35006144 07/2012
Presentation
Drawbacks
Each time a STU file is saved, a backup copy is also created, with the same name
as the STU file, and the extension BAK files. By changing the file extension from
BAK to STU, it is possible to revert to the state the project was, the last time it was
saved. BAK files are stored in the same folder as the project STU file.
35006144 07/2012
27
Presentation
STA File
This file type is used for archiving projects and can be created only after the project
has been generated. This file type allows forward compatibility between the different
versions of Unity Pro.
There is 2 ways to create a STA file:
STA file can be created manually by accessing the File Save Archive menu
in the Unity Pro main window.
STA file is created automatically every time the project is saved as a STU file if
it is in Built state.
NOTE: The STA file created automatically is saved into the same directory and with
the same filename as the STU project file, except that a .Auto suffix is appended
to the filename. If an existing automatic STA file already exists, it is overwritten
without any confirmation.
NOTE: If the project is in Built state, saving a STU file through a Unity Pro Server
creates a STA file as well.
The following table presents the STA file advantages and drawbacks:
Advantages
Drawbacks
been generated.
size memory supports.
28
35006144 07/2012
Presentation
Choose a location for the file to be saved. Do not save files in the default Schneider
Electric directory:
C:\Program Files\Schneider Electric\Unity Pro
Files saved in this directory may be deleted during Unity Pro installation.
Click on Save.
Remember the location where the *.STA file is stored on the terminal as it will be
needed when recovering the project.
35006144 07/2012
Step
Action
Click on Open.
29
Presentation
XEF File
This file type is used for exporting projects in an XML source format and can be
created at any stage of a project.
The following table presents the XEF file advantages and drawbacks:
Advantages
Drawbacks
Medium size.
ZEF File
This file type is used for exporting projects with global DTMs configuration and can
be created at any stage of a project. For details on project export/import, refer to
chapter Import / Export (see Unity Pro, Operating Modes).
The following table presents the ZEF file advantages and drawbacks:
Advantages
Drawbacks
Medium size.
30
35006144 07/2012
Presentation
Action
Choose a location for the file to be saved. Do not save files in the default Schneider
Electric directory:
C:\Program Files\Schneider Electric\Unity Pro
Files saved in this directory may be deleted during Unity Pro installation.
Click on Export and select the export file format (*.ZEF or *.XEF).
Remember the location where the *.ZEF or *.XEF file is stored on the workstation as
it is needed when recovering the project.
Action
Click on Open.
Computability Information
The STU files are not compatible across Unity Pro versions. In order to use a project
with different Unity Pro versions, users must either store, the:
Unity Pro Archived Application Files (STA):
With the STA file, it is possible to reuse the current built project with the new
Unity Pro version installed on the computer.
Unity Pro Application Exchange Files (ZEF):
The ZEF file must be used if the project has been built.
Unity Pro Application Exchange Files (XEF):
The XEF file must be used if the project has been built.
35006144 07/2012
31
Presentation
STU
STA
XEF
ZEF
Binary applications
Yes
Yes
No
No
Source applications
Yes
Yes
Yes
Yes
Internal database
Yes
No
No
No
10
1.6
10
10
10
Possible
Possible
Not possible,
see (2)
Not possible,
see (2)
File backup
Possible
Possible,
see (3)
Possible
Possible
32
35006144 07/2012
Presentation
Configurator
Configurator Window
The configurator window is split into two windows:
Catalog window
A module can be selected from this window and directly inserted in the graphical
representation of the PLC configuration by dragging and dropping.
Graphical representation of the PLC configuration
Representation of the Configurator window:
One of the following shortcut menus is called depending on the position of the
mouse pointer:
Mouse pointer on the background allows among others:
Change CPU,
Selection of different Zoom factors.
35006144 07/2012
Presentation
Module Configuration
The module configuration window (called via the modules shortcut menu or a
double-click on the module) is used to configure the module. This also includes
channel selection, selection of functions for the channel selected, assignment of
State RAM addresses (only Quantum) etc.
Module configuration window for a Premium I/O module:
34
35006144 07/2012
Presentation
Module Properties
The module properties window (called via the modules shortcut menu) shows the
modules properties such as the power consumption, number of I/O points (only
Premium) and more.
The module properties window for the power supply shows the total current of the
rack:
35006144 07/2012
35
Presentation
Network Configuration
The network configuration is called via the communications folder.
Network configuration:
36
35006144 07/2012
Presentation
35006144 07/2012
37
Presentation
Data Editor
Introduction
The data editor offers the following features:
Declaration of variable instances
Definition of derived data types (DDTs)
Definition of Device derived data types (Device DDTs)
Instance declaration of elements and derived function blocks (EFBs/DFBs)
Definition of derived function block (DFBs) parameters
The following functions are available in all tabs of the data editor:
Copy, Cut, Paste
Expand/collapse structured data
Sorting according to Type, Symbol, Address etc.
Filter
Inserting, deleting and changing the position of columns
Drag and Drop between the data editor and the program editors
Undo the last change
Export/Import
Variables
The Variables tab is used for declaring variables.
Variables tab:
38
35006144 07/2012
Presentation
35006144 07/2012
39
Presentation
Each I/O Module is associated with one implicit device DDT instance:
Implicit Device DDT instances are created by default on device insertion and
refreshed automatically by the PLC. They contain the modules status, modules
and channels health bits, values of the modules inputs, values of the modules
outputs, etc.
The Implicit Device DDT can be:
linked to a device (Managed)
not linked to a device (Un-managed)
NOTE: IODDT and topologic address (see Modicon M340 with Unity Pro, CANopen,
User Manual) are no longer supported with the Modicon M340 remote I/O modules.
All the informations (bits and registers) related to a channel are accessible directly
as a field of device DDT structure.
NOTE: Optional Explicit structures are DDT Explicit DDT, created on demand from
data editor and used through Function block to be refreshed.
NOTE: Optional Explicit DDT types are proposed in the data editor to support Status
or Command data used by explicit exchanges on a Channel of an IO Modules in a
M340 remote I/O drop. Explicit DDT instances are created manually by the user in
the data editor and used as Input or Output Parameter with the Function block
managing the explicit exchange (READ_STS_QX (see Unity Pro, I/O
Management, Block Library), WRITE_CMD_QX (see Unity Pro, I/O
Management, Block Library)).
40
35006144 07/2012
Presentation
35006144 07/2012
41
Presentation
Function Blocks
The Function blocks tab is used for the instance declaration of elements and
derived function blocks (EFBs/DFBs).
Tab Function blocks:
42
35006144 07/2012
Presentation
DFB Types
The DFB types tab is used for the defining derived function block (DFBs)
parameters.
The creation of DFB logic is carried out directly in one or more sections of the FBD,
LD, IL or ST programming languages.
Tab DFB types:
35006144 07/2012
43
Presentation
Data Usage
Data types and instances created using the data editor can be inserted (context
dependent) in the programming editors.
The following functions are available:
Access to all programming language editors
Only compatible data is displayed
View of the functions, function blocks, procedures and derived data types
arranged according to their library affiliation
Instance declaration during programming is possible
Online Modifications
It is possible to modify the type of a variable or a Function Block (FB) instance
declared in application or in a Derived Function Block (DFB) directly in online mode
(see Unity Pro, Operating Modes). That means it is not required to stop the
application to perform such a type modification.
These operations can be done either in the data editor or in the properties editor, in
the same way as in offline mode.
44
35006144 07/2012
Presentation
CAUTION
UNEXPECTED APPLICATION BEHAVIOR
When changing the type of a variable, the new value of the variable to be modified
depends on its kind:
In the case of an unlocated variable, the variable is set to the initial value, if
one exists. Otherwise, it is set to the default value.
In the case of a located variable, the variable restarts with the initial value if
one exists. Otherwise, the current binary value is unchanged.
Before applying the variable type change, check the impact of the new value of the
variable on the application execution.
Failure to follow these instructions can result in injury or equipment damage.
NOTE: It is not possible to modify the type of a variable declared in Derived Data
Type (DDT) in online mode (see Unity Pro, Operating Modes). The application has
to be switched into offline mode (see Unity Pro, Operating Modes) in order to build
such a modification.
Restrictions About Online Modifications
In the following cases, the online type modification of a variable or of a Function
Block (FB) is not allowed:
If the variable is used as network global data, the online type modification is not
permitted.
Whether the current FB can not be removed online, or a new FB can not be added
online, the online type modification of this FB is not allowed. Indeed, some
Elementary Function Blocks (EFB) like the Standard Function Blocks (SFB) do
not allow to be added or removed online. As a result, changing the type of an EFB
instance to a SFB instance is not possible, and conversely.
In both of these cases, the following dialog box is displayed:
NOTE: Due to these limitations, if a Derived Function Block (DFB) contains at least
one instance of a SFB, it is not be possible to add or remove instance of this DFB in
online mode (see Unity Pro, Operating Modes).
35006144 07/2012
45
Presentation
Program Editor
Introduction
A program can be built from:
Tasks, that are executed cyclically or periodically.
Tasks are built from:
Sections
Subroutines
Example of a Program:
46
35006144 07/2012
Presentation
Tasks
Unity Pro supports multiple tasks (Multitasking).
The tasks are executed "parallel" and independently of each other whereby the
execution priorities are controlled by the PLC. The tasks can be adjusted to meet
various requirements and are therefore a powerful instrument for structuring the
project.
A multitask project can be constructed from:
A Master task (MAST)
The Master task is executed cyclically or periodically.
It forms the main section of the program and is executed sequentially.
A Fast task (FAST)
The Fast task is executed periodically. It has a higher priority than the Master
task. The Fast task is used for processes that are executed quickly and
periodically.
One to four AUX task(s))
The AUX tasks are executed periodically. They are used for slow processing and
have the lowest priority.
The project can also be constructed with a single task. In this case, only the Master
task is active.
Event Processing
Event processing takes place in event sections. Event sections are executed with
higher priority than the sections of all other tasks. They are suited to processing that
requires very short reaction times after an event is triggered.
The following section types are available for event processing:
Sections for processing time controlled events (Timerx Section)
Sections for processing hardware controlled events (Evtx Section)
35006144 07/2012
47
Presentation
Sections
Sections are autonomous program units in which the logic of the project is created.
The sections are executed in the order shown in the project browser (structural
view). Sections are connected to a task.
The same section cannot be belong to more than one task at the same time.
The following programming languages are supported:
FBD (Function Block Diagram)
LD (Ladder Diagram Language)
SFC (Sequential Function Chart)
IL (Instruction List)
ST (Structured Text)
Subroutine
Subroutines are created as separate units in subroutine sections.
Subroutines are called from sections or from another subroutine.
Nesting of up to 8 levels is possible.
A subroutine cannot call itself (not recursive).
Subroutines are assigned a task. The same subroutine cannot be called by different
tasks.
The following programming languages are supported:
FBD (Function Block Diagram)
LD (Ladder Diagram Language)
IL (Instruction List)
ST (Structured Text)
48
35006144 07/2012
Presentation
Objects
The objects of the FBD (Function Block Diagram) programming language help to
divide a section into a number of:
Elementary Functions (EFs),
Elementary Function Blocks (EFBs)
Derived Function Blocks (DFBs)
Procedures
Subroutine calls
Jumps
Links
Actual Parameters
Text objects to comment on the logic
35006144 07/2012
49
Presentation
Properties
FBD sections have a grid behind them. A grid unit consists of 10 coordinates. A grid
unit is the smallest possible space between 2 objects in an FBD section.
The FBD programming language is not cell oriented but the objects are still aligned
with the grid coordinates.
An FBD section can be configured in number of cells (horizontal grid coordinates
and vertical grid coordinates).
The program can be entered using the mouse or the keyboard.
Input Aids
The FBD editor offers the following input aids:
Toolbars for quick and easy access to the desired objects
Syntax and semantics are checked as the program is being written.
Incorrect functions and function blocks are displayed in blue
Unknown words (e.g. undeclared variables) or unsuitable data types are
marked with a red wavy line
Brief description of errors in the Quickinfo (Tooltip)
50
35006144 07/2012
Presentation
35006144 07/2012
51
Presentation
Objects
The objects of the LD programming language help to divide a section into a number
of:
Contacts,
Coils,
Elementary Functions (EFs)
Elementary Function Blocks (EFBs),
Derived Function Blocks (DFBs)
Procedures
Control elements
Operation and compare blocks which represent an extension to IEC 61131-3
Subroutine calls
Jumps
Links
Actual Parameters
Text objects to comment on the logic
Properties
LD sections have a background grid that divides the section into lines and columns.
The LD programming language is cell oriented, i.e. only one object can be placed in
each cell.
LD sections can be 11-64 columns and 17-2000 lines in size.
The program can be entered using the mouse or the keyboard.
Input Aids
The LD editor offers the following input aids:
Objects can be selected from the toolbar, the menu or directly using shortcut keys
Syntax and semantics are checked as the program is being written.
Incorrect objects are displayed in blue
Unknown words (e.g. undeclared variables) or unsuitable data types are
marked with a red wavy line
Brief description of errors in the Quickinfo (Tooltip)
52
35006144 07/2012
Presentation
35006144 07/2012
53
Presentation
Representation
Representation of an SFC section:
54
35006144 07/2012
Presentation
Objects
An SFC section provides the following objects for creating a program:
Steps
Macro steps (embedded sub-step sequences)
Transitions (transition conditions)
Transition sections
Action sections
Jumps
Links
Alternative sequences
Parallel sequences
Text objects to comment on the logic
Properties
The SFC editor has a background grid that divides the section into 200 rows and 32
columns.
The program can be entered using the mouse or the keyboard.
Input Aids
The SFC editor offers the following input aids:
Toolbars for quick and easy access to the desired objects
Automatic step numbering
Direct access to actions and transition conditions
Syntax and semantics are checked as the program is being written.
Incorrect objects are displayed in blue
Unknown words (e.g. undeclared variables) or unsuitable data types are
marked with a red wavy line
Brief description of errors in the Quickinfo (Tooltip)
35006144 07/2012
55
Presentation
Step Properties
Step properties:
The step properties are defined using a dialog box that offers the following features:
Definition of initial steps
Definition of diagnostics times
Step comments
Allocation of actions and their qualifiers
56
35006144 07/2012
Presentation
Instruction List IL
Introduction
The IL editor is used for instruction list programming according to IEC 61131-3.
Representation
Representation of an IL section:
Objects
An instruction list is composed of a series of instructions.
Each instruction begins on a new line and consists of:
An operator
A modifier if required
One or more operands if required
A label as a jump target if required
A comment about the logic if required.
Input Aids
The IL editor offers the following input aids:
Syntax and semantics are checked as the program is being written.
Keywords and comments are displayed in color
Unknown words (e.g. undeclared variables) or unsuitable data types are
marked with a red wavy line
Brief description of errors in the Quickinfo (Tooltip)
35006144 07/2012
57
Presentation
Structured Text ST
Introduction
The ST editor is used for programming in structured text according to IEC 61131-3.
Representation
Representation of an ST section:
Objects
The ST programming language works with "Expressions".
Expressions are constructions consisting of operators and operands that return a
value when executed.
Operators are symbols representing the operations to be executed.
Operators are used for operands. Operands are variables, literals, function and
function block inputs/outputs etc.
Instructions are used to structure and control the expressions.
Input Aids
The ST editor offers the following input aids:
Syntax and semantics are checked as the program is being written.
Keywords and comments are displayed in color
Unknown words (e.g. undeclared variables) or unsuitable data types are
marked with a red wavy line
Brief description of errors in the Quickinfo (Tooltip)
58
Presentation
PLC Simulator
Introduction
The PLC simulator enables error searches to be carried out in the project without
being connected to a real PLC.
All project tasks (Mast, Fast, AUX and Event) that run on a real PLC are also
available in the Simulator. The difference from a real PLC is the lack of I/O modules
and communication networks (such as e.g. ETHWAY, Fipio and Modbus Plus) nondeterministic realtime behavior.
Naturally, all debugging functions, animation functions, breakpoints, forcing
variables etc. are available with the PLC simulator.
Representation
Representation of a dialog box:
59
Presentation
Export/Import
Introduction
The export and import functions allow you to use existing data in a new project. The
XML export/import format makes is possible to provide or accept data from external
software.
Export
The following objects can be exported:
Complete projects, including configuration
Sections of all programming languages
Subroutine sections of all programming languages
Derived function blocks (DFBs)
Derived data types (DDTs)
Device derived data types (Device DDTs)
Variable declarations
Operator Screen
Import
All objects that can be exported can naturally be imported as well.
There are two types of import:
Direct import
Imports the object exactly as it was exported.
Import with the assistant
The assistant allows you to change the variables names, sections or functional
modules. The mapping of addresses can also be modified.
60
35006144 07/2012
Presentation
User Documentation
User Documentation
Scope of the user documentation:
The following are just some of the services provided for documenting the project:
Print the entire project (2) or in sections (3)
Selection between structural and functional view (1)
Adjustment of the result (footer, general information, etc.)
Local printing for programming language editors, configurator, etc.
Special indication (bold) for keywords
Paper format can be selected
Print preview (4)
Documentation save
35006144 07/2012
61
Presentation
Debug Services
Searching for Errors in the User Application
The following are just some of the features provided to optimize debugging in the
project:
Set breakpoints in the programming language editors
Step by step program execution, including step into, step out and step over
Call memory for recalling the entire program path
Control inputs and outputs
Online Mode
Online mode is when a connection is established between the PC and the PLC.
Online mode is used on the PLC for debugging, for animation and for changing the
program.
A comparison between the project of the PC and project of the PLC takes place
automatically when the connection is established.
This comparison can produce the following results:
Different projects on the PC and the PLC
In this case, online mode is restricted. Only PLC control commands (e.g. start,
stop), diagnostic services and variable monitoring are possible. Changes cannot
be made to the PLC program logic or configuration. However, the downloading
and uploading functions are possible and run in an unrestricted mode (same
project on PC and PLC).
Same projects on the PC and the PLC
There are two different possibilities:
ONLINE SAME, BUILT
The last project generation on the PC was downloaded to the PLC and no
changes were made afterwards, i.e. the projects on the PC and the PLC are
absolutely identical.
In this case, all animation functions are available and unrestricted.
ONLINE EQUAL, NOT BUILT
The last project generation on the PC was downloaded to the PLC, however
changes were made afterwards.
In this case, the animation functions are only available in the unchanged
project components.
62
35006144 07/2012
Presentation
Animation
Different possibilities are provided for the animation of variables:
Section animation
All programming languages (FBD, LD, SFC, IL and ST) can be animated.
The variables and connections are animated directly in the section.
35006144 07/2012
63
Presentation
64
Tooltips
A tooltip with the value of a variable is displayed when the mouse pointer passes
over that variable.
Inspection window
An inspection window can be created for any variable. This window displays the
value of the variable, the address and any comments (if available). This function
is available in all programming languages.
35006144 07/2012
Presentation
35006144 07/2012
Variables window
This window displays all variables used in the current section.
Animation table
The value of all variables in the project can be displayed, changed or forced in
animation tables. Values can be changed individually or simultaneously together.
65
Presentation
Watch Point
Watch points allow you to view PLC data at the exact moment at which it is created
(1) and not only at the end of a cycle.
Animation tables can be synchronized with the watch point (2).
A counter (3) determines how often the watch point has been updated.
ST section with watch point:
66
35006144 07/2012
Presentation
Breakpoint
Breakpoints allow you to stop processing of the project at any point.
ST section with breakpoint:
35006144 07/2012
67
Presentation
68
35006144 07/2012
Presentation
Diagnostic Viewer
Description
Unity Pro provides system and project diagnostics.
Errors which occur are displayed in a diagnostics window. The section which caused
the error can be opened directly from the diagnostics window in order to correct the
error.
35006144 07/2012
69
Presentation
Operator Screen
Introduction
Operator windows visualize the automation process.
The operator screen editor makes it easy to create, change and manage operator
screens.
Operator screens are created and accessed via the project browser.
70
35006144 07/2012
Presentation
35006144 07/2012
71
Presentation
72
35006144 07/2012
Unity Pro
Application Structure
35006144 07/2012
Application Structure
II
In This Part
This part describes the application program and memory structures associated with
each type of PLC.
What Is in This Part?
This part contains the following chapters:
Chapter
35006144 07/2012
Chapter Name
Page
75
77
115
Operating Modes
131
System Objects
157
73
Application Structure
74
35006144 07/2012
Unity Pro
PLC Functions
35006144 07/2012
35006144 07/2012
75
PLC Functions
Modicon M340
Processors
Master task
cyclic or
periodic
Fast task
periodic
Auxiliary tasks
periodic
Maximum size
of a section
Premium: TSX
Atrium:
TSX
P57 5
P57 6634
PCI 57
204/354
31
43
53
651
652 60
670 60
671 60
672 60
672 61
651 60S
671 60S
16Mb
64Kb
32
64
32
64
128
64
64
128
Timer type
event
processing
16
32
32
16
32
32
Total of I/O
type and Timer
type event
processing
64
32
64
128
64
64
128
76
35006144 07/2012
Unity Pro
Program Structure
35006144 07/2012
3
Subject of this Chapter
This chapter describes the structure and execution of the programs created using
the Unity Pro software.
What Is in This Chapter?
This chapter contains the following sections:
Section
35006144 07/2012
Topic
Page
3.1
78
3.2
84
3.3
89
3.4
Multitasking Execution
97
77
Program Structure
3.1
78
Page
79
80
81
83
35006144 07/2012
Program Structure
Control
The master task can be controlled by program, by bits and system words.
35006144 07/2012
System objects
Description
%SW0
Task period.
%S30
%S11
Watchdog error.
%S19
Period overrun.
%SW27
%SW28
%SW29
%SW30
%SW31
%SW32
79
Program Structure
80
System objects
Description
%SW1
Task period.
%S31
%S11
Watchdog error
%S19
Period overrun.
%SW33
%SW34
%SW35
35006144 07/2012
Program Structure
35006144 07/2012
System objects
Description
%SW2
%SW3
%SW4
%SW5
%S32
%S33
%S34
%S35
%S11
Watchdog error
%S19
Period overrun.
%SW36
81
Program Structure
82
System objects
Description
%SW39
%SW42
%SW45
%SW37
%SW40
%SW43
%SW46
%SW38
%SW41
%SW44
%SW47
35006144 07/2012
Program Structure
Description
%S38
%S39
%SW48
%SW75
35006144 07/2012
83
Program Structure
3.2
84
Page
Description of Sections
85
87
Description of Subroutines
88
35006144 07/2012
Program Structure
Description of Sections
Overview of the Sections
Sections are autonomous programming entities.
The identification tags of the instruction lines, the contact networks, etc. are specific
to each section (no program jump to another section is possible).
These are programmed either in:
35006144 07/2012
85
Program Structure
Characteristics of a Section
The following table describes the characteristics of a section.
86
Characteristic
Description
Name
Language
Task or
processing
Condition
(optional)
Comment
Protection
35006144 07/2012
Program Structure
The SFC sections are programmable only in the master task (see detailed
description of SFC sections)
Example
The following diagram gives an example of the structure of an SFC section, and
uses the chart to show the macro step calls that are used.
35006144 07/2012
87
Program Structure
Description of Subroutines
Overview of Subroutines
Subroutines are programmed as separate entities, either in:
The calls to subroutines are carried out in the sections or from another subroutine.
The number of nestings is limited to 8.
A subroutine cannot call itself (non recursive).
Subroutines are also linked to a task. The same subroutine cannot be called from
several different tasks.
Example
The following diagram shows a task structured into sections and subroutines.
Characteristics of a Subroutine
The following table describes the characteristics of a subroutine.
88
Characteristic
Description
Name
Language
Task
Comment
35006144 07/2012
Program Structure
3.3
35006144 07/2012
Page
90
92
Periodic Execution
93
94
95
89
Program Structure
Illustration
The following illustration shows the operating cycle.
Description
Acquisition of
inputs
Writing to memory of the status of the data on the inputs of the discrete and
application-specific modules associated with the task,
These values can be modified by forcing values.
Program
processing
Updating of
outputs
NOTE: During the input acquisition and output update phases, the system also
implicitly monitors the PLC (management of system bits and words, updating of
current values of the real time clock, updating of status LEDs and LCD screens (not
for Modicon M340), detection of changes between RUN/STOP, etc.) and the
processing of requests from the terminal (modifications and animation).
90
35006144 07/2012
Program Structure
Operating Mode
PLC in RUN, the processor carries out internal processing, input acquisition,
processing of the application program and the updating of outputs in that order.
PLC in STOP, the processor carries out:
internal processing,
input acquisition (1),
and depending on the chosen configuration:
fallback mode: the outputs are set to fallback position.
maintain mode: the last value of the outputs is maintained.
(1) for Quantum PLCs, input acquisition is inhibited when the PLC is in STOP.
35006144 07/2012
91
Program Structure
%I Reading of inputs
%Q Writing of outputs
Description
This type of operation consists of sequencing the task cycles, one after another.
After having updated the outputs, the system performs its own specific processing
then starts another task cycle, without pausing.
Cycle Check
The cycle is checked by the watchdog (see page 94).
92
35006144 07/2012
Program Structure
Periodic Execution
Description
In this operating mode, input acquisition, the processing of the application program
and the updating of outputs are all carried out periodically over a defined period of
1 to 255 ms.
At the start of the PLC cycle, a time out whose current value is initialized to the
defined period starts the countdown.
The PLC cycle must be completed before this time out expires and launches a new
cycle.
Operation
The following diagram shows the execution phases of the PLC cycle.
%I Reading of inputs
%Q Writing of outputs
Operating Mode
The processor carries out internal processing, input acquisition, processing of the
application program and the updating of outputs in that order.
If the period is not yet over, the processor completes its operating cycle until the
end of the period by performing internal processing.
If the operating time is longer than that assigned to the period, the PLC signals a
period overrun by setting the system bit %S19 of the task to 1. Processing then
continues and is executed fully (however, it must not exceed the watchdog time
limit). The following cycle is started after the outputs have been implicitly written
for the current cycle.
Cycle Check
Two checks are carried out:
35006144 07/2012
Program Structure
NOTE: These different items of information can also be accessed explicitly from the
configuration editor.
94
35006144 07/2012
Program Structure
35006144 07/2012
95
Program Structure
Description
Phase
1
Description
Request to update:
the inputs of the first drop (i=1)
the outputs of the last drop (i=5)
Request to update:
the inputs of the third drop (i=3)
the outputs of the first drop (i=1)
Request to update:
the inputs of the fourth drop (i=4)
the outputs of the second drop (i=2)
Request to update:
the inputs of the last drop (i=5)
the outputs of the third drop (i=3)
96
35006144 07/2012
Program Structure
3.4
Multitasking Execution
35006144 07/2012
Page
98
100
Task Control
102
105
107
108
112
113
97
Program Structure
Description
Master
MAST
Fast
FAST
Auxiliary
AUX 0 to 3
Event
Illustration
The following diagram shows the tasks in a multitasking structure and their level of
priority.
Description
The master (MAST) task is still the application base. The other tasks differ
depending on the type of PLC (see page 76).
Levels of priority are fixed for each task in order to prioritize certain types of
processing.
Event processing can be activated asynchronously with respect to periodic tasks by
an order generated by external events. It is processed as a priority and requires any
processing in progress to be stopped.
98
35006144 07/2012
Program Structure
Subroutine limitations
In Unity Pro version 6.0 of higher, subroutines can only be used in one task. For
example, MASK subroutines cannot be called from TIMER and EVENT tasks.
Precautions
CAUTION
UNEXPECTED MULTITASK APPLICATION BEHAVIOR
The sharing of Inputs/Outputs between different tasks can lead to unforeseen
behavior by the application.
We specifically recommend you associate each output or each input to one task
only.
Failure to follow these instructions can result in injury or equipment damage.
NOTE:
During an update of %M linked to FAST task I/O, you must either:
do them at the same time in the FAST task
mask the FAST task (%S31) while updating
35006144 07/2012
99
Program Structure
Description
The interrupted task takes over again when processing of the priority task is
complete.
Legend:
I: acquisition of inputs
P: program processing
O: updating of outputs
100
35006144 07/2012
Program Structure
Task Control
The execution of fast and event processing tasks can be controlled by the program
using the following system bits:
%S30 is used to control whether or not the MAST master task is active
%S31 is used to control whether or not the FAST task is active..
%S32 to %S35 are used to control whether or not the auxiliary tasks AUX0 to
AUX3 are active.
%S38 is used to control whether EVTi event processing is active.
NOTE: The elementary functions MASKEVT and UNMASKEVT also allow the
global masking and unmasking of events by the program.
35006144 07/2012
101
Program Structure
Task Control
Cyclic and Periodic Operation
In multitasking operation, the highest priority task shall be used in periodic mode in
order to allow enough time for lower priority tasks to be executed.
For this reason, only the task with the lowest priority should be used in cyclic mode.
Thus, choosing cyclic operating mode for the master task excludes using auxiliary
tasks.
Measurement of Task Durations
The duration of tasks is continually measured. This measurement represents the
duration between the start and the end of execution of the task. This measurement
includes the time taken up by tasks of higher priority which may interrupt the
execution of the task being measured.
The following system words (see page 189) give the current, maximum and
minimum cycle times for each task (value in ms)
Measurement of times
MAST
FAST
AUX0
AUX1
AUX2
AUX3
Current
%SW30
%SW33
%SW36
%SW39
%SW42
%SW45
Maximum
%SW31
%SW34
%SW37
%SW40
%SW43
%SW46
Minimum
%SW32
%SW35
%SW38
%SW41
%SW44
%SW47
NOTE: The maximum and minimum times are taken from the times measured since
the last cold restart.
Task Periods
The task periods are defined in the task properties. They can be modified by the
following system words.
System words
Task
Values
Default values
Observations
%SW0
MAST
0..255ms
Cyclic
0 = cyclic operation
%SW1
FAST
1..255ms
5ms
%SW2
AUX0
10ms..2.55s
100ms
%SW3
AUX1
10ms..2.55s
200ms
%SW4
AUX2
10ms..2.55s
300ms
%SW5
AUX3
10ms..2.55s
400ms
When the cycle time of the task exceeds the period, the system sets the system bit
%S19 of the task to 1 and continues with the following cycle.
NOTE: The values of the periods do not depend on the priority of tasks. It is possible
to define the period of a fast task which is larger than the master task.
102
35006144 07/2012
Program Structure
Watchdog
The execution of each task is controlled by a configurable watchdog by using the
task properties.
The following table gives the range of watchdog values for each of the tasks:
Tasks
Watchdog values
(min...max) (ms)
MAST
10..1500
250
%SW11
FAST
10..500
100
AUX0
100..5000
2000
AUX1
100..5000
2000
AUX2
100..5000
2000
AUX3
100..5000
2000
If watchdog overflow should occur, the application is declared in error, which causes
the PLC to stop immediately (HALT state).
The word %SW11 contains the watchdog value of the master task in ms. This value
is not modifiable by the program.
The bit %S11 indicates a watchdog overflow. It is set to 1 by the system when the
cycle time becomes greater than the watchdog.
NOTE:
35006144 07/2012
103
Program Structure
Task Control
When the application program is being executed, it is possible to activate or inhibit
a task by using the following system bits:
System bits
Task
%S30
MAST
%S31
FAST
%S32
AUX0
%S33
AUX1
%S34
AUX2
%S35
AUX3
The task is active when the associated system bit is set to 1. These bits are tested
by the system at the end of the master task.
When a task is inhibited, the inputs continue to be read and the outputs continue to
be written.
On startup of the application program, for the first execution cycle only the master
task is active. At the end of the first cycle the other tasks are automatically activated
except if one of the tasks in inhibited (associated system bit set to 0) by the program.
Controls on Input Reading and Output Writing Phases
The bits of the following system words can be used (only when the PLC is in RUN)
to inhibit the input reading and output writing phases.
Inhibition of
phases...
MAST
FAST
AUX0
AUX1
AUX2
AUX3
reading of
inputs
%SW8.0
%SW8.1
%SW8.2
%SW8.3
%SW8.4
%SW8.5
writing of
outputs
%SW9.0
%SW9.1
%SW9.2
%SW9.3
%SW9.4
%SW9.5
NOTE: By default, the input reading and output writing phases are active (bits of
system words %SW8 and %SW9 set to 0).
On Quantum, inputs/outputs which are distributed via DIO bus are not assigned by
the words %SW8 and %SW9.
104
35006144 07/2012
Program Structure
35006144 07/2012
105
Program Structure
Example on Premium
With its 8 successive channel modularity (channels 0 to 7, channels 8 to 15, etc.),
the inputs/outputs of the Premium discrete modules can be assigned in groups of 8
channels, independently of the MAST, AUXi or FAST task.
Example: it is possible to assign the channels of a 28 input/output module as
follows:
106
35006144 07/2012
Program Structure
Management of Priorities
EVT0 event processing is the highest priority processing. It can itself interrupt
other types of event processing.
EVTi event processing triggered by input/output modules (priority 1) take priority
over TIMERi event processing triggered by timers (priority 2).
On Modicon M340, Premium and Atrium PLCs: types of event processing with
priority level 1 are stored and processed in order.
On Quantum PLC: the priority of priority 1 processing types is determined:
by the position of the input/output module in the rack,
by the position of the channel in the module.
The module with the lowest position number has the highest level of priority.
Event processing triggered by timer is given priority level 2. The processing
priority is determined by the lowest timer number.
Control
The application program can globally validate or inhibit the various types of event
processing by using the system bit %S38. If one or more events occur while they are
inhibited, the associated processing is lost.
Two elementary functions of the language, MASKEVT() and UNMASKEVT(), used
in the application program can also be used to mask or unmask event processing.
If one or more events occur while they are masked, they are stored by the system
and the associated processing is carried out after unmasking.
35006144 07/2012
107
Program Structure
Value
Default
value
Role
Time base
1 ms, 10ms,
100ms, 1 sec
10ms
Preset
1..1023
10
Phase
0..1023
108
35006144 07/2012
Program Structure
Type
Comment
Enable
BOOL
Reset_Timer
BOOL
Hold_Timer
BOOL
Nb_Task_Event
BYTE
Type
Comment
Status_Timer
WORD
Status word.
Current_Value
TIME
35006144 07/2012
109
Program Structure
Normal operation
The following table describes the triggering of TIMER-type event processing
operations (see timing diagram above).
Phase
Description
When a rising edge is received on the RESET input, the timer is reset to 0.
The current value VALUE of the timer increases from 0 towards the preset value
at a rate of one unit for each pulse of the time base.
An event is generated when the current value has reached the preset value, the
timer is reset to 0, and then reactivated. The associated event processing is also
triggered, if the event is not masked. It can be deferred if an event processing
task with a higher or identical priority is already in progress.
When the ENABLE input is at 0, the events are no longer sent out. TIMER type
event processing is no longer triggered.
When the HOLD input is at 1, the timer is frozen, and the current value stops
incrementing, until this input returns to 0.
The event processing tasks must have the same time base and preset values.
The RESET and HOLD inputs must not be set to 1.
110
35006144 07/2012
Program Structure
35006144 07/2012
Description
ON a STOP RUN transition of the PLC, timing is triggered so that the preset
value is reached at the end of a time period equal to Phase x time base, when
the first event is sent out.
The current value VALUE of the timer increases from 0 towards the preset value
at a rate of one unit for each pulse of the time base.
An event is generated when the current value has reached the preset value, the
timer is reset to 0, and then reactivated. The associated event processing is also
triggered, if the event is not masked. If can be deferred, if there is an event
processing task of higher or identical priority already in progress.
111
Program Structure
Description
All the outputs associated with the event processing are updated.
Premium/Atrium PLCs
The inputs acquired and the outputs updated are:
the inputs associated with the channel which caused the event
the inputs and outputs used during event processing
Quantum PLCs
The inputs acquired and the outputs updated are selected in the configuration. Only
local inputs/outputs can be selected.
Programming Rule
The inputs (and the associated group of channels) exchanged during the execution
of event processing are updated (loss of historical values, and thus edges). You
should therefore avoid testing fronts on these inputs in the master (MAST), fast
(FAST) or auxiliary (AUXi) tasks.
112
35006144 07/2012
Program Structure
Action
Unmasking phase
The task which can be interrupted must in particular:
Enable processing of events at system level: set bit %S38 to 1 (default
value).
Unmask events with the instruction UNMASKEVT (active by default).
Unmask the events concerned at channel level (for events triggered by
input/output modules) by setting the input/output modules implicit language
objects for unmasking of events to 1. By default, the events are masked.
Check that the stack of events at system level is not saturated (bit %S39
must be at 0).
35006144 07/2012
113
Program Structure
114
35006144 07/2012
Unity Pro
Memory Structure
35006144 07/2012
4
Subject of this Chapter
This chapter describes the application memory structure of Premium, Atrium and
Quantum PLCs.
What Is in This Chapter?
This chapter contains the following sections:
Section
35006144 07/2012
Topic
Page
4.1
116
4.2
124
115
Memory Structure
4.1
116
Page
117
121
123
35006144 07/2012
Memory Structure
Structure
The data and program are supported by the processor modules internal RAM.
The following diagram describes the memory structure.
State RAM
For Data (see graphic above) also State RAM is available, if you select Mixed
topological and State RAM in the Configuration tab of a Modicon M340 processor
(see Unity Pro, Operating Modes).
To use this option you need Unity Pro 6.1 or later and Modicon M340 firmware 2.4
or later.
NOTE: If you want to import a legacy LL984 Compact application which uses
Modbus request to communicate with an HMI, you have to use State RAM
addressing to preserve the Modbus exchange between PLC and HMI.
35006144 07/2012
117
Memory Structure
Data use
0xxxxx
%Qr.m.c.d,%Mi
1xxxxx
%Ir.m.c.d, %Ii
3xxxxx
%IWr.m.c.d, %IWi
4xxxxx
%QWr.m.c.d, %MWi
NOTE: Not all data represented in topological addressing is available in State RAM.
Please refer to Topological/State RAM Addressing of Modicon M340 Discrete
Modules (see Modicon M340 Using Unity Pro, Discrete Input/Output Modules, User
Manual) and Topological/State RAM Addressing of Modicon M340 Analog Modules
(see Modicon M340 with Unity Pro, Analog input/output modules, User manual).
Program Backup
If the memory card is present, working properly and not write-protected, the program
is saved on the memory card:
Automatically, after:
a download
online modification
a rising edge of the system bit %S66 in the project program
Manually:
with the command PLC Project backup Backup Save
in an animation table by setting the system bit %S66
WARNING
LOSS OF DATA - APPLICATION NOT SAVED
The interruption of an application saving procedure by an untimely or rough
extraction of the memory card, may lead to the loss of saved application.The bit
%S65 (see page 170) allows managing a correct extraction (See help page
%65 bit in system bit chapter)
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
The memory card uses Flash technology, therefore no battery is necessary.
118
35006144 07/2012
Memory Structure
Program Restore
If the memory card is present and working properly, the program is copied from the
PLC memory card to the internal memory:
Automatically after:
a power cycle
Manually, with the Unity Pro command PLC Project backup Backup
Restore
NOTE: When you insert the memory card in run or stop mode, you have to do a
power cycle to restore the project on the PLC.
Saved Data
Located, unlocated data, diagnostic buffer are automatically saved in the internal
Flash memory at power-off. They are restored at warm start.
Save_Param
The SAVE_PARAM function does both current and initial parameter adjustment in
internal RAM (as in other PLCs). In this case, the internal RAM and the memory card
content are different (%S96 = 0 and the CARDERR LED is on). On cold start (after
application restore), the current parameter are replaced by the last adjusted initial
values only if a save to memory card function (Backup Save or %S66 rising edge)
was done.
Save Current Value
On a %S94 rising edge, the current values replace the initial values in internal
memory. The internal RAM and the memory card content are different (%S96 = 0
and the CARDERR LED is on). On cold start, the current values are replaced by the
most recent initial values only if a save to memory card function (Backup Save or
%S66 rising edge) was done.
35006144 07/2012
119
Memory Structure
Delete Files
There are two ways to delete all the files on the memory card:
Formatting the memory card (delete all files of the file system partition)
Deleting the content of directory \DataStorage\ (delete only files added by user)
CAUTION
INOPERABLE MEMORY CARD
Do not format the memory card with a non-Schneider tool. The memory card needs
a structure to contain program and data. Formatting with another tool destroys this
structure.
Failure to follow these instructions can result in injury or equipment damage.
%MW Backup
The values of the %MWi can be saved in the internal Flash memory using %SW96
(see page 193). These values will be restored at cold start, including application
download, if the option Initialize of %MW on cold start is unchecked in the
processor Configuration screen (see Unity Pro, Operating Modes).
For %MW words, the values can be saved and restored on cold restart or download if
the option Reset of %MW on cold restart is not checked in the processor Configuration
screen. With the %SW96 word, management of memory action %MW internal words
(save, delete) and information on the actions states %MW internal words is possible.
Memory Card Specifics
Two types of memory card are available:
120
application: these cards contain the application program and Web pages
application + file storage: these cards contain the application program, data
files from Memory Card File Management EFBs, and Web pages
35006144 07/2012
Memory Structure
35006144 07/2012
121
Memory Structure
Memory Backup
The internal RAM is backed up by a Ni-Cad battery supported by the processor
module.
The RAM memory cards are backed up by a Ni-Cad battery.
Specificities of Memory Cards
Three types of memory card are offered:
application: these cards contain the application program. The cards offered use
either RAM or Flash EPROM technology
application + file storage: in addition to the program, these cards also contain
a zone which can be used to backup/restore data using the program. The cards
on offer use either RAM or Flash EPROM technology
file storage: these cards can be used to backup/restore data using the program.
These cards use SRAM technology.
The following diagram describes the memory structure with an application and file
storage card.
NOTE: On processors with 2 memory card slots, the lower slot is reserved for the
file storage function.
122
35006144 07/2012
Memory Structure
located data:
%M, %S Boolean and %MW,%SW numerical data
data associated with modules (%I, %Q, %IW, %QW,%KW etc.)
unlocated data:
Boolean and numerical data (instances)
EFB and DFB instances
executable codes:
program code
code associated with EFs, EFBs and the management of I/O modules
code associated with DFBs
constants:
KW constant words
constants associated with inputs/outputs
initial data values
This zone also contains the necessary information for downloading the application:
graphic codes, symbols etc.
Other Information
Other information relating to the configuration and structure of the application are
also stored in the memory (in a data or program zone depending on the type of
information).
35006144 07/2012
123
Memory Structure
4.2
124
Page
125
128
35006144 07/2012
Memory Structure
35006144 07/2012
125
Memory Structure
Memory Backup
The internal RAM is backed up by a Ni-Cad battery supported by the processor
module.
The RAM memory cards are backed up by a Ni-Cad battery.
Start-up with Application Saved in Backup Memory
The following table describes the different results according to the PLC state,
according to the PLC mem switch (see Quantum with Unity Pro, Hardware,
Reference Manual), and also indicates if the box "Auto RUN" is checked or not
checked.
PLC State
PLC Mem
Auto RUN in
Switch1
Appl2
NONCONF
Start or Off
Off
NONCONF
Start or Off
On
NONCONF
Not Applicable
1
2
126
Results
Start and Stop are valid for the 434 and 534 models only and Off is valid for the 311 only. Mem Prt is valid on all
models.
The Automatic RUN in the application refers to the application that is loaded.
35006144 07/2012
Memory Structure
PLC State
PLC Mem
Auto RUN in
Results
Switch
Appl
Configured
Start or Off
Off
Configured
Start or Off
On
Configured
Do not Care
1
2
Start and Stop are valid for the 434 and 534 models only and Off is valid for the 311 only. Mem Prt is valid on all
models.
The Automatic RUN in the application refers to the application that is loaded.
application: these cards contain the application program. The cards on offer use
either RAM or Flash EPROM technology
application + file storage: in addition to the program, these cards also contain
a zone which can be used to backup/restore data using the program. The cards
on offer use either RAM or Flash EPROM technology
file storage: these cards can be used to backup/restore data using the program.
These cards use SRAM technology.
The following diagram describes the memory structure with an application and file
storage card.
NOTE: On processors with 2 memory card slots, the lower slot is reserved for the
file storage function.
35006144 07/2012
127
Memory Structure
Located Data
This zone contains located data (State Ram):
Address Object address
Data use
0xxxxx
%Qr.m.c.d,%Mi
1xxxxx
%Ir.m.c.d, %Ii
3xxxxx
%IWr.m.c.d, %IWi
4xxxxx
%QWr.m.c.d, %MWi
User Program
This zone contains the executable codes of the application.
program code
code associated with EFs, EFBs and the management of I/O modules
code associated with DFBs
initial variable values
This zone also contains the necessary information for downloading the application:
graphic codes, symbols etc.
Operating System
On 140 CPU 31/41/51 processors, this contains the operating system for
processing the application. This operating system is transferred from an internal
EPROM memory to internal RAM on power up.
Application Backup
A Flash EPROM memory zone of 1435K8, available on processors 140 CPU
31/41/51, can be used to backup the program and the initial values of variables.
The application stored in this zone is automatically transferred to internal RAM when
the PLC processor is powered up (if the PLC MEM switch is set to off on the
processor front panel).
128
35006144 07/2012
Memory Structure
Other Information
Other information relating to the configuration and structure of the application are
also stored in the memory (in a data or program zone depending on the type of
information).
35006144 07/2012
129
Memory Structure
130
35006144 07/2012
Unity Pro
Operating Modes
35006144 07/2012
Operating Modes
5
Subject of this Chapter
The chapter describes the operating modes of the PLC in the event of power outage
and restoral, the impacts on the application program and the updating of
inputs/outputs.
What Is in This Chapter?
This chapter contains the following sections:
Section
35006144 07/2012
Topic
Page
5.1
5.2
144
5.3
156
132
131
Operating Modes
5.1
132
Page
133
135
139
142
143
35006144 07/2012
Operating Modes
Alternating Current
Direct Current
10ms
1ms
Illustration
The following illustration shows the different power cycle phases.
35006144 07/2012
133
Operating Modes
Operation
The table describes the power outage processing phases.
Phase
Description
On power outage, the system saves the application context, the values of
application variables, and the state of the system on internal Flash memory.
The system sets all the outputs into fallback state (state defined in
configuration).
On power restoral, some actions and checks are done to verify if warm restart
is available:
restoring from internal Flash memory application context,
verification with memory card (presence, application availability),
verification that the application context is identical to the memory card
context,
If all checks are correct, a warm restart (see page 139) is done, otherwise a cold
start (see page 135) is carried out.
134
35006144 07/2012
Operating Modes
Startup characteristics
Loading of an application
Restoral after power supply outage with loss Cold start forced in STOP or RUN mode as
of context
defined in the configuration
CAUTION
LOSS OF DATA ON APPLICATION TRANSFER
Loading or transferring an application to the PLC typically involves initialization of
unlocated variables.
To save the located variables:
Avoid the initialization of the %MWi by unchecking Initialize %MWi on cold start
in the configuration screen of the CPU.
It is necessary to assign a topological address to the data if the process requires
keeping the current values of the data when transferring the application.
Failure to follow these instructions can result in injury or equipment damage.
35006144 07/2012
135
Operating Modes
CAUTION
LOSS OF DATA ON APPLICATION TRANSFER
Do not press the RESET button on the power supply. Otherwise, %MWi is reset
and initial values are loaded.
Failure to follow these instructions can result in injury or equipment damage.
CAUTION
RISK OF LOSS OF APPLICATION
If there is no memory Card in the PLC during a cold restart the application is lost.
Failure to follow these instructions can result in injury or equipment damage.
Illustration
The diagram below describes how a cold restart operates.
136
35006144 07/2012
Operating Modes
Operation
The table below describes the program execution restart phases on cold restart.
Phase
Description
Note : If the number of %MW words exceeds the backup size (see the memory
structure of M340 PLCs (see page 117)) during the save operation the
remaining words are set to 0.
Initializing elementary function blocks on the basis of initial data.
Initializing data declared in the DFBs: either to 0 or to the initial value declared
in the DFB type.
Initializing system bits and words.
Positioning charts to initial steps.
Cancelling any forcing.
Initializing message and event queues.
Sending configuration parameters to all discrete input/output modules and
application-specific modules.
For this first restart cycle the system does the following:
Relaunches the master task with the %S0 (cold restart) and %S13 (first cycle
in RUN) bits set to 1, and the %SW10 word (detection of a cold restart during
the first task cycle) is set to 0.
Resets the %S0 and %S13 bits to 0, and sets each bit of the word %SW10 to
1 at the end of this first cycle of the master task.
Activates the fast task and event processing at the end of the first cycle of the
master task.
137
Operating Modes
Output Changes
As soon as a power outage is detected, the outputs are set in the fallback position:
either they are assigned the fallback value,
or the current value is maintained,
138
35006144 07/2012
Operating Modes
CAUTION
RISK OF LOSS OF APPLICATION
If there is no Memory Card in the PLC during a warm restart the application is lost.
Failure to follow these instructions can result in injury or equipment damage.
Illustration
The diagram below describes how a warm restart operates.
35006144 07/2012
139
Operating Modes
Operation
The table below describes the program execution restart phases on warm restart.
Phase
1
Description
Program execution doesnt resume from the element where the power outage
occurred. The remaining program is discarded during the warm start. Each
task will restart from the beginning.
At the end of the restart cycle, the system carries out the following:
restore the applications variable value,
set bit %S1 to 1,
the initialization of message and event queues,
the sending of configuration parameters to all discrete input/output and
application-specific modules,
the deactivation of the fast task and event processing (until the end of the
master task cycle).
master task.
140
35006144 07/2012
Operating Modes
NOTE: SFC interpreter is independent, if the transition is valid, the SFC chart
evolves while %S1 is true.
Output Changes
As soon as a power outage is detected, the outputs are set in the fallback position:
either they are assigned the fallback value,
or the current value is maintained,
depending on the choice made in the configuration.
After power restoral, the outputs stay in security mode (equal to 0) until they are
updated by a running task.
35006144 07/2012
141
Operating Modes
WARNING
UNEXPECTED SYSTEM BEHAVIOR - UNEXPECTED PROCESS START
The following actions will trigger automatic start in RUN:
Restoring the application from memory card,
Unintentional or careless use of the reset button.
To avoid an unwanted restart when in RUN mode use:
The RUN/STOP input on Modicon M340
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
142
35006144 07/2012
Operating Modes
35006144 07/2012
143
Operating Modes
5.2
144
Page
145
147
152
155
35006144 07/2012
Operating Modes
Alternating Current
Direct Current
Premium
10ms
1ms
Atrium
30ms
Quantum
10ms
1ms
Illustration
The illustration shows the different types of power restoral detected by the system.
35006144 07/2012
145
Operating Modes
Operation
The table below describes the power outage processing phases.
Phase
Description
On power outage the system stores the application context and the time of
outage.
It sets all the outputs in the fallback state (state defined in configuration).
On power restoral, the saved context is compared to the current one, which
defines the type of startup to be performed:
if the application context has changed (i.e. loss of system context or new
application), the PLC initializes the application: cold start,
if the application context is the same, the PLC carries out a restart without
initialization of data: warm restart.
146
35006144 07/2012
Operating Modes
Startup characteristics
Loading of an application
Restoral after power supply outage with loss Cold start forced in STOP or RUN mode as
of context
defined in the configuration
CAUTION
LOSS OF DATA ON APPLICATION TRANSFER
Loading or transferring an application to the PLC typically involves initialization of
unlocated variables.
To save located variables with Premium and Quantum PLCs:
Save and restore %M and %MW by clicking PLC Transfer Data.
For Premium PLCs:
Avoid the initialization of %MW by unchecking Initialize %MWi on cold start in
the configuration screen of the CPU.
For Quantum PLCs:
Avoid the initialization of %MW by unchecking %MWi Reset in the configuration
screen of the CPU.
It is necessary to assign a topological address to the data if the process requires
keeping the current values of the data when transferring the application.
Failure to follow these instructions can result in injury or equipment damage.
35006144 07/2012
147
Operating Modes
Illustration
The diagram below describes how a cold restart operates.
148
35006144 07/2012
Operating Modes
Operation
The table below describes the program execution restart phases on cold restart.
Phase
1
Description
The startup is performed in RUN or in STOP depending on the status of the
Automatic start in RUN parameter defined in the configuration or, if this
is in use, depending on the state of the RUN/STOP input.
Program execution is resumed at the start of the cycle.
The system carries out the following:
the initialization of data (bits, I/O image, words etc.) with the initial values
defined in the data editor (value set to 0, if no other initial value has been
defined). For %MW words, the values can be retained on cold restart if the
Reset of %MW on cold restart option is unchecked in the Configuration
screen of the processor
the initialization of elementary function blocks on the basis of initial data
the initialization of data declared in the DFBs: either to 0 or to the initial
value declared in the DFB type
the initialization of system bits and words
the deactivation of tasks, other than the master task, until the end of the first
master task cycle
the positioning of charts to initial steps
the cancellation of any forcing
the initialization of message and event queues
the sending of configuration parameters to all discrete input/output modules
and application-specific modules
For this first restart cycle the system does the following:
relaunches the master task with the %S0 (cold restart) and %S13 (first cycle
in RUN) bits set to 1, and the %SW10 word (detection of a cold restart
during the first task cycle) is set to 0
resets the %S0 and %S13 bits to 0, and sets each bit of the word %SW10
to 1 at the end of this first cycle of the master task
activates the fast task and event processing at the end of the first cycle of
the master task
35006144 07/2012
149
Operating Modes
After power restoral, the outputs remain at zero until they are updated by the task.
NOTE: The behavior of forced outputs was changed between Modsoft/NxT/Concept
and Unity Pro.
With Modsoft/NxT/Concept, you cannot force outputs if the Quantum processor
memory protection switch is set to "On".
With Unity Pro, you can force outputs if the Quantum processor memory protection
switch is set to "On".
With Modsoft/NxT/Concept, forced outputs retain their status after a cold start.
With Unity Pro, forced outputs lose their status after a cold start.
CAUTION
UNEXPECTED APPLICATION BEHAVIOR - FORCED VARIABLES
Check your forced variables and memory protection switch when shifting
betweenModsoft/NxT/Concept and Unity Pro.
Failure to follow these instructions can result in injury or equipment damage.
150
35006144 07/2012
Operating Modes
35006144 07/2012
151
Operating Modes
Illustration
The diagram below describes how a warm restart operates.
152
35006144 07/2012
Operating Modes
Operation
The table below describes the program execution restart phases on warm restart.
Phase
1
2
Description
Program execution resumes starting from the element where the power outage
occurred, without updating the outputs.
At the end of the restart cycle, the system carries out the following:
the initialization of message and event queues
the sending of configuration parameters to all discrete input/output and
application-specific modules
the deactivation of the fast task and event processing (until the end of the
35006144 07/2012
153
Operating Modes
After power restoral, the outputs remain in the fallback position until they are
updated by the task.
Output Changes, for Extension Rack
If power outage occurs on rack where CPU is located:
Fallback state as soon as CPU loss is detected
Security state during I/O configuration
State calculated by CPU after the first run of the task driving this output
After power is restored, the outputs remain in the fallback position until they are
updated by the task
154
35006144 07/2012
Operating Modes
WARNING
UNEXPECTED SYSTEM BEHAVIOR - UNEXPECTED PROCESS START
The following actions will trigger "automatic start in RUN":
Inserting the PCMCIA card when the PLC is powered up (Premium, Quantum),
Replacing the processor while powered up (Premium, Quantum),
Unintentional or careless use of the reset button,
If the battery is found to be defective in the event of a power outage (Premium,
Quantum).
To avoid an unwanted restart when in RUN mode:
We stongly recommend to use the RUN/STOP input on Premium PLCs or the
switch on the front of the panel of the processor for Quantum PLCs
We strongly recommend not to use memorized inputs as RUN/STOP input of
the PLC.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
35006144 07/2012
155
Operating Modes
5.3
Precaution
WARNING
UNEXPECTED APPLICATION BEHAVIOR
When the PLC is in Halt, all tasks are stopped. Check the behavior of the
associated I/Os to ensure that the consequences of the PLC Halt on the
application are acceptable.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
156
35006144 07/2012
Unity Pro
System Objects
35006144 07/2012
System Objects
6
Subject of this Chapter
This chapter describes the system bits and words of Unity Pro language.
Note: The symbols, associated with each bit object or system word, mentioned in
the descriptive tables of these objects, are not implemented as standard in the
software, but can be entered using the data editor.
They are proposed in order to ensure the homogeneity of their names in the different
applications.
What Is in This Chapter?
This chapter contains the following sections:
Section
35006144 07/2012
Topic
Page
6.1
System Bits
6.2
System Words
179
6.3
208
6.4
221
6.5
238
158
157
System Objects
6.1
System Bits
WARNING
UNEXPECTED APPLICATION BEHAVIOR
Do not use system objects (%Si, %SWi) as variable when they are not
documented.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
What Is in This Section?
This section contains the following topics:
Topic
158
Page
159
160
162
164
167
170
174
177
35006144 07/2012
System Objects
35006144 07/2012
159
System Objects
Function
%S0
Cold start
COLDSTART
Description
Normally on 0, this bit is set on 1 by:
power restoral with loss of data
(battery fault)
the user program
the terminal
a change of cartridge
Initial
state
Modicon Premium
M340
Atrium
Quantum
1
(1 cycle)
YES
YES
YES
YES
YES
YES
(except for
safety
PLCs)
160
35006144 07/2012
System Objects
Bit
Symbol
Function
Description
%S4
TB10MS
Timebase
10 ms
Initial
state
Modicon Premium
M340
Atrium
Quantum
YES
YES
YES
(except for
safety
PLCs)
Timebase
100 ms
Idem %S4
YES
YES
YES
(except for
safety
PLCs)
%S6
TB1SEC
Time
base 1 s
Idem %S4
YES
YES
YES
(except for
safety
PLCs)
%S7
TB1MIN
Time base
1 min
Idem %S4
YES
YES
YES
(except for
safety
PLCs)
35006144 07/2012
161
System Objects
Function
Description
%S9
OUTDIS
Initial Modicon
state M340
Premium Quantum
Atrium
YES (1)
YES
NO
YES
YES
YES
162
Global I/O
detected
error
35006144 07/2012
System Objects
Detected network communication errors with remote devices are not reported on
bits %S10, %S16 and %S119.
CAUTION
UNEXPECTED APPLICATION BEHAVIOR - SPECIFIC VARIABLE BEHAVIOR
Manage detected network communication errors with remote devices with a
method specific to each type of communication modules (NOM, NOE, NWM, CRA,
CRP) or motion modules (MMS):
communication function blocks status (if they are used
communication modules status (if they exist)
Failure to follow these instructions can result in injury or equipment damage.
Bit
Symbol
Function
Description
%S11
WDG
Watchdog
overflow
YES
YES
YES
%S12
PLCRUNNING
YES
YES
YES
YES
YES
YES
%S13
First cycle
1RSTSCANRUN after
switching to
RUN
35006144 07/2012
Initial
state
163
System Objects
Function
Initial Modicon
state M340
Premium Quantum
Atrium
YES
YES
YES
(except for
safety
PLCs)
YES
YES
YES
%S15
Character
STRINGERROR string fault
%S16
IOERRTSK
Description
CAUTION
UNEXPECTED APPLICATION BEHAVIOR - SPECIFIC VARIABLE BEHAVIOR
On Quantum, network communication errors with remote devices detected by
communication modules (NOM, NOE, NWM, CRA, CRP) and motion modules
(MMS) are not reported on bits %S10, %S16 and %S119.
Failure to follow these instructions can result in injury or equipment damage.
164
35006144 07/2012
System Objects
Bit
Symbol
Function
Description
%S17
CARRY
YES
YES
YES
%S18
OVERFLOW
YES
YES
YES
YES
YES
YES
35006144 07/2012
Task period
overrun
(periodical
scanning)
165
System Objects
Bit
Symbol
Function
Description
%S20
INDEXOVF
Index
overflow
YES
YES
YES
(except
for safety
PLCs)
YES
YES
YES
%S21
First task
1RSTTASKRUN cycle
166
35006144 07/2012
System Objects
Function
Description
%S30
MASTACT
Activation/
deactivation
of the master
task
YES
YES
YES
(except for
safety PLCs)
%S31
FASTACT
Activation/
deactivation
of the fast
task
YES
YES
YES
(except for
safety PLCs)
%S32
AUX0ACT
Activation/
deactivation
of the
auxiliary
task 0
NO
YES
YES
(except for
safety PLCs)
%S33
AUX1ACT
Activation/
deactivation
of the
auxiliary
task 1
NO
YES
YES
(except for
safety PLCs)
%S34
AUX2ACT
Activation/
deactivation
of the
auxiliary
task 2
NO
YES
YES
(except for
safety PLCs)
%S35
AUX3ACT
Activation/d
eactivation of
the auxiliary
task 3
NO
YES
YES
(except for
safety PLCs)
%S38
ACTIVEVT
Enabling/
inhibition of
events
YES
YES
YES
(except for
safety PLCs)
35006144 07/2012
Quantum
167
System Objects
Bit
Symbol
Function
Description
Quantum
%S39
EVTOVR
YES
YES
YES
(except for
safety PLCs)
%S40
RACK0ERR
Rack 0
input/output
fault
YES
YES
NO
Rack 1
input/output
fault
YES
YES
NO
%S42
RACK2ERR
Rack 2
input/output
fault
YES
YES
NO
%S43
RACK3ERR
Rack 3
input/output
fault
YES
YES
NO
%S44
RACK4ERR
Rack 4
input/output
fault
YES
YES
NO
%S45
RACK5ERR
Rack 5
input/output
fault
YES
YES
NO
%S46
RACK6ERR
Rack 6
input/output
fault
YES
YES
NO
%S47
RACK7ERR
Rack 7
input/output
fault
YES
YES
NO
168
35006144 07/2012
System Objects
Bit
Symbol
Function
%S50
RTCWRITE
YES
YES
YES
%S51
RTCERR
Time loss in
real time
clock
YES
YES
YES
YES
YES
YES
%S59
Incremental
RTCTUNING update of the
time and date
via word
%SW59
35006144 07/2012
Description
Quantum
169
System Objects
Function
Description
%S65
CARDIS
memory
This bit is used to ensure information
card disable consistency when a memory card is
extracted from the CPU.
To do this, it is necessary to generate a
rising edge on the bit %S65 before
extracting the memory card.
On a rising edge detection, the card
accessing LED turns off when the
current accesses are finished (reading
and writing of files, application saving).
The CARDERR LED is unchanged.
Now the memory card can be extracted,
the CARDERR LED remains or turns
on.
When a memory card is inserted:
the accessing LED turns on
the CARDERR LED shows the
memory card status
%S65 remains unchanged
%S65 must reset to 0 to allow rising
edge detection.
Initial Modicon
state M340
0
YES
Premium Quantum
Atrium
NO
NO
170
35006144 07/2012
System Objects
Bit
Symbol
Function
Description
Initial Modicon
state M340
Premium Quantum
Atrium
%S66
LEDBATT
APPLIBCK
Application
backup
YES
NO
NO
%S67
PCMCIABAT0
State of the
application
memory
card battery
NO
YES
YES
171
System Objects
Bit
Symbol
Function
Description
Initial Modicon
state M340
Premium Quantum
Atrium
%S68
PLCBAT
State of
processor
battery
NO
YES
YES
%S75
PCMCIABAT1
State of the
data storage
memory
card battery
NO
YES
YES
172
35006144 07/2012
System Objects
Bit
Symbol
Function
Description
Initial Modicon
state M340
Premium Quantum
Atrium
%S76
Configured
DIAGBUFFCONF diagnostics
buffer
YES
YES
YES
%S77
DIAGBUFFFFULL
Full
diagnostics
buffer
YES
YES
YES
%S78
HALTIFERROR
Stop in the
event of
error
YES
YES
YES
%S79
MBFBCTRL
Modbus
forced bit
control
NO
NO
YES
35006144 07/2012
173
System Objects
Function
Description
%S80
RSTMSGCNT
Reset
message
counters
YES
YES
YES
%S82
NO
YES
NO
%S90
COMRFSH
Refresh
common
words
NO
YES
NO
%S91
LCKASYNREQ
Lock
asynchronous
request
NO
YES
NO
%S92
EXCHGTIME
Measurement mode
of the communication
function
YES
YES
NO
174
35006144 07/2012
System Objects
Bit
Symbol
Function
%S94
Saving
SAVECURRVAL adjustment
values
%S96
BACKUPPROGOK
Backup
program
OK
Description
YES
YES
YES
(except
for safety
PLCs)
YES
NO
NO
CAUTION
APPLICATION UPLOAD NOT SUCCESSFUL
The bit %S94 must not be set to 1 during an upload.
If the bit %S94 is set to 1 then the upload may be impossible.
Failure to follow these instructions can result in injury or equipment damage.
35006144 07/2012
175
System Objects
CAUTION
LOSS OF DATA
The bit %S94 must not be used with the TSX MFP or the TSX MCP flash
PCMCIA memory. The function of this system bit is not available with this type of
memory.
Failure to follow these instructions can result in injury or equipment damage.
176
35006144 07/2012
System Objects
Function
Description
Initial Modicon
state M340
Premium Quantum
Atrium
%S100
PROTTERINL
NO
YES
NO
%S117
ERIOERR
Detected
RIO error
on Ethernet
I/O network
No
No
YES
%S118
REMIOERR
YES
YES
YES
%S119
LOCIOERR
YES
YES
YES
CAUTION
%S119 for Quantum PLCs
On Quantum, network communication errors with remote devices detected by
communication modules (NOM, NOE, NWM, CRA, CRP) and motion modules
(MMS) are not reported on bits %S10, %S16 and %S119.
Failure to follow these instructions can result in injury or equipment damage.
35006144 07/2012
177
System Objects
Bit
Symbol
Function
Description
%S120
DIOERRPLC
NO
NO
YES
(except
for safety
PLCs)
%S121
DIOERRNOM1
NO
NO
YES
(except
for safety
PLCs)
%S122
DIOERRNOM2
NO
NO
YES
(except
for safety
PLCs)
%S123
ADJBX
Adjust Bus X
YES
YES
NO
178
35006144 07/2012
System Objects
6.2
System Words
WARNING
UNEXPECTED APPLICATION BEHAVIOR
Do not use system objects (%Si, %SWi) as variable when they are not
documented.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
What Is in This Section?
This section contains the following topics:
Topic
35006144 07/2012
Page
180
184
189
191
193
205
206
179
System Objects
Function
%SW0
MASTPERIOD
YES
YES
YES
(except
for safety
PLCs)
%SW1
FASTPERIOD
Fast task
scanning
period
YES
YES
YES
(except
for safety
PLCs)
%SW2
AUX0PERIOD
%SW3
AUX1PERIOD
%SW4
AUX2PERIOD
%SW5
AUX3PERIOD
Auxiliary
task
scanning
period
NO
YES (1)
YES (1)
(except
for safety
PLCs)
%SW6
%SW7
IP Address
YES
NO
NO
180
Description
Initial
state
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW8
TSKINHIBIN
Initial
state
0
YES (3)
YES(2)
(except
for safety
PLCs)
35006144 07/2012
181
System Objects
Word
Symbol
Function
Description
Initial
state
%SW9
TSKINHIBOUT
Monitoring
of task
output
update
YES (3)
YES
YES (4)
(except
for safety
PLCs)
CAUTION
UNEXPECTED APPLICATION BEHAVIOR
Before setting the %SW9 value to 1, ensure that the output behavior will remain
appropriate:
On Premium/Atrium:
Module outputs located on the X Bus automatically switch to the configured mode
(fallback or maintain). On the Fipio bus, certain devices do not manage fallback
mode, then only maintain mode is possible.
On Quantum:
All outputs, as well as the local or remote rack (RIO) are maintained in the state
that preceded the switch to 1 of the %SW9 bit corresponding to the task.
The Distributed Inputs/Outputs (DIO) are not assigned by the system word %SW9.
Failure to follow these instructions can result in injury or equipment damage.
182
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW10
TSKINIT
First cycle
after cold
start
Initial
state
Modicon Premium
M340
Atrium
Quantum
YES
YES
YES
(except
for safety
PLCs)
YES
YES
YES
35006144 07/2012
Watchdog
duration
183
System Objects
Function
Description
Initial
state
%SW12
UTWPORTADDR
Processor
serial port
address
YES
YES
NO
(see
%SW12
below)
%SW12
APMODE
Mode of the
application
processor
16#A501
NO
NO
YES
Only on
safety
PLCs
254
(16#00FE)
NO
YES
NO
(see
%SW13
below)
184
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW13
INTELMODE
Mode of the
Intel
processor
Initial
state
NO
NO
YES
Only on
safety
PLCs
Commercial
version of
PLC
processor
YES
YES
YES
%SW15
OSCOMMPATCH
PLC
processor
patch
version
YES
YES
YES
%SW16
OSINTVERS
Firmware
version
number
YES
YES
YES
35006144 07/2012
185
System Objects
Word
Symbol
Function
Description
%SW17
FLOATSTAT
Error status
on floating
operation
Initial
state
YES
YES
YES
Only on
safety
PLCs
YES
YES
YES
186
35006144 07/2012
System Objects
Word
Symbol
Function
%SD20:
%SW20 and
%SW21
MSCOUNTER
Absolute
For M340 and Quantum PLCs
time counter %SD20 is incremented every
1/1000th of a second by the system
(even when the PLC is in STOP,
%SD20 is no longer incremented if
the PLC is powered down). %SD20
can be read by the user program or
by the terminal.
%SD20 is reset on a cold start.
%SD20 is not reset on a warm start.
For Premium
TSX P57 14M/24M/34M/C024M/
024M and TSX PCI57 204M/354M
PLCs, %SD20 is incremented by 5
every 5/1000th of a second by the
system. For all the others Premium
PLCs, %SD20 is time counter at 1
ms like Quantum and M340 PLCs.
For Quantum safety PLC, knowing
that the 2 processors must process
exactly the same data, the value of
%SD18 is updated at the beginning
of the mast task, and then frozen
during the application execution.
YES
YES
YES
%SW23
Rotary
The least significant byte contains
switch value the Ethernet processor rotary
switch.
It can be read by the user program
or by the terminal.
YES
NO
NO
%SW26
Number of
requests
processed
YES
NO
NO
35006144 07/2012
Description
Initial
state
187
System Objects
Word
Symbol
Function
Description
%SW27
%SW28
%SW29
System
overhead
time
Initial
state
-
NO
NO
overhead time.
%SW28 contains the maximum
system overhead time.
%SW29 contains the minimum
system overhead time.
The system overhead time depends
on the configuration (number of
I/O...) and on the current cycle
requests (communication,
diagnostics).
System overhead time = Mast
Cycle Time - User code execution
time.
These can be read and written by
the user program or by the terminal.
188
35006144 07/2012
System Objects
Function
Description
Initial
state
Modicon
M340
Premium
Quantum
%SW30
Master task
MASTCURRTIME execution
time
YES
YES
YES
%SW31
MASTMAXTIME
Maximum
master task
execution
time
YES
YES
YES
%SW32
MASTMINTIME
Minimum
master task
execution
time
YES
YES
YES
%SW33
Fast task
FASTCURRTIME execution
time
YES
YES
YES
(except for
safety
PLCs)
%SW34
FASTMAXTIME
Maximum
fast task
execution
time
YES
YES
YES
(except for
safety
PLCs)
%SW35
FASTMINTIME
Minimum
fast task
execution
time
YES
YES
YES
(except for
safety
PLCs)
NOTE: Execution time is the time elapsed between the start (input acquisition) and
the end (output update) of a scanning period. This time includes the processing of
event tasks, the fast task, and the processing of console requests. In a Quantum
HSBY configuration, %SW30,%SW31 and %SW32 include the time of Copro Data
exchange between Primary and Stand By CPU.
35006144 07/2012
189
System Objects
Function
Description
Initial Modicon
state M340
Premium
Quantum
%SW36
AUX0CURRTIME
%SW39
AUX1CURRTIME
%SW42
AUX2CURRTIME
%SW45
AUX3CURRTIME
Auxiliary
task
execution
time
NO
YES (1)
YES (1)
(different
function in
Safety
PLCs)
%SW37
AUX0MAXTIME
%SW40
AUX1MAXTIME
%SW43
AUX2MAXTIME
%SW46
AUX3MAXTIME
Maximum
auxiliary task
execution
time
NO
YES (1)
YES (1)
(different
function in
Safety
PLCs)
%SW38
AUX0MINTIME
%SW41
AUX1MINTIME
%SW44
AUX2MINTIME
%SW47
AUX3MINTIME
Minimum
auxiliary task
execution
time
NO
YES (1)
YES (1)
(different
function in
Safety
PLCs)
NOTE: %SW36 to %SW39 have a specific function in Quantum Safety PLCs, refer
to Unity_Pro_XLS Software Operating Modes Specifics guide for more details.
190
35006144 07/2012
System Objects
Function
Description
Initial
state
Modicon
M340
%SW48
IOEVTNB
Number of
events
%SW49
DAYOFWEEK
%SW50
SEC
%SW51
HOURMIN
%SW52
MONTHDAY
%SW53
YEAR
Real-time
clock
function
Premium Quantum
Atrium
YES
YES
YES
(except
for safety
PLCs)
YES
YES
YES
(16#HHMM),
%SW52: Month and Day
(16#MMDD),
%SW53: Year (16#YYYY).
35006144 07/2012
191
System Objects
Word
Symbol
Function
Description
%SW54
STOPSEC
%SW55
STOPHM
%SW56
STOPMD
%SW57
STOPYEAR
%SW58
STOPDAY
Real-time
clock
function on
last stop
%SW59
ADJDATETIME
Adjustment
of current
date
192
Initial
state
Modicon
M340
Premium Quantum
Atrium
YES
YES
YES
YES
YES
YES
35006144 07/2012
System Objects
Function
Description
Initial Modicon
state M340
Premium Quantum
Atrium
%SW70
WEEKOFYEAR
Real-time clock
function
YES
YES
YES
%SW71
KEY_SWITCH
Position of the
switches on the
Quantum front
panel
NO
NO
YES
%SW75
TIMEREVTNB
Timer-type
event counter
YES
YES (1)
YES
(except
for Safety
PLCs)
%SW76
DLASTREG
Diagnostics
function:
recording
YES
YES
YES
successful,
= 1 if the diagnostics buffer
full.
35006144 07/2012
193
System Objects
Word
Symbol
Function
Description
%SW77
DLASTDEREG
Diagnostics
function:
non-recording
Initial Modicon
state M340
Premium Quantum
Atrium
YES
YES
YES
YES
YES
YES
successful,
= 1 if the diagnostics buffer
invalid,
= 22 if the error has not been
recorded.
%SW78
DNBERRBUF
194
Diagnostics
function:
number of
errors
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW80
MSGCNT0
%SW81
MSGCNT1
Message
management
Initial Modicon
state M340
0
YES
Premium Quantum
Atrium
YES
YES
35006144 07/2012
195
System Objects
Word
Symbol
Function
Description
%SW82
%SW83
Message
management
Initial Modicon
state M340
Premium Quantum
Atrium
NO
YES
YES
YES
YES
NO
For Quantum:
%SW82: Number of Modbus
messages sent or received on
serial port 1,
%SW83: Number of Modbus
messages sent or received on
serial port 2.
%SW84
MSGCNT4
%SW85
MSGCNT5
Premium:
Telegram
management
Modicon M340:
Message
management
196
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW86
MSGCNT6
Message
management
Initial Modicon
state M340
Premium Quantum
Atrium
YES
YES
NO
YES
YES
YES
35006144 07/2012
197
System Objects
Word
Symbol
Function
%SW88
ASNSERVCNT
%SW89
APPSERVCNT
198
Description
For Premium:
Initial Modicon
state M340
0
YES
Premium Quantum
Atrium
YES
NO
processed by asynchronous
server per master (MAST)
task cycle,
%SW89: Number of requests
processed by server functions
(immediately) per master
(MAST) task cycle.
For Modicon M340:
%SW88: Number of HTTP
requests received by the
processors Web server per
second,
%SW89: Number of FTP
requests received by the FTP
server per second.
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW90
MAXREQNB
Maximum
number of
requests
processed per
master task
cycle
Initial Modicon
state M340
N
YES
Premium Quantum
Atrium
YES
YES
maximum 4 + 4 = 9),
TSX 57 1: N = 4 (minimum 2,
maximum 4 + 4 = 8),
TSX 57 2: N = 8 (minimum 2,
maximum 8 + 4 = 12),
TSX 57 3: N = 12 (minimum 2,
maximum 12 + 4 = 16),
TSX 57 4: N = 16 (minimum 2,
maximum 16 + 4 = 20),
TSX 57 5: N = 16 (minimum 2,
maximum 16 + 4 = 20)
For Quantum range:
140 CPU 31/43/53/: N =
10 (minimum 5, maximum
10 + 4 = 14),
140 CPU 6: N = 20
(minimum 5, maximum
20 + 4 = 24),
NOTE: Requests may come from
various modules or embedded
communication ports. The
communication exchange
capacity of each port is limited,
therefore the maximum request
value set in %SW90 might not be
reached.
35006144 07/2012
199
System Objects
Word
Symbol
Function
Description
Initial Modicon
state M340
Continued
%SW90
MAXREQNB
Maximum
number of
requests
processed per
master task
cycle
N
The Word is initialized by the
system with N (default value) If
the value 0 is entered, it is the
value N that is taken into account.
If a value between 1 and
minimum is entered, it is the
minimum value that is taken into
account. If a value greater than
maximum is entered, it is
maximum value that is taken into
account.
The number of requests to be
processed per cycle should take
into account requests from all
communication ports (having
access to the server.) This means
that requests from other clients
than communication EFs, like IO
Scanner, connected HMI and so
on should also be taken into
account.
%SW91-92
YES
YES
Premium Quantum
Atrium
YES
YES
YES
NO
200
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW93
Memory card
file system
format
command &
status
Initial Modicon
state M340
0
YES
Premium Quantum
Atrium
NO
NO
35006144 07/2012
201
System Objects
Word
Symbol
Function
Description
%SW94
%SW95
Application
modification
signature
Initial Modicon
state M340
Premium Quantum
Atrium
YES
NO
NO
YES
NO
NO
Command and
Diagnostic of
Save and
Restore
202
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW96
CMDDIAGSAVEREST
Command and
Diagnostic of
Save and
Restore
YES
NO
NO
%SW97
CARDSTS
Card status
YES
NO
NO
35006144 07/2012
Initial Modicon
state M340
Premium Quantum
Atrium
203
System Objects
Word
Symbol
Function
%SW991
1
INPUTADR/SWAP
Description
Initial Modicon
state M340
Premium Quantum
Atrium
NO
YES1
NO
NO
NO
YES2
NO
NO
YES
CRA
compatibility
high status
register
%SW100
CCOTF_COUNT
204
CCOTF
counting status
register
35006144 07/2012
System Objects
Function
%SW108
FORCEDIOIM
Forced bit
counting
status
register
Description
Word %SW108:
Initial Modicon
state M340
Quantum
Premium
Atrium
YES
YES
YES
is unforced
%SW109
FORCEDANA
Forced
analog
channel
counting
status
register
Word %SW109:
increment each time an analog
channel is forced
decrement each time an analog
channel is unforced
YES
YES1
YES
%SW116
REMIOERR
Fipio I/O
error
NO
NO
YES
Limited to analog channels of Modicon M340 Analog Modules in M340 remote I/O drops
35006144 07/2012
205
System Objects
Function
Description
%SW123
ADJBUSX
System
allowance
to BUS X
YES
YES
NO
%SW124
CPUERR
Type of
processor
or system
error
YES
YES
YES
206
Initial
state
Modicon
M340
Premium Quantum
Atrium
35006144 07/2012
System Objects
Word
Symbol
Function
%SW125
Last fault
BLKERRTYPE detected
Description
The code of the last fault detected is given
in this word:
The following error codes cause the PLC
to stop if %S78 is set to 1. %S15, %S18
and %S20 are always activated
independently of %S78:
16#2258: execution of HALT instruction
16#DE87: calculation error on floatingpoint numbers (%S18, these errors are
listed in the word %SW17)
16#DEB0: Watchdog overflow (%S11)
16#DEF0: division by 0 (%S18)
16#DEF1: character string transfer
error (%S15)
16#DEF2: arithmetic error; %S18
16#DEF3: index overflow (%S20)
Initial
state
Modicon
M340
Premium Quantum
Atrium
YES
YES
YES
YES
YES
YES
Blocking
error
instruction
address
35006144 07/2012
207
System Objects
6.3
WARNING
UNEXPECTED APPLICATION BEHAVIOR
Do not use system objects (%Si, %SWi) as variable when they are not
documented.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
What Is in This Section?
This section contains the following topics:
Topic
Description of System Words %SW60 to %SW65
208
Page
209
213
214
216
217
219
220
35006144 07/2012
System Objects
Function
Description
%SW60
HSB_CMD
Premium
Hot
Standby
command
register
%SW60.1
=0 sets PLC A to OFFLINE mode.
=1 sets PLC A to RUN mode.
YES
NO
%SW60.2
=0 sets PLC B to OFFLINE mode.
=1 sets PLC B to RUN mode.
%SW60.4 OS Version Mismatch
=0 If OS Versions Mismatch with Primary, Standby
35006144 07/2012
209
System Objects
Word
Symbol
Function
Description
%SW61
HSB_STS
Premium
Hot
Standby
status
register
YES
NO
210
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW61
HSB_STS
Premium
Hot
Standby
status
register
YES
NO
YES
NO
Premium
Hot
Standby
status
register
35006144 07/2012
211
System Objects
Word
Symbol
Function
Description
%SW62
HSBY_
REVERSE0
%SW63
HSBY_
REVERSE1
%SW64
HSBY_
REVERSE2
%SW65
HSBY_
REVERSE3
Premium
Transfer
word
212
YES
NO
35006144 07/2012
System Objects
Function
Description
Initial
state
%SW128...143
ERRORCNXi
where i = 0 to 15
Faulty Fipio Each bit in this group of words indicates the state of a device connected
connection to the Fipio bus.
Normally set to 1, the presence of a 0 in one of these bits indicates the
point
occurrence of a fault on this connection point. For a non-configured
connection point, the corresponding bit is always 1.
Table showing correspondence between word bits and connection point address:
Bit 0 Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 Bit 7 Bit 8 Bit 9 Bit
10
Bit
11
Bit
12
Bit
13
Bit
14
Bit
15
%SW128
10
11
12
13
14
15
%SW129
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
%SW130
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
%SW131
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
%SW132
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
%SW133
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
%SW134
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
%SW135
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
%SW136
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
%SW137
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
%SW138
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
%SW139
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
%SW140
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
%SW141
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
%SW142
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
%SW143
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
35006144 07/2012
213
System Objects
Function
Description
Initial
state
%SW144
BAOPMOD
Fipio bus
arbiter function
operating
mode
This system word is used to start and stop the bus arbiter function and the
producer / consumer function. It can modify the starting, automatic and
manual modes of the bus in the event of a stop.
%SW144.0
= 1: producer / consumer function in RUN.
= 0: producer / consumer function in STOP (no variables are
exchanged on the bus).
%SW144.1
= 1: bus arbiter is in RUN 0.
= 0: bus arbiter is in STOP (no variables or message scanning is
%SW145
BAPARAM
Modification of
Fipio Bus
Arbiter
Parameters
The bits are set to 1 by the user, and reset to 0 by the system when
initialization has been carried out.
%SW145.0 = 1: modification of the priority of the bus arbiter; the most
significant byte for this system word contains the value of the priority of
the bus arbiter which is to be applied to the bus.
%SW145.1 and %SW145.2 are reserved.
%SW145.3 to %SW145.7 reserved on 0.
%SW145.8 to %SW145.15: this byte contains the value which is applied
to the bus, according to the value of bit 0.
These parameters can be modified when the bus arbiter is in RUN, but for
them to be taken into account by the application, the BA must be stopped
then restarted.
%SW146 Fipio bus
BASTATUS arbiter function
display
214
The least significant byte indicates the status of the producer / consumer
function.
The most significant byte indicates the status of the bus arbiter function.
Byte value:
16#00: the function does not exist (no Fipio application).
16#70: the function has been initialized but is not operational (in STOP).
16#F0: the function is currently being executed normally (in RUN).
35006144 07/2012
System Objects
CAUTION
UNINTENDED SYSTEM BEHAVIOR
Modifying the %SW144 and %SW145 system words can cause the PLC to stop.
Failure to follow these instructions can result in injury or equipment damage.
35006144 07/2012
215
System Objects
Function
Description
%SW147
TCRMAST
MAST network
cycle time
A value which is not zero indicates (in ms) the value of the MAST task
network cycle time (TCRMAST).
%SW148
TCRFAST
FAST network
cycle time
A value which is not zero indicates (in ms) the value of the first FAST
task network cycle time (TCRFAST).
%SW150
NBFRSENT
Number of
frames sent
This word indicates the number of frames sent by the Fipio channel
manager.
%SW151
NBFRREC
Number of
frames received
%SW152
Number of
This word indicates the number of messages resent by the Fipio
NBRESENTMSG messages resent channel manager.
216
Initial
state
35006144 07/2012
System Objects
Function
Description
%SW153
FipioERR0
List of Fipio
channel
manager faults
Initial
state
0
35006144 07/2012
217
System Objects
218
bit 12 = "unknown frame type received": within the frame body, the first byte
identifies the type of frame link. A set number of frame types are defined in the
WorldFip standard link protocol. Any other code found within a frame is therefore
an unknown frame type.
bit 13 = "a truncated frame has been received": a frame section is recognized by
a sequence of symbols delimiting the end of the frame, while the destination
station awaits the arrival of a delimiter sequence for the start of the frame.
bit 14 = "unused, non-significant value".
bit 15 = "unused, non-significant value"
35006144 07/2012
System Objects
Function
Description
%SW154
FipioERR1
Initial
state
0
35006144 07/2012
219
System Objects
Function
Description
%SW155
NBEXPLFIP
Number of explicit
exchanges on Fipio
Operating status of
%SW160 to
the PLC modules
%SW167
PREMRACK0 to
PREMRACK7
220
Initial
state
35006144 07/2012
System Objects
6.4
WARNING
UNEXPECTED APPLICATION BEHAVIOR
Do not use system objects (%Si, %SWi) as variable when they are not
documented.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
What Is in This Section?
This section contains the following topics:
Topic
Description of Quantum System Words %SW60 to %SW66
35006144 07/2012
Page
222
227
228
231
221
System Objects
Function
Description
Initial
state
%SW60
HSB_CMD
%SW60.2
0 sets PLC B to OFFLINE mode.
1 sets PLC B to ONLINE mode.
NOTE: The Primary CPU controller goes to RUN Offline only if the secondary
CPU is RUN Standby.
At Startup of the Secondary PLC, the secondary CPU goes to Online mode
(RUN Standby) only if both bits %SW60.1 and %SW60.2 are set to 1
(regardless of A/B assignment).
If bits %SW60.1 and %SW60.2 are set to 0 simultaneously, a switchover
occurs:
Primary controller goes RUN Offline, and,
Standby controller now operates as RUN Primary.
To complete the switchover, bits %SW60.1 and %SW60.2 must be set back
to 1. This makes the Offline CPU going back to Online mode (Run Standby).
The OFFLINE/ONLINE mode controlled by the %SW60.1 and %SW60.2 bits
is not linked to the LCD Keypad ONLINE/OFFLINE mode (see Modicon
Quantum, Hot Standby System, User Manual).
%SW60.3
0 If an application mismatch is detected, Standby CPU is forced to
OFFLINE mode.
1 Standby CPU operates normally even if a mismatch occurs.
%SW60.4
0 authorizes an update of the firmware only after the application has
stopped.
1 authorizes an update of the firmware without the application stopping.
%SW60.5
0 no action (default)
1 request for an application transfer from the Primary to the Standby
%SW60.8
0 address switch on Modbus port 1 during a primary swap.
1 no address switch on Modbus port 1 during a primary swap.
222
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW60
HSB_CMD
Initial
state
0
%SW60.10
0 address switch on Modbus port 3 during a primary swap.
1 no address switch on Modbus port 3 during a primary swap.
%SW61
HSB_STS
Quantum
status
register
significant.
1 the CPU-sync link is not valid. In this case, the contents of the bit 5 is
223
System Objects
Word
Symbol
Function
%SW62
HSBY_
REVERSE0
%SW63
HSBY_
REVERSE1
%SW64
HSBY_
REVERSE2
%SW65
HSBY_
REVERSE3
Hot Standby These 4 words may be modified is the Hot Standby MAST task first section of
the user application program.
reverse
transfer word They are then transferred automatically from the Standby processor to update
the Primary PLC.
They may be read on the Primary PLC and used in the Hot Standby
application.
224
Description
Initial
state
0
35006144 07/2012
System Objects
Word
Symbol
Function
%SW66
CCOTF_
STATUS
Status of an
Ethernet I/O
configuration
change
35006144 07/2012
Description
Meaning of the bytes of the word %SW66 (XXYY):
Initial
state
0
XX: The higher byte of the word is associated with the CCOTF status
225
System Objects
Word
Symbol
Function
%SW66
CCOTF_
STATUS
Status of an
Ethernet I/O
configuration
change
Description
Initial
state
Continued:
XX: The higher byte of the word is associated with the CCOTF status
226
35006144 07/2012
System Objects
Function
Description
%SW98
CRA_COMPAT_LOW
%SW99
CRA_COMPAT_HIGH
%SW100
CCOTF_COUNT
CCOTF
counting
status
register
Initial state
ERIO
CCOTF
counting
status
register
35006144 07/2012
Forced
analog
channel
counting
status
register
Word %SW108:
Word %SW109:
increment each time an analog channel is forced
decrement each time an analog channel is unforced
NOTE:
NOTE: Limited to analog channels of Modicon M340 Analog
Modules in M340 remote I/O drops
227
System Objects
Function
%SW110
%SW111
%SW128
NB_P502_CNX
Number of
connections open
%SW129
NB_DENIED_CNX
Number of
connections refused
%SW130
NB_P502_REF
Number of
messages refused
Number of
messages sent
Number of
messages received
%SW136
NB_IOS_CNX
Number of devices
scanned
%SW137
NB_IOS_MSG
%SW138
GLBD_ERROR
Global Data
coherence error
%SW139
BW_GLBD_IOS
%SW140
BW_OTHER_MSG
IP Address
228
Description
Initial
state
35006144 07/2012
System Objects
Word
Symbol
Function
IP subnetwork mask This double word %SD143 receives the subnetwork mask
of the Ethernet link.
Default Ethernet
gateway address
%SW147 to %SW149
MAC_ADDR1 to 3
MAC Addresses
%SW150
%SW151
BOARD_STS
Status of Ethernet
link
%SW152 to %SW153
ERIO_DROP_ERROR
Detected ERIO Drop The bits of words %SW152 to %SW153 are associated
error status
with the detected Ethernet RIO Drop status.
The bit is set to 0 if at least one I/O module in the drop has
detected error.
It is set to 1 if all modules are operating correctly.
%SW152.0: Drop No. 1
%SW152.1: Drop No. 2
...........
%SW153.14: Drop No. 31
%SW160 to %SW167
REFRESH_IO
35006144 07/2012
Description
Initial
state
229
System Objects
Word
Symbol
Function
Description
%SW168 to %SW171
VALID_GD
Operating status of
Global Data
%SW172 to %SW173
ERIO_CONNECT_
STATUS
Hot Standby
%SW176 to %SW177
SDBY_ERIO_CONNECT_ Detected Ethernet
RIO
STATUS
Communications
Drop error status
230
Initial
state
35006144 07/2012
System Objects
Function
Description
%SW180 to %SW339
IOHEALTHij
i=1..32, j=1..5
Initial
state
0
35006144 07/2012
231
System Objects
Word
Symbol
Function
Description
%SW340
MB+DIOSLOT
Slot number of
the processor
with Modbus
Plus link
Slot number of the processor with the built-in Modbus Plus link for
connection to the first DIO network. The slot number is coded
from 0 to 15.
This word is not available on Quantum safety PLCs.
%SW341 to %SW404
MB+IOHEALTHi
i=1..64
Operating status
of the distributed
station modules
of the first DIO
network
%SW405
NOM1DIOSLOT
Slot number of
the first interface
module of the
DIO network
%SW406 to %SW469
NOM1DIOHEALTHi
i=1..64
Operating status
of the distributed
station modules
of the second
DIO network
232
Initial
state
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW470
NOM2DIOSLOT
Slot number of
the second
interface module
of the DIO
network
%SW471 to %SW534
NOM2DIOHEALTHi
i=1..64
Operating status
of the distributed
station modules
of the third DIO
network
35006144 07/2012
Initial
state
233
System Objects
Word
Symbol
Function
Description
%SW535
RIOERRSTAT
RIO error on
start-up
This word stores the start-up error code. This word is always set
to 0 when the system is running; in the event of error, the PLC
does not start up, but generates a stop status code
01: I/O assignment length
02: Remote I/O link number
03: Number of stations in the I/O assignment
04: I/O assignment checksum
10: Length of the station descriptor
11: I/O station number
12: Station autonomy time
13: ASCII port number
14: Number of station modules
15: Station already configured
16: Port already configured
17: More than 1024 output points
18: More than 1024 input points
20: Module slot address
21: Module rack address
22: Number of output bytes
23: Number of input bytes
25: First reference number
26: Second reference number
28: Internal bits outside the 16 bit range
30: Unpaired odd output module
31: Unpaired odd input module
32: Unpaired odd module reference
33: Reference 1x after register 3x
34: Reference of dummy module already used
35: Module 3x is not a dummy module
36: Module 4x is not a dummy module
Communication
%SW536
status on
CAERRCNT0
cable A
%SW537
CAERRCNT1%SW538
CAERRCNT2
Initial
state
%SW537:
most significant byte: counts receiver errors
least significant byte: counts incorrect station receptions.
%SW538:
%SW538.15 = 1, short frame
%SW538.14 = 1, no end-of-frame
%SW538.3 = 1, CRC error
%SW538.2 = 1, alignment error
%SW538.1 = 1, overrun error
%SW538.13 to 4 and 0 are unused
234
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW539
CBERRCNT0
%SW540
CBERRCNT1 to
%SW541
CBERRCNT2
Initial
state
-
%SW540:
most significant byte: counts receiver errors
least significant byte: counts incorrect station receptions.
%SW541:
%SW541.15 = 1, short frame
%SW541.14 = 1, no end-of-frame
%SW541.3 = 1, CRC error
%SW541.2 = 1, alignment error
%SW541.1 = 1, overrun error
%SW541.13 to 4 and 0 are unused
%SW542
GLOBERRCNT0
%SW543
GLOBERRCNT1
%SW544
GLOBERRCNT2
Global
communication
status
%SW545 to %SW547
MODUNHEALTH1
IOERRCNT1
IORETRY1
Status of the
local station
errors.
%SW547: this is used as a counter for 16-bit input/output bus
repetitions.
35006144 07/2012
235
System Objects
Word
Symbol
Function
Description
Initial
state
%SW548 to %SW640
MODUNHEALTHi
IOERRCNTi
IORETRYi
(i=2..32)
Status of
decentralized
stations
station 2:
most significant byte: counts the errors detected
least significant byte: counts "non-responses".
%SW550: is the global error totalizer counter for cable B
station 2:
most significant byte: counts the errors detected
least significant byte: counts "non-responses".
The words:
%SW551 to 553 are assigned to station 3
%SW554 to 556 are assigned to station 4
.......
%SW638 to 640 are assigned to station 32
236
35006144 07/2012
System Objects
Word
Symbol
Function
Description
%SW641 to %SW702
ERIO_MOD_HEALTH
Ethernet RIO
Module Health
bit status
Initial
state
0
%SW642:
rack 1 in BMX CRA 312 0 drop 1
rack 2 in 140 CRA 312 00 drop 1
NOTE:
for BMX CRA 312 0
Rack 0 is the main rack
Rack 1 is the extension rack
...........
%SW701:
rack 0 in BMX CRA 312 0 drop 31
rack 1 in 140 CRA 312 00 drop 31
%SW702:
rack 1 in BMX CRA 312 0 drop 31
rack 2 in 140 CRA 312 00 drop 31
Bits 0 to 15 of each of these words are associated with the
modules located in positions:
16 to 1 of the 140 CRA 312 00 Drop module.
15 to 0 of the BMX CRA 312 0 Drop module.
The bit is set to 0 if the module has a detected error.
It is set to 1 if the module is operating correctly.
35006144 07/2012
237
System Objects
6.5
Function
Description
Initial
State
%SW138 and
%SW140
Modicon M340
%SW139 and
%SW141
Modicon M340
WARNING
UNINTENDED EQUIPMENT OPERATION
You must set the values of the 4 system words %SW138, %SW139, %SW140 and
%SW141 using the Initial value mechanism.
Do not use programming code to set the values.
Otherwise, when using the PLC init command or setting %S0 to 1 or
downloading an application, the 4 system words are set to 0000 and the behavior
of Modbus server is wrong.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
238
35006144 07/2012
System Objects
Function
Description
Initial
State
Inhibit the I/O error raised by the system when a configured device on the CANopen bus is not present.
This inhibition can be managed with 4 system words
%SW142,143,144,145.
These System words implement a bit list indicating CANopen
node error to inhibit:
bit 0 of %SW142 concerns device at node address 1.
bit 1 of %SW142 concerns device at node address 2.
...
bit15 of %SW145 concerns device at node address 64.
Bit values:
If the bit is at 0 and device not present, then an error is
raised.
If the bit is at 1 and device not present, then no error is
raised.
NOTE: The default value is 0.
NOTE: This inhibition can be performed on the fly, but in
order for it to be taken into account, the CANopen Master
must be reset (by setting bit 5 of the output word
.%QW0.0.2.0 to 1).
NOTE: The system words %SW142 to %SW145 are
available since SV 2.1 of the CPU OS.
%SW146 and
%SW147
Modicon M340
35006144 07/2012
239
System Objects
Word
Symbol
Function
240
Description
Initial
State
35006144 07/2012
Unity Pro
Data Description
35006144 07/2012
Data Description
III
In This Part
This part describes the different data types that can be used in a project, and how
to implement them.
What Is in This Part?
This part contains the following chapters:
Chapter
7
Page
243
Data Types
251
Data Instances
311
Data References
327
10
35006144 07/2012
Chapter Name
General Overview of Data
241
Data Description
242
35006144 07/2012
Unity Pro
General Overview of Data
35006144 07/2012
7
Subject of this Chapter
This chapter provides a general overview of:
35006144 07/2012
Page
General
244
245
247
249
250
243
General
Introduction
A data item designates an object which can beinstantiated such as:
a variable,
a function block.
the data instances phase, which defines its storage location and property, which
is:
located, or
unlocated.
Illustration
The following are the three phases that characterize the data:
Instantiating a data item consists in allocating it a memory slot according to its type.
Referencing a data item consists in defining a reference for it (name, address, etc.)
allowing it to be accessed in the memory.
244
35006144 07/2012
Definitions
Data type families and their definitions.
35006144 07/2012
Family
Definition
EDT
245
Family
DDT
Definition
Derived Data Types, such as:
Arrays, which contain elements of the same type:
Bool tables (EDT tables)
EBool tables (Device DDT Arrays)
tables of tables (DDT tables)
tables of structures (DDT tables)
structures, which contain elements of the different types:
Bool structures, Word structures, etc. (EDT structures)
EBool tables (Device DDT structure)
structures of tables, structures of structures, structures of
DFB
246
35006144 07/2012
35006144 07/2012
247
Definitions
Definition of the memory allocations of data instances.
248
Data instance
Definition
Unlocated
Located
35006144 07/2012
35006144 07/2012
249
With Allow extended character set option selected, the application is compliant
with the IEC standard
With Allow extended character set option not selected, the user has a certain
degree of flexibility, but the application is not compliant with the IEC standard
The extended character set used for names entered into the application concerns:
DFB (Derived Function Block) user function blocks or DDT (Derived data type)
the internal elements composing a DFB/EFB function block data type or a derived
data type (DDT)
the data instances
characters corresponding to ASCII codes 192 to 223 (except for code 215)
characters corresponding to ASCII codes 224 to 255 (except for code 247)
250
35006144 07/2012
Unity Pro
Data Types
35006144 07/2012
Data Types
8
Subject of this Chapter
This chapter describes all the data types that can be used in an application.
What Is in This Chapter?
This chapter contains the following sections:
Section
35006144 07/2012
Topic
Page
8.1
252
8.2
263
8.3
269
8.4
274
8.5
277
8.6
281
8.7
294
8.8
302
8.9
304
8.10
306
251
Data Types
8.1
Boolean types
Integer types
Time types
252
Page
253
Boolean Types
255
Integer Types
260
262
35006144 07/2012
Data Types
35006144 07/2012
253
Data Types
254
Type
Designation
Format
(bits)
Default
value
BOOL
Boolean
0=(False)
EBOOL
0=(False)
INT
Integer
16
DINT
Double integer
32
UINT
Unsigned integer
16
UDINT
32
TIME
32
T=0s
35006144 07/2012
Data Types
Boolean Types
At a Glance
There are two types of Boolean. These are:
BOOL type, which contains only the value FALSE (=0) or TRUE (=1)
EBOOL type, which contains the value FALSE (=0) or TRUE (=1) but also
information concerning the management of falling or rising edges and forcing
In the case of the word extracted bit, it is accessible via an address containing the
following information:
Address settings:
35006144 07/2012
255
Data Types
The default value for the bits associated with the EBOOL type is FALSE (=0).
It is accessible via an address specifying the offset of the corresponding byte:
Address settings:
256
35006144 07/2012
Data Types
Type
Internal bit
EBOOL
System bit
BOOL
BOOL
%I inputs
Module error bit
BOOL
BOOL
Input bit
EBOOL
%Q outputs
Output bit
35006144 07/2012
EBOOL
257
Data Types
value copying
address copying
EBOOL destination
BOOL source
Yes
Yes
EBOOL source
Yes
Yes
BOOL
Yes
No
EBOOL
In ->Yes
In-Out ->No
Out ->Yes
Yes
BOOL
Yes
In ->Yes
In-Out ->No
Out -> Yes
EBOOL
In ->Yes
In-Out ->No
Out -> Yes
Yes
258
ARRAY[i..j) OF EBOOL
destination
No
ARRAY[i..j) OF
EBOOL source
Yes
No
35006144 07/2012
Data Types
BOOL (Var:BOOL)
declared variable
Yes
No
EBOOL (Var:EBOOL)
declared variable
No
Yes
Compatibility
EBOOL data types follow the rules below:
35006144 07/2012
259
Data Types
Integer Types
At a Glance
Integer types are used to represent a value in different bases. These are:
NOTE: In decimal representation, if the chosen type is signed, the value can be
preceded by the + sign or - sign (the + sign is optional).
Integer Type (INT)
Signed type with a 16-bit format.
This table shows the range in each base.
Base
from...
to...
Decimal
-32768
32767
Binary
2#1000000000000000
2#0111111111111111
Octal
8#100000
8#077777
Hexadecimal
16#8000
16#7FFF
from...
to...
Decimal
-2147483648
2147483647
Binary
2#10000000000000000000000000000000
2#01111111111111111111111111111111
Octal
8#20000000000
8#17777777777
Hexadecimal
16#80000000
16#7FFFFFFF
260
35006144 07/2012
Data Types
from...
to...
Decimal
65535
Binary
2#0
2#1111111111111111
Octal
8#0
8#177777
Hexadecimal
16#0
16#FFFF
35006144 07/2012
Base
from...
to...
Decimal
4294967295
Binary
2#0
2#11111111111111111111111111111111
Octal
8#0
8#37777777777
Hexadecimal
16#0
16#FFFFFFFF
261
Data Types
days (D)
hours (H)
minutes (M)
seconds (S)
milliseconds (MS)
Entering a Value
This table shows the possible ways of entering the maximum value of the Time type,
according the authorized units of time.
262
Diagram
Comment
T#4294967295MS
value in milliseconds
T#4294967S_295MS
value in seconds\milliseconds
T#71582M_47S_295MS
value in minutes\seconds\milliseconds
T#1193H_2M_47S_295MS
value in hours\minutes\seconds\milliseconds
T#49D_17H_2M_47S_295MS
value in days\hours\minutes\seconds\milliseconds
35006144 07/2012
Data Types
8.2
Date type
Time of Day type (TOD)
Date and Time (DT) type
35006144 07/2012
Page
264
266
267
268
263
Data Types
Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010 (unused)
1011 (unused)
1100 (unused)
1101 (unused)
1110 (unused)
1111 (unused)
264
Decimal value
2450
Binary value
0010
0100
0101
0000
35006144 07/2012
Data Types
Binary value
0111
1000
1001
1001
0011
0000
0001
0110
35006144 07/2012
Type
Designation
Scale (bits)
Default value
DATE
Date
32
D#1990-01-01
TIME_OF_DAY
Time of day
32
TOD#00:00:00
DATE_AND_TIME
64
DT#1990-01-01-00:00:00
265
Data Types
Month (09)
Day (20)
0000 1001
0010 0000
Syntax Rules
The Date type is entered as follows: D#<Year>-<Month>-<Day>
This table shows the lower/upper limits in each field.
Field
Limits
Comment
Year
[1990,2099]
Month
[01,12]
Day
[01,31]
[01,30]
[01,29]
[01,28]
Example:
266
Entry
Comments
D#2001-1-1
d#1990-02-02
35006144 07/2012
Data Types
Minutes (25)
Seconds (47)
0001 0011
0010 0101
0100 0111
Unused
Syntax Rules
The Time of Day type is entered as follows: TOD#<Hour>:<Minutes>:<Seconds>
This table shows the lower/upper limits in each field.
Field
Limits
Comment
Hour
[00,23]
The left 0 is always displayed, but can be omitted at the time of entry
Minute
[00,59]
The left 0 is always displayed, but can be omitted at the time of entry
Second
[00,59]
The left 0 is always displayed, but can be omitted at the time of entry
Example:
35006144 07/2012
Entry
Comment
TOD#1:59:0
tod#23:10:59
Tod#0:0:0
267
Data Types
0010 0000
Hour (13)
Least significant
byte
0001 0011
0010 0101
Unused
0100 0111
Syntax Rules
The Date and Time type is entered as follows:
DT#<Year>-<Month>-<Day>-<Hour>:<Minutes>:<Seconds>
This table shows the lower/upper limits in each field.
Field
Limits
Comment
Year
[1990,2099]
Month
[01,12]
Day
[01,31]
[01,30]
[01,29]
[01,28]
Hour
[00,23]
Minute
[00,59]
Second
[00,59]
Example:
Entry
Comment
DT#2000-1-10-0:40:0
dt#1999-12-31-23:59:59
Dt#1990-10-2-12:02:30
268
35006144 07/2012
Data Types
8.3
Representation:
The value of the fixed-point part (Mantissa) is between [0, 1[, and is calculated using
the following formula.
35006144 07/2012
269
Data Types
This table gives the values in the different fields according to number type.
e
]0, 255[
[0, 1[
0 or 1
Number type
[0, 1[
normalized
E-45
near (1.4
denormalized DEN
255
+ infinity (INF)
255
- infinity (-INF)
255
0 or 1
SNAN
255
0 or 1
QNAN
+0
-0
NOTE:
Standard IEC 559 defines two classes of NAN (not a number): QNAN and SNAN.
QNAN: is a NAN whose bit 22 is set to 1
SNAN: is a NAN whose bit 22 is set to 0
They behave as follows:
QNAN do not trigger errors when they appear in operands of a function or an
expression.
SNAN trigger an error when they appear in operands of a function or an arithmetic
expression (See %SW17 (see page 184) and %S18 (see page 164)).
This table gives the calculation formula of the value of the floating-point number:
Floating-point number
Value
Normalized
Denormalized (DEN)
270
35006144 07/2012
Data Types
Scale (bits)
Default value
REAL
32
0.0
E=129
M=8359248
1000001
11111111000110101010000
35006144 07/2012
271
Data Types
The gap becomes very important for big values as shown below:
Value
M=8359248
2127
2127
NOTE: The gap corresponds to the weight of the less significant bit.
In order to get an expected resolution, it is necessary to define the maximum range
for the calculation according the following formula:
For instance, if the accuracy needs to be = 0.001, the fixed-point part will be:
with:
272
35006144 07/2012
Data Types
Example:
Increment a value by 0.001 from 33000 to 1000000,
Count from 33000000 to 1000000000 (value times 1000) with 1 as increment,
Get the result multiplying the value by 0.001.
The accuracy F minimum per range will be:
From...to...
F (minimum)
3300...65536
0.004
65536...131072
0.008
...
...
524288...1000000
0.063
35006144 07/2012
273
Data Types
8.4
The size of the character string can be optimized during the definition of the type
using the STRING[<size>] command, <size> being an unsigned integer UINT
capable of defining a string of between 1 and 65535 ASCII characters.
NOTE: The ASCII characters 0-127 are common to all languages, but the
characters 128-255 are language dependent. Be careful is the language of the Unity
Pro is not the same as the OS language. If the two languages are not the same,
CHAR MODE communication can be disturbed and sending characters greater than
127 cannot be guaranteed to be correct. In particular, if the Stop on Reception
character is greater than 127, it is not taken into account.
274
35006144 07/2012
Data Types
Syntax Rules
The entry is preceded by and ends with the quote character "" (ASCII code 16#27).
The $ (dollar) sign is a special character, followed by certain letters which indicate:
$L or $l, go to the next line (line feed)
$N or $n, go to the start of the next line (new line)
$P or $p, go to the next page
$R or $r, carriage return
$T or $t tabulation (Tab)
$$, represents the character $ in a string
$, represents the quote character in a string
The user can use the syntax $nn to display, in a STRING variable, caracters which
must not be printed. It can be a carriage return (ASCII code 16#0D) for instance.
Examples
Entry examples:
Type
35006144 07/2012
Entry
STRING
ABCD
STRING[4]
john
john
STRING[10]
It$s john
Its john*
STRING[5]
*****
STRING[5]
****
STRING[5]
the number
the no
STRING[13]
0123456789
0123456789***
STRING[5]
$R$L
<cr><lf>***
STRING[5]
$$1.00
$1.00
275
Data Types
Variable
declaration
EF output parameter
FB output
parameter
STRING
Fixed size:
16 characters
Fixed size of
16 characters
STRING[<n>]
Fixed size:
n characters
The FB writes a
maximum of
n characters.
276
35006144 07/2012
Data Types
8.5
Byte type
Word type
Dword type
35006144 07/2012
Page
278
279
277
Data Types
hexadecimal (16#)
octal (8#)
binary (2#)
278
Scale (bits)
Default value
BYTE
WORD
16
DWORD
32
35006144 07/2012
Data Types
Lower limit
Upper limit
Hexadecimal
16#0
16#FF
Octal
8#0
8#377
Binary
2#0
2#11111111
Representation examples:
Data content
00001000
16#8
00110011
8#63
00110011
2#110011
Lower limit
Upper limit
Hexadecimal
16#0
16#FFFF
Octal
8#0
8#177777
Binary
2#0
2#1111111111111111
Representation examples:
35006144 07/2012
Data content
0000000011010011
16#D3
1010101010101010
8#125252
0000000011010011
2#11010011
279
Data Types
Lower limit
Upper limit
Hexadecimal
16#0
16#FFFFFFFF
Octal
8#0
8#37777777777
Binary
2#0
2#11111111111111111111111111111111
Representation examples:
280
Data content
00000000000010101101110011011110
16#ADCDE
00000000000000010000000000000000
8#200000
00000000000010101011110011011110
2#10101011110011011110
35006144 07/2012
Data Types
8.6
35006144 07/2012
Page
Arrays
282
Structures
285
286
288
291
293
281
Data Types
Arrays
What Is an Array?
It is a data item that contains a set of data of the same type, such as:
elementary data (EDT),
for example:
a group of BOOL words,
a group of UINT integer words,
etc.
Characteristics
An array is characterized by two parameters:
a parameter which defines its organization (array dimension(s)),
a parameter that defines the type of data it contains.
NOTE: The most complex organization is the array with six dimensions.
The syntax comprising these two parameters is:
282
35006144 07/2012
Data Types
Instancing an array
The instances Tab_1 and Tab_2 are of the same type and the same dimension, the
only difference being that during instancing:
the Tab_1 type takes the name X,
the Tab_2 type must be defined (unnamed table).
NOTE: It is beneficial to name the type, as any modification that has to be made will
only be done so once, otherwise there will be as many modifications as there are
instances.
Examples
This table presents the instances of arrays of different dimensions:
Entry
Comments
NOTE: Many functions (READ_VAR, WRITE_VAR for example) dont recognize the
index of an array of words starting by a number different from 0. If you use such an
index the functions will look at the number of words in the array, but not at the
starting index set in the definition of the array.
WARNING
UNEXPECTED APPLICATION BEHAVIOR - INVALID ARRAY INDEX
When applying functions on variables of array type, check that the functions are
compatible with the arrays starting index value when this value is greater than 0.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
35006144 07/2012
283
Data Types
284
35006144 07/2012
Data Types
Structures
What is a Structure?
It is a data item containing a set of data of a different type, such as:
NOTE: You can create nested structures (nested DDTs) over 8 levels. Recurring
structures (DDT) are not allowed.
Characteristics
A structure is composed of data which are each characterized by:
a type,
a name, which enables it to be identified,
a comment (optional) describing its role.
35006144 07/2012
285
Data Types
Illustration:
Characteristics
A data item belonging to the DDT family is made up of:
the type name (see page 250) (32 characters maximum) defined by the user (not
obligatory for tables but recommended) (see page 283)
the type (structure or table)
an optional comment (of a maximum of 1024 characters). Authorized characters
correspond to the ASCII codes 32 to 255
the description (in the case of a structure) of these elements
the element name (see page 250) (32 characters maximum)
NOTE: The total size of a table or of a structure does not exceed 64 Kbytes.
286
35006144 07/2012
Data Types
Examples
Definition of types
35006144 07/2012
287
Data Types
WARNING
RISK OF INCOMPATIBILITY AFTER CONCEPT CONVERSION
With the Concept programming application, the data structures do not handle any
shift in offsets (each element is set one after the other in the memory, regardless
of its type). Consequently, we recommend that you check everything, in particular
the consistency of the data when using DDTs located on the "State RAM" (risk of
shifts) or functions for communication with other devices (transfers with a different
size from those programmed in Concept).
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Principle for Modicon M340
The storage principle for Modicon M340 PLCs is as follows:
elements are stored in the order in which they are declared in the structure,
the basic element is the byte,
one alignment rule and function of the element:
the BOOL and BYTE types are aligned on either even or uneven bytes,
the INT, WORD and UINT types are aligned on even bytes,
the DINT, UDINT, REAL, TIME, DATE, TOD, DT and DWORD are aligned on
double words,
structures and tables are aligned according to the rules of their elements.
288
35006144 07/2012
Data Types
WARNING
BAD EXCHANGES BETWEEN A MODICON M340 AND A PREMIUM OR
QUANTUM.
Check if the structure of the exchanged data have the same alignments in the two
projects.
Otherwise, the data will not be exchanged properly.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
NOTE: It is possible that the alignment of data are not the same when the project is
transferred from the simulator of Unity Pro to a M340 PLC. So check the structure
of the data of the project.
NOTE: Unity Pro (see Unity Pro, Operating Modes) indicates where the alignment
seems to be different. Check the corresponding instances in the data editor. See the
page of Project settings (see Unity Pro, Operating Modes) to know how enable this
option.
Examples
The table below gives some examples of data structures. In the following examples,
structure type DDTs are addressed to %MWi. The words 1st byte corresponds to the
least significant 8 bits and the words 2nd byte corresponds to the most significant
8 bits.
For all the following structures, the first variable is mapped to the address %MW100:
First Memory Address
Modicon M340
Para_PWM1
%MW100 (1 byte)
%MW100 (1 byte)
t_period: TIME
t_min: TIME
in_max: REAL
st
st
Mode_TOTALIZER
byte)
%MW100 (1 byte)
hold: BOOL
rst: BOOL
%MW100
(1st
st
Info_TOTALIZER
%MW100
35006144 07/2012
(1st
byte)
st
%MW100 (1 byte)
outc: REAL
289
Data Types
cter: UINT
done: BOOL
The table below gives two examples of data structures with arrays:
First Memory Address
Modicon M340
st
%MW100 (1 byte)
%MW100
(2nd
%MW104
(1st
byte)
byte)
EHC105_Out
%MW100
(1st
byte)
Quit: BYTE
%MW100
(2nd
byte)
%MW103
(1st
byte)
CPCfg_ex
st
%MW100 (1 byte)
st
%MW101 (1 byte)
290
%MW102
(1st
%MW103
(1st
%MW104
(1st
byte)
byte)
byte)
st
Profile_type: INT
st
Interp_type: INT
%MW100 (1 byte)
%MW101 (1 byte)
%MW102
(1st
byte)
st
%MW103 (1 byte)
%MW104
(1st
byte)
Nb_of_coords: INT
Nb_of_points: INT
reserved: ARRAY [0..4] OF BYTE
Master_offset: DINT
Follower_offset: INT
35006144 07/2012
Data Types
The IODDT types are structures whose size (the number of elements of which they
are composed) depends on the channel or the input\output module that they
represent.
A given input\output module can have more than one IODDT.
The difference with a conventional structure is that:
Examples
IODDT structure for an input\output channel of an analog module
35006144 07/2012
291
Data Types
292
35006144 07/2012
Data Types
35006144 07/2012
293
Data Types
8.7
294
Page
295
297
299
35006144 07/2012
Data Types
the Elementary Function Block (EFB) (see page 245) type family
the User function block (DFB) (see page 245) type family
Illustration:
Illustration
Function block:
35006144 07/2012
295
Data Types
Ladder language
Structured Text language
Instruction List language
Functional block language FBD
A DFB type can have one or more instances where each instance is referenced by
a name (symbol) and possesses DFB data types.
Elementary Function Block (EFB)
Elementary Function Blocks (EFBs) are provided by the manufacturer and are
programmed in C language.
The user can create his own EFB for which he will need an optional software tool
"SDKC".
An EFB type can have one or more instances where each instance is referenced by
a name (symbol) and possesses EFB type data.
296
35006144 07/2012
Data Types
35006144 07/2012
the type name (see page 250), defined by the user for the DFBs,
an optional comment. The authorized characters correspond to the ASCII codes
32 to 255,
the application interface data:
the inputs, not accessible in read\write mode from the application, but read by
the function block code,
the inputs\outputs, not accessible in read\write mode from the application, but
read and written by the function block code,
the outputs, accessible in read only from the application and read and written
by the function block code.
the code:
for DFBs, this is written by the user in PLC language (Structured Text,
Instruction List, Ladder language, function block language), and is structured
in a single section if the IEC option is active, or may be structured in several
sections if this option is inactive
for EFBs, this is written in C language.
297
Data Types
Characteristics
This table gives the characteristics of the elements that make up a type:
Element
EFB
DFB
Name
32 characters
32 characters
Comment
1024 characters
1024 characters
Input Data
32 maximum
32 maximum
Input/Output data
32 maximum
32 maximum
Output data
32 maximum
32 maximum
Number of interfaces
(Inputs+Outputs+Inputs/Outputs)
32 maximum (2)
32 maximum (2)
Public data
No limits (1)
No limits (1)
Private data
No limits (1)
No limits (1)
Programming language
C language
Language:
Structured Text,
Instruction List,
Ladder language,
function block.
Section
298
35006144 07/2012
Data Types
DDT types
IODDT
Unnamed
tables
ANY_ARRAY
ANY...
Function
block types
other
Input data
Yes
No
Yes
Yes
Yes
Yes (2)
No
Input/output data
Yes (1)
Yes
Yes
Yes
Yes
Yes (2)
No
Output data
Yes
No
Yes
No
Yes
No
Public data
Yes
No
Yes
No
Yes
No
No
Private data
Yes
No
Yes
No
Yes
No
Yes
(1): not authorized for the EBOOL type static data used on Quantum PLCs
(2): not authorized for BOOL and EBOOL type data
(3): must be completed during the execution of the DFB, and not usable outside the
DFB
35006144 07/2012
299
Data Types
Input data
EDT
types
Yes
DDT types
IODDT
Unnamed
tables
ANY_ARRAY
other
No
No
Yes
Yes
ANY...
Function block
types
Yes (1)
No
Input/output data
Yes
Yes
No
Yes
Yes
Yes (1)
No
Output data
Yes
No
No
No
Yes
No
Public data
Yes
No
No
No
Yes
No
No
Private data
Yes
No
No
No
Yes
No
Yes
300
Yes
Yes
No
No
Input/output data
No
No
Yes
Yes
No
No
Public data
Yes
Yes
Private data
Yes
No
35006144 07/2012
Data Types
Yes
Yes
No
No
Input/output data
No
No
Yes
No
No
Public data
Yes
Yes
Private data
Yes
No
WARNING
UNEXPECTED APPLICATION BEHAVIOR - INVALID ARRAY INDEX
When using EFBs and DFBs on variables of array type, only use arrays with
starting index=0.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
35006144 07/2012
301
Data Types
8.8
inputs
input/outputs
outputs
302
ANY_ARRAY_WORD
ANY_ARRAY_UINT
ANY_ARRAY_UDINT
ANY_ARRAY_TOD
ANY_ARRAY_TIME
ANY_ARRAY_STRING
ANY_ARRAY_REAL
ANY_ARRAY_INT
ANY_ARRAY_EBOOL
ANY_ARRAY_DWORD
ANY_ARRAY_DT
ANY_ARRAY_DINT
ANY_ARRAY_DATE
ANY_ARRAY_BYTE
ANY_ARRAY_BOOL
35006144 07/2012
Data Types
Example
This gives us the following DFB:
NOTE: The authorized objects for the various parameters are defined in this table
(see page 591).
35006144 07/2012
303
Data Types
8.9
Illustration:
NOTE: The two structure types SFCSTEP_STATE and SFCSTEP_TIMES are also
linked to each Macro step of the sequential function chart.
304
35006144 07/2012
Data Types
x: BOOL elementary data type (EDT) containing the value TRUE when the step
is active,
t: TIME elementary data type (EDT) containing the activity time of the step. When
deactivated, the step value is maintained until the next activation,
tminErr: BOOL elementary data type (EDT) containing the value TRUE if the
activity time of the step is less than the minimum programmed activity time,
tmaxErr: BOOL elementary data type (EDT) containing the value TRUE if the
activity time of the step is greater than the maximum programmed activity time,
These data types are accessible from the application in read only mode.
Definition of the SFCSTEP_TIMES Structure Type
This structure includes all types of data linked to the definition of the runtime
parameters of the step or of the Macro step.
These data types are:
delay: TIME elementary data type (EDT), defining the polling delay time of the
transition situated downstream from the active step,
tmin: TIME elementary data type (EDT) containing the minimum value during
which the step must at least be executed. If this value is not respected the data
tmin.Err switches to the value TRUE,
tmax: TIME elementary data type (EDT) containing the maximum value during
which the step must at least be executed. If this value is not respected the data
tmax.Err switches to the value TRUE.
These data types are only accessible from the SFC editor.
Data Access Syntax of the Structure SFCSTEP_STATE
The instance names of this structure correspond to the names of the steps or macro
steps of the sequential function chart
35006144 07/2012
Syntax
Comment
Name_Step.x
Name_Step.t
Used to find out the current or total activation time for the step
Name_Step.tminErr
Used to find out if the minimum activation time of the step is less than
the time programmed in Name_Step.tmin
Name_Step.tmaxErr
Used to find out if the maximum activation time of the step is greater
than the time programmed in Name_Step.tmax
305
Data Types
8.10
306
35006144 07/2012
Data Types
ELEMENT_1
ELEMENT_1
ELEMENT_2
ELEMENT_3
ELEMENT_4
YES
NO
NO
NO
NO
ELEMENT_2
YES
ELEMENT_3
NO
NO
ELEMENT_4
NO
NO
NO
NO
35006144 07/2012
307
Data Types
and type...
are...
TAB_1
TAB_2
incompatible
TAB_2
TAB_3
compatible
TAB_4
TAB_5
compatible
TAB_4[25]
TAB_5[28]
compatible
308
35006144 07/2012
Data Types
Example:
35006144 07/2012
309
Data Types
310
35006144 07/2012
Unity Pro
Data Instances
35006144 07/2012
Data Instances
9
Whats in this Chapter?
This chapter describes data instances and their characteristics.
These instances can be:
35006144 07/2012
Page
312
316
319
311
Data Instances
NOTE: Sequential Function Chart (SFC) data type instances are created when they
are inserted in the application program, with a default name that the user can modify.
312
35006144 07/2012
Data Instances
35006144 07/2012
313
Data Instances
Examples:
NOTE: Sequential Function Chart (SFC) data type instances are created the
moment they are inserted in the application program, with a default name that the
user can modify.
314
35006144 07/2012
Data Instances
Constant
%M<i>
System
Input/Output
%S<i>
%Q, %I
%SW<i>
%QW, %IW
%MW<i>
%KW<i>
%MD<i> (1)
%KD<i> (1)
%QD, %ID
%MF<i> (1)
%KF<i> (1)
%QF, %IF
Network
%NW
Legend:
(1) Not available for Modicon M340
NOTE: Located data instances can be used by a direct addressing in the program
Example:
Var_1: DINT AT %MW10
;%MW10 and %MW11 are both used. %MD10 direct addressing can be used or
Var_1 in the program.
35006144 07/2012
315
Data Instances
316
SFC object
Name
Step
Macro step
35006144 07/2012
Data Instances
SFC object
Name
Transition
NOTE: Instance names do not include the name of the section in which the instance
is used, since it can be used in different sections of the application.
Access to an Element of a DDT Family Instance
The access syntax is as follows:
Rule:
The maximum size of the access syntax is 1024 characters, and the possible limits
of a derived data type are as follows:
10 nesting levels (tables/structures)
6 dimensions per table
4 digits (figures) to define the index of a table element
35006144 07/2012
317
Data Instances
Rule:
The maximum size of the access syntax is 1024 characters, and the possible limits
of a derived data type are as follows:
10 nesting levels (tables/structures)
6 dimensions per table
4 digits (figures) to define the index of a table element
318
35006144 07/2012
Data Instances
%M Internal Variables
Access syntax:
Syntax
Format
%M<i> or
%MX<i>
Word
%MW<i>
16 bits (INT)
%MW10
R/W
Word extracted
bit
%MW<i>.<j>
1 bit (BOOL)
%MW15.5
R/W
Double word
%MD<i> (1)
32 bits (DINT)
%MD8
R/W
Real (floating
point)
%MF<i> (1)
32 bits (REAL)
%MF15
R/W
Bit
Example
Program
access rights
R/W
Legend
(1): Not available for Modicon M340.
<i> represents the instance number (starts a 0 for Premium and 1 for Quantum).
For Modicon M340 double-type instance (double word) or floating instance (real)
must be located in an integer type %MW. The index <i> of the %MW has to be even.
NOTE: The %M<i> or %MX<i> data detect edges and manage forcing.
35006144 07/2012
319
Data Instances
Memory organization:
Format
Program access
rights
Word constant
%KW<i>
16 bits (INT)
%KD<i> (1)
32 bits (DINT)
%KF<i> (1)
32 bits (REAL)
Legend
(1): Not available for Modicon M340.
320
35006144 07/2012
Data Instances
%I Constants
Access syntax:
Syntax
Format
Program access
rights
Bit constant
%I<i>
3 bits (EBOOL)
Word constant
%IW<i>
16 bits (INT)
Format
Program
access rights
Bit
R/W or R
Word
%SW<i>
R/W or R
32 bits (INT)
Format
Program
access rights
Common word
%NW<n>.<s>.<d>
16 bits (INT)
R\W or R
%NW<n>.<s>.<d>.<j>
1 bit (BOOL)
R\W or R
35006144 07/2012
321
Data Instances
Syntax
Example
Program
access rights
%CH<@mod>.<c>
%CH4.3.2
%I<@mod>.MOD.ERR
%I4.2.MOD.ERR
%I inputs
BOOL type module error bit
BOOL type channel error bit
%I<@mod>.<c>.ERR
%I4.2.3.ERR
%I<@mod>.<c>
%I4.2.3
%I<@mod>.<c>.<d>
%I4.2.3.1
%IW<@mod>.<c>
%IW4.2.3
%IW<@mod>.<c>.<d>
%IW4.2.3.1
%ID<@mod>.<c>
%ID4.2.3
%ID<@mod>.<c>.<d>
%ID4.2.3.2
%IF<@mod>.<c>
%IF4.2.3
%IF<@mod>.<c>.<d>
%IF4.2.3.2
%Q outputs
EBOOL type bit
%Q<@mod>.<c>
%Q4.20.3
R/W
%Q<@mod>.<c>.<d>
%Q4.20.30.1
R/W
%QW<@mod>.<c>
%QW4.2.3
R/W
%QW<@mod>.<c>.<d>
%QW4.2.3.1
R/W
%QD<@mod>.<c>
%QD4.2.3
R/W
%QD<@mod>.<c>.<d>
%QD4.2.3.2
R/W
%QF<@mod>.<c>
%QF4.2.3
R/W
%QF<@mod>.<c>.<d>
%QF4.2.3.2
R/W
%MW<@mod>.<c>
%MW4.2.3
R/W
%MW<@mod>.<c>.<d>
%MW4.2.3.1
R/W
%MD<@mod>.<c>
%MD4.2.3
R/W
%MD<@mod>.<c>.<d>
%MD4.2.3.2
R/W
%MF<@mod>.<c>
%MF4.2.3
R/W
%MF<@mod>.<c>.<d>
%MF4.2.3.2
R/W
%M variables (Premium)
INT type word
322
35006144 07/2012
Data Instances
Syntax
Example
Program
access rights
%KW4.2.3
%KW<@mod>.<c>
%KW<@mod>.<c>.<d>
%KW4.2.3.1
%KD<@mod>.<c>
%KD4.2.3
%KD<@mod>.<c>.<d>
%KD4.2.3.12
%KF<@mod>.<c>
%KF4.2.3
%KF<@mod>.<c>.<d>
%KF4.2.3.12
<@mod = \<b>.<e>\<r>.<m>
<b> bus number (omitted if station is local).
<e> device connection point number (omitted if station is local, the connection point
is also called Drop for Quantum users).
<r> rack number.
<m> module slot
<c> channel number (0 to 999) or MOD reserved word.
<d> data number (0 to 999) or ERR reserved word (optional if 0 value). For
Modicon M340 <d> is always even.
35006144 07/2012
323
Data Instances
Examples: local station and station on bus for Modicon M340 PLCs.
324
35006144 07/2012
Data Instances
Examples: local station and station on bus for Quantum and Premium PLCs.
35006144 07/2012
325
Data Instances
326
35006144 07/2012
Unity Pro
Data References
35006144 07/2012
Data References
10
Whats in this Chapter?
This chapter provides the references of data instances.
These references can be:
value-based references,
name-based references,
address-based references.
35006144 07/2012
Page
328
330
333
337
327
Data References
Booleans
BOOL
EBOOL
integers
INT
UINT
DINT
UDINT
TIME
reals
REAL
character strings
STRING
The programming software goes beyond the scope of the standard by adding the bit
string types.
328
BYTE
WORD
DWORD
35006144 07/2012
Data References
35006144 07/2012
Immediate value
Type of instance
I am a character string
STRING
T#1s
TIME
D#2000-01-01
DATE
TOD#12:25:23
TIME_OF_DAY
DT#2000-01-01-12:25:23
DATE_AND_TIME
16#FFF0
WORD
UINT
DWORD
329
Data References
330
35006144 07/2012
Data References
Structures:
The user chooses a name (symbol) which can be used to access the data instance:
35006144 07/2012
331
Data References
332
35006144 07/2012
Data References
35006144 07/2012
333
Data References
Object<j>
%M<i>[index]
<j>=<i> + <index>
%MW<i>[index]
<j>=<i> + <index>
%KW<i>[index]
<j>=<i> + <index>
%MD<i>[index]
<j>=<i> + (<index> x 2)
%KD<i>[index]
<j>=<i> + (<index> x 2)
%MF<i>[index]
<j>=<i> + (<index> x 2)
%KF<i>[index]
<j>=<i> + (<index> x 2)
Examples:
334
35006144 07/2012
Data References
Examples:
35006144 07/2012
335
Data References
Address
Write access
%Ix.<i>:L
No
%Qx.<i>:L
Yes
Internal bits
%M<i>:L
Yes
Address
Write access
Internal words
%MW<i>:L
%MD<i>:L
%MF<i>:L
Yes
Constant words
%KW<i>:L
%KD<i>:L
%KF<i>:L
No
System words
%SW50:4
Yes
Examples:
%M2:65 Defines an EBOOL table from %M2 to %M66
%M125:30 Defines an INT table from %MW125 to %MW154
336
35006144 07/2012
Data References
Some rules have been defined in order to avoid conflicts occurring. This means that
it is necessary to differentiate between the different domains of application of data
What is a Domain?
It is an area of the application from which a variable can or cannot be accessed, such
as:
Rules
This table defines whether or not it is possible to use a name that already exists in
the application for newly-created elements:
Application
Content ->
New elements
(below)
Section
SR
DDT/IO
DDT
FB
type
FB
Instances
EF
Variable
Section
No
No
Yes
Yes
Yes
Yes
Yes
SR
No
No
Yes
Yes
No
(1)
No
DDT/IODDT
No
No
No
No (4)
No
No (4) No
FB type
Yes
Yes
No
No
(3)
No
(3)
FB Instances
No
No
No
Yes
No
Yes
No
EF
Yes
(2)
No
No
No
No
No
Variable
Yes
No
Yes
Yes
No
(1)
No
(1): An instance belonging to the application domain cannot have the same name as
an EF.
(2): An instance belonging to the type domain (internal variable) can have the same
name as an EF. The EF in question cannot be used in this type.
35006144 07/2012
337
Data References
(3): The creation or import of EFB/DFBs with the same name as an existing instance
are prohibited.
(4): An DDT/IODDT element might have the same name of an FB/EF, however it is
not advised as the FB/EF should not be used in the application.
NOTE: A number of additional considerations to the rules given in the table are listed
below, specifying that:
338
Within a type, an instance (internal variable) cannot have the same name as the
type name of the object to which it belongs,
There is no conflict between the name of an instance belonging to a section of
the application and the name of the instance belonging to a section of a DFB,
There is no conflict between the name of a section belonging to a task and the
name of the section belonging to a DFB.
35006144 07/2012
Unity Pro
Programming Language
35006144 07/2012
Programming Language
IV
Contents of this Part
This part describes the syntax of the programming languages that are available.
What Is in This Part?
This part contains the following chapters:
Chapter
35006144 07/2012
Chapter Name
Page
11
341
12
369
13
413
14
475
15
527
339
Programming Language
340
35006144 07/2012
Unity Pro
Function Block Language FBD
35006144 07/2012
11
Overview
This chapter describes the function block language FBD which conforms to
IEC 61131.
What Is in This Chapter?
This chapter contains the following topics:
Topic
35006144 07/2012
Page
342
344
Subroutine Calls
354
Control Elements
355
Link
356
Text Object
358
359
362
Loop Planning
367
341
Objects
The objects of the FBD programming language (Function Block Diagram) help to
divide a section into a number of:
EFs and EFBs (Elementary Functions (see page 344) and Elementary Function
Blocks (see page 345)),
DFBs (Derived Function Blocks) (see page 346),
Procedures (see page 346) and
Control Elements (see page 355).
These objects, combined under the name FFBs, can be linked with each other by:
Links (see page 356) or
Actual Parameters (see page 347).
Comments regarding the section logic can be provided using text objects (see Text
Object, page 358).
342
35006144 07/2012
Section Size
One FBD section consists of a window containing a single page.
This page has a grid background. A grid unit consists of 10 coordinates. A grid unit
is the smallest possible space between 2 objects in an FBD section.
The FBD programming language is not cell oriented but the objects are still aligned
with the grid coordinates.
An FBD section can be configured in number of cells (horizontal grid coordinates
and vertical grid coordinates).
IEC Conformity
For a description of the extent to which the FBD programming language conforms
to IEC, see IEC Conformity (see page 661).
35006144 07/2012
343
Elementary Function
Elementary functions (EF) have no internal states. If the input values are the same,
the value on the output is the same every time the function is called. For example,
the addition of two values always gives the same result.
An elementary function is represented graphically as a frame with inputs and one
output. The inputs are always represented on the left and the output is always on the
right of the frame.
The name of the function, i.e. the function type, is displayed in the center of the
frame.
The execution number (see page 359) for the function is shown to the right of the
function type.
The function counter is shown above the frame. The function counter is the
sequential number of the function within the current section. Function counters
cannot be modified.
Elementary Function
344
35006144 07/2012
35006144 07/2012
345
DFB
Derived function blocks (DFBs) have the same properties as elementary function
blocks. The user can create them in the programming languages FBD, LD, IL, and/or
ST.
The only difference to elementary function blocks is that the derived function block
is represented as a frame with double vertical lines.
Derived Function Block
Procedure
Procedures are functions viewed technically.
The only difference to elementary functions is that procedures can occupy more
than one output and they support data type VAR_IN_OUT.
Procedures are a supplement to IEC 61131-3 and must be enabled explicitly.
To the eye, procedures are no different than elementary functions.
Procedure
346
35006144 07/2012
Parameters
Inputs and outputs are required to transfer values to or from an FFB. These are
called formal parameters.
Objects are linked to formal parameters; these objects contain the current process
states. They are called actual parameters.
Formal and actual parameters:
At program runtime, the values from the process are transferred to the FFB via the
actual parameters and then output again after processing.
Only one object (actual parameter) of the following types may be linked to FFB
inputs:
Variable
Address
Literal
ST Expression (see page 529)
ST expressions on FFB inputs are a supplement to IEC 61131-3 and must be
enabled explicitly.
Link
The following combinations of objects (actual parameters) can be linked to FFB
outputs:
one variable
a variable and one or more connections (but not for VAR_IN_OUT
(see page 353) outputs)
an address
an address and one or more connections (but not for VAR_IN_OUT
(see page 353) outputs)
one or more connections (but not for VAR_IN_OUT (see page 353) outputs)
The data type of the object to be linked must be the same as that of the FFB
input/output. If all actual parameters consist of literals, a suitable data type is
selected for the function block.
35006144 07/2012
347
Exception: For generic FFB inputs/outputs with data type ANY_BIT, it is possible to
link objects of data type INT or DINT (not UINT and UDINT).
This is a supplement to IEC 61131-3 and must be enabled explicitly.
Example:
Allowed:
Not allowed:
EDT
STRING
ARRAY
ANY_ARRAY IODDT
STRUCT FB
ANY
EFB: Input
EFB: VAR_IN_OUT +
EFB: Output
DFB: Input
DFB: VAR_IN_OUT +
DFB: Output
EF: Input
EF: VAR_IN_OUT
EF: Output
Procedure: Input
348
35006144 07/2012
Parameter type
EDT
STRING
ARRAY
ANY_ARRAY IODDT
STRUCT FB
ANY
Procedure:
VAR_IN_OUT
Procedure: Output
not applicable
FFBs that use actual parameters on the inputs that have not yet received any value
assignment, work with the initial values of these actual parameters.
If no value is allocated to a formal parameter, then the initial value will be used for
executing the function block. If no initial value has been defined then the default
value ("0") is used.
If a formal parameter is not assigned a value and the function block/DFB instance is
invoked more than once, then the subsequently executed invocations are run with
the last effective actual value.
NOTE: Unassigned data structures will always be initialized with value "0", initial
values can not be defined.
Public Variables
In addition to inputs and outputs, some function blocks also provide public variables.
These variables transfer static values (values that are not influenced by the process)
to the function block. They are used for setting parameters for the function block.
Public variables are a supplement to IEC 61131-3.
The assignment of values to public variables is made using their initial values.
Public variables are read via the instance name of the function block and the names
of the public variables.
35006144 07/2012
349
Example:
Private Variables
In addition to inputs, outputs and public variables, some function blocks also provide
private variables.
Like public variables, private variables are used to transfer statistical values (values
that are not influenced by the process) to the function block.
Private variables can not be accessed by user program. These type of variables can
only be accessed by the animation table.
NOTE: Nested DFBs are declared as private variables of the parent DFB. So their
variables are also not accessible through programming, but trough the animation
table.
Private variables are a supplement to IEC 61131-3.
Programming Notes
Attention should be paid to the following programming notes:
FFBs are only executed if the input EN=1 or if the input EN is grayed out (see also
EN and ENO (see page 351)).
Boolean inputs and outputs can be inverted.
Special conditions apply when using VAR_IN_OUT variables (see page 353).
Function block/DFB instances can be called multiple times (see also Multiple
Function Block Instance Call (see page 351)).
350
35006144 07/2012
35006144 07/2012
351
EN/ENO handling with function blocks that have one variable and one link as
output parameters:
Functions/Procedures
As defined in IEC61131-3, the outputs from deactivated functions (EN input set to
"0") are undefined. (The same applies to procedures.)
Here nevertheless an explanation of the output statuses in this case:
EN/ENO handling with function/procedure blocks that (only) have one link as
an output parameter:
352
35006144 07/2012
If this project setting is set to 1, the link maintains the old value it had during
the last correctly executed cycle.
Please refer to Maintain output links on disabled EF (see Unity Pro, Operating
Modes).
The OUT1 variable on the same pin either retains its previous status or can be
changed externally without influencing the link. The variable and the link are
saved independently of each other.
The output behavior of the FFBs does not depend on whether the FFBs are invoked
without EN/ENO or with EN=1.
NOTE: For disabled function blocks (EN = 0) with an internal time function (e.g.
function block DELAY), time seems to keep running, since it is calculated with the
help of a system clock and is therefore independent of the program cycle and the
release of the block.
VAR_IN_OUT Variable
FFBs are often used to read a variable at an input (input variables), to process it and
to output the altered values of the same variable (output variables).
This special type of input/output variable is also called a VAR_IN_OUT variable.
The link between input and output variables is represented by a line in the FFB.
VAR_IN_OUT variable
The following special features are to be noted when using FFBs with VAR_IN_OUT
variables.
All VAR_IN_OUT inputs must be assigned a variable.
Via graphical links only VAR_IN_OUT outputs with VAR_IN_OUT inputs can be
connected.
Only one graphical link can be connected to a VAR_IN_OUT input/output.
A combination of variable/address and graphical connections is not possible for
VAR_IN_OUT outputs).
No literals or constants can be connected to VAR_IN_OUT inputs/outputs.
No negations can be used on VAR_IN_OUT inputs/outputs.
Different variables/variable components can be connected to the VAR_IN_OUT
input and the VAR_IN_OUT output. In this case the value of the variables/variable
component on the input is copied to the at the output variables/variable
component.
35006144 07/2012
353
Subroutine Calls
Calling a Subroutine
In FBD, subroutines are called using the following blocks.
The subroutine to be called must be located in the same task as the FBD section
called.
Subroutines can also be called from within subroutines.
Subroutine calls are a supplement to IEC 61131-3 and must be enabled explicitly.
In SFC action sections, subroutine calls are only allowed when Multitoken Operation
is enabled.
354
35006144 07/2012
Control Elements
Introduction
Control elements are used for executing jumps within an FBD section and for
returning from a subroutine (SRx) or derived function block (DFB) to the main
program.
Control Elements
The following control elements are available.
Designation
Representation
Jump
Label
Return
Description
When the status of the left link is 1, a jump is made to a label (in the current
section).
To generate a conditional jump, a jump object is linked to a Boolean FFB
output.
To generate an unconditional jump, the jump object is assigned the value
1 for example, using the AND function.
LABEL:
Labels (jump targets) are indicated as text with a colon at the end.
This text is limited to 32 characters and must be unique within the entire
section. The text must conform to general naming conventions.
Jump labels can only be placed between the first two grid points on the left
edge of the section.
Note: Jump labels may not "cut through" networks, i.e. an assumed line
from the jump label to the right edge of the section may not be crossed by
any object. This is also valid for links.
RETURN objects can not be used in the main program.
In a DFB, a RETURN object forces the return to the program which called
the DFB.
The rest of the DFB section containing the RETURN object is not
executed.
The next sections of the DFB are not executed.
The program which called the DFB will be executed after return from the
DFB.
If the DFB is called by another DFB, the calling DFB will be executed
after return.
In a SR, a RETURN object forces the return to the program which called
the SR.
The rest of the SR containing the RETURN object is not executed.
The program which called the SR will be executed after return from
the SR.
35006144 07/2012
355
Link
Description
Links are vertical and horizontal connections between FFBs.
Representation
The link coordinates are identified by a filled circle.
356
35006144 07/2012
Programming Notes
Attention should be paid to the following programming notes:
Links can be used for any data type.
The data types of the inputs/outputs to be linked must be the same.
Several links can be connected with one FFB output. Only one may be linked with
an FFB input however.
Inputs and outputs may be linked to one-another. Linking more than one output
together is not possible. That means that no OR connection is possible using
links in FBD. An OR function is to be used in this case.
Overlapping links with other objects is permitted.
Links may not be used to create loops since the sequence of execution in this
case cannot be clearly determined in the section. Loops must be created using
actual parameters (see Loop Planning, page 367).
To avoid links crossing each other, links can also be represented in the form of
connectors.
The source and target for the connection are labeled with a name that is unique
within the section.
The connector name has the following structure depending on the type of source
object for the connection:
For functions: "Function counter/formal parameter" for the source of the
connection
35006144 07/2012
For function blocks: "Instance name/formal parameter" for the source of the
connection
357
Text Object
Description
Text can be positioned as text objects using FBD Function Block language. The size
of these text objects depends on the length of the text. The size of the object,
depending on the size of the text, can be extended vertically and horizontally to fill
further grid units. Text objects may not overlap with FFBs; however they may
overlap with links.
358
35006144 07/2012
35006144 07/2012
359
Priorities
Priorities in Defining the Signal Flow Within a Section.
360
Priority
Rule
Description
Link
User Definition
Network by
Network
Output Sequence
Rung by Rung
35006144 07/2012
Example
Example of the Execution Sequence of Objects in an FBD Section:
35006144 07/2012
361
362
35006144 07/2012
35006144 07/2012
363
Network Positions
The correct execution sequence can be achieved by changing the position of the
networks in the section (see also Original Situation, page 362).
364
35006144 07/2012
Explicit Definition
The correct execution sequence can be achieved by explicitly changing the
execution sequence of an FFB. To indicate that which FFBs had their execution
order changed, the execution number is shown in a black field (see also Original
Situation, page 362).
NOTE: Only one reference of an instance is allowed, e.g. the instance ".7" may only
be referenced once.
35006144 07/2012
365
FFB Positions
The position of FFBs only influences the execution sequence if more than one FFB
is linked to the same output of the "calling" FFB (see also Original Situation,
page 362).
In the first network, block positions .4 and .5 are switched. In this case (common
origins for both block inputs) the execution sequence of both blocks is switched as
well (processed from top to bottom).
In the second network, block positions .7 and .8 are switched. In this case (different
origins for the block inputs) the execution sequence of the blocks is not switched
(processed in the order the block outputs are called).
366
35006144 07/2012
Loop Planning
Non-Permitted Loops
Configuring loops exclusively via links is not permitted since it is not possible to
clearly specify the signal flow (the output of one FFB is the input of the next FFB,
and the output of this one is the input of the first).
Non-permitted Loops via Links
35006144 07/2012
367
368
35006144 07/2012
Unity Pro
Ladder Diagram (LD)
35006144 07/2012
12
Overview
This chapter describes the ladder diagram language LD which conforms to
IEC 611311.
What Is in This Chapter?
This chapter contains the following topics:
Topic
35006144 07/2012
Page
370
Contacts
373
Coils
374
376
Control Elements
387
388
Links
390
Text Object
393
Edge Recognition
394
403
Loop Planning
405
407
369
370
35006144 07/2012
Representation of an LD Section
Representation:
35006144 07/2012
371
Objects
The objects of the LD programming language help to divide a section into a number
of:
Contacts (see page 373)
Coils (see page 374)
EFs and EFBs (Elementary Functions (see page 376) and Elementary Function
Blocks (see page 377))
DFBs (Derived Function Blocks (see page 378))
Procedures (see page 379)
Control Elements (see page 387) and
Operation and Comparison blocks (see page 388) that represent an extension to
IEC 61131-3
These objects can be connected with each other by means of:
Links (see page 390) or
Actual Parameters (see page 379) (FFBs only).
Comments regarding the section logic can be provided using text objects (see Text
Object, page 393).
Section Size
One LD section consists of a window containing a single page.
This page has a grid that divides the section into rows and columns.
A width of 11-64 columns and 17-2000 lines can be defined for LD sections.
The LD programming language is cell oriented, i.e. only one object can be placed in
each cell.
Processing Sequence
The processing sequence of the individual objects in an LD section is determined by
the data flow within the section. Networks connected to the left power rail are
processed from top to bottom (link to the left power rail). Networks that are
independent of each other within the section are processed according to their
position (from top to bottom) (see also Execution Sequence and Signal Flow,
page 403).
IEC Conformity
For a description of IEC conformity for the LD programming language, see IEC
Conformity (see page 661).
372
35006144 07/2012
Contacts
Introduction
A contact is an LD element that transfers a status on the horizontal link to its right
side. This status is the result of a Boolean AND operation on the status of the
horizontal link on the left side with the status of the relevant Boolean actual
parameter.
A contact does not change the value of the relevant actual parameter.
Contacts take up one cell.
The following are permitted as actual parameters:
Boolean variables
Boolean constants
Boolean addresses (topological addresses or symbolic addresses)
ST expression (see page 529) delivering a Boolean result (e.g. VarA OR VarB)
ST expressions as actual parameters for contacts are a supplement to IEC
61131-3 and must be enabled explicitly
Contact Types
The following contacts are available:
Designation
Representation
Description
Normally open
In the case of normally open contacts, the status of the left link is
transferred to the right link if the status of the relevant Boolean
actual parameter (indicated with xxx) is ON. Otherwise, the status
of the right link is OFF.
Normally closed
In the case of normally closed contacts, the status of the left link is
transferred to the right link if the status of the relevant Boolean
actual parameter (indicated with xxx) is OFF. Otherwise, the status
of the right link is OFF.
With contacts for detection of positive transitions, the right link for
a program cycle is ON if a transfer of the relevant actual parameter
(labeled by xxx) goes from OFF to ON and the status of the left link
is ON at the same time. Otherwise, the status of the right link is 0.
Also see Edge Recognition, page 394.
With contacts for detection of negative transitions, the right link for
a program cycle is ON if a transfer of the relevant actual parameter
(labeled by xxx) goes from ON to OFF and the status of the left link
is ON at the same time. Otherwise, the status of the right link is 0.
Also see Edge Recognition, page 394.
35006144 07/2012
373
Coils
Introduction
A coil is an LD element which transfers the status of the horizontal link on the left
side, unchanged, to the horizontal link on the right side. The status is stored in the
respective Boolean actual parameter.
Normally, coils follow contacts or FFBs, but they can also be followed by contacts.
Coils take up one cell.
The following are permitted as actual parameters:
Boolean variables
Boolean addresses (topological addresses or symbolic addresses)
Coil Types
The following coils are available:
Designation
Representation
Description
Coil
With coils, the status of the left link is transferred to the relevant Boolean
actual parameter (indicated by xxx) and the right link.
negated coil
With negated coils, the status of the left link is copied onto the right link. The
inverted status of the left link is copied to the relevant Boolean actual
parameter (indicated by xxx). If the left link is OFF, then the right link will
also be OFF and the relevant Boolean actual parameter will be ON.
Coil for
detecting
positive
transitions
With coils that detect positive transitions, the status of the left link is copied
onto the right link. The relevant actual parameter of data type EBOOL
(indicated by xxx) is 1 for a program cycle, if a transition of the left link from
0 to 1 is made.
Also see Edge Recognition, page 394.
Coil for
detecting
negative
transitions
With coils that detect negative transitions, the status of the left link is copied
onto the right link. The relevant actual Boolean parameter (indicated by xxx)
is 1 for a program cycle, if a transition of the left link from 1 to 0 is made.
Also see Edge Recognition, page 394.
Set coil
With set coils, the status of the left link is copied onto the right link. The
relevant Boolean actual parameter (indicated by xxx) is set to ON if the left
link has a status of ON, otherwise it remains unchanged. The relevant
Boolean actual parameter can be reset through the reset coil.
Also see Edge Recognition, page 394.
Reset coil
With reset coils, the status of the left link is copied onto the right link. The
relevant Boolean actual parameter (indicated by xxx) is set to OFF if the left
link has a status of ON, otherwise it remains unchanged. The relevant
Boolean actual parameter can be set through the set coil.
Also see Edge Recognition, page 394.
374
35006144 07/2012
Designation
Representation
Description
Stop coil
With halt coils, if the status of the left link is 1, the program execution is
stopped immediately. (With stop coils the status of the left link is not copied
to the right link.)
Call coil
With call coils, the status of the left link is copied to the right link. If the status
of the left link is ON then the respective sub-program (indicated by xxx) is
called.
The subroutine to be called must be located in the same task as the calling
LD section. Subroutines can also be called from within subroutines.
Subroutines are a supplement to IEC 61131-3 and must be enabled
explicitly.
In SFC action sections, call coils (subroutine calls) are only allowed when
Multitoken Operation is enabled.
35006144 07/2012
375
376
35006144 07/2012
35006144 07/2012
377
DFB
Derived function blocks (DFBs) have the same properties as elementary function
blocks. The user can create them in the programming languages FBD, LD, IL, and/or
ST.
The only difference to elementary function blocks is that the derived function block
is represented as a frame with double vertical lines.
Derived Function Block
378
35006144 07/2012
Procedure
Procedures are functions viewed technically.
The only difference to elementary functions is that procedures can occupy more
than one output and they support data type VAR_IN_OUT.
To the eye, procedures are no different than elementary functions.
Procedures are a supplement to IEC 61131-3 and must be enabled explicitly.
Procedure
Parameters
Inputs and outputs are required to transfer values to or from an FFB. These are
called formal parameters.
Objects are linked to formal parameters; these objects contain the current process
states. They are called actual parameters.
Formal and actual parameters:
At program runtime, the values from the process are transferred to the FFB via the
actual parameters and then output again after processing.
35006144 07/2012
379
Only one object (actual parameter) of the following types may be linked to FFB
inputs:
Contact
Variable
Address
Literal
ST Expression
ST expressions on FFB inputs are a supplement to IEC 61131-3 and must be
enabled explicitly.
Link
The following combinations of objects (actual parameters) can be linked to FFB
outputs:
one or more coils
one or more contacts
one variable
a variable and one or more connections (but not for VAR_IN_OUT
(see page 386) outputs)
an address
an address and one or more connections (but not for VAR_IN_OUT
(see page 386) outputs)
one or more connections (but not for VAR_IN_OUT (see page 386) outputs)
The data type of the object to be linked must be the same as that of the FFB
input/output. If all actual parameters consist of literals, a suitable data type is
selected for the function block.
Exception: For generic FFB inputs/outputs with data type ANY_BIT, it is possible to
link objects of data type INT or DINT (not UINT and UDINT).
This is a supplement to IEC 61131-3 and must be enabled explicitly.
Example:
Allowed:
380
35006144 07/2012
Not allowed:
EDT
STRING
ARRAY
ANY_ARRAY IODDT
STRUCT FB
ANY
EFB: Input
DFB: Output
EFB: VAR_IN_OUT +
DFB: Input
DFB: VAR_IN_OUT +
EFB: Output
EF: Input
EF: VAR_IN_OUT
EF: Output
Procedure: Input
Procedure:
VAR_IN_OUT
Procedure: Output
not applicable
FFBs that use actual parameters on the inputs that have not yet received any value
assignment, work with the initial values of these actual parameters.
If no value is allocated to a formal parameter, then the initial value will be used for
executing the function block. If no initial value has been defined then the default
value (0) is used.
If a formal parameter is not assigned a value and the function block/DFB is
instanced more than once, then the subsequent instances are run with the old value.
35006144 07/2012
381
Public Variables
In addition to inputs/outputs, some function blocks also provide public variables.
These variables transfer statistical values (values that are not influenced by the
process) to the function block. They are used for setting parameters for the function
block.
Public variables are a supplement to IEC 61131-3.
The assignment of values to public variables is made using their initial values.
Public variables are read via the instance name of the function block and the names
of the public variables.
Example:
Private Variables
In addition to inputs, outputs and public variables, some function blocks also provide
private variables.
Like public variables, private variables are used to transfer statistical values (values
that are not influenced by the process) to the function block.
Private variables can not be accessed by user program. These type of variables can
only be accessed by the animation table.
NOTE: Nested DFBs are declared as private variables of the parent DFB. So their
variables are also not accessible through programming, but trough the animation
table.
Private variables are a supplement to IEC 61131-3.
382
35006144 07/2012
Programming Notes
Attention should be paid to the following programming notes:
FFBs will only be processed when they are directly or indirectly connected to the
left bus bar.
If the FFB will be conditionally executed, the EN input may be pre-linked through
contacts or other FFBs (also see EN and ENO (see page 383)).
Boolean inputs and outputs can be inverted.
Special conditions apply when using VAR_IN_OUT variables (see page 386).
Function block/DFB instances can be called multiple times (also see ).Multiple
Function Block Instance Call (see page 383)
Multiple Function Block Instance Call
Function block/DFB instances can be called more than once; other than instances
from communication EFBs and function blocks/DFBs with an ANY output but no ANY
input: these can only be called once.
Calling the same function block/DFB instance more than once makes sense, for
example, in the following cases:
If the function block/DFB has no internal value or it is not required for further
processing.
In this case, memory is saved by calling the same function block/DFB instance
more than once since the code for the function block/DFB is only loaded once.
The function block/DFB is then handled like a "Function".
If the function block/DFB has an internal value and this is supposed to influence
various program segments, for example, the value of a counter should be
increased in different parts of the program.
In this case, calling the same function block/DFB means that temporary results
do not have to be saved for further processing in another part of the program.
EN and ENO
One EN input and one ENO output can be used in all FFBs.
If the value of EN is equal to "0" when the FFB is invoked, the algorithms defined by
the FFB are not executed and ENO is set to "0".
If the value of EN is equal to "1" when the FFB is invoked, the algorithms defined by
the FFB will be executed. After the algorithms have been executed successfully, the
value of ENO is set to "1". If an error occurs when executing these algorithms, ENO
is set to "0".
If the EN pin is not assigned a value, when the FFB is invoked, the algorithm defined
by the FFB is executed (same as if EN equals to "1"), Please refer to Maintain output
links on disabled EF (see Unity Pro, Operating Modes).
35006144 07/2012
383
Functions/Procedures
As defined in IEC61131-3, the outputs from deactivated functions (EN input set to
"0") are undefined. (The same applies to procedures.)
Here nevertheless an explanation of the output statuses in this case:
EN/ENO handling with function/procedure blocks that (only) have one link as
an output parameter:
384
35006144 07/2012
EN/ENO handling with function/procedure blocks that have one variable and
one link as output parameters:
35006144 07/2012
385
VAR_IN_OUT-Variable
FFBs are often used to read a variable at an input (input variables), to process it and
to output the altered values of the same variable (output variables).
This special type of input/output variable is also called a VAR_IN_OUT variable.
The link between input and output variables is represented by a line in the FFB.
VAR_IN_OUT variable
The following special features are to be noted when using FFBs with VAR_IN_OUT
variables.
All VAR_IN_OUT inputs must be assigned a variable.
Via graphical links only VAR_IN_OUT outputs with VAR_IN_OUT inputs can be
connected.
Only one graphical link can be connected to a VAR_IN_OUT input/output.
A combination of variable/address and graphical connections is not possible for
VAR_IN_OUT outputs.
No literals or constants can be connected to VAR_IN_OUT inputs/outputs.
No negations can be used on VAR_IN_OUT inputs/outputs.
Different variables/variable components can be connected to the VAR_IN_OUT
input and the VAR_IN_OUT output. In this case the value of the variables/variable
component on the input is copied to the at the output variables/variable
component.
386
35006144 07/2012
Control Elements
Introduction
Control elements are used for executing jumps within an LD section and for
returning from a subroutine (SRx) or derived function block (DFB) to the main
program.
Control elements take up one cell.
Control Elements
The following control elements are available.
Designation
Representation
Jump
Label
Return
Description
When the status of the left link is 1, a jump is made to a label (in the current
section).
To generate an unconditional jump, the jump object must be placed directly
on the left power rail.
To generate a conditional jump, a jump object is placed at the end of a
series of contacts.
LABEL:
Labels (jump targets) are indicated as text with a colon at the end.
This text is limited to 32 characters and must be unique within the entire
section. The text must conform to general naming conventions.
Jump labels can only be placed in the first cell directly on the power rail.
Note: Jump labels may not "cut through" networks, i.e. an assumed line
from the jump label to the right edge of the section may not be crossed by
any object. This also applies to Boolean links and FFB links.
RETURN objects can not be used in the main program.
In a DFB, a RETURN object forces the return to the program which called
the DFB.
The rest of the DFB section containing the RETURN object is not
executed.
The next sections of the DFB are not executed.
The program which called the DFB will be executed after return from the
DFB.
If the DFB is called by another DFB, the calling DFB will be executed
after return.
In a SR, a RETURN object forces the return to the program which called
the SR.
The rest of the SR containing the RETURN object is not executed.
The program which called the SR will be executed after return from
the SR.
35006144 07/2012
387
Representation
Description
When the status of the left link is 1, the ST instruction in the block
is executed.
All ST instructions (see page 529) are allowed except the
control instructions:
(RETURN,
JUMP,
IF,
CASE,
FOR
etc.)
For operate blocks, the state of the left link is passed to the right
link (regardless of the result of the ST instruction).
A block can contain up to 4096 characters. If not all characters
can be displayed then the beginning of the character sequence
will be followed by suspension points (...).
An operate block takes up 1 line and 4 columns.
Example:
388
35006144 07/2012
Designation
Horizontal
Matching Block
Representation
Description
Horizontal compare blocks used to execute a compare
expression (<, >, <=, >=, =, <>) in the ST programming
language. (Note: The same functionality is also possible using
ST expressions (see page 529).)
A compare block performs an AND of its left In-pin and the result
of its compare condition and assigns the result of this AND
unconditionally to its right Out-pin.
For example, if the state of the left link is 1 and the result of the
comparison is 1, the state of the right link is 1.
A horizontal matching block can contain up to 4096 characters.
If not all characters can be displayed then the beginning of the
character sequence will be followed by suspension points (...).
A horizontal matching block takes up 1 line and 2 columns.
Example:
35006144 07/2012
389
Links
Description
Links are connections between LD objects (contacts, coils and FFBs etc.).
There are 2 different types of links:
Boolean Links
Boolean links consist of one or more segments linking Boolean objects (contacts,
coils) with one another.
There are different types of Boolean links as well:
Horizontal Boolean Links
Horizontal Boolean links enable sequential contacts and coil switching.
Vertical Boolean Links
Vertical Boolean links enable parallel contacts and coil switching.
FFB Links
FFB connections are a combination of horizontal and vertical segments that
connect FFB inputs/outputs with other objects.
Connections:
390
35006144 07/2012
35006144 07/2012
391
Connection points between more FFB links are shown with a filled circle.
To avoid links crossing each other, FFB links can also be represented in the form
of connectors.
The source and target for the FFB connection are labeled with a name that is
unique within the section.
The connector name has the following structure depending on the type of source
object for the connection:
For functions: "Function counter/formal parameter" for the source of the
connection
For function blocks: "Instance name/formal parameter" for the source of the
connection
Vertical Links
The "Vertical Link" is special. The vertical link serves as a logical OR. With this form
of the OR link, 32 inputs (contacts) and 64 outputs (coils, links) are possible.
392
35006144 07/2012
Text Object
Introduction
Text can be positioned as text objects in the Ladder Diagram (LD). The size of these
text objects depends on the length of the text. The size of the object, depending on
the size of the text, can be extended vertically and horizontally to fill further grid
units. Text objects may overlap with other objects.
35006144 07/2012
393
Edge Recognition
Introduction
During the edge recognition, a bit is monitored during a transition from 0 -> 1
(positive edge) or from 1 -> 0 (negative edge).
For this, the value of the bit in the previous cycle is compared to the value of the bit
in the current cycle. In this case, not only the current value, but also the old value,
are needed.
Instead of a bit, 2 bits are therefore needed for edge recognition (current value and
old value).
Because the data type BOOL only offers one single bit (current value), there is
another data type for edge recognition, EBOOL (expanded BOOL). In addition to edge
recognition, the data type EBOOL provides an option for forcing. It must also be
saved whether forcing the bit is enabled or not.
The data type EBOOL saves the following data:
the current value of the bit in Value bit
the old value of the bit in History bit
(the content of the value bit is copied to the History bit at the beginning of each
cycle)
Information whether forcing of the bit is enabled in Force-Bit
(0 = Forcing disabled, 1 = Forcing enabled)
Restrictions for EBOOL
CAUTION
UNINTENDED EQUIPMENT OPERATION
To perform a good edge detection the %M must be updated at each task cycle.
When performing a unique writing, the edge will be infinite.
Failure to follow these instructions can result in injury or equipment damage.
Using an EBOOL variable for contacts to recognize positive (P) or negative (N) edges
or with an EF called RE or FE, you have to adhere to the restrictions described
below.
394
35006144 07/2012
Current Value
Edge Detect
Description
35006144 07/2012
395
Anytime the value bit of A equals 1 and the history bit equals 0, B is set to 1 for a
cycle (cycle 1, 4, and 9).
396
35006144 07/2012
Anytime the value bit of A equals 0 and the history bit equals 1, B is set to 1 for a
cycle (cycle 2 and 8).
Forcing Bits
When forcing bits, the value of the variable determined by the logic will be
overwritten by the force value.
In the example, a negative edge of the variable A is supposed to be recognized and
B should therefore be set for a cycle.
Anytime the value bit or force bit of A equals 0 and the history bit equals 1, B is set
to 1 for a cycle (cycle 1 and 8).
35006144 07/2012
397
The following examples show the different behavior depending on the variable type.
Variable A is define as BOOL, whenever A is set to 1, %MW1 is incremented by 1.
398
35006144 07/2012
35006144 07/2012
399
Variable C is defined as EBOOL, the behavior is identical than variable A. The history
bit is updated.
400
35006144 07/2012
At the beginning of the second cycle, the value bit of B equals 0. When forcing B
within this cycle, the force bit and value bit are set to 1. While processing the first
line of the logic in the third cycle, the history bit of the coil (B) will also be set to 1.
Problem:
During edge recognition (comparison of the value bit and the history bit) in the
second line of the logic, no edge is recognized, because due to the updating, the
value bit and history bit on line 1 of B are always identical.
Solution:
In this example, the variable B is first assigned to the link to recognize positive edges
and then the coil.
At the beginning of the second cycle, the value bit of B equals 0. When forcing B
within this cycle, the force bit and value bit are set to 1. While processing the first
line of the logic in the third cycle, the history bit of the link (B) will remain set to 0.
Edge recognition recognizes the difference between value bits and history bit and
sets the coil (C) to 1 for one cycle.
35006144 07/2012
401
Using Set Coil or Reset Coil Can Cause the Loss of Edge Recognition
Using set coil or reset coil can cause the loss of edge recognition with EBOOL
variables.
The variable above the set/reset coil (variable C in the example) is always affected
by the value of the left link.
If the left link is 1, the value bit (variable C in the example) is copied to the history bit
and the value bit is set to 1.
If the left link is 0, the value bit (variable C in the example) is copied to the history bit,
but the value bit is not changed.
This means that whatever value the left link has before the set or reset coil, the
history bit is always updated.
In the example, a positive edge of the variable C should be recognized and set D for
a cycle.
Code
line
Behavior in LD
Corresponds to in ST
IF A AND B
THEN C := 1;
ELSE C := C;
END_IF;
A = 1,
B = 1,
C = 1, History bit = 0
IF NOT(A) AND NOT(B)
THEN C := 0;
ELSE C := C;
END_IF;
A = 1,
B = 1,
C = 1, History = 1
-
C = 1, History = 1
D = 0, as the value bit and history bit of C are
identical.
The rising edge of C, shown in code line 1, is not
recognized by the code in line 2, as this forces the
history bit to be updated.
(If the condition is FALSE, the present value of C is
again assigned to C, see ELSE statement in code
line 2 in ST example.)
402
35006144 07/2012
35006144 07/2012
The signal flow with FFB links is from the FFB output to the FFB input, regardless
of which direction they are made in.
An FFB is only processed if all elements (FFB outputs etc.) to which its inputs are
linked are processed.
The execution sequence of FFBs that are linked with various outputs of the same
FFB runs from top to bottom.
The execution sequence of objects is not influenced by their positions within the
network.
The execution sequence for FFBs is represented as execution number by the
FFB.
403
Priorities
Priorities when defining the signal flow within a section:
Priority
Rule
Description
Link
Network by
Network
Output sequence
Rung by Rung
Example
Example of the execution sequence of objects in an LD section:
NOTE: The execution numbers for contacts and coils is not shown. They are only
shown in the graphic to provide a better overview.
404
35006144 07/2012
Loop Planning
Non-Permitted Loops
Creating loops using links alone is not permitted because it is not possible to clearly
define the signal flow (the output of one FFB is the input of the next FFB, and the
output of this one is the input of the first again).
Non-permitted loops via links:
35006144 07/2012
405
406
35006144 07/2012
35006144 07/2012
407
408
35006144 07/2012
Network Positions
The correct execution sequence can be achieved by changing the position of the
networks in the section (see also Original Situation, page 407).
35006144 07/2012
409
Positioning of Objects
The position of objects can only have an influence on the execution order if several
inputs (left link of Contacts/Coils, FFB inputs) are linked with the same output of the
object "to be called" (right link of Contacts/Coils, FFB outputs) (see also Original
Situation, page 407).
Original situation:
In the first network, block positions 0.1 and 0.2 are switched. In this case (common
origins for both block inputs) the execution sequence of both blocks is switched as
well (processed from top to bottom). The same applies when switching coils C and
D in the second network.
410
35006144 07/2012
In the third network, block positions 0.4 and 0.5 are switched. In this case (different
origins for the block inputs) the execution sequence of the blocks is not switched
(processed in the sequence that the block outputs are called in). The same applies
when switching coils G and H in the last network.
35006144 07/2012
411
412
35006144 07/2012
Unity Pro
SFC Sequence Language
35006144 07/2012
13
Overview
This chapter describes the SFC sequence language which conforms to IEC 611311.
What Is in This Chapter?
This chapter contains the following sections:
Section
35006144 07/2012
Topic
Page
13.1
414
13.2
420
13.3
428
13.4
435
13.5
Jump
440
13.6
Link
441
13.7
442
13.8
Text Objects
447
13.9
Single-Token
448
13.10
Multi-Token
459
413
13.1
Overview
This section contains a general overview of the SFC sequence language.
What Is in This Section?
This section contains the following topics:
Topic
414
Page
415
Link Rules
419
35006144 07/2012
35006144 07/2012
415
416
35006144 07/2012
35006144 07/2012
417
Section Size
IEC Conformity
For a description of the extent to which the SFC programming language conforms
to IEC, see IEC Conformity (see page 661).
418
35006144 07/2012
Link Rules
Link Rules
The table indicates which object outputs can be linked with which object inputs.
From object output of
To object input of
Step
Transition
Alternative Branch
Parallel joint
Transition
Step
Jump
Parallel Branch
Alternative joint
Alternative Branch
Transition
Alternative joint
Step
Jump
Parallel Branch
Alternative joint
Parallel Branch
Step
Jump
Alternative joint (only with Multi-Token
(see page 459))
Parallel joint
Transition
Alternative branch (only with Multitoken
(see page 459))
Alternative joint
35006144 07/2012
419
13.2
Overview
This section describes the step and macro step objects of the SFC sequence
language.
What Is in This Section?
This section contains the following topics:
Topic
420
Page
Step
421
424
35006144 07/2012
Step
Step Types
The following types of steps exist:
Type
Representation
Description
"Normal" Step
A step becomes active when the previous step becomes inactive (a delay
that may be defined must pass) and the upstream transition is satisfied. A
step normally becomes inactive when a delay that may be defined passes
and the downstream transition is satisfied. For a parallel joint, all previous
steps must satisfy these conditions.
Zero or more actions belong to every step. Steps without action are known
as waiting steps.
Initial step
Macro Step
Input step
Output step
Step Names
When creating a step, it is assigned with a suggested number. The suggested
number is structured as follows S_i_j, whereas i is the (internal) current number
of the section and j is the (internal) current step number in the current section.
You can change the suggested numbers to give you a better overview. Step names
(maximum 32 characters) must be unique over the entire project, i.e. no other step,
variable or section etc. may exist with the same name. There are no case
distinctions. The step name must correspond with the standardized name
conventions.
35006144 07/2012
421
Step Times
Each step can be assigned a minimum supervision time, a maximum supervision
time and a delay time:
Minimum Supervision Time
The minimum supervision time sets the minimum time for which the step should
normally be active. If the step becomes inactive before this time has elapsed, an
error message is generated. In animation mode, the error is additionally identified
by a colored outline (yellow) around the step object.
If no minimum supervision time or a minimum supervision time of 0 is entered,
step supervision is not carried out.
The error status remains the same until the step becomes active again.
Maximum Supervision Time
The maximum supervision time specifies the maximum time in which the step
should normally be active. If the step is still active after this time has elapsed, an
error message is generated. In animation mode, the error is additionally identified
by a colored outline (pink) around the step object.
If no maximum supervision time or a maximum supervision time of 0 is entered,
step supervision is not carried out.
The error status remains the same until the step becomes inactive.
Delay Time
The delay time (step dwell time) sets the minimum time for which the step must
be active.
NOTE: The defined times apply for the step only, not for the allocated actions.
Individual times can be defined for these.
Setting the Step Times
The following formula is to be used for defining/determining these times:
Delay time< minimum supervision time< maximum supervision time
There are 2 ways to assign the defined values to a step:
As a duration literal
Use of the data structure SFCSTEP_TIMES
422
35006144 07/2012
SFCSTEP_TIMES Variable
Every step can be implicitly allocated a variable of data type SFCSTEP_TIMES. The
elements for this data structure can be read from and written to (read/write).
The data structure is handled the same as any other data structure, i.e. they can be
used in variable declarations and therefore accessing the entire data structure (e.g.
as FFB parameter) is possible.
Structure of the Data Structure:
Element Name
Data type
Description
"VarName".delay
TIME
Delay Time
"VarName".min
TIME
"VarName".max
TIME
SFCSTEP_STATE Variable
Every step is implicitly allocated a variable of data type SFCSTEP_STATE. This step
variable has the name of the allocated step. The elements for this data structure can
only be read (read only).
You can see the SFCSTEP_STATE variables in the Data Editor. The Comment for
a SFCSTEP_STATE variable is the comment entered as a property of the step itself.
Please refer to "Defining the properties of steps" (see Unity Pro, Operating Modes)
in the Unity Pro Operating Modes Manual.
The data structure cannot be used in variable declarations. Therefore, accessing the
entire data structure (e.g. as FFB parameter) is not possible.
Structure of the Data Structure:
Element Name
Data type
Description
"StepName".t
TIME
Current dwell time in the step. If the step is deactivated, the value of
this element is retained until the step is activated again.
"StepName".x
BOOL
1: Step active
0: Step inactive
"StepName".tminErr
BOOL
"StepName".tmaxErr
BOOL
35006144 07/2012
423
Macro steps are a supplement to IEC 61131-3 and must be enabled explicitly.
Input Step
Every macro section begins with an input step.
Representation of an input step:
424
35006144 07/2012
Output Step
Every macro section ends with an output step.
Representation of an output step:
35006144 07/2012
Multi-Token
A maximum of 100 initial steps can be placed per section (including all their
macro sections).
425
The name of the macro section is identical to the name of the macro step that it is
called from. If the name of the macro step is changed then the name of the
respective macro section is changed automatically.
A macro section can only be used once.
Macro Step Processing
Macro Step Processing:
Phase
426
Description
If the output step of the macro section is active then the transitions following the
macro step are enabled.
The macro step becomes inactive when the output step is activated which
causes the following transition conditions to be enabled and the transition
condition to be TRUE. At the same time, the output step in the macro section is
activated.
35006144 07/2012
Step Names
When creating a step, it is assigned with a suggested number.
Meanings of the Suggested Numbers:
Step Type
Macro Step
MS_i_j
MS = Macro Step
i = (internal) current (sequential) number of the current section
j = (internal) current (sequential) macro step number of the current
section
Input step
MS_k_l_IN
MS = Macro Step
k = (internal) current (sequential) number of the calling section
l = (internal) current (sequential) macro step number of the calling
section
IN = Input Step
Output step
MS_k_l_OUT
MS = Macro Step
k = (internal) current (sequential) number of the calling section
l = (internal) current (sequential) macro step number of the calling
section
OUT = Output Step
"Normal" Step
(within a macro
section)
S_k_m
S = Step
k = (internal) current (sequential) number of the calling section
m = (internal) current (sequential) step number of the calling section
You can change the suggested numbers to give you a better overview. Step names
(maximum 28 characters for macro step names, maximum 32 characters for step
names) must be unique within the entire project, i.e. no other step, variable or
section (with the exception of the name of the macro section assigned to the macro
step) etc. may exist with the same name. There are no case distinctions. The step
name must correspond with the standardized name conventions.
If the name of the macro step is changed then the name of the respective macro
section and the steps within it are changed automatically.
For example If MS_1_1 is renamed to MyStep then the step names in the macro
section are renamed to MyStep_IN, MyStep_1, ..., MyStep_n, MyStep_OUT.
35006144 07/2012
427
13.3
Overview
This section describes the actions and action sections of the SFC sequence
language.
What Is in This Section?
This section contains the following topics:
Topic
428
Page
Action
429
Action Section
431
Qualifier
432
35006144 07/2012
Action
Introduction
Actions have the following properties:
An action can be a Boolean variable (action variable (see page 429)) or a section
(action section (see page 431)) of programming language FBD, LD, IL or ST.
A step can be assigned none or several actions. A step which is assigned no
action has a waiting function, i.e. it waits until the assigned transition is
completed.
If more than one action is assigned to a step they are processed in the sequence
in which they are positioned in the action list field.
Exception: Independent of their position in the action list field, actions with the
qualifier (see page 432) P1 are always processed first and actions with the
qualifier P0 are processed last.
The control of actions is expressed through the use of qualifiers (see page 432).
A maximum of 20 actions can be assigned to each step.
The action variable that is assigned to an action can also be used in actions from
other steps.
The action variable can also be used for reading or writing in any other section of
the project (multiple assignment).
Actions that are assigned an qualifier with duration can only be activated one
time.
Only Boolean variables/addresses or Boolean elements of multi-element
variables are allowed as action variables.
Actions have unique names.
The name of the action is either the name of the action variable or the name of
the action section.
Action Variable
The following are authorized as action variables:
Address of data type BOOL
An action can be assigned to a hardware output using an address. In this case,
the action can be used as enable signal for a transition, as input signal in another
section and as output signal for the hardware.
Simple variable or element of a multi-element variable of data type BOOL
The action can be used as an input signal with assistance from a variable in
another section.
Unlocated Variable
With unlocated variables, the action can be used as enable signal for a
transition and as input signal in another section.
Located Variable
With located variables the action can be used as an enabling signal for a
transition, as an input signal in another section and as an output signal for the
hardware.
35006144 07/2012
429
Action Names
If an address or a variable is used as an action then that name (e.g. %Q10.4,
Variable1) is used as the action name.
If an action section is used as an action then the section name is used as the action
name.
Action names (maximum 32 characters) must be unique over the entire project, i.e.
no other transition, variable or section etc. may exist with the same name. There are
no case distinctions. The action name must correspond with the standardized name
conventions.
430
35006144 07/2012
Action Section
Introduction
An action section can be created for every action. This is a section which contains
the logic of the action and it is automatically linked with the action.
Name of the Action Section
The name of the action section is always identical to the assigned action, see Action
Names, page 430.
Programming Languages
FBD, LD, IL and ST are possible as programming languages for action sections.
Properties of Action Sections
Action sections have the following properties:
Action sections can have any amount of outputs.
Subroutine calls are only possible in action sections when Multitoken operation is
enabled.
Note: The called subroutines are not affected by the controller of the sequence
string, i.e.
the qualifier assigned to the called action section does not affect the
subroutine
the subroutine also remains active when the called step is deactivated
35006144 07/2012
431
Qualifier
Introduction
Each action that is linked to a step must have a qualifier which defines the control
for that action.
Available Qualifiers
The following qualifiers are available:
Qualifier
Meaning
Description
N / None
Not Stored
If the step is active then action is 1 and if the step is inactive the action is 0.
Overriding
reset
The action, which is set in another step with the qualifier S, is reset. The activation of
any action can also be prevented.
Note: Qualifiers are automatically declared as unbuffered. This means that the value
is reset to 0 after stop and cold restart, e.g. when voltage is on/off. Should a buffered
output be required, please use the RS or SR function block from the standard block
library.
432
35006144 07/2012
Qualifier
Meaning
Description
Set (saved)
The set action remains active, even when the associated step becomes inactive. The
action only becomes inactive, when it is reset in another step of the current SFC
section, using the qualifier R.
Note: If an action variable is modified outside of the current SFC section, it may no
longer reflect the actions activation state.
Time limited
If the step is active, the action is also active. After the process of the time duration,
defined manually for the action, the action returns to 0, even if the step is still active.
The action also becomes 0 if the step is inactive.
Note: For this qualifier, an additional duration of data type TIME must be defined.
Delayed
If the step is active, the internal timer is started and the action becomes 1 after the
process of the time duration, which was defined manually for the action. If the step
becomes inactive after that, the action becomes inactive as well. If the step becomes
inactive before the internal time has elapsed then the action does not become active.
Note: For this qualifier, an additional duration of data type TIME must be defined.
Pulse
If the step becomes active, the action becomes 1 and this remains for one program
cycle, independent of whether or not the step remains active.
Note: A maximum of 100 actions are permitted using the S qualifier per SFC Section.
35006144 07/2012
433
Qualifier
Meaning
Description
DS
Delayed and
saved
If the step becomes active, the internal timer is started and the action becomes active
after the process of the manually defined time duration. The action first becomes
inactive again when qualifier R is used for a reset in another step. If the step becomes
inactive before the internal time has elapsed then the action does not become active.
Note: For this qualifier, an additional duration of data type TIME must be defined.
P1
Pulse (rising
edge)
If the step becomes active (0->1-edge), the action becomes 1 and this remains for
one program cycle, independent of whether or not the step remains active.
Note: Independent of their position in the action list field, actions with the qualifier P1
are always processed first. More information can be found in the Action
(see page 429) of the SFC sequence language.
P0
Pulse (falling
edge)
If the step becomes inactive (1->0-edge), the action becomes 1 and this remains for
one program cycle.
Note: Independent of their position in the action list field, actions with the qualifier P0
are always processed last. More information can be found in the Action
(see page 429) of the SFC sequence language.
434
35006144 07/2012
13.4
Overview
This section describes the transition objects and transition sections of the SFC
sequence language.
What Is in This Section?
This section contains the following topics:
Topic
35006144 07/2012
Page
Transition
436
Transition Section
438
435
Transition
Introduction
A transition provides the condition through which the checks of one or more pretransition steps pass on one or more consecutive steps along the corresponding
link.
Transition Condition
Every transition is allocated with a transition condition of data type BOOL.
The following are authorized as transaction conditions:
an address (input or output)
a variable (input or output)
a Literal or
a Transition Section (see page 438)
Address
Variable
Literal
Transition Section
Transition Name
If an address or a variable is used as a transition condition then the transition name
is defined with that name (e.g. %I10.4, Variable1).
If a transition section is used as a transition condition then the section name is used
as the transition name.
Transition names (maximum 32 characters) must be unique over the entire project,
i.e. no other transition, variable or section (with the exception of the assigned
transition section) etc., may exist with the same name. There are no case
distinctions. The transition name must correspond with the standardized name
conventions.
436
35006144 07/2012
Enabling a Transition
A transition is enabled if the steps immediately preceding it are active. Transitions
whose immediately preceding steps are not active are not normally analyzed.
NOTE: If no transition condition is defined, the transition will never be active.
Triggering a Transition
A transition is triggered when the transition is enabled and the associated transition
conditions are satisfied.
Triggering a transition leads to the disabling (resetting) of all immediately preceding
steps that are linked to the transition, followed by the activation of all immediately
following steps.
Trigger Time for a Transition
The transition trigger time (switching time) can theoretically be as short as possible,
but can never be zero. The transition trigger time lasts at least the duration of a
program cycle.
35006144 07/2012
437
Transition Section
Introduction
For every transition, a transition section can be created. This is a section containing
the logic of the transition condition and it is automatically linked with the transition.
Name of Transition Section
The name of the transition section is always identical to the assigned transition, see
Transition Name, page 436.
Programming Languages
FBD, LD, IL and ST are possible as programming languages for transition sections.
Suggested Networks for Transition Section:
Language Suggested Network
Description
FBD
LD
IL
438
35006144 07/2012
Description
ST
35006144 07/2012
439
13.5
Jump
Jump
General
Jumps are used to indicate directional links that are not represented in their full
length.
Representation of a jump:
Properties of Jumps
Jumps have the following properties:
More than one jump may have the same target step.
In accordance with IEC 61131-3, jumps into a parallel sequence (see page 445)
or out of a parallel sequence are not possible.
If it should also be used again then it must be enabled explicitly.
With jumps, there is a difference between a Sequence Jump (see page 451) and
a Sequence Loop (see page 452).
The jump target is indicated by the jump target symbol (>).
Jump Name
Jumps do not actually have their own names. Instead, the name of the target step
(jump target) is shown inside of the jump symbol.
440
35006144 07/2012
13.6
Link
Link
Introduction
Links connect steps and transitions, transitions and steps etc.
Properties of Links
Links have the following properties:
Links between objects of the same type (step with step, transition with transition,
etc.) are not possible
Links are possible between:
unlinked object outputs and
unlinked or linked step inputs
(i.e. multiple step inputs can be linked)
35006144 07/2012
Overlapping links and other SFC objects (step, transition, jump, etc.) is not
possible
Overlapping links and links is possible
Crossing links with links is possible and is indicated by a "broken" link:
With links, there is a difference between a String Jump (see page 451) and a
String Loop (see page 452)
441
13.7
Overview
This section describes the branch and merge objects of the SFC sequence
language.
What Is in This Section?
This section contains the following topics:
Topic
442
Page
443
445
35006144 07/2012
35006144 07/2012
443
444
35006144 07/2012
35006144 07/2012
445
446
35006144 07/2012
13.8
Text Objects
Text Object
Introduction
Text can be positioned in the form of text objects using SFC sequence language.
The size of these text objects depends on the length of the text. This text object is
at least the size of a cell and can be vertically and horizontally enlarged to other cells
according to the size of the text. Text objects can overlap with other SFC objects.
35006144 07/2012
447
13.9
Single-Token
Overview
This section describes the "Single-Token" operating mode for sequence controls.
What Is in This Section?
This section contains the following topics:
Topic
448
Page
449
Alternative String
450
451
Parallel Strings
454
456
35006144 07/2012
35006144 07/2012
449
Alternative String
Alternative Strings
According to IEC 61131-3, only one switch (1-off-n-select) can be made from the
transitions. The branch to be run is determined by the result of the transition
conditions of the transitions that follow the alternative branch. Branch transitions are
processed from left to right. If a transition condition is satisfied, the remaining
transitions are no longer processed The branch with the satisfied transition is
activated. This results in a left to right priority for branches.
If none of the transitions are switched, the step that is currently set remains set.
Alternative Strings:
If...
Then
450
35006144 07/2012
If...
Then
35006144 07/2012
451
Sequence Loop
A sequence loop is a special type of alternative branch with which one or more
branches lead back to a previous step.
A sequence loop can be made with jumps or with links.
Sequence loop:
If...
Then
The loop from S_1_12 by means of transition conditions c and f back to S_1_12 is repeated until transition condition
b is true or c is false and d is true.
If transition conditions b and c are false and d is true,
The loop from S_1_11 to S_1_12 and back to S_1_11 via transition conditions a and d is repeated until transition
condition b or c is true.
452
35006144 07/2012
If...
Then
The loop from S_1_3 via transition condition e, to S_1_4 via transition condition f and a jump back to S_1_3 again,
is now repeated infinitely.
35006144 07/2012
453
Parallel Strings
Parallel Strings
With parallel branches, switching a single transition leads to a parallel activation of
more than one (maximum 32) steps (branches). This applies with Single-Token as
well as with Multi-Token.
Processing Parallel Strings:
If...
Then
454
35006144 07/2012
If...
Then
Since S_7_3, S_7_4 and S_7_5 are linked with a parallel merge, no sequence can follow to S_7_6 because S_7_3
and S_7_4 can never be active at the same time.
(Either S_7_3 is activated with transition condition b or S_7_4 with transition condition c, never both at the same
time.)
Therefore S_7_3, S_7_4 and S_7_5 can never be active at the same time either. The string is blocked.
The same problem occurs if transition condition b is false and c is true when entering the alternative branch.
35006144 07/2012
455
If...
Then
456
35006144 07/2012
If...
Then
35006144 07/2012
457
If...
Then
...
...
458
35006144 07/2012
13.10
Multi-Token
Overview
This section describes the "Multi-Token" operating mode for sequence controls.
What Is in This Section?
This section contains the following topics:
Topic
35006144 07/2012
Page
460
Alternative String
462
Parallel Strings
465
469
470
459
460
35006144 07/2012
35006144 07/2012
461
Alternative String
Alternative Strings
The user can define the behavior for the evaluation of transition conditions in
alternative branches with Multi-Token.
The following are possible:
Processing is from left to right with a stop after the first active transition (1-off-nselect). This corresponds with the behavior of alternative strings with SingleToken (see page 450).
Parallel processing of all transitions of the alternative branch (x-off-n-select)
x-off-n-select
With Multi-Token, more than one parallel switch can be made from the transitions
(1-off-n-select). The branches to be run are determined by the result of the transition
conditions of the transitions that follow the alternative branch. The transitions of the
branches are all processed. All branches with satisfied transitions are activated.
If none of the transitions are switched, the step that is currently set remains set.
x-off-n-select:
If...
Then
462
35006144 07/2012
A second token is created by the parallel activation of the two alternative branches. These two tokens are now running
parallel to one another, i.e. S_5_11 and S_5_12 are active at the same time.
Token 1 (S_5_11)
Token 2 (S_5_12)
If...
Then
If...
Then
then a sequence is run from
S_5_12 to S_5_13.
If S_5_13 is still active (token 1) because of the activation of transition condition c, then token 2 is ended and the
string will be further processed as Single-Token. If S_5_13 is no longer active (token 1), then it is reactivated by token
2 and both tokens continue running parallel (Multi-Token).
35006144 07/2012
463
If...
Then
Since S_6_1 and S_6_2 are linked by a parallel merge, the branch cannot be departed because S_6_1 and S_6_2
can never be active at the same time.
(Either S_6_1 is activated with transition condition a or S_6_2 with transition condition b.)
Therefore S_6_1 and S_6_2 can never be active at the same time either. The string is blocked.
This block can be removed, for example, by a second timed token that runs via transition b.
464
35006144 07/2012
Parallel Strings
Parallel Strings
With parallel branches, switching a single transition leads to a parallel activation of
more than one (maximum 32) steps (branches). This applies with Single-Token as
well as with Multi-Token
Processing Parallel Strings:
If...
Then
35006144 07/2012
465
If...
Then
A second token is created by the sequence running on the alternative merge out of the parallel string. The two tokens
are running parallel to one another, i.e. S_5_2 and S_5_3 are active at the same time.
Token 1 (S_5_3)
If...
Step S_5_3 is active.
Token 2 (S_5_2)
Then
If...
Then
If S_5_3 is still active (token 1) then token 2 is ended and the string is further processed as Single-Token.
If S_5_3 is no longer active (token 1), then it is reactivated by token 2 and both tokens continue running parallel (MultiToken).
466
35006144 07/2012
If...
Then
A second token is created by the sequence running on the alternative merge out of the parallel string. These two
tokens are now running parallel to one another, i.e. S_5_1 and S_5_2 are active at the same time.
Token 1 (S_5_2)
If...
Step S_5_2 is active.
Token 2 (S_5_1)
Then
If...
Then
If S_5_2 is still active (token 1) then token 2 is ended and the string is further processed as Single-Token.
If S_5_2 is no longer active (token 1), then it is reactivated by token 2 and both tokens continue running parallel (MultiToken).
35006144 07/2012
467
If...
Then
Since S_7_3, S_7_4 and S_7_5 are linked by a parallel merge, the parallel string cannot be departed because
S_7_3 and S_7_4 can never be active at the same time.
(Either S_7_3 is activated with transition condition b or S_7_4 with transition condition c.)
Therefore S_7_3, S_7_4 and S_7_5 cannot be active at the same time either. The string is blocked.
This block can be removed for example, by a second timed token that runs via transition c.
468
35006144 07/2012
If...
Then
If S_1_1 and S_1_3 are active and transition condition c, then a sequence runs from S_1_1 and S_1_3 to a jump
which belongs to the common transition, is true,
to S_1_1.
If S_1_1 is activated by the jump,
Since S_1_1 and S_1_3 are not active at the same time, the string cannot continue. The string is blocked.
This block can removed by e.g. a second timed token that is set to reactivate step S_1_2.
35006144 07/2012
469
If...
Then
A second token is created by the jump out of the parallel string. Both tokens are running parallel to one another, i.e.
S_2_1 and S_2_3 are active at the same time.
470
35006144 07/2012
Token 1 (S_2_1)
Token 2 (S_2_3)
If...
Then
If...
Then
If transition condition d is
true,
If transition condition f is
true,
If S_2_5 is still active (token 1) because of the activation of transition condition e, then token 2 is ended and the string
will be further processed as Single-Token.
If S_2_5 is no longer active (token 1), then it is reactivated by token 2 and both tokens continue running parallel (MultiToken).
If...
Then
A second token is created by the jump out of a branch string. Both tokens are running parallel to one another, i.e.
S_4_3 and S_4_1 are active at the same time.
35006144 07/2012
471
Token 1 (S_4_3)
Token 2 (S_4_1)
If...
Then
If...
Then
If step S_4_3 is still active (token 1) during the activation by token 2 then token 2 is ended and the string will continue
to be processed as Single-Token.
If step S_4_3 is no longer active (token 1) because of the activation by token 2 , then it is reactivated by token 2 and
both tokens continue running parallel (Multi-Token).
In both cases, true transition condition d causes the parallel string to be left.
If...
Then
A second token is created by the sequence running on the alternative branch out of the parallel string. Both tokens
are running parallel to one another, i.e. S_3_1 and S_3_5 are active at the same time.
472
35006144 07/2012
Token 1 (S_3_1)
If...
Token 2 (S_3_5)
Then
If...
Then
If transition condition d is
true,
If transition condition a is true then a sequence runs to S_3_1 and S_3_2. This ends token 2 and the string is again
processed as Single-Token.
If the transition condition a is true,
then a sequence runs to S_3_1 and S_3_2.
If transition condition b is
true and c is false,
Since S_3_4 cannot become active, S_3_1 remains (token 1) active until a sequence appears on S_3_2 (token 2)
and the transition is b.
If S_4_4 is no longer active (token 1), then it is reactivated by token 2 and both tokens continue running parallel (MultiToken).
(Merging the two tokens can also be done in S_4_3.)
35006144 07/2012
473
474
35006144 07/2012
Unity Pro
Instruction List (IL)
35006144 07/2012
14
Overview
This chapter describes the programming language instruction list IL which conforms
to IEC 61131.
What Is in This Chapter?
This chapter contains the following sections:
Section
35006144 07/2012
Topic
Page
14.1
476
14.2
500
475
14.1
Overview
This section contains a general overview of the IL instruction list.
What Is in This Section?
This section contains the following topics:
Topic
476
Page
477
Operands
481
Modifier
484
Operators
486
Subroutine Call
496
497
Comment
499
35006144 07/2012
35006144 07/2012
477
Meaning
LD 10
ADD 25
ST A
Compare operations likewise always refer to the accumulator. The Boolean result of
the comparison is stored in the accumulator and therefore becomes the current
accumulator content.
Example of a comparison:
Command
Meaning
LD B
GT 10
ST A
Section Size
The length of an instruction line is limited to 300 characters.
The length of an IL section is not limited within the programming environment. The
length of an IL section is only limited by the size of the PLC memory.
478
35006144 07/2012
Syntax
Identifiers and Keywords are not case sensitive.
Spaces and tabs have no influence on the syntax and can be used as and when
required,
Exception: Not allowed - spaces and tabs
keywords
literals
values
identifiers
variables and
limiter combinations [e.g. (* for comments)]
Execution Sequence
Instructions are executed line by line, from top to bottom. This sequence can be
altered with the use of parentheses.
If, for example, A, B, C and D have the values 1, 2, 3 and 4, and are calculated as
follows:
LD A
ADD B
SUB C
MUL C
ST E
the result in E will be 0.
In the case of the following calculation:
LD A
ADD B
SUB(
LD C
MUL D
)
ST E
the result in E will be -9.
Error Behavior
The following conditions are handled as an error when executing an expression:
Attempting to divide by 0.
Operands do not contain the correct data type for the operation.
The result of a numerical operation exceeds the value range of its data type
35006144 07/2012
479
IEC Conformity
For a description of IEC conformity for the IL programming language, see IEC
Conformity (see page 661).
480
35006144 07/2012
Operands
Introduction
Operators are used for operands.
An operand can be:
an address
a literal
a variable
a multi-element variable
an element of a multi-element variable
an EFB/DFB output or
an EFB/DFB call
Data Types
The operand and the current accumulator content must be of the same type. Should
operands of various types be processed, a type conversion must be performed
beforehand.
In the example the integer variable i1 is converted into a real variable before being
added to the real variable r4.
LD i1
INT_TO_REAL
ADD r4
ST r3
As an exception to this rule, variables with data type TIME can be multiplied or
divided by variables with data type INT, DINT, UINT or UDINT.
Permitted operations:
LD
timeVar1
DIV dintVar1
ST timeVar2
LD
timeVar1
MUL intVar1
ST timeVar2
LD
timeVar1
MUL 10
ST timeVar2
This function is listed by IEC 61131-3 as "undesired" service.
35006144 07/2012
481
Example
Data type
no prefix
BOOL
%MX20
BOOL
%QB102.3
BYTE
%KW43
INT
%QD100
DINT
%MF100
REAL
482
35006144 07/2012
35006144 07/2012
483
Modifier
Introduction
Modifiers influence the execution of the operators (see Operators, page 486).
Table of Modifiers
Table of Modifiers:
484
Modifier
Use of
Operators of
data type
Description
BOOL, BYTE,
WORD, DWORD
BOOL
CN
BOOL
35006144 07/2012
35006144 07/2012
Modifier
Use of
Operators of
data type
Description
all
485
Operators
Introduction
An operator is a symbol for:
an arithmetic operation to be executed,
a logical operation to be executed or
calling an elementary function block - DFBs or subroutines.
Operators are generic, i.e. they adapt automatically to the data type of the operands.
Load and Save Operators
IL programming language load and save operators:
Operator
Modifier
Meaning
Operands
LD
N
(only for
operands of
data type
BOOL, BYTE,
WORD or
DWORD)
Loads the
operands
value into the
accumulator
486
Description
35006144 07/2012
Operator
Modifier
Meaning
Operands
Description
ST
N
(only for
operands of
data type
BOOL, BYTE,
WORD or
DWORD)
Saves the
accumulator
value in the
operand
Variable, direct
address of any data
type
35006144 07/2012
487
Modifier
Meaning
Operands
Description
Sets the
operand to 1,
when the
accumulator
content is 1
Variable, direct
address of BOOL
data type
Sets the
operand to 0
when the
accumulator
content is 1
Variable, direct
address of BOOL
data type
488
35006144 07/2012
Logical Operators
IL programming language logic operators:
Operator
Modifier
Meaning
Operands
Description
AND
N, N(, (
Logical AND
Literal, variable,
direct address of
BOOL, BYTE, WORD
or DWORD data types
OR
N, N(, (
Logical OR
Literal, variable,
direct address of
BOOL, BYTE, WORD
or DWORD data types
XOR
N, N(, (
Logical
exclusive OR
Literal, variable,
direct address of
BOOL, BYTE, WORD
or DWORD data types
35006144 07/2012
489
Operator
Modifier
Meaning
Operands
Description
NOT
Logical
negation
(complement)
Accumulator
contents of data
types BOOL, BYTE,
WORD or DWORD
Arithmetic Operators
IL programming language Arithmetic operators:
Operator
Modifier
Meaning
Operands
Description
ADD
Addition
Literal, variable,
direct address of
data types INT,
DINT, UINT, UDINT,
REAL or TIME
SUB
Subtraction
Literal, variable,
direct address of
data types INT,
DINT, UINT, UDINT,
REAL or TIME
MUL
Multiplication
Literal, variable,
direct address of
data type INT,
DINT, UINT, UDINT
or REAL
490
35006144 07/2012
Operator
Modifier
Meaning
Operands
Description
DIV
Division
Literal, variable,
direct address of
data type INT,
DINT, UINT, UDINT
or REAL
MOD
Modulo
Division
Literal, variable,
direct address of
INT, DINT, UINT or
UDINT data types
35006144 07/2012
491
Comparison Operators
IL programming language comparison operators:
Operator
Modifier
Meaning
GT
GE
Comparison:
>=
Literal, variable,
direct address of
data type BOOL,
BYTE, WORD, DWORD,
STRING, INT, DINT,
UINT, UDINT, REAL,
TIME, DATE, DT or
TOD
EQ
492
Operands
Description
35006144 07/2012
Operator
Modifier
Meaning
Operands
Description
NE
Comparison:
<>
Literal, variable,
direct address of
data type BOOL,
BYTE, WORD, DWORD,
STRING, INT, DINT,
UINT, UDINT, REAL,
TIME, DATE, DT or
TOD
LE
Comparison:
<=
Literal, variable,
direct address of
data type BOOL,
BYTE, WORD, DWORD,
STRING, INT, DINT,
UINT, UDINT, REAL,
TIME, DATE, DT or
TOD
LT
35006144 07/2012
493
Call Operators
IL programming language call operators:
Operator
Modifier
Meaning
Operands
Description
CAL
C, CN
(only if the
accumulator
contents are
of the BOOL
data type)
FUNCTIO
NNAME
Executing a
function
PROCEDU
RENAME
Executing a
procedure
Structuring Operators
IL programming language structuring operators:
Operator
Modifier
Meaning
Operands
Description
JMP
C, CN
(only if the
accumulator
contents are
of the BOOL
data type)
Jump to label
LABEL
494
35006144 07/2012
Operator
Modifier
Meaning
Operands
Description
RET
C, CN
(only if the
accumulator
contents are
of the BOOL
data type)
Return to the
next highest
program
organization
unit
35006144 07/2012
Processing
deferred
operations
495
Subroutine Call
Call Subroutine
A subroutine call consists of the CAL operator, followed by the name of the
subroutine section, followed by an empty parameter list (optional).
Subroutine calls do not return a value.
The subroutine to be called must be located in the same task as the IL section called.
Subroutines can also be called from within subroutines.
e.g.
ST A
CAL SubroutineName ()
LD B
or
ST A
CAL SubroutineName
LD B
Subroutines are a supplement to IEC 61131-3 and must be enabled explicitly.
In SFC action sections, subroutine calls are only allowed when Multitoken Operation
is enabled.
496
35006144 07/2012
35006144 07/2012
497
Example
start2: LD A
ST counter.CU
LD B
ST counter.R
LD C
ST counter.PV
CAL counter
JMPCN start4
start1: LD A
AND B
OR C
ST D
JMPC start3
LD A
ADD E
JMP start5
start3: CAL counter (
CU:=A
R:=B
PV:=C )
JMP start1
LD A
OR B
OR C
ST D
start4: JMPC start1
LD C
OR B
start5: ST A
498
35006144 07/2012
Comment
Description
In the IL editor, comments always start with the string (* and end in the string *).
Any comments can be entered between these character strings.
Nesting comments is not permitted according to IEC 61131-3. If comments are
nested nevertheless, then they must be enabled explicitly.
35006144 07/2012
499
14.2
Overview
Calling Elementary Functions, Elementary Function Blocks, Derived Function
Blocks and Procedures in the IL programming language.
What Is in This Section?
This section contains the following topics:
Topic
500
Page
501
506
Calling Procedures
518
35006144 07/2012
501
Not all formal parameters must be assigned a value for formal calls. Which formal
parameter types must be assigned a value can be seen in the following table.
Parameter type
EDT
STRING
ARRAY
ANY_ARRAY IODDT
STRUCT FB
ANY
Input
VAR_IN_OUT
Output
not applicable
If no value is assigned to a formal parameter, the initial value will be used when the
function is executed. If no initial value has been defined, the default value (0) is
used.
Programming Notes
Attention should be paid to the following programming notes:
Functions are only executed if the input EN=1 or the EN input is not used (see also
EN and ENO (see page 505)).
All generic functions are overloaded. This means the functions can be called with
or without entering the data type.
E.g.
LD i1
ADD i2
ST i3
is identical to
LD i1
ADD_INT i2
ST i3
In contrast to ST, functions in IL cannot be nested.
There are two ways of invoking a function:
Formal call (calling a function with formal parameter names)
Informal call (calling a function without formal parameter names)
502
35006144 07/2012
Formal Call
With this type of call (call with formal parameter names), the function is called using
an instruction sequence consisting of the function name, followed by the bracketed
list of value assignments (actual parameters) to the formal parameters. The order in
which the formal parameters are listed is not significant. The list of actual
parameters may be wrapped immediately following a comma. After executing the
function the result is loaded into the accumulator and can be stored using ST.
EN and ENO can be used for this type of call.
Calling a function with formal parameter names:
or
LIMIT (
MN:=0,
IN:=var1,
MX:=var2
)
ST out
Calling the same function in FBD:
With formal calls, values do not have to be assigned to all formal parameters (see
also Parameter (see page 501)).
LIMIT (MN:=0, IN:=var1)
ST out
Calling the same function in FBD:
35006144 07/2012
503
Informal Call
With this type of call (call without formal parameter names), the function is called
using an instruction sequence made up by loading the first actual parameter into the
accumulator, followed by the function name and an optional list of actual
parameters. The order in which the actual parameters are listed is significant. The
list of actual parameters cannot be wrapped. After executing the function the result
is loaded into the accumulator and can be stored using ST.
EN and ENO cannot be used for this type of call.
Calling a function with formal parameter names:
NOTE: Note that when making an informal call, the list of actual parameters cannot
be put in brackets. IEC 61133-3 requires that the brackets be left out in this case to
illustrate that the first actual parameter is not a part of the list.
Invalid informal call for a function:
504
35006144 07/2012
EN and ENO
With all functions an EN input and an ENO output can be configured.
If the value of EN is equal to "0" when the function is called, the algorithms defined
by the function are not executed and ENO is set to "0".
If the value of EN is equal to 1 when the function is called, the algorithms defined by
the function are executed. After the algorithms have been executed successfully,
the value of ENO is set to "1". If an error occurred while executing the algorithms, ENO
is set to "0".
If the EN pin is not assigned a value, when the FFB is invoked, the algorithm defined
by the FFB is executed (same as if EN equals to "1").
If ENO is set to "0" (caused when EN=0 or an error occurred during execution), the
output of the function is set to "0".
The output behavior of the function does not depend on whether the function was
called up without EN/ENO or with EN=1.
If EN/ENO are used, the function call must be formal.
LIMIT (EN:=1, MN:=0, IN:=var1, MX:=5, ENO=>var2)
ST out
Calling the same function in FBD:
35006144 07/2012
505
The following can be used as actual parameters for function block outputs:
Variable
Address
The data type of the actual parameters must match the data type of the formal
parameters. The only exceptions are generic formal parameters whose data type is
determined by the actual parameter.
Exception:
When dealing with generic ANY_BIT formal parameters, actual INT or DINT (not
UINT and UDINT) parameters can be used.
This is a supplement to IEC 61131-3 and must be enabled explicitly.
Example:
Allowed:
AND (AnyBitParam := IntVar1, AnyBitParam2 := IntVar2)
506
35006144 07/2012
Not allowed:
AND_WORD (WordParam1 := IntVar1, WordParam2 := IntVar2)
(In this case, AND_INT must be used.)
AND_ARRAY_WORD (ArrayInt, ...)
(In this case an explicit type conversion must be carried out using
INT_ARR_TO_WORD_ARR (...).
Not all formal parameters need be assigned a value. You can see which formal
parameter types must be assigned a value in the following table.
Parameter type
EDT
STRING
ARRAY
ANY_ARRAY IODDT
STRUCT FB
ANY
EFB: Input
EFB: VAR_IN_OUT +
EFB: Output
DFB: Input
DFB: VAR_IN_OUT +
DFB: Output
not applicable
If no value is allocated to a formal parameter, then the initial value will be used for
executing the function block. If no initial value has been defined then the default
value (0) is used.
If a formal parameter is not assigned a value and the function block/DFB is
instanced more than once, then the following instances are run with the old value.
35006144 07/2012
507
Public Variables
In addition to inputs and outputs, some function blocks also provide public variables.
These variables transfer statistical values (values that are not influenced by the
process) to the function block. They are used for setting parameters for the function
block.
Public variables are a supplement to IEC 61131-3.
The assignment of values to public variables is made via their initial values or via the
load and save instructions.
Example:
Public variables are read via the instance name of the function block and the names
of the public variables.
Example:
Private Variables
In addition to inputs, outputs and public variables, some function blocks also provide
private variables.
Like public variables, private variables are used to transfer statistical values (values
that are not influenced by the process) to the function block.
Private variables can not be accessed by user program. These type of variables can
only be accessed by the animation table.
NOTE: Nested DFBs are declared as private variables of the parent DFB. So their
variables are also not accessible through programming, but trough the animation
table.
Private variables are a supplement to IEC 61131-3.
508
35006144 07/2012
Programming Notes
Attention should be paid to the following programming notes:
Functions are only executed if the input EN=1 or the EN input is not used (see also
EN and ENO (see page 515)).
The assignment of variables to ANY or ARRAY output types must be made using
the => operator (see also Formal Form of CAL with a List of the Input Parameters
(see page 510)).
Assignments cannot be made outside the function block call.
The instruction
My_Var := My_SAH.OUT
is invalid, if the output OUT of the SAH function block is of type ANY.
The instruction
Cal My_SAH (OUT=>My_Var)
is valid.
Special conditions apply when using VAR_IN_OUT variables (see page 516).
The use of function blocks consists of two parts:
the Declaration (see page 509)
calling the function block
Function block/DFB instances can be called multiple times; other than instances
of communication EFBs, these can only be called once (see Multiple Call of a
Function Block Instance (see page 515)).
Declaration
Before calling a function block it must be declared in the variables editor.
35006144 07/2012
509
or
CAL MY_COUNT (CU:=var1,
R:=reset,
PV:=100,
Q=>out,
CV=>current)
Calling the same function block in FBD:
It is not necessary to assign a value to all formal parameters (see also Parameter
(see page 506)).
CAL MY_COUNT (CU:=var1, R:=reset, Q=>out, CV=>current)
510
35006144 07/2012
The value of a function block output can be stored and then saved by loading the
function block output (function block instance name and separated by a full stop or
entering the formal parameter).
Loading and saving function block outputs:
With informal calls it is not necessary to assign a value to all formal parameters (see
also Parameter (see page 506)).
35006144 07/2012
511
An empty parameter field does not have to be used if formal parameters are omitted
at the end.
MY_COUNT (var1, reset)
Calling the same function block in FBD:
512
35006144 07/2012
35006144 07/2012
FB type
S1, R
SR
S, R1
RS
CLK
R_TRIG
CLK
F_TRIG
CU, R, PV
CD, LD, PV
IN, PT
TP
IN, PT
TON
IN, PT
TOF
513
514
35006144 07/2012
35006144 07/2012
515
VAR_IN_OUT Variable
Function blocks are often used to read a variable at an input (input variables), to
process it and to output the updated values of the same variable (output variables).
This special type of input/output variable is also called a VAR_IN_OUT variable.
The following special features are to be noted when using function blocks/DFBs with
VAR_IN_OUT variables.
All VAR_IN_OUT inputs must be assigned a variable.
VAR_IN_OUT inputs may not have literals or constants assigned to them.
VAR_IN_OUT outputs may not have values assigned to them.
VAR_IN_OUT variables cannot be used outside the block call.
Calling a function block with a VAR_IN_OUT variable in IL:
CAL MY_FBLOCK(IN1:=V1, IN2:=V2, IO1:=V3,
OUT1=>V4, OUT2=>V5)
Calling the same function block in FBD:
516
LD V1
CAL InOutFB
AND V2
35006144 07/2012
AND InOutFB.inout
35006144 07/2012
LD V1
ST InOutFB.IN1
CAL InOutFB(inout:=V2)
517
Calling Procedures
Procedure
Procedures are provided in the form of libraries. The logic of the procedure is
created in the programming language C and may not be modified in the IL editor.
Procedures - like functions - have no internal states. If the input values are the same,
the value on the output is the same every time the procedure is executed. For
example, the addition of two values gives the same result every time.
In contrast to functions, procedures do not return a value and support VAR_IN_OUT
variables.
Procedures are a supplement to IEC 61131-3 and must be enabled explicitly.
Parameter
"Inputs and outputs" are required to transfer values to or from procedures. These are
called formal parameters.
The current process states are transferred to the formal parameters. These are
called actual parameters.
The following can be used as actual parameters for procedure inputs:
Variable
Address
Literal
The following can be used as actual parameters for procedure outputs:
Variable
Address
The data type of the actual parameter must match the data type of the formal
parameter. The only exceptions are generic formal parameters whose data type is
determined by the actual parameter.
When dealing with generic ANY_BIT formal parameters, actual parameters of the
INT or DINT (not UINT and UDINT) data types can be used.
This is a supplement to IEC 61131-3 and must be enabled explicitly.
Example:
Allowed:
AND (AnyBitParam := IntVar1, AnyBitParam2 := IntVar2)
Not allowed:
AND_WORD (WordParam1 := IntVar1, WordParam2 := IntVar2)
(In this case, AND_INT must be used.)
AND_ARRAY_WORD (ArrayInt, ...)
(In this case an explicit type conversion must be carried out using
INT_ARR_TO_WORD_ARR (...).
518
35006144 07/2012
Not all formal parameters must be assigned a value for formal calls. Which formal
parameter types must be assigned a value can be seen in the following table.
Parameter type
EDT
STRING
ARRAY
ANY_ARRAY IODDT
STRUCT FB
ANY
Input
VAR_IN_OUT
Output
not applicable
If no value is allocated to a formal parameter, then the initial value will be used for
executing the function block. If no initial value has been defined, the default value
(0) is used.
Programming Notes
Attention should be paid to the following programming notes:
Procedures are only executed if the input EN=1 or the EN input is not used (see
also EN and ENO (see page 523)).
Special conditions apply when using VAR_IN_OUT variables (see page 523).
There are two ways of calling a procedure:
Formal call (calling a function with formal parameter names)
In this case variables can be assigned to outputs using the => operator (calling
a function block in shortened form).
Informal call (calling a function without formal parameter names)
Formal Call
With this type of call (call with formal parameter names), the procedure is called
using an optional CAL instruction sequence followed by the name of the procedure
and a bracketed list of actual parameter to formal parameter assignments. The
assignment of the input formal parameter is made using the := assignment and
the output formal parameter is made using the => assignment. The order in which
the input formal parameters and output formal parameters are listed is not
significant.
The list of actual parameters may be wrapped immediately following a comma.
EN and ENO can be used for this type of call.
35006144 07/2012
519
or
CAL PROC (IN1:=var1, IN2:=var1, OUT1=>result1,OUT2=>result2)
or
PROC (IN1:=var1,
IN2:=var1,
OUT1=>result1,
OUT2=>result2)
or
CAL PROC (IN1:=var1,
IN2:=var1,
OUT1=>result1,
OUT2=>result2)
Calling the same procedure in FBD:
With formal calls, values do not have to be assigned to all formal parameters (see
also Parameter (see page 518)).
PROC (IN1:=var1, OUT1=>result1, OUT2=>result2)
or
CAL PROC (IN1:=var1, OUT1=>result1, OUT2=>result2)
Calling the same procedure in FBD:
520
35006144 07/2012
NOTE: Note that when making an informal call, the list of actual parameters cannot
be put in brackets. IEC 61133-3 requires that the brackets be left out in this case to
illustrate that the first actual parameter is not a part of the list.
Invalid informal call for a procedure:
35006144 07/2012
521
or
CAL PROC (var1,
var2,
result1,
result2)
Calling the same procedure in FBD:
NOTE: Unlike informal calls without a CAL instruction, when making informal calls
with a CAL instruction, the value to be processed (first actual parameter) is not
explicitly loaded in the battery. Instead it is part of the list of actual parameters. For
this reason, when making informal calls with a CAL instruction, the list of actual
parameters must be put in brackets.
522
35006144 07/2012
EN and ENO
With all procedures, an EN input and an ENO output can be configured.
If the value of EN is equal to "0" when the procedure is called, the algorithms defined
by the procedure are not executed and ENO is set to "0".
If the value of EN is "1" when the procedure is called, the algorithms defined by the
function are executed. After the algorithms have been executed successfully, the
value of ENO is set to "1". If an error occurs when executing these algorithms, ENO
is set to "0".
If the EN pin is not assigned a value, when the FFB is invoked, the algorithm defined
by the FFB is executed (same as if EN equals to "1").
If ENO is set to "0" (caused when EN=0 or an error occurred during executing), the
outputs of the procedure are set to "0".
If EN/ENO are used, the procedure call must be formal. The assignment of variables
to ENO must be made using the => operator.
PROC (EN:=1, IN1:=var1, IN2:=var2,
ENO=>error, OUT1=>result1, OUT2=>result2) ;
Calling the same procedure in FBD:
VAR_IN_OUT Variable
Procedures are often used to read a variable at an input (input variables), to process
it and to output the updated values of the same variable (output variables). This
special type of input/output variable is also called a VAR_IN_OUT variable.
The following special features are to be noted when using procedures with
VAR_IN_OUT variables.
All VAR_IN_OUT inputs must be assigned a variable.
VAR_IN_OUT inputs may not have literals or constants assigned to them.
VAR_IN_OUT outputs may not have values assigned to them.
VAR_IN_OUT variables cannot be used outside of the procedure call.
Calling a procedure with VAR_IN_OUT variable in IL:
PROC3 (IN1:=V1, IN2:=V2, IO1:=V3,
OUT1=>V4, OUT2=>V5) ;
35006144 07/2012
523
CAL InOutProc
AND V2
AND InOutProc.inout
524
LD V1
InOutFB V2
35006144 07/2012
35006144 07/2012
525
526
35006144 07/2012
Unity Pro
Structured Text (ST)
35006144 07/2012
15
Overview
This chapter describes the programming language structured text ST which
conforms to IEC 61131.
What Is in This Chapter?
This chapter contains the following sections:
Section
35006144 07/2012
Topic
Page
15.1
528
15.2
Instructions
539
15.3
559
527
15.1
Overview
This section contains a general overview of the structured text ST.
What Is in This Section?
This section contains the following topics:
Topic
528
Page
529
Operands
532
Operators
534
35006144 07/2012
35006144 07/2012
529
Section Size
The length of an instruction line is limited to 300 characters.
The length of an ST section is not limited within the programming environment. The
length of an ST section is only limited by the size of the PLC memory.
Syntax
Identifiers and Keywords are not case sensitive.
Exception: Not allowed - spaces and tabs
keywords
literals
values
identifiers
variables and
limiter combinations [e.g. (* for comments)]
Execution Sequence
The evaluation of an expression consists of applying the operators to the operands
in the sequence as defined by the rank of the operators (see Table of Operators
(see page 534)). The operator with the highest rank in an expression is performed
first, followed by the operator with the next highest rank, etc., until the evaluation is
complete. Operators with the same rank are performed from left to right, as they are
written in the expression. This sequence can be altered with the use of parentheses.
If, for example, A, B, C and D have the values 1, 2, 3 and 4, and are calculated as
follows:
A+B-C*D
the result is -9.
In the case of the following calculation:
(A+B-C)*D
the result is 0.
If an operator contains two operands, the left operand is executed first, e.g. in the
expression
SIN(A)*COS(B)
the expression SIN(A) is calculated first, then COS(B) and only then is the product
calculated.
530
35006144 07/2012
Error Behavior
The following conditions are handled as an error when executing an expression:
Attempting to divide by 0.
Operands do not contain the correct data type for the operation.
The result of a numerical operation exceeds the value range of its data type
If an error occurs when executing the operation, the corresponding Systembit (%S)
is set (if supported by the PLC being used).
IEC Conformity
For a description of IEC conformity for the ST programming language, see IEC
Conformity (see page 661).
35006144 07/2012
531
Operands
Introduction
An operand can be:
an address
a literal
a variable
a multi-element variable
an element of a multi-element variable
a function call
an FFB output
Data Types
Data types, which are in an instruction of processing operands, must be identical.
Should operands of various types be processed, a type conversion must be
performed beforehand.
In the example the integer variable i1 is converted into a real variable before being
added to the real variable r4.
r3 := r4 + SIN(INT_TO_REAL(i1)) ;
As an exception to this rule, variables with data type TIME can be multiplied or
divided by variables with data type INT, DINT, UINT or UDINT.
Permitted operations:
timeVar1 := timeVar2 / dintVar1;
timeVar1 := timeVar2 * intVar1;
timeVar := 10 * time#10s;
This function is listed by IEC 61131-3 as "undesired" service.
Direct Use of Addresses
Addresses can be used directly (without a previous declaration). In this case the
addresses data type is assigned directly. The assignment is made using the "Large
prefix".
The different large prefixes are given in the following table:
Large prefix / Symbol
532
Example
Data type
no prefix
BOOL
%MX20
BOOL
%QB102.3
BYTE
%KW43
INT
%QD100
DINT
%MF100
REAL
35006144 07/2012
35006144 07/2012
533
Operators
Introduction
An operator is a symbol for:
an arithmetic operation to be executed or
a logical operation to be executed or
a function edit (call)
Operators are generic, i.e. they adapt automatically to the data type of the operands.
Table of Operators
Operators are executed in sequence according to priority, see also Execution
Sequence, page 530.
ST programming language operators:
Operator
Meaning
Order of
rank
possible operands
Description
()
Use of
Brackets:
1 (highest)
Expression
FUNCNAME Function
processing
(Actual
parameter - (call)
list)
Expression, Literal,
Variable, Address (all data
types)
Negation
Expression, Literal,
Variable, Address of Data
TypeINT, DINT or REAL
NOT
Complement
Expression, Literal,
Variable, Address of Data
Type BOOL, BYTE, WORD or
DWORD
**
Exponentiation 4
Expression, Literal,
Variable, Address of Data
TypeREAL (Basis) and
INT, DINT, UINT, UDINT
or REAL (Exponent)
534
35006144 07/2012
Operator
Meaning
Order of
rank
possible operands
Description
Multiplication
Expression, Literal,
Variable, Address of Data
TypeINT, DINT, UINT,
UDINT or REAL
Division
Expression, Literal,
Variable, Address of Data
TypeINT, DINT, UINT,
UDINT or REAL
MOD
Modulo
Expression, Literal,
Variable, Address of Data
Type INT, DINT, UINT or
UDINT
Addition
Expression, Literal,
Variable, Address of Data
Type INT, DINT, UINT,
UDINT, REAL or TIME
Subtraction
Expression, Literal,
Variable, Address of Data
Type INT, DINT, UINT,
UDINT, REAL or TIME
35006144 07/2012
535
Operator
Meaning
Order of
rank
possible operands
Description
<
Less than
comparison
Expression, Literal,
Variable, Address of Data
Type BOOL, BYTE, INT,
DINT, UINT, UDINT, REAL,
TIME, WORD, DWORD,
STRING, DT, DATE or TOD
>
Greater than
comparison
Expression, Literal,
Variable, Address of Data
Type BOOL, BYTE, INT,
DINT, UINT, UDINT, REAL,
TIME, WORD, DWORD,
STRING, DT, DATE or TOD
<=
Less than or
equal to
comparison
Expression, Literal,
Variable, Address of Data
Type BOOL, BYTE, INT,
DINT, UINT, UDINT, REAL,
TIME, WORD, DWORD,
STRING, DT, DATE or TOD
>=
Greater than or 7
equal to
comparison
Expression, Literal,
Variable, Address of Data
Type BOOL, BYTE, INT,
DINT, UINT, UDINT, REAL,
TIME, WORD, DWORD,
STRING, DT, DATE or TOD
536
35006144 07/2012
Operator
Meaning
Order of
rank
possible operands
Description
Equality
Expression, Literal,
Variable, Address of Data
Type BOOL, BYTE, INT,
DINT, UINT, UDINT, REAL,
TIME, WORD, DWORD,
STRING, DT, DATE or TOD
<>
Inequality
Expression, Literal,
Variable, Address of Data
Type BOOL, BYTE, INT,
DINT, UINT, UDINT, REAL,
TIME, WORD, DWORD,
STRING, DT, DATE or TOD
&
Logical AND
Expression, Literal,
Variable, Address of Data
Type BOOL, BYTE, WORD or
DWORD
AND
Logical AND
Expression, Literal,
Variable, Address of Data
Type BOOL, BYTE, WORD or
DWORD
35006144 07/2012
537
Operator
Meaning
Order of
rank
possible operands
Description
XOR
Logical
Exclusive OR
10
Expression, Literal,
Variable, Address of Data
Type BOOL, BYTE, WORD or
DWORD
OR
Logical OR
11 (lowest)
Expression, Literal,
Variable, Address of Data
Type BOOL, BYTE, WORD or
DWORD
538
35006144 07/2012
15.2
Instructions
Overview
This section describes the instructions for the programming language of structured
text ST.
What Is in This Section?
This section contains the following topics:
Topic
35006144 07/2012
Page
Instructions
540
Assignment
541
544
545
546
547
548
551
552
553
Subroutine Call
554
RETURN
555
Empty Instruction
556
557
Comment
558
539
Instructions
Description
Instructions are the "Commands" of the ST programming language.
Instructions must be terminated with semicolons.
Several instructions (separated by semicolons) can be present in one line.
A single semicolon represents an Empty instruction (see page 556).
540
35006144 07/2012
Assignment
Introduction
When an assignment is performed, the current value of a single or multi-element
variable is replaced by the result of the evaluation of the expression.
An assignment consists of a variable specification on the left side, followed by the
assignment operator :=, followed by the expression to be evaluated.
Both variables (left and right sides of the assignment operator) must have the same
data type.
Arrays are a special case. After being explicitly enabled, assignment of two arrays
with different lengths can be made.
Assigning the Value of a Variable to Another Variable
Assignments are used to assign the value of a variable to another variable.
The instruction
A := B ;
is used, for example, to replace the value of the variable A with the current value of
variable B. If A and B are elementary data types, the individual value of B is passed
to A. If A and B are derived data types, the values of all B elements are passed to A.
Assigning the Value of a Literal to a Variable
Assignments are used to assign a literal to variables.
The instruction
C := 25 ;
is used, for example, to assign the value 25 to the variable C.
Assigning the Value of an Operation to a Variable
Assignments are used to assign to a variable a value which is the result of an
operation.
The instruction
X := (A+B-C)*D ;
is used, for example, to assign the result of the operation (A+B-C)*D to the variable
X.
35006144 07/2012
541
542
35006144 07/2012
35006144 07/2012
543
544
35006144 07/2012
35006144 07/2012
545
COS(B) ;
;
;
;
546
35006144 07/2012
See Also
ELSE (see page 545)
35006144 07/2012
547
548
35006144 07/2012
35006144 07/2012
549
550
35006144 07/2012
35006144 07/2012
551
552
35006144 07/2012
35006144 07/2012
553
Subroutine Call
Subroutine Call
A subroutine call consists of the name of the subroutine section followed by an
empty parameter list.
Subroutine calls do not return a value.
The subroutine to be called must be located in the same task as the ST section
called.
Subroutines can also be called from within subroutines.
For example:
SubroutineName () ;
Subroutine calls are a supplement to IEC 61131-3 and must be enabled explicitly.
In SFC action sections, subroutine calls are only allowed when Multitoken Operation
is enabled.
554
35006144 07/2012
RETURN
Description
RETURN instructions can be used in DFBs (derived function blocks) and in SRs
(subroutines).
RETURN instructions can not be used in the main program.
In a DFB, a RETURN instruction forces the return to the program which called the
DFB.
The rest of the DFB section containing the RETURN instruction is not executed.
The next sections of the DFB are not executed.
The program which called the DFB will be executed after return from the DFB.
If the DFB is called by another DFB, the calling DFB will be executed after return.
In a SR, a RETURN instruction forces the return to the program which called the
SR.
The rest of the SR containing the RETURN instruction is not executed.
The program which called the SR will be executed after return from the SR.
35006144 07/2012
555
Empty Instruction
Description
A single semicolon ; represents an empty instruction.
For example,
IF x THEN ; ELSE ..
In this example, an empty instruction follows the THEN instruction. This means that
the program exits the IF instruction as soon as the IF condition is 1.
556
35006144 07/2012
35006144 07/2012
557
Comment
Description
In the ST editor, comments always start with the string (* and end in the string *).
Any comments can be entered between these character strings. Comments can be
entered in any position in the ST editor, except in keywords, literals, identifiers and
variables.
Nesting comments is not permitted according to IEC 61131-3. If comments are
nested nevertheless, then they must be enabled explicitly.
558
35006144 07/2012
15.3
Overview
Calling Elementary Functions, Elementary Function Blocks, Derived Function
Blocks and Procedures in the ST programming language.
What Is in This Section?
This section contains the following topics:
Topic
35006144 07/2012
Page
560
566
Procedures
574
559
35006144 07/2012
Not all formal parameters must be assigned with a value. You can see which formal
parameter types must be assigned with a value in the following table.
Parameter type
EDT
STRING
ARRAY
ANY_ARRAY IODDT
STRUCT FB
ANY
Input
VAR_IN_OUT
Output
not applicable
If no value is allocated to a formal parameter, then the initial value will be used for
executing the function block. If no initial value has been defined then the default
value (0) is used.
Programming Notes
Attention should be paid to the following programming notes:
All generic functions are overloaded. This means the functions can be called with
or without entering the data type.
E.g.
i1 := ADD (i2, 3);
is identical to
i1 := ADD_INT (i2, 3);
Functions can be nested (see also Nesting Functions, page 564).
Functions are only executed if the input EN=1 or the EN input is not used (see also
EN and ENO, page 564).
There are two ways of calling a function:
Formal call (calling a function with formal parameter names)
Informal call (calling a function without formal parameter names)
35006144 07/2012
561
Formal Call
With formal calls (calls with formal parameter names), the call consists of the actual
parameter of the output, followed by the assignment instruction :=, then the function
name and then by a bracketed list of value assignments (actual parameters) to the
formal parameter. The order in which the formal parameters are enumerated in a
function call is not significant.
EN and ENO can be used for this type of call.
Calling a function with formal parameter names:
With formal calls it is not necessary to assign a value to all formal parameters (see
also Parameters, page 560).
out:=LIMIT (MN:=0, IN:=var1) ;
Calling the same function in FBD:
562
35006144 07/2012
Informal Call
With informal calls (calls without formal parameter names), the call consists of the
actual parameter of the output, followed by the symbol of the assignment instruction
:=, then the function name and then by a bracketed list of the inputs actual
parameters. The order that the actual parameters are enumerated in a function call
is significant.
EN and ENO cannot be used for this type of call.
Calling a function without formal parameter names:
With informal calls it is not necessary to assign a value to all formal parameters (see
also Parameters, page 560).
This is a supplement to IEC 61131-3 and must be enabled explicitly.
An empty parameter field is used to skip a parameter.
Call with empty parameter field:
out:=LIMIT ( ,var1, 5 + var) ;
Calling the same function in FBD:
An empty parameter field does not have to be used if formal parameters are omitted
at the end.
out:=LIMIT (0, var1) ;
Calling the same function in FBD:
35006144 07/2012
563
Nesting Functions
A function call can include the call of further functions. The nesting depth is not
limited.
Nested call of array function:
out:=LIMIT (MN:=4, IN:=MUL(IN1:=var1, IN2:=var2), MX:=5) ;
Calling the same function in FBD:
Functions that return a value of the ANY_ARRAY data type can not be used within
a function call.
Unauthorized nesting with ANY_ARRAY:
EN and ENO
With all functions an EN input and an ENO output can be configured.
If the value of EN is equal to "0", when the function is called, the algorithms defined
by the function are not executed and ENO is set to "0".
If the value of EN is equal to "1", when the function is called, the algorithms which
are defined by the function are executed. After successful execution of these
algorithms, the value of ENO is set to "1". If an error occurs during execution of these
algorithms, ENO will be set to "0".
If the EN pin is not assigned a value, when the FFB is invoked, the algorithm defined
by the FFB is executed (same as if EN equals to "1").
If ENO is set to "0" (caused when EN=0 or an error occurred during executing), the
output of the function is set to "0".
The output behavior of the function does not depend on whether the function was
called up without EN/ENO or with EN=1.
564
35006144 07/2012
35006144 07/2012
565
The following can be used as actual parameters for function block outputs:
Variable
Address
The data type of the actual parameters must match the data type of the formal
parameters. The only exceptions are generic formal parameters whose data type is
determined by the actual parameter.
When dealing with generic ANY_BIT formal parameters, actual parameters of the
INT or DINT (not UINT and UDINT) data types can be used.
This is a supplement to IEC 61131-3 and must be enabled explicitly.
Example:
Allowed:
AND (AnyBitParam := IntVar1, AnyBitParam2 := IntVar2);
Not allowed:
AND_WORD (WordParam1 := IntVar1, WordParam2 := IntVar2);
(In this case, AND_INT must be used.)
AND_ARRAY_WORD (ArrayInt, ...);
(In this case an explicit type conversion must be carried out using
INT_ARR_TO_WORD_ARR (...);.)
566
35006144 07/2012
Not all formal parameters must be assigned with a value. Which formal parameter
types must be assigned a value can be seen in the following table.
Parameter type
EDT
STRING
ARRAY
ANY_ARRAY IODDT
STRUCT FB
ANY
EFB: Input
EFB: VAR_IN_OUT +
EFB: Output
DFB: Input
DFB: VAR_IN_OUT +
DFB: Output
not applicable
If no value is allocated to a formal parameter, then the initial value will be used for
executing the function block. If no initial value has been defined then the default
value (0) is used.
If a formal parameter is not assigned with a value and the function block/DFB is
instanced more than once, then the following instances are run with the old value.
Public Variables
In addition to inputs and outputs, some function blocks also provide public variables.
These variables transfer statistical values (values that are not influenced by the
process) to the function block. They are used for setting parameters for the function
block.
Public variables are a supplement to IEC 61131-3.
The assignment of values to public variables is made via their initial values or
assignments.
Example:
Public variables are read via the instance name of the function block and the names
of the public variables.
Example:
35006144 07/2012
567
Private Variables
In addition to inputs, outputs and public variables, some function blocks also provide
private variables.
Like public variables, private variables are used to transfer statistical values (values
that are not influenced by the process) to the function block.
Private variables can not be accessed by user program. These type of variables can
only be accessed by the animation table.
NOTE: Nested DFBs are declared as private variables of the parent DFB. So their
variables are also not accessible through programming, but trough the animation
table.
Private variables are a supplement to IEC 61131-3.
Programming Notes
Attention should be paid to the following programming notes:
Functions blocks are only executed if the input EN=1 or the EN input is not used
(see also EN and ENO, page 572).
The assignment of variables to ANY or ARRAY output types must be made using
the => operator (see also Formal Call, page 569).
Assignments cannot be made outside of the function block call.
The instruction
My_Var := My_SAH.OUT;
is invalid, if the output OUT of the SAH function block is of type ANY.
The instruction
Cal My_SAH (OUT=>My_Var);
is valid.
Special conditions apply when using VAR_IN_OUT variables (see page 572).
The use of function blocks consists of two parts in ST:
the Declaration (see page 568)
calling the function block
Function block/DFB instances can be called multiple times; other than instances
of communication EFBs, these can only be called once (see Multiple Function
Block Instance Call, page 571).
Declaration
Before calling a function block it must be declared in the variables editor.
568
35006144 07/2012
Formal Call
With formal calls (call with formal parameter names), the function block is called
using an instruction sequence made from the function blocks instance names that
follows a bracketed list of actual parameter assignments to the formal parameters.
Assign input formal parameters via :=Assignment and the assignment of the input
formal parameter using the := assignment. The sequence in which the input formal
parameters and output formal parameters are enumerated is not significant.
EN and ENO can be used for this type of call.
Calling a function block with formal parameter names:
Assigning the value of a function block output is made by entering the actual
parameter name, followed by the assignment instruction :=followed by the instance
name of the function block and loading the formal parameter of the function block
output (separated by a full-stop).
E.g.
MY_COUNT (CU:=var1, R:=reset, PV:=100 + value);
Q := MY_COUNT.out ;
CV := MY_COUNT.current ;
NOTE: Type Array DDTs cannot be assigned this way. However, Type Structure
DDTs may be assigned.
It is not necessary to assign a value to all formal parameters (see also Parameter,
page 566).
MY_COUNT (CU:=var1, R:=reset, Q=>out, CV=>current);
Calling the same function block in FBD:
35006144 07/2012
569
Informal Call
With informal calls (call without Formal parameter names), the function block is
called using an instruction made from the function block instance names, followed
by a bracketed list of the actual parameters for the inputs and outputs. The order in
which the actual parameters are listed in a function block call is significant.
EN and ENO cannot be used for this type of call.
Calling a function block without formal parameter names:
With informal calls it is not necessary to assign a value to all formal parameters (see
also Parameter, page 566). This does not apply for VAR_IN_OUT variables, for input
parameters with dynamic lengths and outputs of type ANY. It must always be
assigned a variable.
This is a supplement to IEC 61131-3 and must be enabled explicitly.
An empty parameter field is used to skip a parameter.
Call with empty parameter field:
MY_COUNT (var1, , 100 + value, out, current) ;
Calling the same function block in FBD:
An empty parameter field does not have to be used if formal parameters are omitted
at the end.
MY_COUNT (var1, reset) ;
Calling the same function block in FBD:
570
35006144 07/2012
35006144 07/2012
571
EN and ENO
With all function blocks/DFBs, an EN input and an ENO output can be configured.
If the value of EN is equal to "0", when the function block/DFB is called, the
algorithms defined by the function block/DFB are not executed and ENO is set to "0".
If the value of EN is equal to "1", when the function block/DFB is invoked, the
algorithms which are defined by the function block/DFB will be executed. After the
algorithms have been executed successfully, the value of ENO is set to "1". If an error
occurred while executing the algorithms, ENO is set to "0".
If the EN pin is not assigned a value, when the FFB is invoked, the algorithm defined
by the FFB is executed (same as if EN equals to "1").
If ENO is set to "0" (results from EN=0 or an error during execution), the outputs of
the function block/DFB retain the status from the last cycle in which they were
correctly executed.
The output behavior of the function blocks/DFBs does not depend on whether the
function blocks/DFBs are called without EN/ENO or with EN=1.
If EN/ENO are used, the function block call must be formal. The assignment of
variables to ENO must be made using the => operator.
MY_COUNT (EN:=1, CU:=var1, R:=reset, PV:=100 + value,
ENO=>error, Q=>out, CV=>current) ;
Calling the same function block in FBD:
VAR_IN_OUT-Variable
Function blocks are often used to read a variable at an input (input variables), to
process it and to restate the altered values of the same variable (output variables).
This special type of input/output variable is also called a VAR_IN_OUT variable.
The following special features are to be noted when using function blocks/DFBs with
VAR_IN_OUT variables.
All VAR_IN_OUT inputs must be assigned a variable.
VAR_IN_OUT inputs may not have literals or constants assigned to them.
VAR_IN_OUT outputs may not have values assigned to them.
VAR_IN_OUT variables cannot be used outside of the function block call.
Calling a function block with VAR_IN_OUT variable in ST:
MY_FBLOCK(IN1:=V1, IN2:=V2, IO1:=V3, OUT1=>V4, OUT2=>V5);
572
35006144 07/2012
35006144 07/2012
573
Procedures
Procedure
Procedures are provided in the form of libraries. The logic of the procedure is
created in the programming language C and may not be modified in the ST editor.
Procedures - like functions - have no internal states. If the input values are the same,
the value on the output is the same for all executions of the procedure. For example,
the addition of two values gives the same result at every execution.
In contrast to functions, procedures do not return a value and support VAR_IN_OUT
variables.
Procedures are a supplement to IEC 61131-3 and must be enabled explicitly.
Parameter
"Inputs and outputs" are required to transfer values to or from procedures. These are
called formal parameters.
The current process states are transferred to the formal parameters. These are
called actual parameters.
The following can be used as actual parameters for procedure inputs:
Variable
Address
Literal
ST Expression
The following can be used as actual parameters for procedure outputs:
Variable
Address
The data type of the actual parameters must match the data type of the formal
parameters. The only exceptions are generic formal parameters whose data type is
determined by the actual parameter.
When dealing with generic ANY_BIT formal parameters, actual parameters of the
INT or DINT (not UINT and UDINT) data types can be used.
This is a supplement to IEC 61131-3 and must be enabled explicitly.
Example:
Allowed:
AND (AnyBitParam := IntVar1, AnyBitParam2 := IntVar2);
Not allowed:
AND_WORD (WordParam1 := IntVar1, WordParam2 := IntVar2);
(In this case, AND_INT must be used.)
AND_ARRAY_WORD (ArrayInt, ...);
(In this case an explicit type conversion must be carried out using
INT_ARR_TO_WORD_ARR (...);.
574
35006144 07/2012
Not all formal parameters must be assigned with a value. You can see which formal
parameter types must be assigned with a value in the following table.
Parameter type
EDT
STRING
ARRAY
ANY_ARRAY IODDT
STRUCT FB
ANY
Input
VAR_IN_OUT
Output
not applicable
If no value is allocated to a formal parameter, then the initial value will be used for
executing the function block. If no initial value has been defined then the default
value (0) is used.
Programming Notes
Attention should be paid to the following programming notes:
Procedures are only executed if the input EN=1 or the EN input is not used (see
also EN and ENO, page 577).
Special conditions apply when using VAR_IN_OUT variables (see page 578).
There are two ways of calling a procedure:
Formal call (see page 575) (calling a function with formal parameter names)
This way variables can be assigned to outputs using the => operator.
Informal call (see page 576) (call without formal parameter names)
Formal Call
With formal calls (call with formal parameter names), the procedures are called
using an instruction sequence made from the procedure name, followed by a
bracketed list of actual parameter assignments to the formal parameters. The
assignment of the input formal parameter is made using the := assignment and
the output formal parameter is made using the => assignment. The sequence in
which the input formal parameters and output formal parameters are enumerated is
not significant.
EN and ENO can be used for this type of call.
35006144 07/2012
575
With formal calls it is not necessary to assign a value to all formal parameters (see
also Parameter, page 574).
PROC (IN1:=var1, OUT1=>result1, OUT2=>result2);
Calling the same procedure in FBD:
Informal Call
With informal calls (call without formal parameter names), procedures are called
using an instruction made from the procedure name, followed by a bracketed list of
the inputs and outputs actual parameters. The order that the actual parameters are
enumerated in a procedure call is significant.
EN and ENO cannot be used for this type of call.
Calling a procedure without formal parameter names:
576
35006144 07/2012
With informal calls it is not necessary to assign a value to all formal parameters (see
also Parameter, page 574).
This is a supplement to IEC 61131-3 and must be enabled explicitly.
An empty parameter field is used to skip a parameter.
Call with empty parameter field:
PROC (var1, , result1, result2) ;
Calling the same procedure in FBD:
An empty parameter field does not have to be used if formal parameters are omitted
at the end.
PROC (var1, var2, result1) ;
Calling the same procedure in FBD:
EN and ENO
With all procedures, an EN input and an ENO output can be configured.
If the value of EN is equal to "0", when the procedure is called, the algorithms defined
by the procedure are not executed and ENO is set to "0".
If the value of EN is "1" when the procedure is called, the algorithms defined by the
function are executed. After successful execution of these algorithms, the value of
ENO is set to "1". If an error occurs during execution of these algorithms, ENO will be
set to "0".
If the EN pin is not assigned a value, when the FFB is invoked, the algorithm defined
by the FFB is executed (same as if EN equals to "1").
If ENO is set to "0" (caused when EN=0 or an error occurred during executing), the
outputs of the procedure are set to "0".
The output behavior of the procedure does not depend on whether the function is
called without EN or with EN=1.
35006144 07/2012
577
If EN/ENO are used, the procedure call must be formal. The assignment of variables
to ENO must be made using the => operator.
PROC (EN:=1, IN1:=var1, IN2:=var2,
ENO=>error, OUT1=>result1, OUT2=>result2) ;
Calling the same procedure in FBD:
VAR_IN_OUT Variable
Procedures are often used to read a variable at an input (input variables), to process
it and to restate the altered values of the same variable (output variables). This
special type of input/output variable is also called a VAR_IN_OUT variable.
The following special features are to be noted when using procedures with
VAR_IN_OUT variables.
All VAR_IN_OUT inputs must be assigned a variable.
VAR_IN_OUT inputs may not have literals or constants assigned to them.
VAR_IN_OUT outputs may not have values assigned to them.
VAR_IN_OUT variables cannot be used outside of the procedure call.
Calling a procedure with VAR_IN_OUT variable in ST:
PROC2 (IN1:=V1, IN2:=V2, IO1:=V3,
OUT1=>V4, OUT2=>V5) ;
Calling the same procedure in FBD:
578
35006144 07/2012
35006144 07/2012
579
580
35006144 07/2012
Unity Pro
DFB
35006144 07/2012
V
In This Part
This part presents:
35006144 07/2012
Chapter Name
Page
16
583
17
589
18
601
19
607
20
625
581
DFB
582
35006144 07/2012
Unity Pro
Overview of DFBs
35006144 07/2012
16
35006144 07/2012
Page
584
586
583
Overview of DFBs
one or more sections written in Ladder (LD), Instruction List (IL), Structured Text
(ST) or Functional Block Diagram (FBD) language
input/output parameters
public or private internal variables
Function blocks can be used to structure and optimize your application. They can be
used whenever a program sequence is repeated several times in your application,
or to set a standard programming operation (for example, an algorithm that controls
a motor, incorporating local safety requirements).
By exporting then importing these blocks, they can be used by a group of
programmers working on a single application or in different applications.
Benefits of Using a DFB
Using a DFB function block in an application enables you to:
Furthermore, LD and FBD languages provide a graphic view of the DFBs, facilitating
the design and debugging of your program.
DFB Created with Previous Software Versions
DFBs created using PL7 and Concept must first be converted using the converters
that come with the product, before being used in the application.
584
35006144 07/2012
Overview of DFBs
Domain of Use
The following table shows the domain of use for the DFBs.
Function
Domain
Unity Pro
(1) IL: Instruction List , ST: Structured Text, LD: LaDder, FBD: Functional Block
Diagram language.
35006144 07/2012
585
Overview of DFBs
Action
Create a copy of this function block, called an instance, every time the DFB is
used in the application.
NOTE: If you use a DFB that is already in the User-Defined Library and modify it,
the new modified type will be used for any additional instances in the open project.
However, the User-Defined Library remains unchanged.
Description of a DFB Type
The following diagram shows a graphic representation of a DFB model.
586
35006144 07/2012
Overview of DFBs
Name: name of the DFB type (max. 32 characters). This name must be unique in
the libraries, the authorized characters used depend on the choice made in the
Identifiers area of the Language extensions tab in the Project Settings
(see Unity Pro, Operating Modes):
Inputs: input parameters (excluding input/output parameters).
Outputs: output parameters (excluding input/output parameters).
Inputs/Outputs: input/output parameters.
Public variables: internal variables accessible by the application program.
Private variables: nested internal variables or DFBs, not accessible by the
application program.
Sections: DFB code sections in LD, IL, ST or FBD.
Comment of a maximum of 1024 characters. Formatting characters (carriage
return, tab, etc.) are not authorized.
For each type of DFB, a descriptive file is also accessible via a dialog box: size of
the DFB, number of parameters and variables, version number, date of last
modification, protection level, etc.
Online Help for DFB Types
It is possible to link an HTML help file to each DFB in the User-Defined Library. This
file must:
Have a name that is identical to the linked DFB,
Be located in the directory \Schneider
Electric\FFBLibset\CustomLib\MyCustomFam\ Language (where Language is
named Eng, Fre, Ger, Ita, Spa or Chs according to the language desired).
Creation of a DFB Instance
Once the DFB type is created, you can define an instance of this DFB via the
variable editor or when the function is called in the program editor.
Use of DFB Instances
A DFB instance is used as follows
A DFB instance can be used in all application program tasks, except event tasks and
Sequential Function Chart (SFC) transitions.
35006144 07/2012
587
Overview of DFBs
Storage
The DFB types the user creates can be stored (see Unity Pro, Operating Modes) in
the function and function block library.
588
35006144 07/2012
Unity Pro
Description of DFBs
35006144 07/2012
17
35006144 07/2012
Page
590
DFB Parameters
592
DFB Variables
596
598
589
Description of DFBs
The internal data of the DFB must be defined using symbols (this data cannot be
addressed as an address).
Elements to Define for Each Parameter
When the function block is created, the following must be defined for each
parameter:
Name: Name of DFB type (max. 32 characters). This name must be unique in the
libraries; the authorized characters used depend on the choice made in the
Identifiers area of the Language extensions tab in Project Settings (see Unity
Pro, Operating Modes):
A type of object (BOOL, INT, REAL, etc.).
A comment of a maximum of 1024 characters (optional). Formatting characters
(carriage return, tab, etc.) are not allowed.
An initial value.
The read/write attribute that defines whether the variable may or may not be
written in runtime: R (read only) or R/W (read/write). This attribute must only be
defined for public variables.
The backup attribute that defines whether the variable may or may not be saved.
Types of Objects
The types of objects that may be defined for the DFB parameters belong to the
following families:
Elementary data family: EDT. This family includes the following object types:
Boolean (BOOL, EBOOL), Integer (INT, DINT, etc.), Real (REAL), Character
string (STRING), Bit string (BYTE, WORD, etc.), etc.
Derived data family: DDT. This family includes table (ARRAY) and structure (user
or IODDT) object types.
Generic data families: ANY_ARRAY_xxx.
The function block family: FB. This family includes EFB and DFB object types.
590
35006144 07/2012
Description of DFBs
EDT
Inputs
VAL
Inputs/out
puts
(2)
L-ADR
STRING
Anonymous
or DDT array
DDT (1)
IODDT
GDT:
ANY_ARRAY_x
FB
ANY...
L-ADR-LG
L-ADR-LG
L-ADR
No
L-ADR-LG
No
L-ADR-LG
L-ADR-LG
L-ADR-LG
L-ADR
No
L-ADR-LG
Outputs
VAL
VAL
L-ADR-LG
VAL
No
L-ADR-LG
No
L-ADR-LG
Public
variables
VAL
VAL
VAL
VAL
No
No
No
No
Private
variables
VAL
VAL
VAL
VAL
No
No
RTE No
Key:
(1)
(2)
CAUTION
UNEXPECTED APPLICATION BEHAVIOR - ARRAY INDEX
Take into account the shift of the index for ARRAY variables that have a not null
start index on ANY_ARRAY_x entry (the shift equals the start index value).
Failure to follow these instructions can result in injury or equipment damage.
35006144 07/2012
591
Description of DFBs
DFB Parameters
Illustration
This illustration shows some examples of DFB parameters
Maximum
number
Role
Inputs
32 (1)
Outputs
32 (2)
Inputs/
Outputs
32
Legend:
(1) Number of inputs + Number of inputs/outputs less than or equal to 32
(2) Number of outputs + Number of inputs/outputs less than or equal to 32
NOTE: The IODDT related to CANopen devices for Modicon M340 cannot be used
as a DFB I/O parameter. During the analyse/build step of a project, the following
message:"This IODDT cannot be used as a DFB parameter" advises the limitations
to the user.
592
35006144 07/2012
Description of DFBs
the section(s) that make up the code of the DFB is/are not executed (this is
managed by the system),
the ENO output parameter is set to 0 (FALSE) by the system.
35006144 07/2012
the section(s) that make up the code of the DFB is/are executed (this is managed
by the system),
the ENO output parameter is set to 1 (TRUE) by the system.
593
Description of DFBs
If an error is detected (for example a processing error) by the DFB instance, the user
has the option of setting the ENO output parameter to 0 (FALSE). In this case:
either the output parameters are frozen in the state they were in during the
previous process until the fault disappears,
or the user provides a function in the DFB code whereby the outputs are forced
to the required state until the fault disappears.
VAR_IN_OUT Variable
Function blocks are often used to read a variable at an input (input variables), to
process it and to output the updated values of the same variable (output variables).
This special type of input/output variable is also called a VAR_IN_OUT variable.
The following special features are to be noted when using function blocks/DFBs with
VAR_IN_OUT variables.
All VAR_IN_OUT inputs must be assigned a variable.
VAR_IN_OUT inputs may not have literals or constants assigned to them.
VAR_IN_OUT outputs may not have values assigned to them.
VAR_IN_OUT variables cannot be used outside the block call.
Calling a function block with a VAR_IN_OUT variable in IL:
CAL MY_FBLOCK(IN1:=V1, IN2:=V2, IO1:=V3,
OUT1=>V4, OUT2=>V5)
Calling the same function block in FBD:
594
LD V1
CAL InOutFB
AND V2
35006144 07/2012
Description of DFBs
AND InOutFB.inout
35006144 07/2012
LD V1
ST InOutFB.IN1
CAL InOutFB(inout:=V2)
595
Description of DFBs
DFB Variables
Description of the Variables
This table shows the role of each type of variable.
Variable
Maximum
number
Role
Public
unlimited
Private
unlimited
NOTE: Nested DFBs are declared as private variables of the parent DFB. So their
variables are also not accessible through programming, but trough the animation
table.
Variables that Can Be Accessed by the Application Program
The only variables that can be accessed by the application program are public
variables. To make this possible, the following syntax must be used in the program:
DFB_Name.Variable_Name
DFB_Name represents the name of the instance of the DFB used (maximum of 32
characters),
Variable_Name represents the name of the public variable (maximum of 8
characters).
Example: Control.Gain indicates the public variable Gain of the DFB instance
called Control
596
35006144 07/2012
Description of DFBs
NOTICE
APPLICATION UPLOAD NOT SUCCESSFUL
The bit %S94 must not be set to 1 during an upload.
If the bit %S94 is set to 1 upload then the upload may be impossible.
Failure to follow these instructions can result in equipment damage.
35006144 07/2012
597
Description of DFBs
Defining a Section
A section is defined by:
Programming Rules
When executed, a DFB section can only use the parameters you have defined for
the function block (input, output and input/output parameters and internal variables).
Consequently, a DFB function block cannot use either the global variables of the
application, or the input/output objects, except the system words and bits (%Si,
%SWi and %SDi).
A DFB section has maximum access rights (read and write) for its parameters.
598
35006144 07/2012
Description of DFBs
Example of Code
The following program provides an example of Structured Text code
35006144 07/2012
599
Description of DFBs
600
35006144 07/2012
Unity Pro
DFB instance
35006144 07/2012
18
35006144 07/2012
Page
602
603
604
601
DFB instance
You must identify each DFB instance you create with a name of a maximum 32
characters, the authorized characters used depend on the choice made in the
Identifiers area of the Language extensions tab in the Project Settings
(see Unity Pro, Operating Modes).
The first character must be a letter! Keywords and symbols are prohibited.
Creation of an Instance
From a DFB type, you can create as many instances as necessary; the only
limitation is the size of the PLC memory.
Initial Values
The initial values of the parameters and public variables that you defined when
creating the DFB type can be modified for each DFB instance.
Not all DFB parameters have an initial value.
Modification of the initial values of the elements in the DFB instances
EDT (except String
String type) Type
EDT
DDT
structure
FB
ANY_ARRAY IODDT
ANY_...
Inputs
Yes
No
No
No
No
Input/Output
No
No
No
No
No
No
No
Outputs
Yes
Yes
No
Yes
No
Public variables
Yes
Yes
Yes
Yes
Private Variables
No
No
No
No
No
No
String
Type
EDT
DDT
FB
structure
ANY_ARRAY
IODDT
ANY_...
Inputs
Yes
No
No
No
No
No
Input/Output
No
No
No
No
No
No
No
Outputs
Yes
Yes
No
Yes
No
Public variables
Yes
Yes
Yes
Yes
Private Variables
Yes
Yes
Yes
Yes
No
602
35006144 07/2012
DFB instance
Action
NOTE: The internal variables of DFBs are not reinitialized when using Build project
online command after an input modification. To reinitialize all internal variables use
Rebuild all project command.
Debugging of DFBs
The Unity Pro software offers several DFB debugging tools:
35006144 07/2012
animation table: all parameters, and public and private variables are displayed
and animated in real-time. Objects may be modified and forced
breakpoint, step by step and program diagnostics
runtime screens: for unitary debugging
603
DFB instance
604
Elements
Description
Cpt_parts
Input parameters
Output parameters
35006144 07/2012
DFB instance
Description
The number of edges it counts is then stored by the variable V_cour. This
variable is reset by a rising edge on the Reset input.
When the number of edges counted is equal to the preset value, the Done output
is set to 1. This variable is reset by a rising edge on the Reset input.
Example of Use
Let us suppose your application needs to count 3 part types (for example, bolts, nuts
and screws). The DFB type Cpt_parts can be used three times (3 instances) to
perform these different counts.
The number of parts to be procured for each type is defined in the words %MD10,
%MD12 and %MD14 respectively. When the number of parts is reached, the
counter sends a command to an output (%Q1.2.1, %Q1.2.2 or %Q1.2.3) which then
stops the procurement system for the corresponding parts.
35006144 07/2012
605
DFB instance
606
35006144 07/2012
Unity Pro
Use of DFBs
35006144 07/2012
19
35006144 07/2012
Page
608
611
614
616
619
623
607
Use of DFBs
unconnected input parameters keep the value of the previous call or the
initialization value defined for these parameters, if the block has never been
called
all of the objects assigned to the input, input/output and output parameters must
be of the same type as those defined when the DFB type was created (for
example: if the type INT is defined for the input parameter "speed", then you
cannot assign it the type DINT or REAL)
The only exceptions are BOOL and EBOOL types for input and output
parameters (not for input/output parameters), which can be mixed.
Example: The input parameter "Validation" may be defined as BOOL and
associated with a %Mi internal bit of type EBOOL. However, in the internal code
of the DFB type, the input parameter actually has BOOL-type properties (it cannot
manage edges).
608
35006144 07/2012
Use of DFBs
Assignment of Parameters
The following table summarizes the different possibilities for assigning parameters
in the different programming languages.
Parameter
Type
Inputs
EDT (2)
Optional (3)
BOOL
Optional
DDT
Compulsory
Inputs/outputs
Outputs
ANY_...
Connected or object
Compulsory
ANY_ARRAY
Connected or object
Compulsory
EDT
Connected or object
Compulsory
DDT
Connected or object
Compulsory
IODDT
Connected or object
Compulsory
ANY_...
Connected or object
Compulsory
ANY_ARRAY
Connected or object
Compulsory
EDT
Connected or object
Optional
DDT
Connected or object
Optional
ANY_...
Connected or object
Compulsory
ANY_ARRAY
Connected or object
Optional
(1) Connected in Ladder (LD) or Function Block Diagram (FBD) language. Value or
object in Instruction List (IL) or Structured Text (ST) language.
(2) Except BOOL-type parameters
(3) Except for STRING-type parameters that is compulsory.
35006144 07/2012
609
Use of DFBs
WARNING
UNEXPECTED EQUIPMENT OPERATION
Check the size of arrays when copying from source into target arrays using DFBs.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
When using dynamic arrays, it is mandatory to check the sizes of arrays that are
identical. In specific case, using dynamic arrays as an output or input/output, an
overflow could lead to improper execution of the program and stop of the PLC.
This behavior occurs if the following conditions are fulfilled simultaneously:
Use of a DFB with at least one output or I/O parameter of dynamic array type
(ANY_ARRAY_XXX).
In the coding of a DFB, use of a function or function block (FFB of type FIFO,
LIFO, MOVE, MVX, T2T, SAH or SEL). Note that, the function or FFB needs two
ANY type parameters with at least one defined on the output.
The DFB parameter of the dynamic array is used in writting during the FFB call
(on the ANY type parameter). For other ANY parameters, an array with a fixed
size is used.
The size of the fixed size array is bigger than the size of the dynamic array
calculated to store the result.
In this example, Table_1 is an array with a fixed size, Table_2 is a dynamic array
of type ANY_ARRAY_WORD. This program checks the size of each array. The
functions LENGTH_ARWORD compute the size of each array in order to condition the
execution of the MOVE function.
610
35006144 07/2012
Use of DFBs
Modicon M340
Premium
Quantum
Discrete application
T_DIS_IN_GEN
No
No
No
T_DIS_IN_STD
No
No
No
T_DIS_EVT
No
No
No
T_DIS_OUT_GEN
No
No
No
T_DIS_OUT_STD
No
No
No
T_DIS_OUT_REFLEX
No
No
No
T_ANA_IN_GEN
No
No
No
T_ANA_IN_STD
No
No
No
T_ANA_IN_CTRL
No
Yes
No
Analog application
T_ANA_IN_EVT
No
Yes
No
T_ANA_OUT_GEN
No
No
No
T_ANA_OUT_STD
No
No
No
T_ANA_IN_BMX
Yes
No
No
T_ANA_IN_T_BMX
Yes
No
No
T_ANA_OUT_BMX
Yes
No
No
T_ANA_IN_VE
No
No
No
T_ANA_IN_VWE
No
No
No
T_ANA_BI_VWE
No
No
No
T_ANA_BI_IN_VWE
No
No
No
T_COUNT_ACQ
No
Yes
No
T_COUNT_HIGH_SPEED
No
Yes
No
T_COUNT_STD
No
Yes
No
Counting application
35006144 07/2012
611
Use of DFBs
IODDT families
Modicon M340
Premium
Quantum
T_SIGN_CPT_BMX
Yes
No
No
T_UNSIGN_CPT_BMX
Yes
No
No
T_CNT_105
No
No
No
No
No
No
T_CCY_GROUP1_2_3
No
No
No
T_AXIS_AUTO
No
Yes
No
T_AXIS_STD
No
Yes
No
T_INTERPO_STD
No
Yes
No
T_STEPPER_STD
No
Yes
No
Sercos application
T_CSY_CMD
No
Yes
No
T_CSY_TRF
No
Yes
No
T_CSY_RING
No
Yes
No
T_CSY_IND
No
Yes
No
T_CSY_FOLLOW
No
Yes
No
T_CSY_COORD
No
Yes
No
T_CSY_CAM
No
Yes
No
T_COM_STS_GEN
Yes
Yes
No
T_COM_UTW_M
No
Yes
No
T_COM_UTW_S
No
Yes
No
T_COM_MB
No
Yes
No
T_COM_CHAR
No
Yes
No
T_COM_FPW
No
Yes
No
T_COM_MBP
No
Yes
No
T_COM_JNET
No
Yes
No
Communication application
612
T_COM_ASI
No
Yes
No
T_COM_ETY_1X0
No
Yes
No
T_COM_ETY_210
No
Yes
No
T_COM_IBS_128
No
Yes
No
T_COM_IBS_242
No
Yes
No
T_COM_PBY
No
Yes
No
35006144 07/2012
Use of DFBs
IODDT families
Modicon M340
Premium
Quantum
T_COM_CPP100
No
Yes
No
T_COM_ETYX103
No
Yes
No
T_COM_ETHCOPRO
No
Yes
No
T_COM_MB_BMX
Yes
No
No
T_COM_CHAR_BMX
Yes
No
No
T_COM_CO_BMX
Yes
No
No
T_COM_ETH_BMX
Yes
No
No
Adjustment application
T_PROC_PLOOP
No
Yes
No
T_PROC_3SING_LOOP
No
Yes
No
T_PROC_CASC_LOOP
No
Yes
No
T_PROC_SPP
No
Yes
No
T_PROC_CONST_LOOP
No
Yes
No
No
Yes
No
No
No
No
Weiging application
T_WEIGHING_ISPY101
Common to all applications
T_GEN_MOD
35006144 07/2012
613
Use of DFBs
via a textual call in an operation block in which the syntax and constraints on the
parameters are identical to those of Structured Text language
via a graphic call
The inputs of the function blocks may be connected or assigned a value, an object
or an expression. In any case, the type of external element (value, evaluation of the
expression, etc.) must be identical to that of the input parameter.
A DFB block must have at least one connected Boolean input and an output (if
necessary). For this you may use the EN input parameters and the ENO output
parameter (see the description of these parameters below).
It is compulsory to connect or assign the ANY_ARRAY-type inputs, the generic datatype outputs (ANY_...) and the input/outputs of a DFB block.
Graphic Representation of a DFB Block
The following illustration shows a simple DFB programming example.
614
35006144 07/2012
Use of DFBs
Element
Connected input
Input parameters
Output parameters
Input/output parameters
35006144 07/2012
615
Use of DFBs
a formal call, when arguments are assignments (parameter = value). In this case,
the order in which the arguments are entered in the list is not important.
The EN input parameter and the ENO output parameter can be used to control
the execution of the function block
an informal call, when arguments are values (expression, object or an immediate
value). In this case, the order in which the arguments are entered in the list must
follow the order of the DFB input parameters, including for non-assigned inputs
(the argument is an empty field)
It is not possible to use EN and ENO parameters.
616
35006144 07/2012
Use of DFBs
Meaning
Cpt_1
Input parameters
:=
Clear
100
Done
Output parameter
=>
%Q1.2.1
35006144 07/2012
617
Use of DFBs
618
Element
Meaning
Cpt_1
35006144 07/2012
Use of DFBs
35006144 07/2012
619
Use of DFBs
Example of a DFB
The following example explains the different calls of a DFB in Instruction List. This
is the instance Cpt_1 of the Cpt_parts: type DFB
620
35006144 07/2012
Use of DFBs
Meaning
CAL
Cpt_1
Input parameters
:=
Done
Output parameter
=>
%Q1.2.1
35006144 07/2012
Element
Meaning
CAL
Cpt_1
621
Use of DFBs
622
Element
Meaning
LD Clear
ST Cpt_1.Reset
CAL Cpt_1(
35006144 07/2012
Use of DFBs
35006144 07/2012
623
Use of DFBs
Element
Connected input
Input parameters
Output parameter
624
35006144 07/2012
Unity Pro
Diagnostics DFB
35006144 07/2012
20
Presentation of User Diagnostic DFBs
General
The Unity Pro application is used to create your own diagnostic DFBs (see Unity
Pro, Operating Modes).
These diagnostic DFBs are standard DFBs that you will have configured beforehand
with the Diagnostic property and in which you will have used the following two
functions:
REGDFB (see Unity Pro, Diagnostics, Block Library) to save the alarm date
DEREG (see Unity Pro, Diagnostics, Block Library) to de-register the alarm
35006144 07/2012
The diagnostic is integrated in the project, and can thus be conceived during
development and therefore better meets the users requirements.
The error dating and recording system is done at the source (in the PLC), which
means the information exactly represents the state of the process.
You can connect a number of Viewers (Unity Pro, Magelis, Factory Cast) which
will transcribe the exact state of the process to the user. Each Viewer is
independent, and any action performed on one (for example, an
acknowledgement) is automatically viewed on the others.
625
Diagnostics DFB
626
35006144 07/2012
Unity Pro
35006144 07/2012
Appendices
At a Glance
The appendix contains additional information.
What Is in This Appendix?
The appendix contains the following chapters:
Chapter
35006144 07/2012
Chapter Name
Page
629
IEC Compliance
661
627
628
35006144 07/2012
Unity Pro
EFB Error Codes and Values
35006144 07/2012
A
Introduction
The following tables show the error codes and error values created for the EFBs sort
by library and family.
What Is in This Chapter?
This chapter contains the following topics:
Topic
Tables of Error Codes for the Base Library
35006144 07/2012
Page
630
632
633
637
644
651
653
660
629
Error code
Error
value in
Hex
Error description
DIVTIME
E_DIVIDE_BY_ZERO
-30176
16#8A20
Divide by zero
DIVTIME
E_NEGATIVE_INPUT_
FOR_TIME_OPERATION
-30177
16#8A1F
DIVTIME
E_ARITHMETIC_ ERROR
-30170
16#8A26
Arithmetic error
DIVTIME
E_ERR_ARITHMETIC
-30003
16#8ACD
DIVTIME
FP_ERROR
MULTIME
E_ERR_ARITHMETIC
-30003
16#8ACD
MULTIME
E_ARITHMETIC_ERROR_
MUL_OV
-30172
16#8A24
MULTIME
E_ARITHMETIC_ERROR_
ADD_OV
-30173
16#8A23
MULTIME
E_ARITHMETIC_ERROR_
BIG_PAR
-30171
16#8A25
MULTIME
E_NEGATIVE_INPUT_
FOR_TIME_OPERATION
-30177
16#8A1F
MULTIME
FP_ERROR
630
35006144 07/2012
Statistical
Table of error codes and errors values created for EFBs of the Statistical
family.
Error
value in
Hex
Error description
-30183
16#8A19
Error code
AVE
E_INPUT_VALUE_OUT_ F
OF_RANGE
AVE
E_DIVIDE_BY_ZERO
-30176
16#8A20
Divide by zero
AVE
FP_ERROR
AVE
E_ARITHMETIC_
ERROR
-30170
16#8A26
Arithmetic error
AVE
E_FP_STATUS_FAILED
-30150
16#8A3A
AVE
E_ARITHMETIC_
ERROR_MUL_OV
-30172
16#8A24
AVE
E_ARITHMETIC_
ERROR_ADD_OV
-30173
16#8A23
AVE
E_ARITHMETIC_
ERROR_BIG_PAR
-30171
16#8A25
AVE
E_ARITHMETIC_
ERROR_UNSIGN_OV
-30174
16#8A22
MAX
FP_ERROR
MIN
FP_ERROR
MUX
E_SELECTOR_OUT_
OF_RANGE
-30175
16#8A21
35006144 07/2012
ENO state
in case of
error
Error
value in
Dec
EFB
name
631
632
ENO state in
case of error
E_EFB_ONLEVT T/F
16#8A0C
35006144 07/2012
Error code
Error
ENO state Error
in case of value in value in
Hex
Dec
error
Error description
CREAD_REG E_EFB_MSTR_ERROR
-30191
CREAD_REG E_EFB_NOT_STATE_
RAM_4X
-30531
CREAD_REG -
8195
16#2003
CREAD_REG -
8206
16#200E
CREAD_REG -
See tables of :
Modbus Plus and SY/MAX EtherNet
-30191
CWRITE_REG -
8195
16#2003
CWRITE_REG -
8206
16#200E
35006144 07/2012
633
Error
ENO state Error
in case of value in value in
Hex
Dec
error
Error description
CWRITE_REG -
See tables of :
Modbus Plus and SY/MAX EtherNet
Error Codes (see Modicon
Quantum with Unity, Ethernet
Network Modules, User Manual)
SY/MAX specific Error Codes
(see Modicon Quantum with Unity,
Ethernet Network Modules, User
Manual)
TCP/IP EtherNet Error Codes
(see Modicon Quantum with Unity,
Ethernet Network Modules, User
Manual)
MBP_MSTR
E_EFB_OUT_OF_
RANGE
-30192
MBP_MSTR
E_EFB_NOT_STATE_
RAM_4X
-30531
MBP_MSTR
8195
16#2003
MBP_MSTR
8206
16#200E
MBP_MSTR
See tables of :
Modbus Plus and SY/MAX EtherNet
Error Codes (see Modicon
Quantum with Unity, Ethernet
Network Modules, User Manual)
SY/MAX specific Error Codes
(see Modicon Quantum with Unity,
Ethernet Network Modules, User
Manual)
TCP/IP EtherNet Error Codes
(see Modicon Quantum with Unity,
Ethernet Network Modules, User
Manual)
READ_REG
W_WARN_OUT_OF_
RANGE
30110
READ_REG
E_EFB_NOT_STATE_
RAM_4X
-30531
EFB name
634
Error code
35006144 07/2012
Error description
EFB name
Error code
Error
ENO state Error
in case of value in value in
Hex
Dec
error
READ_REG
E_EFB_MSTR_ERROR
-30191
READ_REG
8195
16#2003
READ_REG
MBPUNLOC
8206
16#200E
READ_REG
See tables of :
Modbus Plus and SY/MAX EtherNet
W_WARN_OUT_OF_
RANGE
30110
WRITE_REG
E_EFB_NOT_STATE_
RAM_4X
-30531
WRITE_REG
E_EFB_MSTR_ERROR
-30191
WRITE_REG
8195
16#2003
WRITE_REG
8206
16#200E
35006144 07/2012
635
EFB name
Error code
Error
ENO state Error
in case of value in value in
Hex
Dec
error
Error description
WRITE_REG
See tables of :
Modbus Plus and SY/MAX EtherNet
Error Codes (see Modicon
Quantum with Unity, Ethernet
Network Modules, User Manual)
SY/MAX specific Error Codes
(see Modicon Quantum with Unity,
Ethernet Network Modules, User
Manual)
TCP/IP EtherNet Error Codes
(see Modicon Quantum with Unity,
Ethernet Network Modules, User
Manual)
636
35006144 07/2012
Error description
I_FILTER
E_EFB_NOT_CONFIGURED F
-30188
I_SET
E_EFB_USER_ERROR_1
-30200
I_SET
E_EFB_USER_ERROR_2
-30201
I_SET
E_EFB_USER_ERROR_3
-30202
I_SET
E_EFB_USER_ERROR_4
-30203
I_SET
E_EFB_USER_ERROR_5
-30204
I_SET
E_EFB_USER_ERROR_11
-30210
I_SET
E_EFB_USER_ERROR_12
-30211
I_SET
E_EFB_USER_ERROR_13
-30212
O_FILTER E_EFB_NOT_CONFIGURED F
-30188
O_SET
E_EFB_USER_ERROR_1
-30200
O_SET
E_EFB_USER_ERROR_2
-30201
O_SET
E_EFB_USER_ERROR_3
-30202
O_SET
E_EFB_USER_ERROR_4
-30203
O_SET
E_EFB_USER_ERROR_5
-30204
O_SET
E_EFB_USER_ERROR_11
-30210
O_SET
E_EFB_USER_ERROR_12
-30211
O_SET
E_EFB_USER_ERROR_13
-30212
35006144 07/2012
637
Error code
ENO state
in case of
error
Error
value in
Dec
Error
value in
Hex
Error description
I_NORM
E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
I_NORM
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
I_NORM_WARN
E_EFB_NO_WARNING_
STATUS_AVAILABLE
-30189
16#8A13
I_NORM_WARN
E_EFB_POS_OVER_
RANGE
-30186
16#8A16
Positive overflow
I_NORM_WARN
E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
I_NORM_WARN
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
I_PHYS
E_EFB_NO_WARNING_
STATUS_AVAILABLE
-30189
16#8A13
I_PHYS
E_INPUT_VALUE_OUT_
OF_RANGE
-30183
16#8A19
I_PHYS
E_EFB_NO_
MEASURING_RANGE
-30185
16#8A17
Internal error
I_PHYS
E_EFB_POS_OVER_
RANGE
-30186
16#8A16
Positive overflow
I_PHYS
E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
I_PHYS
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
I_PHYS_WARN
E_EFB_NO_WARNING_
STATUS_AVAILABLE
-30189
16#8A13
I_PHYS_WARN
E_EFB_FILTER_SQRT_
NOT_AVAIL
-30195
16#8A0D
I_PHYS_WARN
E_INPUT_VALUE_OUT_
OF_RANGE
-30183
16#8A19
I_PHYS_WARN
E_EFB_NO_
MEASURING_RANGE
-30185
16#8A17
Internal error
I_PHYS_WARN
E_EFB_POS_OVER_
RANGE
-30186
16#8A16
Positive overflow
638
35006144 07/2012
EFB name
Error code
ENO state
in case of
error
Error
value in
Dec
Error
value in
Hex
Error description
I_PHYS_WARN
E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
I_PHYS_WARN
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
I_RAW
E_EFB_OUT_OF_
RANGE
-30192
16#8A10
I_RAW
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
I_RAWSIM
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
I_SCALE
E_EFB_POS_OVER_
RANGE
-30186
16#8A16
Positive overflow
I_SCALE
E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
I_SCALE
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
I_SCALE_WARN
E_EFB_NO_WARNING_
STATUS_AVAILABLE
-30189
16#8A13
I_SCALE_WARN
E_EFB_POS_OVER_
RANGE
-30186
16#8A16
Positive overflow
I_SCALE_WARN
E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
I_SCALE_WARN
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
O_NORM
E_EFB_POS_OVER_
RANGE
-30186
16#8A16
Positive overflow
O_NORM
E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
O_NORM
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
O_NORM_WARN E_EFB_POS_OVER_
RANGE
-30186
16#8A16
Positive overflow
O_NORM_WARN E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
O_NORM_WARN E_EFB_NOT_
CONFIGURED
-30188
16#8A14
35006144 07/2012
639
EFB name
Error code
ENO state
in case of
error
Error
value in
Dec
Error
value in
Hex
Error description
O_PHYS
E_EFB_NO_
MEASURING_RANGE
-30185
16#8A17
Internal error
O_PHYS
E_EFB_POS_OVER_
RANGE
-30186
16#8A16
Positive overflow
O_PHYS
E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
O_PHYS
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
O_PHYS_WARN
E_EFB_NO_
MEASURING_RANGE
-30185
16#8A17
Internal error
O_PHYS_WARN
E_EFB_POS_OVER_
RANGE
-30186
16#8A16
Positive overflow
O_PHYS_WARN
E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
O_PHYS_WARN
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
O_RAW
E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
O_RAW
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
O_SCALE
E_INPUT_VALUE_OUT_
OF_RANGE
-30183
16#8A19
O_SCALE
E_EFB_POS_OVER_
RANGE
-30186
16#8A16
Positive overflow
O_SCALE
E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
O_SCALE
E_EFB_NOT_
CONFIGURED
-30188
16#8A14
O_SCALE_WARN E_INPUT_VALUE_OUT_
OF_RANGE
-30183
16#8A19
O_SCALE_WARN E_EFB_POS_OVER_
RANGE
-30186
16#8A16
Positive overflow
O_SCALE_WARN E_EFB_NEG_OVER_
RANGE
-30187
16#8A15
Negative overflow
O_SCALE_WARN E_EFB_NOT_
CONFIGURED
-30188
16#8A14
640
35006144 07/2012
Immediate I/O
Table of error codes and errors values created for EFBs of the Immediate I/O
family.
EFB name
Error code
ENO state
in case of
error
Error value
in Dec
IMIO_IN
0000
0000
Operation OK
IMIO_IN
8193
2001
IMIO_IN
8194
2002
IMIO_IN
8195
2003
IMIO_IN
-4095
F001
Module not OK
IMIO_OUT
0000
0000
Operation OK
IMIO_OUT
8193
2001
IMIO_OUT
8194
2002
IMIO_OUT
8195
2003
IMIO_OUT
-4095
F001
Module not OK
35006144 07/2012
641
Error code
Error
value in
Hex
Error description
ACI030
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
ACI040
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
ACI040
E_EFB_CURRENT_MODE_
NOT_ALLOWED
-30197
16#8A0B
ACO020
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
ACO130
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
ACO130
E_EFB_CURRENT_MODE_
NOT_ALLOWED
-30197
16#8A0B
AII330
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
AII330
E_EFB_ILLEGAL_CONFIG_
DATA
-30198
16#8A0A
AII33010
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
AII33010
E_EFB_CURRENT_MODE_
NOT_ALLOWED
-30197
16#8A0B
AIO330
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
AIO330
E_EFB_CURRENT_MODE_
NOT_ALLOWED
-30197
16#8A0B
AMM090
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
ARI030
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
ARI030
E_EFB_ILLEGAL_CONFIG_
DATA
-30198
16#8A0A
ATI030
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
AVI030
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
AVO020
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
642
35006144 07/2012
EFB name
Error code
Error
value in
Hex
Error description
DROP
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
ERT_854_10
ES_WRONG_SLOT
ERT_854_10
E_WRONG_SLOT
20480
16#5000
-30215
16#89F9
Defined as
E_EFB_USER_ERROR_16
ERT_854_10
ES_HEALTHBIT
24576
16#6000
ERT_854_10
E_HEALTHBIT
-30216
16#89F8
Defined as
E_EFB_USER_ERROR_17
ERT_854_10
ES_TIMEOUT
32768
16#8000
ERT_854_10
E_TIMEOUT
-30210
16#89FE
Defined as
E_EFB_USER_ERROR_11
ERT_854_10
E_ERT_BASIC - values
-30199
16#8A09
Defined as
E_EFB_USER_ERROR_1 + 1
ERT_854_10
E_WRONG_ANSW
-30211
16#89FD
Defined as
E_EFB_USER_ERROR_12
ERT_854_10
ES_CBUF_OFLOW
28672
16#7000
ERT_854_10
E_CBUF_OFLOW
-30217
16#89F7
Defined as
E_EFB_USER_ERROR_18
ERT_854_10
ES_WRONG_PAKET
8192
16#2000
ERT_854_10
E_WRONG_PAKET
-30212
16#89FC
Defined as
E_EFB_USER_ERROR_13
ERT_854_10
ES_WRONG_FELD
12288
16#3000
ERT_854_10
E_WRONG_FELD
-30213
16#89FB
Defined as
E_EFB_USER_ERROR_14
QUANTUM
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
QUANTUM
E_EFB_UNKNOWN_DROP
-30190
16#8A12
XBE
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
XBE
E_EFB_UNKNOWN_DROP
-30190
16#8A12
XDROP
E_EFB_NOT_CONFIGURED F
-30188
16#8A14
NOTE: For details about ERT_854_10, please refer to the ERT_854_10 description
(see Quantum with Unity Pro, 140 ERT 854 10 Time Stamp Module, Users manual)
in the IO Management Library.
35006144 07/2012
643
Error code
ENO state
in case of
error
Error
value in
Dec
Error
value in
Hex
Error description
DTIME
W_WARN_OUT_OF_
RANGE
30110
16#759E
DTIME
FP_ERROR
DTIME
T/F
INTEGRATOR
E_ERR_DEN
-30152
16#8A38
INTEGRATOR
E_ERR_IB_MAX_MIN
-30102
16#8A6A
INTEGRATOR
FP_ERROR
LAG_FILTER
E_ERR_DEN
-30152
16#8A38
LAG_FILTER
FP_ERROR
LDLG
E_ERR_DEN
-30152
16#8A38
LDLG
FP_ERROR
LEAD
E_ERR_DEN
-30152
16#8A38
LEAD
FP_ERROR
MFLOW
W_WARN_OUT_OF_
RANGE
30110
16#759E
MFLOW
FP_ERROR
644
35006144 07/2012
EFB name
Error code
ENO state
in case of
error
Error
value in
Dec
Error
value in
Hex
Error description
MFLOW
T/F
QDTIME
E_ERR_DEN
-30152
16#8A38
SCALING
E_ERR_NULL_INPUT_S F
CALE
-30121
16#8A57
SCALING
FP_ERROR
SCALING
T/F
TOTALIZER
W_WARN_OUT_OF_
RANGE
30110
16#759E
TOTALIZER
FP_ERROR
TOTALIZER
W_WARN_TOTALIZER_ T
CTER_MAX
30113
16#75A1
TOTALIZER
T/F
VEL_LIM
E_ERR_DEN
-30152
16#8A38
VEL_LIM
E_ERR_AB1_MAX_MIN
-30101
16#8A6B
VEL_LIM
FP_ERROR
35006144 07/2012
645
Controller
Table of error codes and errors values created for EFBs of the Controller family.
EFB name
Error code
ENO state
in case of
error
Error
value in
Dec
AUTOTUNE
W_WARN_OUT_OF_
RANGE
30110
AUTOTUNE
E_ERR_NULL_INPUT_
SCALE
-30121
AUTOTUNE
W_WARN_AUTOTUNE_
FAILED
30111
AUTOTUNE
FP_ERROR
AUTOTUNE
E_ERR_AUTOTUNE_
ID_UNKNOWN
-30120
AUTOTUNE
T/F
PI_B
W_WARN_OUT_OF_
RANGE
30110
PI_B
E_ERR_NULL_INPUT_
SCALE
-30121
PI_B
FP_ERROR
PI_B
T/F
PIDFF
W_WARN_OUT_OF_
RANGE
30110
PIDFF
E_ERR_NULL_INPUT_
SCALE
-30121
PIDFF
FP_ERROR
PIDFF
T/F
SAMPLETM
E_EFB_SAMPLE_TIME_ F
OVERFLOW
-30184
W_WARN_OUT_OF_
RANGE
30110
STEP2
646
Error
value in
Hex
Error description
16#759E
Internal error
16#8A18
Parameter out of range
16#759E
35006144 07/2012
EFB name
Error code
ENO state
in case of
error
Error
value in
Dec
Error
value in
Hex
Error description
STEP2
FP_ERROR
STEP2
T/F
STEP3
W_WARN_OUT_OF_
RANGE
30110
STEP3
FP_ERROR
STEP3
T/F
Mathematics
Table of error codes and errors values created for EFBs of the Mathematics
family.
EFB name
Error code
COMP_DB
W_WARN_OUT_OF_ T
RANGE
30110
COMP_DB
FP_ERROR
K_SQRT
W_WARN_OUT_OF_ T
RANGE
30110
K_SQRT
FP_ERROR
MULDIV_W
FP_ERROR
SUM_W
FP_ERROR
35006144 07/2012
Error
value in
Hex
Error description
647
Measurement
Table of error codes and errors values created for EFBs of the Measurement
family.
Error code
Error description
Error
value in
Hex
AVGMV
E_ERR_DEN
-30152
AVGMV
W_WARN_AVGMV
30108
EFB name
AVGMV
FP_ERROR
AVGMV_K
E_ERR_DEN
-30152
AVGMV_K
W_WARN_AVGMV_K T
30109
AVGMV_K
FP_ERROR
DEAD_ZONE
E_ERR_DEN
-30152
DEAD_ZONE
E_ERR_DZONE
-30119
DEAD_ZONE
FP_ERROR
LOOKUP_TABLE1 E_ERR_DEN
-30152
LOOKUP_TABLE1 E_ERR_POLY_
ANZAHL
-30107
LOOKUP_TABLE1 E_ERR_POLY_
FOLGE
-30108
LOOKUP_TABLE1 FP_ERROR
648
35006144 07/2012
Output Processing
Table of error codes and errors values created for EFBs of the Output
Processing family.
EFB
name
Error code
ENO state
in case of
error
Error
value in
Dec
Error
value in
Hex
Error description
MS
W_WARN_OUT_OF_
RANGE
30110
16#759E
MS
FP_ERROR
MS
T/F
PWM1
WAF_PBM_TMINMAX
-30113
PWM1
FP_ERROR
SERVO FP_ERROR
T/F
SPLRG W_WARN_OUT_OF_
RANGE
30110
16#759E
SPLRG E_ERR_NULL_INPUT_ F
SCALE
-30121
16#8A57
SPLRG FP_ERROR
T/F
35006144 07/2012
649
Setpoint Management
Table of error codes and errors values created for EFBs of the Setpoint
Management family.
Error
value in
Hex
Error description
30110
16#759E
T/F
RATIO
FP_ERROR
RATIO
T/F
SP_SEL W_WARN_OUT_OF_ T
RANGE
30110
16#759E
SP_SEL FP_ERROR
T/F
EFB
name
Error code
RAMP
W_WARN_OUT_OF_ T
RANGE
RAMP
FP_ERROR
RAMP
650
35006144 07/2012
Error code
Error
value in
Hex
Error description
CFG_CP_F
BAD_REVISION
16#8A08
defined as E_EFB_USER_ERROR_1
-30200
CFG_CP_F
MMF_BAD_4X
9010
16#2332
CFG_CP_F
MMF_ABORT_SUB
7004
16#1B5C
CFG_CP_V
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
CFG_CP_V
MMF_BAD_4X
9010
16#2332
CFG_CP_V
MMF_ABORT_SUB
7004
16#1B5C
CFG_CS
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
CFG_CS
MMF_ABORT_SUB
7004
16#1B5C
CFG_FS
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
CFG_FS
MMF_ABORT_SUB
7004
16#1B5C
CFG_IA
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
CFG_IA
MMF_ABORT_SUB
7004
16#1B5C
CFG_RA
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
CFG_RA
MMF_ABORT_SUB
7004
16#1B5C
CFG_SA
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
CFG_SA
MMF_ABORT_SUB
7004
16#1B5C
DRV_DNLD
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
DRV_DNLD
MMF_ABORT_SUB
7004
16#1B5C
DRV_UPLD
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
DRV_UPLD
MMF_ABORT_SUB
7004
16#1B5C
IDN_CHK
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
IDN_CHK
MMF_ABORT_SUB
7004
16#1B5C
IDN_XFER
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
IDN_XFER
MMF_ABORT_SUB
7004
16#1B5C
MMF_BITS
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
35006144 07/2012
651
EFB name
Error code
Error
value in
Hex
Error description
MMF_ESUB
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
MMF_ESUB
MMF_ABORT_SUB
7004
16#1B5C
MMF_IDNX
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
MMF_IDNX
MMF_ABORT_SUB
7004
16#1B5C
MMF_JOG
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
MMF_JOG
MMF_ABORT_SUB
7004
16#1B5C
MMF_JOG
MMF_SUB_TIMEO
UT
7005
16#1B5D
MMF_MOVE BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
MMF_MOVE MMF_ABORT_SUB
7004
16#1B5C
MMF_RST
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
MMF_SUB
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
MMF_SUB
MMF_ABORT_SUB
7004
16#1B5C
MMF_USUB
BAD_REVISION
-30200
16#8A08
defined as E_EFB_USER_ERROR_1
MMF_USUB
MMF_ABORT_SUB
7004
16#1B5C
NOTE: For details about MMF error codes and error values, please refer to the
Faults and Error Reporting (see Unity Pro, Drive control, Block Library) description
in the Motion Library.
652
35006144 07/2012
EFB name
Error code
Error
ENO state Error
in case of value in value in
Hex
Dec
error
DELAY
E_ERR_DEN
-30152
INTEGRATOR1
E_ERR_DEN
-30152
INTEGRATOR1
E_ERR_IB_MAX_MIN
-30102
INTEGRATOR1
FP_ERROR
LAG1
E_ERR_DEN
-30152
LAG1
FP_ERROR
LEAD_LAG1
E_ERR_DEN
-30152
LEAD_LAG1
FP_ERROR
LIMV
E_ERR_DEN
-30152
LIMV
E_ERR_AB1_MAX_MIN F
-30101
LIMV
FP_ERROR
PI1
E_ERR_DEN
-30152
PI1
E_ERR_PI_MAX_MIN
-30103
PI1
FP_ERROR
PID1
E_ERR_DEN
-30152
PID1
E_ERR_PID_MAX_MIN F
-30104
PID1
FP_ERROR
PIDP1
E_ERR_DEN
-30152
PIDP1
E_ERR_PID_MAX_MIN F
-30104
PIDP1
FP_ERROR
35006144 07/2012
Error description
EFB name
Error code
Error
ENO state Error
in case of value in value in
Hex
Dec
error
SMOOTH_RATE
E_ERR_DEN
-30152
SMOOTH_RATE
FP_ERROR
THREE_STEP_CON1 E_ERR_DEN
-30152
THREE_STEP_CON1 W_WARN_DSR_TN
30101
16#7595 TN = 0
THREE_STEP_CON1 W_WARN_DSR_TSN
30102
16#7596 TSN = 0
THREE_STEP_CON1 W_WARN_DSR_KP
30103
16#7597 KP <= 0
THREE_STEP_CON1 E_ERR_DSR_HYS
-30105
THREE_STEP_CON1 FP_ERROR
THREEPOINT_CON1 E_ERR_DEN
-30152
THREEPOINT_CON1 W_WARN_ZDR_XRR
30105
THREEPOINT_CON1 W_WARN_ZDR_T1T2
30104
16#7598 T2 > T1
THREEPOINT_CON1 FP_ERROR
THREEPOINT_CON1 E_ERR_ZDR_HYS
-30106
TWOPOINT_CON1
-30152
E_ERR_DEN
TWOPOINT_CON1
W_WARN_ZDR_XRR
30105
TWOPOINT_CON1
W_WARN_ZDR_T1T2
30104
16#7598 T2 > T1
TWOPOINT_CON1
FP_ERROR
TWOPOINT_CON1
E_ERR_ZDR_HYS
-30106
654
35006144 07/2012
CLC_PRO
Table of error codes and errors values created for EFBs of the CLC_PRO family.
EFB name
Error code
Error
value in
Hex
Error description
ALIM
E_ERR_DEN
-30152
ALIM
WAF_AB2_VMAX
-30111
16#8A61
vmax <= 0
ALIM
WAF_AB2_BMAX
-30112
16#8A60
bmax <= 0
ALIM
FP_ERROR
COMP_PID
E_ERR_DEN
-30152
COMP_PID
WAF_KPID_KUZ
-30110
16#8A62
COMP_PID
WAF_KPID_OGUG
-30104
16#8A68
COMP_PID
WAF_KPID_UZ
-30109
16#8A63
db < 0
COMP_PID
FP_ERROR
DEADTIME
E_ERR_DEN
-30152
DERIV
E_ERR_DEN
-30152
DERIV
FP_ERROR
FGEN
E_ERR_DEN
-30152
FGEN
WAF_SIG_TV_MAX
-30116
FGEN
WAF_SIG_TH_MAX
-30117
FGEN
WAF_SIG_TA_MAX
30106
FGEN
WAF_SIG_T1_MIN
30107
FGEN
WAF_SIG_FKT
-30118
FGEN
FP_ERROR
INTEG
E_ERR_DEN
-30152
INTEG
E_ERR_IB_MAX_MIN
-30102
INTEG
FP_ERROR
LAG
E_ERR_DEN
-30152
LAG
FP_ERROR
LAG2
E_ERR_DEN
-30152
LAG2
FP_ERROR
35006144 07/2012
Error description
EFB name
Error code
Error
value in
Hex
LEAD_LAG
E_ERR_DEN
-30152
LEAD_LAG
FP_ERROR
PCON2
E_ERR_DEN
-30152
PCON2
W_WARN_ZDR_XRR
30105
PCON2
W_WARN_ZDR_T1T2
30104
16#7598 T2 > T1
PCON2
FP_ERROR
PCON2
E_ERR_ZDR_HYS
-30106
PCON3
E_ERR_DEN
-30152
PCON3
W_WARN_ZDR_XRR
30105
PCON3
W_WARN_ZDR_T1T2
30104
16#7598 T2 > T1
PCON3
FP_ERROR
PCON3
E_ERR_ZDR_HYS
-30106
PD_OR_PI
E_ERR_DEN
-30152
PD_OR_PI
WAF_PDPI_OG_UG
-30103
16#8A69
PD_OR_PI
FP_ERROR
PDM
PDM_TMAX_TMIN
-30115
PDM
PDM_OG_UG
-30114
16#8A69
PDM
FP_ERROR
PI
E_ERR_DEN
-30152
PI
E_ERR_PI_MAX_MIN
-30103
PI
FP_ERROR
PID
E_ERR_DEN
-30152
PID
E_ERR_PID_MAX_MIN F
-30104
PID
FP_ERROR
PID_P
E_ERR_DEN
-30152
PID_P
E_ERR_PID_MAX_MIN F
-30104
656
35006144 07/2012
EFB name
Error code
Error
value in
Hex
Error description
PID_P
FP_ERROR
PIP
E_ERR_DEN
-30152
PIP
E_ERR_PI_MAX_MIN
-30103
PIP
FP_ERROR
PPI
E_ERR_DEN
-30152
PPI
E_ERR_PI_MAX_MIN
-30103
PPI
FP_ERROR
PWM
WAF_PBM_TMINMAX
-30113
PWM
FP_ERROR
QPWM
WAF_PBM_TMINMAX
-30113
QPWM
FP_ERROR
SCON3
E_ERR_DEN
-30152
SCON3
W_WARN_DSR_TN
30101
16#7595 TN = 0
SCON3
W_WARN_DSR_TSN
30102
16#7596 TSN = 0
SCON3
W_WARN_DSR_KP
30103
16#7597 KP <= 0
SCON3
E_ERR_DSR_HYS
-30105
SCON3
FP_ERROR
VLIM
E_ERR_DEN
-30152
VLIM
E_ERR_AB1_MAX_MIN F
-30101
VLIM
FP_ERROR
35006144 07/2012
657
Extension/Compatibility
Table of error codes and errors values created for EFBs of the
Extension/Compatibility family.
EFB name
Error code
ENO
Error
state in value in
case of Dec
error
Error
value in
Hex
Error description
AKF_TA
E_AKFEFB_TIMEBASE_IS_
ZERO
-30482
16#88EE
AKF_TE
E_AKFEFB_TIMEBASE_IS_
ZERO
-30482
16#88EE
AKF_TI
E_AKFEFB_TIMEBASE_IS_
ZERO
-30482
16#88EE
AKF_TS
E_AKFEFB_TIMEBASE_IS_
ZERO
-30482
16#88EE
AKF_TV
E_AKFEFB_TIMEBASE_IS_
ZERO
-30482
16#88EE
FIFO
E_INPUT_VALUE_OUT_OF_ F
RANGE
-30183
16#8A19
GET_3X
E_INPUT_VALUE_OUT_OF_ F
RANGE
-30183
16#8A19
GET_4X
E_INPUT_VALUE_OUT_OF_ F
RANGE
-30183
16#8A19
GET_BIT
E_INPUT_VALUE_OUT_OF_ F
RANGE
-30183
16#8A19
IEC_BMDI
E_EFB_USER_ERROR_1
-30200
16#8A08
IEC_BMDI
E_EFB_USER_ERROR_2
-30201
16#8A07
IEC_BMDI
E_EFB_USER_ERROR_3
-30202
16#8A06
IEC_BMDI
E_EFB_USER_ERROR_4
-30203
16#8A05
IEC_BMDI
E_EFB_USER_ERROR_5
-30204
16#8A04
658
35006144 07/2012
EFB name
Error code
ENO
Error
state in value in
case of Dec
error
Error
value in
Hex
Error description
IEC_BMDI
E_EFB_USER_ERROR_6
-30205
16#8A03
IEC_BMDI
E_EFB_USER_ERROR_7
-30206
16#8A02
IEC_BMDI
E_EFB_USER_ERROR_8
-30207
16#8A01
IEC_BMDI
E_EFB_USER_ERROR_9
-30208
16#8A00
IEC_BMDI
E_EFB_USER_ERROR_10
-30209
16#89FF
IEC_BMDI
E_EFB_USER_ERROR_11
-30210
16#89FE
IEC_BMDI
E_EFB_USER_ERROR_12
-30211
16#89FD
IEC_BMDI
E_EFB_USER_ERROR_13
-30212
16#89FC
LIFO
E_INPUT_VALUE_OUT_OF_ F
RANGE
-30183
16#8A19
PUT_4X
E_INPUT_VALUE_OUT_OF_ F
RANGE
-30183
16#8A19
-30175
16#8A21
E_INPUT_VALUE_OUT_OF_ F
RANGE
-30183
16#8A19
MUX_DINTARR_125 E_SELECTOR_OUT_OF_
RANGE
SET_BIT
35006144 07/2012
659
Error value
in Dec
Error value
in Hex
Error description
FP_ERROR
-30150
16#8A3A
E_FP_STATUS_FAILED_IE
-30151
16#8A39
E_FP_STATUS_FAILED_DE
-30152
16#8A38
E_FP_STATUS_FAILED_ZE
-30154
16#8A36
E_FP_STATUS_FAILED_ZE_IE
-30155
16#8A35
E_FP_STATUS_FAILED_OE
-30158
16#8A32
E_FP_STATUS_FAILED_OE_IE
-30159
16#8A31
E_FP_STATUS_FAILED_OE_ZE
-30162
16#8A2E
E_FP_STATUS_FAILED_OE_ZE_IE -30163
16#8A2D
E_FP_NOT_COMPARABLE
16#8A2A
Internal error
660
-30166
35006144 07/2012
Unity Pro
IEC Compliance
35006144 07/2012
IEC Compliance
B
Overview
This chapter contains the compliance tables required by IEC 61131-3.
What Is in This Chapter?
This chapter contains the following sections:
Section
35006144 07/2012
Topic
Page
B.1
662
B.2
664
B.3
687
B.4
689
661
IEC Compliance
B.1
662
35006144 07/2012
IEC Compliance
35006144 07/2012
663
IEC Compliance
B.2
Overview
This system complies with the requirements of IEC 61131-3 for the language and
feature listed in the following tables.
What Is in This Section?
This section contains the following topics:
Topic
664
Page
Common elements
665
IL language elements
677
ST language elements
679
680
LD language elements
681
Implementation-dependent parameters
682
Error Conditions
685
35006144 07/2012
IEC Compliance
Common elements
Common elements
IEC compliance table for common elements:
Table No. Feature No.
1
3a
4a
5a
Comments
3a
Pragmas
35006144 07/2012
Description of Feature
Integer literals
Real literals
Base 2 literals
Base 8 literals
Base 16 literals
Typed literals
Dollar sign
Single quote
Line feed
New line
Carriage return
Tab
Double quote
665
IEC Compliance
10
12
14
666
Description of Feature
1a
1b
long prefix
2a
2b
long prefix
10
12
13
14
15
16
17
18
19
35006144 07/2012
IEC Compliance
17
18
19
19a
20
35006144 07/2012
Description of Feature
Input location
Output location
Memory location
Initialization of constants
10
Negated input
Negated output
667
IEC Compliance
21
22
23
24
25
668
Description of Feature
Overloaded functions
Typed functions
ABS function
SQRT function
LN function
LOG function
EXP function
SIN function
COS function
TAN function
ASIN function
10
ACOS function
11
ATAN function
12
ADD function
13
MUL function
14
SUB function
15
DIV function
16
MOD function
17
EXPT function
18
MOVE function
SHL function
SHR function
ROR function
ROL function
35006144 07/2012
IEC Compliance
Description of Feature
26
AND function
OR function
XOR function
NOT function
SEL function
2a
MAX function
2b
MIN function
LIMIT function
MUX function
GT function
GE function
EQ function
LE function
LT function
27
28
29
35006144 07/2012
10
NE function
669
IEC Compliance
Description of Feature
30
1a
1b
ADD_TIME function
33
34
35
670
2b
ADD_TOD_TIME function
3b
ADD_DT_TIME function
4a
4b
SUB_TIME function
5b
SUB_DATE_DATE function
6b
SUB_TOD_TIME function
7b
SUB_TOD_TOD function
8b
SUB_DT_TIME function
9b
SUB_DT_DT function
10a
10b
MULTIME function
11a
11b
DIVTIME function
1a
2a
2b
3a
4a
4b
4c
35006144 07/2012
IEC Compliance
Description of Feature
36
1a
1b
1d
2a
2b
2d
3a
3b
37
2a
3a
39
19
40
3a
7a
7b
7c
7d
2l
41
42
43
35006144 07/2012
3d
1
2f
3s
3i
671
IEC Compliance
Description of Feature
44
None - no qualifier
Qualifier N
Qualifier R
Qualifier S
Qualifier L
Qualifier D
Qualifier P
Qualifier DS
11
Qualifier P1
12
Qualifier P0
45
45a
46
Single sequence
2a
5a
6a
CONFIGURATION...END_CONFIGURATION construction
(Note 12, page 676)
49
50
672
5a
5b
6a
6c
5a
5b
35006144 07/2012
IEC Compliance
Note 1
List of type conversion functions:
BOOL_TO_BYTE, BOOL_TO_DINT, BOOL_TO_INT, BOOL_TO_REAL,
BOOL_TO_TIME, BOOL_TO_UDINT, BOOL_TO_UINT, BOOL_TO_WORD,
BOOL_TO_DWORD
BYTE_TO_BOOL, BYTE_TO_DINT, BYTE_TO_INT, BYTE_TO_REAL,
BYTE_TO_TIME, BYTE_TO_UDINT, BYTE_TO_UINT, BYTE_TO_WORD,
BYTE_TO_DWORD, BYTE_TO_BIT
DINT_TO_BOOL, DINT_TO_BYTE, DINT_TO_INT, DINT_TO_REAL,
DINT_TO_TIME, DINT_TO_UDINT, DINT_TO_UINT, DINT_TO_WORD,
DINT_TO_DWORD, DINT_TO_DBCD, DINT_TO_STRING
INT_TO_BOOL, INT_TO_BYTE, INT_TO_DINT, INT_TO_REAL, INT_TO_TIME,
INT_TO_UDINT, INT_TO_UINT, INT_TO_WORD, INT_TO_BCD, INT_TO_DBCD,
INT_TO_DWORD, INT_TO_STRING
REAL_TO_BOOL, REAL_TO_BYTE, REAL_TO_DINT, REAL_TO_INT,
REAL_TO_TIME, REAL_TO_UDINT, REAL_TO_UINT, REAL_TO_WORD,
REAL_TO_DWORD, REAL_TO_STRING
TIME_TO_BOOL, TIME_TO_BYTE, TIME_TO_DINT, TIME_TO_INT,
TIME_TO_REAL, TIME_TO_UDINT, TIME_TO_UINT, TIME_TO_WORD,
TIME_TO_DWORD, TIME_TO_STRING
UDINT_TO_BOOL, UDINT_TO_BYTE, UDINT_TO_DINT, UDINT_TO_INT,
UDINT_TO_REAL, UDINT_TO_TIME, UDINT_TO_UINT, UDINT_TO_WORD,
UDINT_TO_DWORD
UINT_TO_BOOL, UINT_TO_BYTE, UINT_TO_DINT, UINT_TO_INT,
UINT_TO_REAL, UINT_TO_TIME, UINT_TO_UDINT, UINT_TO_WORD,
UINT_TO_DWORD,
WORD_TO_BOOL, WORD_TO_BYTE, WORD_TO_DINT, WORD_TO_INT,
WORD_TO_REAL, WORD_TO_TIME, WORD_TO_UDINT, WORD_TO_UINT,
WORD_TO_BIT, WORD_TO_DWORD
DWORD_TO_BOOL, DWORD_TO_BYTE, DWORD_TO_DINT, DWORD_TO_INT,
DWORD_TO_REAL, DWORD_TO_TIME, DWORD_TO_UDINT, DWORD_TO_UINT,
DWORD_TO_BIT,
The effects of each conversion are described in the help text supplied with the Base
Library.
Note 2
List of types for truncate function:
REAL_TRUNC_DINT, REAL_TRUNC_INT, REAL_TRUNC_UDINT,
REAL_TRUNC_UINT
The effects of each conversion are described in the help text supplied with the Base
Library.
35006144 07/2012
673
IEC Compliance
Note 3
List of types for BCD conversion function:
BCD_TO_INT, DBCD_TO_INT, DBCD_TO_DINT
674
Syntax
Data type
Internal bit
%M<i> or %MX<i>
EBOOL
EBOOL
ARRAY [..] OF EBOOL
Internal word
%MW<i>
INT
%MD<i>
DINT
No mapping, because of
overlapping between
%MW<i> and %MD<i> and
%MF<i>.
Internal real
%MF<i>
REAL
No mapping, because of
overlapping between
%MW<i> and %MD<i> and
%MF<i>.
35006144 07/2012
IEC Compliance
Syntax
Data type
Constant word
%KW<i>
INT
%KD<i>
DINT
No mapping, because of
overlapping between
%KW<i> and %KD<i> and
%KF<i>.
This kind of variables only
exists on Premium PLCs.
Constant real
%KF<i>
REAL
No mapping, because of
overlapping between
%KW<i> and %KD<i> and
%KF<i>.
This kind of variables only
exists on Premium PLCs.
System bit
%S<i> or %SX<i>
EBOOL
EBOOL
System word
%SW<i>
INT
INT
%SD<i>
DINT
DINT
Flat bit
%I<i>
EBOOL
EBOOL
ARRAY [..] OF EBOOL
This kind of variables only
exists on Qantum PLCs.
Flat word
%IW<i>
INT
35006144 07/2012
Common word
%NWi.j.k
INT
INT
Topological variables
...
Same Type
(On some digital I/O
modules it is allowed to
map arrays of EBOOL on
%IX<topo> and
%QX<topo> objects.)
Extract bits
%MWi.j, ...
BOOL
BOOL
675
IEC Compliance
Note 6
Only operator "+" (for ADD), "-" (for SUB), "*" (for MUL) or "/" (for DIV) in ST
language.
Note 7
This feature is only presented in the "expanded view" of the chart.
Note 8
This feature is presented in the "expanded view" of the chart, but not as
concatenated blocks, but as a scrollable list of action names with associated
qualifiers inside one single block symbol.
Note 9
There is only a one-to-one mapping of program instance to task. The textual format
is replaced by a property dialog.
Note 10
The textual format is replaced by a property dialog.
Note 11
All variables are retentive (RETAIN qualifier implicitly assumed in variable
declarations).
Note 12
The textual format is replaced by the project browser representation.
Note 13
Using Mask-IT instruction, the user is able to get a non-preemptive behaviour. You
will find MASKEVT (Global EVT masking) and UNMASKEVT (Global EVT unmasking)
in the System functions of the libset.
Note 14
By default, the multi-task system is preemptive.
676
35006144 07/2012
IEC Compliance
IL language elements
IL language elements
IEC compliance table for IL language elements:
Table No. Feature No.
Feature description
51b
51b
52
35006144 07/2012
S, R operator
7a
NOT operator
10
11
11a
12
13
14
15
16
17
18
19
20
21
677
IEC Compliance
Feature description
53
1a
1b
Note
In DFB only.
678
35006144 07/2012
IEC Compliance
ST language elements
ST language elements
IEC compliance table for ST language elements:
Table No. Feature No.
55
56
Feature description
Parenthesization (expression)
Exponentiation: **
Negation: -
Complement: NOT
Multiply: *
Divide: /
Modulo: MOD
Add: +
10
Subtract: -
11
12
Equality: =
13
Inequality: <>
14
15
16
17
Boolean OR: OR
Assignment
IF statement
CASE statement
FOR statement
WHILE statement
REPEAT statement
EXIT statement
10
Empty statement
Note
In DFB only.
35006144 07/2012
679
IEC Compliance
58
Feature description
10
12
Note
In DFB only.
680
35006144 07/2012
IEC Compliance
LD language elements
LD language elements
IEC compliance table for LD language elements:
Table No. Feature No.
Feature description
59
Horizontal link
Vertical link
60
61
62
Coil
Negated coil
Note
Only graphical representation.
35006144 07/2012
681
IEC Compliance
Implementation-dependent parameters
Implementation-dependent parameters
IEC compliance table for implementation-dependent parameters:
Parameters
Limitations/Behavior
32 characters
682
TIME: precision 1 ms
TIME_OF_DAY: precision 1 s
Not applicable
64 kbytes
no limit
64 kbytes
DINT range
10
16 characters
64 kbytes
35006144 07/2012
IEC Compliance
Parameters
Limitations/Behavior
Error conditions are described in the onlinehelp. Globally %S18 is set for overflow errors.
ENO is also set. The result is depending on the
specific function.
No assignment
35006144 07/2012
683
IEC Compliance
Parameters
Limitations/Behavior
10 ms
Maximum number of transitions per SFC and Limited by the available area for entering
per step
steps/transitions and by the maximum
number of steps per SFC section (1024
Steps).
32 transition per step. Limited by the available
area for entering Alternative/Parallel
branches, maximum is 32 rows.
Maximum number of action blocks per step
20
684
Target dependent;
always < 100 micro-seconds
32
Not applicable
Not applicable
10 ms
Practically no limit
Practically no limit
Practically no limit
Undefined
No restrictions
35006144 07/2012
IEC Compliance
Error Conditions
Error Conditions
IEC standards table for error conditions:
Error conditions
Nested comments
Not applicable
Not applicable
Numerical result exceeds range for data type 4) error is reported during execution
Division by zero
Mixed input data types to a selection function 2) error is reported during programming
Result exceeds range for data type
User program attempts to modify step state or 2) error is reported during programming
time
Side effects in evaluation of transition
condition
Not applicable
Not applicable
Numerical result exceeds range for data type 4) error is reported during execution
35006144 07/2012
685
IEC Compliance
Error conditions
Division by zero
Numerical result exceeds range for data type 4) error is reported during execution
Invalid data type for operation
Not applicable
Not applicable
Note
Identifications for the treatment of error conditions according to IEC 61131-3,
subclause 1.5.1, d):
1) error is not reported
2) error is reported during programming
3) error is reported during analyzing/loading/linking
4) error is reported during execution
686
35006144 07/2012
IEC Compliance
B.3
35006144 07/2012
687
IEC Compliance
688
35006144 07/2012
IEC Compliance
B.4
35006144 07/2012
689
IEC Compliance
690
35006144 07/2012
Unity Pro
Glossary
35006144 07/2012
Glossary
0-9
%I
According to the IEC standard, %I indicates a discrete input-type language object.
%ID
According to the IEC standard, %MW indicates an input double word-type language
object.
Only I/O objects make it possible to locate type instances (%MD<i>, %KD<i>, %QD,
%ID, %MF<i>, %KF<i>, %QF, %IF) by using their topological address (for example
%MD0.6.0.11, %MF0.6.0.31).
%IF
According to the IEC standard, %MW indicates an input real-type language object.
Only I/O objects make it possible to locate type instances (%MD<i>, %KD<i>, %QD,
%ID, %MF<i>, %KF<i>, %QF, %IF) by using their topological address (for example
%MD0.6.0.11, %MF0.6.0.31).
%IW
According to the IEC standard, %IW indicates an analog input -type language object.
35006144 07/2012
691
Glossary
%KD
According to the IEC standard, %MW indicates a constant double word-type language
object.
For Premium/Atrium PLCs double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) should be located by an integer type (%MW<i>,
%KW<i>). Only I/O objects make it possible to locate type instances (%MD<i>,
%KD<i>, %QD, %ID, %MF<i>, %KF<i>, %QF, %IF) by using their topological address
(for example %MD0.6.0.11, %MF0.6.0.31).
For Modicon M340 PLCs, double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) are not available.
%KF
According to the IEC standard, %MW indicates a constant real-type language object.
For Premium/Atrium PLCs double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) should be located by an integer type (%MW<i>,
%KW<i>). Only I/O objects make it possible to locate type instances (%MD<i>,
%KD<i>, %QD, %ID, %MF<i>, %KF<i>, %QF, %IF) by using their topological address
(for example %MD0.6.0.11, %MF0.6.0.31).
For Modicon M340 PLCs, double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) are not available.
%KW
According to the IEC standard, %KW indicates a constant word-type language object.
For Premium/Atrium PLCs double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) should be located by an integer type (%MW<i>,
%KW<i>). Only I/O objects make it possible to locate type instances (%MD<i>,
%KD<i>, %QD, %ID, %MF<i>, %KF<i>, %QF, %IF) by using their topological address
(for example %MD0.6.0.11, %MF0.6.0.31).
For Modicon M340 PLCs, double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) are not available.
%M
According to the IEC standard, %M indicates a memory bit-type language object.
692
35006144 07/2012
Glossary
%MD
According to the IEC standard, %MW indicates a memory double word-type language
object.
For Premium/Atrium PLCs double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) should be located by an integer type (%MW<i>,
%KW<i>). Only I/O objects make it possible to locate type instances (%MD<i>,
%KD<i>, %QD, %ID, %MF<i>, %KF<i>, %QF, %IF) by using their topological address
(for example %MD0.6.0.11, %MF0.6.0.31).
For Modicon M340 PLCs, double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) are not available.
%MF
According to the IEC standard, %MW indicates a memory real-type language object.
For Premium/Atrium PLCs double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) should be located by an integer type (%MW<i>,
%KW<i>). Only I/O objects make it possible to locate type instances (%MD<i>,
%KD<i>, %QD, %ID, %MF<i>, %KF<i>, %QF, %IF) by using their topological address
(for example %MD0.6.0.11, %MF0.6.0.31).
For Modicon M340 PLCs, double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) are not available.
%MW
According to the IEC standard, %MW indicates a memory word-type language object.
For Premium/Atrium PLCs double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) should be located by an integer type (%MW<i>,
%KW<i>). Only I/O objects make it possible to locate type instances (%MD<i>,
%KD<i>, %QD, %ID, %MF<i>, %KF<i>, %QF, %IF) by using their topological address
(for example %MD0.6.0.11, %MF0.6.0.31).
For Modicon M340 PLCs, double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) are not available.
%Q
According to the IEC standard, %Q indicates a discrete output-type language object.
35006144 07/2012
693
Glossary
%QD
According to the IEC standard, %MW indicates an output double word-type language
object.
Only I/O objects make it possible to locate type instances (%MD<i>, %KD<i>, %QD,
%ID, %MF<i>, %KF<i>, %QF, %IF) by using their topological address (for example
%MD0.6.0.11, %MF0.6.0.31).
%QF
According to the IEC standard, %MW indicates an output real-type language object.
Only I/O objects make it possible to locate type instances (%MD<i>, %KD<i>, %QD,
%ID, %MF<i>, %KF<i>, %QF, %IF) by using their topological address (for example
%MD0.6.0.11, %MF0.6.0.31).
%QW
According to the IEC standard, %QW indicates an analog output-type language
object.
A
Animating the links
This is also called power flow, and refers to a type of animation used with Ladder
language and the function blocks. The links are displayed in red, green or black
according to the variables connected.
694
35006144 07/2012
Glossary
ANY
There is a hierarchy between the different types of data. In the DFB, it is sometimes
possible to declare which variables can contain several types of values. Here, we
use ANY_xxx types.
The following diagram shows the hierarchically-ordered structure:
35006144 07/2012
695
Glossary
ARRAY
An ARRAY is a table of elements of the same type.
The syntax is as follows: ARRAY [<terminals>] OF <Type>
Example:
ARRAY [1..2] OF BOOL is a one-dimensional table made up of two BOOL-type
elements.
ARRAY [1..10, 1..20] OF INT is a two-dimensional table made up of 10x20
INT-type elements.
ASCII
ASCII is the abbreviation of American Standard Code for Information Interchange.
This is an American code (but which has become an international standard) that
uses 7 bits to define every alphanumerical character used in English, punctuation
symbols, certain graphic characters and other miscellaneous commands.
Auxiliary tasks
Optional periodic tasks used to process procedures that do not require fast
processing: measurement, adjustment, diagnostic aid, etc.
B
Base 10 literals
A literal value in base 10 is used to represent a decimal integer value. This value can
be preceded by the signs "+" and "-". If the character "_" is employed in this literal
value, it is not significant.
Example:
-12, 0, 123_456, +986
Base 16 literals
An literal value in base 16 is used to represent an integer in hexadecimal. The base
is determined by the number "16" and the sign "#". The signs "+" and "-" are not
allowed. For greater clarity when reading, you can use the sign "_" between bits.
Example:
16#F_F or 16#FF (in decimal 255)
16#F_F or 16#FF (in decimal 224)
696
35006144 07/2012
Glossary
Base 2 literals
A literal value in base 2 is used to represent a binary integer. The base is determined
by the number "2" and the sign "#". The signs "+" and "-" are not allowed. For greater
clarity when reading, you can use the sign "_" between bits.
Example:
2#1111_1111 or 2#11111111 (in decimal 255)
2#1110_0000 or 2#11100000 (in decimal 224)
Base 8 literals
A literal value in base 8 is used to represent an octal integer. The base is determined
by the number "8" and the sign "#". The signs "+" and "-" are not allowed. For greater
clarity when reading, you can use the sign "_" between bits.
Example:
8#3_77 or 8#377 (in decimal 255)
8#34_0 or 8#340 (in decimal 224)
BCD
The Binary Coded Decimal (BCD) format is used to represent decimal numbers
between 0 and 9 using a group of four bits (half-byte).
In this format, the four bits used to code the decimal numbers have a range of
unused combinations.
Example of BCD coding:
the number 2450
is coded: 0010 0100 0101 0000
BIT
This is a binary unit for a quantity of information which can represent two distinct
values (or statuses): 0 or 1.
BOOL
BOOL is the abbreviation of Boolean type. This is the elementary data item in
computing. A BOOL type variable has a value of either: 0 (FALSE) or 1 (TRUE).
A BOOL type word extract bit, for example: %MW10.4.
35006144 07/2012
697
Glossary
Break point
Used in the "debug" mode of the application.
It is unique (one at a time) and, when reached, signals to the processor to stop the
program run.
Used in connected mode, it can be positioned in one of the following program
elements:
LD network,
Structured Text Sequence or Instruction List,
Structured Text Line (Line mode).
BYTE
When 8 bits are put together, this is callad a BYTE. A BYTE is either entered in
binary, or in base 8.
The BYTE type is coded in an 8 bit format, which, in hexadecimal, ranges from
16#00 to 16#FF
C
Constants
An INT, DINT or REAL type variable located in the constant field (%K), or variables
used in direct addressing (%KW, %KD or %KF). The contents of these cannot be
modified by the program during execution.
CPU
Is the abbreviation of Control Processing Unit.
This is the microprocessor. It is made up of the control unit combined with the
arithmetic unit. The aim of the control unit is to extract the instruction to be executed
and the data needed to execute this instruction from the central memory, to establish
electrical connections in the arithmetic unit and logic, and to run the processing of
this data in this unit. We can sometimes find ROM or RAM memories included in the
same chip, or even I/O interfaces or buffers.
Cyclic execution
The master task is executed either cyclically or periodically. Cyclical execution
consists of stringing cycles together one after the other with no waiting time between
the cycles.
698
35006144 07/2012
Glossary
D
DATE
The DATE type coded in BCD in 32 bit format contains the following information:
the year coded in a 16-bit field,
the month coded in an 8-bit field,
the day coded in an 8-bit field.
The DATE type is entered as follows: D#<Year>-<Month>-<Day>
This table shows the lower/upper limits in each field:
Field
Limits
Comment
Year
[1990,2099]
Year
Month
[01,12]
Day
[01,31]
[01,30]
[01,29]
[01,28]
DATE_AND_TIME
see DT
DBCD
Representation of a Double BCD-format double integer.
The Binary Coded Decimal (BCD) format is used to represent decimal numbers
between 0 and 9 using a group of four bits.
In this format, the four bits used to code the decimal numbers have a range of
unused combinations.
Example of DBCD coding:
the number 78993016
is coded: 0111 1000 1001 1001 0011 0000 0001 0110
DDT
DDT is the abbreviation of Derived Data Type.
A derived data type is a set of elements of the same type (ARRAY) or of various types
(structure)
35006144 07/2012
699
Glossary
DFB
DFB is the abbreviation of Derived Function Block.
DFB types are function blocks that can be programmed by the user ST, IL, LD or
FBD.
By using DFB types in an application, it is possible to:
simplify the design and input of the program,
increase the legibility of the program,
facilitate the debugging of the program,
reduce the volume of the generated code.
DFB instance
A DFB type instance occurs when an instance is called from a language editor.
The instance possesses a name, input/output interfaces, the public and private
variables are duplicated (one duplication per instance, the code is not duplicated).
A DFB type can have several instances.
DINT
DINT is the abbreviation of Double Integer format (coded on 32 bits).
The lower and upper limits are as follows: -(2 to the power of 31) to (2 to the power
of 31) - 1.
Example:
-2147483648, 2147483647, 16#FFFFFFFF.
Documentation
Contains all the information of the project. The documentation is printed once
compiled and used for maintenance purposes.
The information contained in the documentation cover:
the hardware and software configuration,
the program,
the DFB types,
the variables and animation tables,
the cross-references.
...
When building the documentation file, you can include all or some of these items.
700
35006144 07/2012
Glossary
Driver
A program indicating to your computers operating system the presence and
characteristics of a peripheral device. We also use the term peripheral device driver.
The best-known drivers are printer drivers. To make a PLC communicate with a PC,
communication drivers need to be installed (Uni-Telway, XIP, Fipway, etc.).
DT
DT is the abbreviation of Date and Time.
The DT type coded in BCD in 64 bit format contains the following information:
The year coded in a 16-bit field,
the month coded in an 8-bit field,
the day coded in an 8-bit field,
the hour coded in a 8-bit field,
the minutes coded in an 8-bit field,
the seconds coded in an 8-bit field.
NOTE: The 8 least significant bits are unused.
The DT type is entered as follows:
DT#<Year>-<Month>-<Day>-<Hour>:<Minutes>:<Seconds>
This table shows the lower/upper limits in each field:
35006144 07/2012
Field
Limits
Comment
Year
[1990,2099]
Year
Month
[01,12]
Day
[01,31]
[01,30]
[01,29]
[01,28]
Hour
[00,23]
Minute
[00,59]
Second
[00,59]
701
Glossary
DWORD
DWORD is the abbreviation of Double Word.
The DWORD type is coded in 32 bit format.
This table shows the lower/upper limits of the bases which can be used:
Base
Lower limit
Upper limit
Hexadecimal
16#0
16#FFFFFFFF
Octal
8#0
8#37777777777
Binary
2#0
2#11111111111111111111111111111111
Representation examples:
Data content
00000000000010101101110011011110
16#ADCDE
00000000000000010000000000000000
8#200000
00000000000010101011110011011110
2#10101011110011011110
E
EBOOL
EBOOL is the abbreviation of Extended Boolean type. A EBOOL type variable brings
a value (0 (FALSE) or 1 (TRUE) but also rising or falling edges and forcing
capabilities.
An EBOOL type variable takes up one byte of memory.
The byte split up into:
one bit for the value,
one bit for the history bit (each time the states object changes, the value is copied
inside the history bit),
one bit for the forcing bit (equals to 0 if the object isnt forced, equal to 1 if the bit
is forced.
702
35006144 07/2012
Glossary
EDT
EDT is the abbreviation of Elementary Data Type.
These types are as follows:
BOOL,
EBOOL,
WORD,
DWORD,
INT,
DINT,
UINT,
UDINT,
REAL,
DATE,
TOD,
DT.
EF
Is the abbreviation of Elementary Function.
This is a block which is used in a program, and which performs a predefined
software function.
A function has no internal status information. Multiple invocations of the same
function using the same input parameters always supply the same output values.
Details of the graphic form of the function invocation can be found in the "[Functional
block (instance)]". In contrast to the invocation of the function blocks, function
invocations only have a single unnamed output, whose name is the same as the
function. In FBD each invocation is denoted by a unique [number] via the graphic
block, this number is automatically generated and can not be altered.
You position and set up these functions in your program in order to carry out your
application.
You can also develop other functions using the SDKC development kit.
EFB
Is the abbreviation for Elementary Function Block.
This is a block which is used in a program, and which performs a predefined
software function.
EFBs have internal statuses and parameters. Even where the inputs are identical,
the output values may be different. For example, a counter has an output which
indicates that the preselection value has been reached. This output is set to 1 when
the current value is equal to the preselection value.
35006144 07/2012
703
Glossary
Elementary Function
see EF
Event processing
Event processing 1 is a program section launched by an event. The instructions
programmed in this section are executed when a software application event (Timer)
or a hardware event (application specific module) is received by the processor.
Event processes take priority over other tasks, and are executed the moment the
event is detected.
The event process EVT0 is of highest priority. All others have the same level of
priority.
NOTE: For M340, IO events with the same priority level are stored in a FIFO and
are treated in the order in which they are received.
All the timers have the same priority. When several timers end at the same time, the
lowest timer number is processed first.
The system word %SW48 counts IO events and telegram processed.
NOTE: TELEGRAM is available only for PREMIUM (not on Quantum or M340)
F
Fast task
Task launched periodically (setting of the period in the PC configuration) used to
carry out a part of the application having a superior level of priority to the Mast task
(master).
704
35006144 07/2012
Glossary
FBD
FBD is the abbreviation of Function Block Diagram.
FBD is a graphic programming language that operates as a logic diagram. In
addition to the simple logic blocks (AND, OR, etc.), each function or function block of
the program is represented using this graphic form. For each block, the inputs are
located to the left and the outputs to the right. The outputs of the blocks can be linked
to the inputs of other blocks to form complex expressions.
FFB
Collective term for EF (Elementary Function), EFB (Elementary Function Block) and
DFB (Derived Function block)
Flash Eprom
PCMCIA memory card containing the program and constants of the application.
FNES
FNES is the abbreviation of Fichiers Neutres dEntres Sorties (Neutral I/O
Documentation).
FNES format describes using a tree structure the PLCs in terms of rack, cards and
channels.
It is based on the CNOMO standard (comit de normalisation des outillages de
machines outils).
Function
see EF
Function block
see EFB
Function view
View making it possible to see the program part of the application through the
functional modules created by the user (see Functional module definition).
35006144 07/2012
705
Glossary
Functional Module
A functional module is a group of program elements (sections, sub-programs, macro
steps, animation tables, runtime screen, etc.) whose purpose is to perform an
automation device function.
A functional module may itself be separated into lower-level functional modules,
which perform one or more sub-functions of the main function of the automation
device.
G
GRAY
Gray or "reflected binary" code is used to code a numerical value being developed
into a chain of binary configurations that can be differentiated by the change in
status of one and only one bit.
This code can be used, for example, to avoid the following random event: in pure
binary, the change of the value 0111 to 1000 can produce random numbers between
0 and 1000, as the bits do not change value altogether simultaneously.
Equivalence between decimal, BCD and Gray:
H
Hyperlink
The hyperlink function enables links to be created between your project and external
documents. You can create hyperlinks in all the elements of the project directory, in
the variables, in the processing screen objects, etc.
The external documents can be web pages, files (xls, pdf, wav, mp3, jpg, gif, etc.).
706
35006144 07/2012
Glossary
I
I/O Object
An I/O object is an implicit or explicit language object for an expert function module
or a I/O device on a fieldbus. They are of the following types: %Ch, %I, %IW, %ID,
%IF, %Q, %QW, % QD, QF, %KW, %KD, %KF, %MW, %MD, and %MF.
The objects topological address depends on the modules position on the rack or
the devices position on the bus.
For Premium/Atrium PLCs double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) should be located by an integer type (%MW<i>,
%KW<i>). Only I/O objects make it possible to locate type instances (%MD<i>,
%KD<i>, %QD, %ID, %MF<i>, %KF<i>, %QF, %IF) by using their topological address
(for example %MD0.6.0.11, %MF0.6.0.31).
For Modicon M340 PLCs, double-type instances of located data (%MD<i>, %KD<i>)
or floating (%MF<i>, %KF<i>) are not available.
IEC 61131-3
International standard: Programmable Logic Controls
Part 3: Programming languages.
IL
IL is the abbreviation of Instruction List.
This language is a series of basic instructions.
This language is very close to the assembly language used to program processors.
Each instruction is composed of an instruction code and an operand.
INF
Used to indicate that a number overruns the allowed limits.
For a number of Integers, the value ranges (shown in gray) are as follows:
707
Glossary
Instantiate
To instantiate an object is to allocate a memory space whose size depends on the
type of object to be instantiated. When an object is instantiated, it exists and can be
manipulated by the program.
INT
INT is the abbreviation of single integer format (coded on 16 bits).
The lower and upper limits are as follows: -(2 to the power of 31) to (2 to the power
of 31) - 1.
Example:
-32768, 32767, 2#1111110001001001, 16#9FA4.
Integer literals
Integer literal are used to enter integer values in the decimal system. The values can
have a preceding sign (+/-). Individual underlines (_ ) between numbers are not
significant.
Example:
-12, 0, 123_456, +986
IODDT
IODDT is the abbreviation of Input/Output Derived Data Type.
The term IODDT designates a structured data type representing a module or a
channel of a PLC module. Each application expert module possesses its own
IODDTs.
K
Keyword
A keyword is a unique combination of characters used as a syntactical programming
language element (See annex B definition of the IEC standard 61131-3. All the key
words used in Unity Pro and of this standard are listed in annex C of the IEC
standard 61131-3. These keywords cannot be used as identifiers in your program
(names of variables, sections, DFB types, etc.)).
708
35006144 07/2012
Glossary
L
LD
LD is the abbreviation of Ladder Diagram.
LD is a programming language, representing the instructions to be carried out in the
form of graphic diagrams very close to a schematic electrical diagram (contacts,
coils, etc.).
Located variable
A located variable is a variable for which it is possible to know its position in the PLC
memory. For example, the variable Water_pressure, is associated with%MW102.
Water_pressure is said to be localized.
M
Macro step
A macro step is the symbolic representation of a unique set of steps and transitions,
beginning with an input step and ending with an output step.
A macro step can call another macro step.
Master task
Main program task.
It is obligatory and is used to carry out sequential processing of the PLC.
Mono Task
An application comprising a single task, and so necessarily the Master task.
Multi task
Application comprising several tasks (Mast, Fast, Auxiliary, event processing).
The order of priority for the execution of tasks is defined by the operating system of
the PLC.
Multiple token
Operating mode of an SFC. In multitoken mode, the SFC may possess several
active steps at the same time.
35006144 07/2012
709
Glossary
N
Naming convention (identifier)
An identifier is a sequence of letters, numbers and underlines beginning with a letter
or underline (e.g., name of a function block type, an instance, a variable or a
section). Letters from national character sets (e.g., , , , ) can be used except in
project and DFB names. Underlines are significant in identifiers; e.g., A_BCD and
AB_CD are interpreted as different identifiers. Multiple leading underlines and
consecutive underlines are invalid.
Identifiers cannot contain spaces. Not case sensitive; e.g., ABCD and abcd are
interpreted as the same identifier.
According to IEC 61131-3 leading digits are not allowed in identifiers. Nevertheless,
you can use them if you activate the check box Allow leading digits in the Tools
Project settings Variables dialog .
Identifiers cannot be keywords.
NAN
Used to indicate that a result of an operation is not a number (NAN = Not A Number).
Example: calculating the square root of a negative number.
NOTE: The IEC 559 standard defines two classes of NAN: quiet NAN (QNAN) and
signaling NaN (SNaN) QNAN is a NAN with the most significant fraction bit set and a
SNAN is a NAN with the most significant fraction bit clear (Bit number 22). QNANs are
allowed to propagate through most arithmetic operations without signaling an
exception. SNAN generally signal an invalid-operation exception whenever they
appear as operands in arithmetic operations (See %SW17 and %S18).
Network
Mainly used in communication, a network is a group of stations which communicate
among one another. The term network is also used to define a group of interconnected graphic elements. This group forms then a part of a program which may be
composed of a group of networks.
O
Operator screen
This is an editor that is integrated into Unity Pro, which is used to facilitate the
operation of an automated process. The user regulates and monitors the operation
of the installation, and, in the event of any problems, can act quickly and simply.
710
35006144 07/2012
Glossary
P
Periodic execution
The master task is executed either cyclically or periodically. In periodic mode, you
determine a specific time (period) in which the master task must be executed. If it is
executed under this time, a waiting time is generated before the next cycle. If it is
executed over this time, a control system indicates the overrun. If the overrun is too
high, the PLC is stopped.
Procedure
Procedures are functions view technically. The only difference to elementary
functions is that procedures can take up more than one output and they support data
type VAR_IN_OUT. To the eye, procedures are no different than elementary
functions.
Procedures are a supplement to IEC 61131-3.
Protection
Option preventing the contents of a program element to be read (read protected), or
to write or modify the contents of a program element (read/write protected).
The protection is confirmed by a password.
35006144 07/2012
711
Glossary
R
REAL
Real type is a coded type in 32 bits.
The ranges of possible values are illustrated in gray in the following diagram:
NOTE: The IEC 559 standard defines two classes of NAN: quiet NAN (QNAN) and
signaling NaN (SNaN) QNAN is a NAN with the most significant fraction bit set and a
SNAN is a NAN with the most significant fraction bit clear (Bit number 22). QNANs are
allowed to propagate through most arithmetic operations without signaling an
exception. SNAN generally signal an invalid-operation exception whenever they
appear as operands in arithmetic operations (See %SW17 and %S18).
NOTE: when an operand is a DEN (De-normalized number) the result is not
significant.
Real literals
An literal real value is a number expressed in one or more decimals.
Example:
-12.0, 0.0, +0.456, 3.14159_26
Real literals with exponent
An Literal decimal value can be expressed using standard scientific notation. The
representation is as follows: mantissa + exponential.
Example:
-1.34E-12 or -1.34e-12
1.0E+6 or 1.0e+6
1.234E6 or 1.234e6
712
35006144 07/2012
Glossary
RS 232C
Serial communication standard which defines the voltage of the following service:
a signal of +12 V indicates a logical 0,
a signal of -12 V indicates a logical 1.
There is, however, in the case of any attenuation of the signal, detection provided
up to the limits -3 V and +3 V.
Between these two limits, the signal will be considered as invalid.
RS 232 connections are quite sensitive to interference. The standard specifies not
to exceed a distance of 15 m or a maximum of 9600 bauds (bits/s).
RS 485
Serial connection standard that operates in 10 V/+5 V differential. It uses two wires
for send/receive. Their "3 states" outputs enable them to switch to listen mode when
the transmission is terminated.
RUN
Function enabling the startup of the application program of the PLC.
RUN Auto
Function enabling the execution of the PLC application program to be started
automatically in the case of a cold start.
Rung
A rung is the equivalent of a sequence in LD; other related terms are "Ladder
network" or, more generally, "Network". A rung is inscribed between two potential
bars of an LD editor and is composed of a group of graphic elements interconnected
by means of horizontal or vertical connections. The dimensions of a rung are 17 to
256 lines and 11 to 64 columns maximum.
S
Section
Program module belonging to a task which can be written in the language chosen
by the programmer (FBD, LD, ST, IL, or SFC).
A task can be composed of several sections, the order of execution of the sections
corresponding to the order in which they are created, and being modifiable.
35006144 07/2012
713
Glossary
SFC
SFC is the abbreviation of Sequential Function Chart.
SFC enables the operation of a sequential automation device to be represented
graphically and in a structured manner. This graphic description of the sequential
behavior of an automation device, and the various situations which result from it, is
performed using simple graphic symbols.
SFC objects
An SFC object is a data structure representing the status properties of an action or
transition of a sequential chart.
Single token
Operating mode of an SFC chart for which only a single step can be active at any
one time.
ST
ST is the abbreviation of Structured Text language.
Structured Text language is an elaborated language close to computer
programming languages. It enables you to structure series of instructions.
STRING
A variable of the type STRING is an ASCII standard character string. A character
string has a maximum length of 65534 characters.
Structure
View in the project navigator with represents the project structure.
Subroutine
Program module belonging to a task (Mast, Fast, Aux) which can be written in the
language chosen by the programmer (FBD, LD, ST, or IL).
A subroutine may only be called by a section or by another subroutine belonging to
the task in which it is declared.
714
35006144 07/2012
Glossary
T
Task
A group of sections and subroutines, executed cyclically or periodically for the MAST
task, or periodically for the FAST task.
A task possesses a level of priority and is linked to inputs and outputs of the PLC.
These I/O are refreshed in consequence.
TIME
The type TIME expresses a duration in milliseconds. Coded in 32 bits, this type
makes it possible to obtain periods from 0 to (2 to the power of 32)-1 milliseconds.
Time literals
The units of type TIME are the following: the days (d), the hours (h), the minutes (m),
the seconds (s) and the milliseconds (ms). A literal value of the type TIME is
represented by a combination of previous types preceded by T#, t#, TIME# or
time#.
Examples: T#25h15m, t#14.7S, TIME#5d10h23m45s3ms
Time Out
In communication projects, The Time out is a delay after which the communication
is stopped if there is no answer of the target device.
TIME_OF_DAY
see TOD
TOD
TOD is the abbreviation of Time of Day.
The TOD type coded in BCD in 32 bit format contains the following information:
the hour coded in a 8-bit field,
the minutes coded in an 8-bit field,
the seconds coded in an 8-bit field.
NOTE: The 8 least significant bits are unused.
The Time of Day type is entered as follows: TOD#<Hour>:<Minutes>:<Seconds>
35006144 07/2012
715
Glossary
Limits
Comment
Hour
[00,23]
Minute
[00,59]
Second
[00,59]
Example: TOD#23:59:45.
Token
An active step of an SFC is known as a token.
U
UDINT
UDINT is the abbreviation of Unsigned Double Integer format (coded on 32 bits)
unsigned. The lower and upper limits are as follows: 0 to (2 to the power of 32) - 1.
Example:
0, 4294967295, 2#11111111111111111111111111111111, 8#37777777777,
16#FFFFFFFF.
UINT
UINT is the abbreviation of Unsigned integer format (coded on 16 bits). The lower
and upper limits are as follows: 0 to (2 to the power of 16) - 1.
Example:
0, 65535, 2#1111111111111111, 8#177777, 16#FFFF.
Unlocated variable
An unlocated variable is a variable for which it is impossible to know its position in
the PLC memory. A variable which have no address assigned is said to be
unlocated.
716
35006144 07/2012
Glossary
V
Variable
Memory entity of the type BOOL, WORD, DWORD, etc., whose contents can be modified
by the program during execution.
Visualization window
This window, also called a watch window, displays the variables that cannot be
animated in the language editors. Only those variables that are visible at a given
time in the editor are displayed.
W
Watch point
Used in the "debug" mode of the application.
It enables the display of animated variables to be synchronized with the execution
of a program element (containing the watch point) in order to ascertain their values
at this precise point of the program.
WORD
The WORD type is coded in 16 bit format and is used to carry out processing on bit
strings.
This table shows the lower/upper limits of the bases which can be used:
Base
Lower limit
Upper limit
Hexadecimal
16#0
16#FFFF
Octal
8#0
8#177777
Binary
2#0
2#1111111111111111
Representation examples
35006144 07/2012
Data content
0000000011010011
16#D3
1010101010101010
8#125252
0000000011010011
2#11010011
717
Glossary
718
35006144 07/2012
Unity Pro
Index
35006144 07/2012
B
AC
Index
Symbols
%S, 158
%SW
generic, 179
Modicon M340, 238
Premium, 208
Quantum, 221
CAL, 494
CASE...OF...END_CASE
ST, 547
channel data structure, 291, 293
cold start, 131, 142
comparison
IL, 486
LD, 388
ST, 534
compatibility
data types, 306
A
ADD
IL, 490
addressing
data instances, 319
input/output, 319
Alignment constraint, 288
AND
IL, 489
ST, 537
ANY_ARRAY, 302
ARRAY, 282
automatic start in RUN, 131
B
BOOL, 255
BYTE, 279
35006144 07/2012
D
D
SFC, 432
data instances, 311
data types, 251
DATE, 266
DDT, 281
derived data types (DDT), 281, 285
derived function block (DFB), 581
representation, 295, 586
Device derived data types (DDDT), 281
DFB
representation, 586
diagnostics DFB, 625
DINT, 260
DIV
IL, 491
719
Index
DS
SFC, 432
DT, 268
DWORD, 279
E
EBOOL, 255
EDT, 251
EFB, 294
elementary data types (EDT), 251
elementary function block (EFB), 294, 295
ELSE, 545
ELSIF...THEN, 546
EN/ENO
FBD, 351
IL, 505, 515, 523
LD, 383
ST, 564, 572, 577
EQ
IL, 492
error codes, 629
event processing, 97
EXIT, 553
I
IEC Compliance, 661
IF...THEN...END_IF
ST, 544
IN_OUT
FBD, 353
IL, 516, 523
LD, 386
ST, 572, 578
input/output
addressing, 319
instruction list (IL)
language, 475, 501, 506, 518
operators, 486
structure, 477
INT, 260
J
JMP
FBD, 355
IL, 494, 497
LD, 387
SFC, 440
ST, 557
F
FBD
language, 341, 344
structure, 342
floating point, 269
FOR...TO...BY...DO...END_FOR
ST, 548
forced bits, 255
G
GE
IL, 492
GT
IL, 492
L
L
SFC, 432
labels
FBD, 355
IL, 497
LD, 387
ST, 557
LD
language, 369, 376
structure, 370
LD operators
IL, 369
LE
IL, 493
LT, 493
HALT, 156
720
35006144 07/2012
Index
IL, 488
LD, 374
SFC, 432
REAL, 269
REPEAT...UNTIL...END_REPEAT, 552
RETURN
FBD, 355
IL, 495
LD, 387
ST, 555
NE
IL, 493
NOT
IL, 490
O
operate, 388
OR
IL, 489
ST, 538
P
P
SFC, 432
P0
SFC, 432
P1
SFC, 432
private variables
DFB, 596
FBD, 350, 382, 508, 568
public variables
DFB, 596
FBD, 349
IL, 508
LD, 382
ST, 567
35006144 07/2012
S
IL, 488
LD, 374
SFC, 432
sections, 84, 85
SFC
language, 413, 429
structure, 415
SFCCHART_STATE, 417
SFCSTEP_STATE, 423
SFCSTEP_TIMES, 423
State RAM
Modicon M340, 117
state RAM of Modicon M340
RUN mode, 143
STOP mode, 143
STRING, 274
structure, 281
structured text (ST)
instructions, 539
language, 527, 560, 566, 574
operators, 534
structure, 529
SUB
IL, 490
subroutines, 84, 88
system bits, 158
721
Index
T
tasks, 77, 81
cyclic, 92
periodic, 93
TIME, 262
TOD, 267
U
UDINT, 260
UINT, 260
W
warm start, 131
watchdogs
mono-task, 94
multi-task, 102
WHILE...DO...END_WHILE
ST, 551
WORD, 279
X
XOR
IL, 489
ST, 538
722
35006144 07/2012