Ecostruxure Expert - Programing Guide
Ecostruxure Expert - Programing Guide
Ecostruxure Expert - Programing Guide
Programming Guide
EIO0000002854.04
06/2022
www.se.com
Legal Information
The Schneider Electric brand and any trademarks of Schneider Electric SE and its
subsidiaries referred to in this guide are the property of Schneider Electric SE or its
subsidiaries. All other brands may be trademarks of their respective owners.
This guide and its content are protected under applicable copyright laws and
furnished for informational use only. No part of this guide may be reproduced or
transmitted in any form or by any means (electronic, mechanical, photocopying,
recording, or otherwise), for any purpose, without the prior written permission of
Schneider Electric.
Schneider Electric does not grant any right or license for commercial use of the guide
or its content, except for a non-exclusive and personal license to consult it on an "as
is" basis. Schneider Electric products and equipment should be installed, operated,
serviced, and maintained only by qualified personnel.
As standards, specifications, and designs change from time to time, information
contained in this guide may be subject to change without notice.
To the extent permitted by applicable law, no responsibility or liability is assumed by
Schneider Electric and its subsidiaries for any errors or omissions in the informational
content of this material or consequences arising out of or resulting from the use of the
information contained herein.
EIO0000002854.04 3
Log ............................................................................................ 106
PLC Settings............................................................................... 107
IEC Objects ............................................................................... 109
Users and Groups ....................................................................... 111
Access Rights ............................................................................. 117
Symbol Rights........................................................................... 121
Task Deployment ........................................................................ 122
Status ........................................................................................ 123
Information ................................................................................. 123
Emulation Settings.................................................................... 123
I/O Mapping...................................................................................... 124
I/O Mapping ................................................................................ 124
Working with the I/O Mapping Dialog Box...................................... 127
Mapping a Device and a Function Block Instance .......................... 130
I/O Mapping in Online Mode......................................................... 131
Implicit Variables for Forcing I/Os ................................................. 132
Select Function Block Dialog Box .............................................. 133
Cybersecurity........................................................................................... 134
General Information ................................................................................ 135
Access Protection with Device User Management ............................... 135
Firewall Settings ............................................................................... 135
Using Certificates.............................................................................. 135
Digital Signature Verification.................................................................... 136
Digital Signature Verification .............................................................. 136
Connecting to the Controller .................................................................... 138
First Login to the Controller with User Rights Management
Activated .......................................................................................... 138
Logoff Current Device User ..................................................................... 139
Logoff / Change Device User ............................................................. 139
Security for the Project and the Application ............................................... 140
Protecting and Saving a Project ......................................................... 140
Protecting and Saving Applications .................................................... 141
Security for the Runtime System / Controller............................................. 142
Encrypting Communication ................................................................ 142
Handling of Device User Management................................................ 142
Visualization........................................................................................... 145
Visualization ..................................................................................... 145
FAQ....................................................................................................... 146
Frequently Asked Questions (FAQ) .................................................... 146
Program .................................................................................................... 147
Program Components............................................................................. 148
Program Organization Unit (POU) ...................................................... 148
POU........................................................................................... 148
Adding and Calling POU Objects .................................................. 148
Program ..................................................................................... 151
Function ..................................................................................... 153
Method....................................................................................... 154
Property ..................................................................................... 158
Interface ..................................................................................... 159
Action......................................................................................... 162
Transition ................................................................................... 164
4 EIO0000002854.04
POUs for Implicit Checks ............................................................. 164
Function Block.................................................................................. 166
General Information..................................................................... 166
Function Block Instance............................................................... 168
Calling a Function Block .............................................................. 169
Configuring a Memory Reserve for the Online Change of Function
Blocks ........................................................................................ 170
Extension of a Function Block ...................................................... 171
Implementing Interfaces .............................................................. 173
Method Invocation....................................................................... 174
SUPER Pointer............................................................................. 176
THIS Pointer............................................................................... 177
Application Objects ........................................................................... 179
Data Type Unit (DUT) ................................................................. 179
Global Variable List - GVL ............................................................ 180
Network Variable List (Receiver)................................................... 181
Persistent Variables..................................................................... 186
External File ............................................................................... 187
Text List ..................................................................................... 189
Image Pool ................................................................................. 194
Application ....................................................................................... 197
Application.................................................................................. 197
Task Configuration.................................................................................. 199
Task Configuration ........................................................................... 199
Adding Tasks .................................................................................... 199
Managing Applications ............................................................................ 200
General Information .......................................................................... 200
Introduction ................................................................................ 200
Building and Downloading Applications .............................................. 201
Building Applications ................................................................... 201
Login.......................................................................................... 202
Build Process at Changed Applications ......................................... 203
Downloading an Application ......................................................... 203
Managing Expired Certificates...................................................... 213
Running Applications ........................................................................ 213
Running Applications................................................................... 213
Maintaining Applications.................................................................... 214
Monitoring .................................................................................. 214
Debugging.................................................................................. 214
Core Dump ................................................................................. 218
Programming Support ................................................................. 220
Refactoring ................................................................................. 220
Static Analysis Light .................................................................... 224
Creating an Archive in Your Controller on Download ...................... 225
Logic Editors ............................................................................................ 227
Common Features of Graphic Editors ...................................................... 228
Common Features of Graphic Editors................................................. 228
FBD/LD/IL Editor .................................................................................... 230
Information on the FBD/LD/IL Editor ................................................... 230
FBD/LD/IL Editor......................................................................... 230
Function Block Diagram (FBD) Language ..................................... 230
EIO0000002854.04 5
Ladder Diagram (LD) Language ................................................... 231
Instruction List (IL) Language ....................................................... 231
Modifiers and Operators in IL ....................................................... 232
Working in the FBD and LD Editor ................................................ 236
Working in the IL Editor................................................................ 240
Cursor Positions in FBD, LD, and IL.............................................. 244
FBD/LD/IL Menu ......................................................................... 247
FBD/LD/IL Editor in Online Mode.................................................. 248
FBD/LD/IL Elements ......................................................................... 252
FBD/LD/IL Toolbox ...................................................................... 252
Network in FBD/LD/IL .................................................................. 253
Assignment in FBD/LD/IL ............................................................ 254
Jump in FBD/LD/IL ...................................................................... 255
Label in FBD/LD/IL ...................................................................... 255
Boxes in FBD/LD/IL..................................................................... 255
RETURN Instruction in FBD/LD/IL ................................................. 256
Branch / Hanging Coil in FBD/LD/IL .............................................. 256
Parallel Branch ........................................................................... 258
Branch Start / End ....................................................................... 260
Set/Reset in FBD/LD/IL ............................................................... 260
Set/Reset Coil............................................................................. 261
Execute ...................................................................................... 261
LD Elements..................................................................................... 262
Contact ...................................................................................... 262
Coil ............................................................................................ 263
Continuous Function Chart (CFC) Editor .................................................. 264
Continuous Function Chart (CFC) Language....................................... 264
CFC Editor ....................................................................................... 264
Cursor Positions in CFC .................................................................... 266
CFC Elements / ToolBox.................................................................... 267
Working in the CFC Editor ................................................................. 271
Execution Order in CFC .................................................................... 274
CFC Editor in Online Mode ................................................................ 277
CFC Editor Page-Oriented................................................................. 279
Sequential Function Chart (SFC) Editor.................................................... 281
SFC Editor ....................................................................................... 281
SFC - Sequential Function Chart Language ........................................ 282
Cursor Positions in SFC .................................................................... 283
Working in the SFC Editor ................................................................. 284
SFC Element Properties ................................................................... 286
SFC Elements / ToolBox.................................................................... 287
Qualifier for Actions in SFC................................................................ 296
Implicit Variables - SFC Flags ............................................................ 297
Sequence of Processing in SFC......................................................... 301
SFC Editor in Online Mode ................................................................ 303
Structured Text (ST) Editor ...................................................................... 305
Information on the ST Editor .............................................................. 305
ST Editor .................................................................................... 305
ST Editor in Online Mode ............................................................. 306
Structured Text ST ............................................................................ 309
Structured Text ST ...................................................................... 309
6 EIO0000002854.04
Expressions................................................................................ 309
Instructions ................................................................................. 310
Object Editors .......................................................................................... 318
Declaration Editors ................................................................................. 319
Textual Declaration Editor.................................................................. 319
Tabular Declaration Editor ................................................................. 320
Declaration Editor in Online Mode ..................................................... 323
Device Type Manager (DTM) Editor ......................................................... 324
DTM Editor....................................................................................... 324
Data Unit Type (DUT) Editor .................................................................... 325
Data Unit Type Editor ........................................................................ 325
Global Variables List (GVL) Editor ............................................................ 326
GVL Editor ....................................................................................... 326
Motion Design Object Editor .................................................................... 327
Motion Design Object Editor .............................................................. 327
Network Variables List (NVL) Editor ......................................................... 330
Information on the NVL Editor ............................................................ 330
Network Variables List Editor........................................................ 330
General Information on Network Variables .......................................... 331
Introduction to Network Variables List (NVL).................................. 331
Configuring the Network Variables Exchange ................................ 333
Network Variables List (NVL) Rules .............................................. 337
Operating State of the Sender and the Receiver ............................ 339
Example ..................................................................................... 339
Compatibility............................................................................... 342
Task Editor ............................................................................................. 346
Information on the Task Configuration................................................. 346
Properties Tab ................................................................................. 347
System Events Tab.......................................................................... 347
Monitor Tab ..................................................................................... 349
Variable Usage Tab.......................................................................... 350
Configuration of a Specific Task ......................................................... 351
Task Processing in Online Mode ........................................................ 353
Watch List Editor .................................................................................... 355
Watch View / Watch List Editor........................................................... 355
Creating a Watch List ........................................................................ 355
Watch List in Online Mode ................................................................. 356
Tools Within Logic Editors ....................................................................... 358
Function and Function Block Finder.................................................... 358
Input Assistant.................................................................................. 360
Tools.......................................................................................................... 363
Data Logging.......................................................................................... 364
Introduction to Data Logging .............................................................. 364
Recipe Manager ..................................................................................... 366
Recipe Manager .............................................................................. 366
Recipe Definition .............................................................................. 369
RecipeManCommands...................................................................... 373
Loading Recipe Values from the Controller ......................................... 381
Memory Usage by Recipes ................................................................ 382
Trace Editor ........................................................................................... 383
Trace Object..................................................................................... 383
EIO0000002854.04 7
Trace Basics............................................................................... 383
Creating a Trace or a Device Trace Object .................................... 384
Trace Configuration........................................................................... 387
Trace Configuration - Tree Views ............................................... 387
Variable Settings ......................................................................... 389
Record Settings .......................................................................... 391
Display Mode............................................................................. 392
Advanced Trace Settings ............................................................. 394
Trace Editor in Online Mode............................................................... 395
Trace Editor in Online Mode ........................................................ 395
Keyboard Operations for Trace Diagrams ........................................... 396
Keyboard Shortcuts..................................................................... 396
Trend Recording..................................................................................... 398
Trend Recording Objects................................................................... 398
Trend Recording Overview........................................................... 398
Trend Recording Objects ............................................................. 398
Trend Recording Configuration .......................................................... 399
Trend Recording Editor ............................................................. 399
Record Settings .......................................................................... 400
Variable Settings ......................................................................... 402
Steps for Trend Recording Configuration....................................... 403
Recording Trend Data ....................................................................... 405
Start the Recording Process ........................................................ 405
Alarm Configuration ................................................................................ 407
General Information .......................................................................... 407
Alarm Management ..................................................................... 407
Defining Alarms .......................................................................... 408
Configuration of the Alarm Management ............................................. 409
Creating an Alarm Configuration............................................... 409
Configuring an Alarm Class.......................................................... 409
Configuring an Alarm Storage ...................................................... 410
Configuring an Alarm Group......................................................... 410
Calling Event Alarms in the Program .................................................. 411
Defining an Event Alarm in the Alarm Group ................................. 411
Program Call for Triggering the Event Alarm ................................. 412
Alarm Management Objects .............................................................. 412
Alarm Configuration..................................................................... 412
Alarm Class ................................................................................ 413
Alarm Group ............................................................................... 416
Alarm Storage............................................................................. 419
Unit Conversion...................................................................................... 421
Unit Conversion Configuration ........................................................... 421
Usage in IEC Editors ......................................................................... 423
Symbol Configuration Editor .................................................................... 425
Symbol Configuration Editor .............................................................. 425
Symbol Configuration ....................................................................... 430
Adding a Symbol Configuration .......................................................... 431
EcoStruxure Machine Expert Controller - HMI Data Exchange ................... 434
EcoStruxure Machine Expert Single Variable Definition........................ 434
Publishing Variables in the Controller.................................................. 437
Selecting Variables in the HMI............................................................ 438
8 EIO0000002854.04
Publishing Variables in the HMI of Vijeo-Designer................................ 438
Parameterization of the Physical Media .............................................. 440
Data Exchange Performance Between Controller and HMI
Configured with Vijeo-Designer .......................................................... 441
Indications for HMI Connections with Vijeo-Designer ........................... 443
Cam Motion Editor .................................................................................. 444
Cam Motion Editor - General Information ............................................ 444
General Information..................................................................... 444
Adding a Cam Object .................................................................. 444
Opening the Motion Editor of a Cam Object ................................. 444
Generating IEC Program Code from Cam Data ................................... 445
Using Cam Data for Function Blocks............................................. 445
Copying the Source Code of the Cam Diagram.............................. 446
Online View and Functions of the Cam Motion Editor ........................... 446
Online View and Functions of the Cam Motion Editor ..................... 446
Discontinuous Courses of the Positions .............................................. 447
Discontinuous Courses of the Positions ........................................ 447
Dialog Boxes .................................................................................... 448
Motion Editor .............................................................................. 448
Generating IEC Source Code....................................................... 455
Configuration .............................................................................. 455
Script Hook Manager ............................................................................ 457
Script Hook Manager ...................................................................... 457
Programming Reference........................................................................ 460
Variables Declaration .............................................................................. 461
Declaration....................................................................................... 461
General Information..................................................................... 461
Best Practices for the Naming of Identifiers ................................... 463
Shadowing Rules ........................................................................ 467
Variables Initialization .................................................................. 469
Declaration ................................................................................. 470
Shortcut Mode ............................................................................ 471
AT Declaration ............................................................................ 471
Keywords ................................................................................... 472
Variable Types .................................................................................. 475
Variable Types ............................................................................ 475
Attribute Keywords for Variable Types........................................... 479
VAR_CONFIG - Configuration Variables......................................... 482
Method Types................................................................................... 483
FB_Init, FB_Reinit, and FB_Exit Methods...................................... 483
Pragma Instructions .......................................................................... 487
Pragma Instructions .................................................................... 487
Message Pragmas ...................................................................... 488
Conditional Pragmas ................................................................... 490
Region Pragmas ......................................................................... 495
Attribute Pragmas ............................................................................. 495
Attribute Pragmas ....................................................................... 495
User-Defined Attributes ............................................................... 496
Attribute call_after_global_init_slot ......................... 497
Attribute call_after_init ................................................. 498
Attribute call_after_online_change_slot ..................... 498
EIO0000002854.04 9
Attribute call_before_global_exit_slot ....................... 499
Attribute call_on_type_change ..................................................... 499
Attribute conditionalshow ................................................. 500
Attribute conditionalshow_all_locals ........................... 500
Attribute const_replaced, Attribute const_non_
replaced .................................................................................. 501
Attribute 'dataflow' ........................................................... 502
Attribute displaymode ......................................................... 503
Attribute enable_dynamic_creation ................................. 503
Attribute estimated-stack-usage ..................................... 503
Attribute ExpandFully ......................................................... 504
Attribute global_init_slot ............................................... 505
Attribute hide ....................................................................... 506
Attribute hide_all_locals ................................................. 507
Attribute initialize_on_call ........................................... 508
Attribute init_namespace ................................................... 508
Attribute init_On_Onlchange ............................................. 508
Attribute instance-path ..................................................... 509
Attributes io_function_block, io_function_block_
mapping .................................................................................... 510
Attribute is_connected ....................................................... 510
Attribute linkalways ........................................................... 511
Attribute monitoring ........................................................... 512
Attribute namespace ............................................................. 514
Attributes no_assign, no_assign_warning ...................... 515
Attribute no_check ............................................................... 516
Attribute no_copy ................................................................. 517
Attribute no-exit ................................................................. 517
Attribute no_init ................................................................. 518
Attribute no_instance_in_retain ..................................... 518
Attribute no_virtual_actions ........................................... 518
Attribute pingroup ............................................................... 520
Attribute pin_presentation_order_inputs/
outputs .................................................................................... 521
Attribute obsolete ............................................................... 522
Attribute pack_mode ............................................................. 523
Attribute ProcessValue ....................................................... 523
Attribute qualified_only ................................................... 524
Attribute reflection ........................................................... 524
Attribute subsequent ........................................................... 525
Attribute symbol ................................................................... 525
Attribute to_string ............................................................. 526
Attribute warning disable .................................................. 527
The Smart Coding Functionality ......................................................... 527
Smart Coding.............................................................................. 527
Data Types............................................................................................. 529
General Information .......................................................................... 529
Data Types ................................................................................. 529
Standard Data Types ........................................................................ 529
Standard Data Types................................................................... 529
Extensions to IEC Standard ............................................................... 535
10 EIO0000002854.04
UNION ....................................................................................... 535
BIT............................................................................................. 535
References ................................................................................. 536
Pointers...................................................................................... 537
User-Defined Data Types .................................................................. 539
Defined Data Types..................................................................... 539
Arrays ........................................................................................ 540
Vector ........................................................................................ 543
Structures................................................................................... 549
Enumerations ............................................................................. 550
Subrange Types.......................................................................... 552
Programming Guidelines......................................................................... 555
Naming Conventions......................................................................... 555
General Information..................................................................... 555
Prefixes............................................................................................ 556
Prefix Parts................................................................................. 556
Order of Prefixes ......................................................................... 556
Scope Prefix ............................................................................... 557
Data Type Prefix ......................................................................... 557
Property Prefix ............................................................................ 559
POU Prefix ................................................................................. 559
Namespace Prefix....................................................................... 560
SmartTag Functions .......................................................................... 561
SmartTag Function ...................................................................... 561
Operators .............................................................................................. 562
Arithmetic Operators ......................................................................... 562
ADD ............................................................................................ 563
MUL ............................................................................................ 565
SUB ............................................................................................ 566
DIV ............................................................................................ 567
MOD ............................................................................................ 569
MOVE .......................................................................................... 570
SIZEOF ...................................................................................... 571
Bitstring Operators ............................................................................ 571
AND ............................................................................................ 572
OR .............................................................................................. 572
XOR ............................................................................................ 573
NOT ............................................................................................ 574
Bit-Shift Operators ............................................................................ 574
SHL ............................................................................................ 574
SHR ............................................................................................ 575
ROL ............................................................................................ 576
ROR ............................................................................................ 577
Selection Operators .......................................................................... 578
SEL ............................................................................................ 578
MAX ............................................................................................ 580
MIN ............................................................................................ 580
LIMIT ........................................................................................ 581
MUX ............................................................................................ 581
Comparison Operators ...................................................................... 582
GT .............................................................................................. 582
EIO0000002854.04 11
LT .............................................................................................. 583
LE .............................................................................................. 583
GE .............................................................................................. 584
EQ .............................................................................................. 585
NE .............................................................................................. 585
Address Operators............................................................................ 586
ADR ............................................................................................ 586
Content Operator ........................................................................ 587
BITADR ...................................................................................... 587
Calling Operator ............................................................................... 588
CAL ............................................................................................ 588
Type Conversion Operators ............................................................... 588
Type Conversion Functions.......................................................... 588
Overloaded Conversions ............................................................. 589
BOOL_TO Conversions............................................................... 590
TO_BOOL Conversions............................................................... 592
Conversion Between Integral Number Types ................................. 593
REAL_TO / LREAL_TO Conversions............................................ 594
TIME_TO/TIME_OF_DAY Conversions ........................................ 595
DATE_TO/DT_TO Conversions.................................................... 597
STRING_TO Conversions ........................................................... 598
TRUNC ........................................................................................ 599
TRUNC_INT ............................................................................... 600
ANY_..._TO Conversions........................................................... 601
TO_<xxx> Conversions............................................................... 601
Numeric Functions ............................................................................ 602
ABS ............................................................................................ 602
SQRT .......................................................................................... 602
LN .............................................................................................. 603
LOG ............................................................................................ 603
EXP ............................................................................................ 604
SIN ............................................................................................ 604
COS ............................................................................................ 605
TAN ............................................................................................ 605
ASIN .......................................................................................... 606
ACOS .......................................................................................... 606
ATAN .......................................................................................... 607
EXPT .......................................................................................... 607
IEC Extending Operators................................................................... 608
IEC Extending Operators ............................................................. 608
__DELETE .................................................................................. 609
__ISVALIDREF .......................................................................... 610
__NEW ........................................................................................ 611
__QUERYINTERFACE .................................................................. 613
__QUERYPOINTER ...................................................................... 614
AND_THEN .................................................................................. 615
OR_ELSE .................................................................................... 615
__TRY, __CATCH, __FINALLY, __ENDTRY ............................... 616
__VARINFO................................................................................ 618
‘__POSITION’ .......................................................................... 620
‘__POUNAME’ ............................................................................ 620
12 EIO0000002854.04
Scope Operators......................................................................... 621
Initialization Operator ........................................................................ 623
INI Operator................................................................................ 623
Multicore Operators .......................................................................... 623
__CURRENTTASK ........................................................................ 624
__COMPARE_AND_SWAP .............................................................. 624
__XADD ...................................................................................... 625
TEST_AND_SET .......................................................................... 626
Operands............................................................................................... 628
Constants......................................................................................... 628
BOOL Constants......................................................................... 628
TIME/LTIME Constants................................................................ 628
DATE Constants ......................................................................... 629
LDATE Constants........................................................................ 629
DATE_AND_TIME Constants....................................................... 630
LDATE_AND_TIME Constants ..................................................... 630
TIME_OF_DAY Constants ........................................................... 631
LTIME_OF_DAY Constants.......................................................... 632
Number Constants ...................................................................... 632
REAL/LREAL Constants .............................................................. 633
String Constants ......................................................................... 633
Typed Constants / Typed Literals.................................................. 634
Variables .......................................................................................... 635
Variables .................................................................................... 635
Addressing Bits in Variables ......................................................... 636
Addresses ........................................................................................ 637
Direct Addresses......................................................................... 637
Functions ......................................................................................... 639
Functions ................................................................................... 639
EcoStruxure Machine Expert Templates ............................................. 640
General Information about Templates....................................................... 641
EcoStruxure Machine Expert Templates ............................................. 641
General Information About EcoStruxure Machine Expert
Templates................................................................................... 641
Administration of EcoStruxure Machine Expert Templates .............. 642
Managing Device Templates.................................................................... 648
Managing Device Templates .............................................................. 648
Facts of Device Templates ........................................................... 648
Adding Devices from Template ..................................................... 648
Creating a Device Template on the Basis of Field Devices or I/O
Modules ..................................................................................... 651
Visualizations Suitable for Creating Device Templates ................... 651
Further Information on Integrating Control Logic into Device
Templates................................................................................... 652
Steps to Create a Device Template ............................................... 654
Managing Function Templates ................................................................. 657
Managing Function Templates ........................................................... 657
Facts of Function Templates ........................................................ 657
Adding Functions from Template .................................................. 658
Application Functions as Basis for Function Templates................... 662
Steps to Create a Function Template ............................................ 663
EIO0000002854.04 13
Troubleshooting and FAQ ...................................................................... 668
Generic - Troubleshooting and FAQ ......................................................... 669
Troubleshooting................................................................................ 669
Log File ...................................................................................... 669
Frequently Asked Questions .............................................................. 669
How Can I Enable and Configure Analog Inputs on
CANopen?.................................................................................. 669
Why is EcoStruxure Machine Expert Startup Performance
Sometimes Slower? .................................................................... 670
How Can I Manage Shortcuts and Menus?.................................... 671
How Can I Increase the Build-Time Performance of EcoStruxure
Machine Expert? ......................................................................... 672
What Can I Do in Case of Issues with Modbus IOScanner on
Serial Line? ................................................................................ 672
What Can I Do If My Network Variables List (NVL)
Communication Has Been Suspended?........................................ 673
Accessing Controllers - Troubleshooting and FAQ..................................... 674
Troubleshooting: Accessing New Controllers ...................................... 674
Accessing New Controllers .......................................................... 674
Connecting via IP Address and Address Information ...................... 675
FAQ - What Can I Do in Case of Connection Problems With the
Controller? ....................................................................................... 677
FAQ - Why is a Connection to the Controller not Possible? ............ 677
FAQ - Why has the Communication Between PC and Controller
been Interrupted?........................................................................ 680
Appendices .............................................................................................. 681
Network Communication ......................................................................... 682
Network Topology ............................................................................. 682
Addressing and Routing .................................................................... 682
Structure of Addresses ...................................................................... 684
Python Script Language .......................................................................... 687
General Information .......................................................................... 687
Introduction ................................................................................ 687
Accessing the Python Interpreter in EcoStruxure Machine
Expert ........................................................................................ 689
Using the Logic Builder Shell........................................................ 691
Using the Logic Builder Scripting Immediate View ....................... 697
Keyboard Commands in the Logic Builder Shell and the
Scripting Immediate View ......................................................... 699
Explore EcoStruxure Machine Expert Python API (with dir()
and inspectapi) ...................................................................... 700
Executing Scripts ........................................................................ 704
Best Practices............................................................................. 704
EcoStruxure Machine Expert Python API ...................................... 706
EcoStruxure Machine Expert Scripting - Python API ...................... 707
Calling Scripts Via Toolbar Icons .................................................. 711
Schneider Electric Script Engine Examples......................................... 713
New Projects .............................................................................. 713
Device Parameters...................................................................... 714
Compiler Version......................................................................... 715
Visualization Profile ..................................................................... 716
14 EIO0000002854.04
Update Project ............................................................................ 716
Update Libraries.......................................................................... 717
Clean and Build Application ......................................................... 718
Communication Settings .............................................................. 718
Start ETEST ............................................................................... 719
Reset Diagnostic Messages......................................................... 720
Reboot the Controller .................................................................. 721
Convert Device ........................................................................... 721
Comparing Projects..................................................................... 723
Advanced Library Management Functions .................................... 724
Accessing POUs ......................................................................... 725
CODESYS Script Engine Examples ................................................... 726
Project........................................................................................ 726
Online Application ....................................................................... 732
Objects....................................................................................... 734
Devices ...................................................................................... 735
System / User Interface (UI) ......................................................... 738
Reading Values........................................................................... 741
Reading Values From Recipe and Send an Email .......................... 742
Determine Device Tree of the Open Project................................... 743
Script Example 4: Import a Device in PLCOpenXML From
Subversion ................................................................................. 743
Script Example 5: Creating and Editing POUs ............................... 744
Script Example 6: User Interface / Interaction with the User ............ 745
Script Example 7: Manipulation of the Project information
Object ........................................................................................ 747
Advanced Example: Checkout a Library from SVN and
Installation in EcoStruxure Machine Expert ................................... 747
Managing Device User Rights Using the Scripting API ......................... 748
Managing Device User Rights Using the Scripting API .................. 748
Controller Feature Sets for Migration........................................................ 750
Controller Feature Sets for Migration .................................................. 750
Glossary ................................................................................................... 753
Index ......................................................................................................... 757
EIO0000002854.04 15
Safety Information
Safety Information
Important Information
Read these instructions carefully, and look at the equipment to become familiar
with the device before trying to install, operate, service, 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.
The addition of this symbol to a “Danger” or “Warning” safety label indicates that an
electrical hazard exists which will result in personal injury if the instructions are not
followed.
This is the safety alert symbol. It is used to alert you to potential personal injury
hazards. Obey all safety messages that follow this symbol to avoid possible injury or
death.
! DANGER
DANGER indicates a hazardous situation which, if not avoided, will result in death or serious
injury.
! WARNING
WARNING indicates a hazardous situation which, if not avoided, could result in death or
serious injury.
! CAUTION
CAUTION indicates a hazardous situation which, if not avoided, could result in minor or
moderate injury.
NOTICE
NOTICE is used to address practices not related to physical injury.
Please Note
Electrical equipment should be installed, operated, serviced, and maintained only
by qualified personnel. No responsibility is assumed by 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.
EIO0000002854.04 17
About the Book
Validity Note
This document has been updated for the release of EcoStruxureTM Machine
Expert V2.0.3.
The characteristics that are described in the present document, as well as those
described in the documents included in the Related Documents section below,
can be found online. To access the information online, go to the Schneider Electric
home page www.se.com/ww/en/download/.
The characteristics that are described in the present document should be the
same as those characteristics that appear online. In line with our policy of constant
improvement, we may revise content over time to improve clarity and accuracy. If
you see a difference between the document and online information, use the online
information as your reference.
18 EIO0000002854.04
About the Book
Related Documents
Document title Reference
Cybersecurity Best Practices CS-Best-Practices-2019-340
EIO0000002837 (FRE);
EIO0000002838 (GER);
EIO0000002840 (SPA);
EIO0000002839 (ITA);
EIO0000002841 (CHS)
EIO0000002844 (GER);
EIO0000002846 (SPA);
EIO0000002845 (ITA);
EIO0000002847 (CHS)
EIO0000002831 (GER);
EIO0000002833 (SPA);
EIO0000002832 (ITA);
EIO0000002834 (CHS)
EIO0000001673 (GER);
EIO0000001675 (SPA);
EIO0000001674 (ITA);
EIO0000001676 (CHS)
EIO0000003049 (GER);
EIO0000003051 (SPA);
EIO0000003050 (ITA);
EIO0000003052 (CHS)
EIO0000002854.04 19
About the Book
EIO0000001694 (GER);
EIO0000001696 (SPA);
EIO0000001695 (ITA);
EIO0000001697 (CHS)
EIO0000002976 (GER);
EIO0000002978 (SPA);
EIO0000002977 (ITA);
EIO0000002979 (CHS)
WARNING
LOSS OF CONTROL
• The designer of any control scheme must consider the potential failure
modes of control paths and, for certain critical control functions, provide a
means to achieve a safe state during and after a path failure. Examples of
critical control functions are emergency stop and overtravel stop, power
outage and restart.
• Separate or redundant control paths must be provided for critical control
functions.
• System control paths may include communication links. Consideration must
be given to the implications of unanticipated transmission delays or failures
of the link.
• Observe all accident prevention regulations and local safety guidelines.1
• Each implementation of this equipment must be individually and thoroughly
tested for proper operation before being placed into service.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
1For additional information, refer to NEMA ICS 1.1 (latest edition), "Safety
Guidelines for the Application, Installation, and Maintenance of Solid State
Control" and to NEMA ICS 7.1 (latest edition), "Safety Standards for Construction
and Guide for Selection, Installation and Operation of Adjustable-Speed Drive
Systems" or their equivalent governing your particular location.
WARNING
UNINTENDED EQUIPMENT OPERATION
• Only use software approved by Schneider Electric for use with this
equipment.
• Update your application program every time you change the physical
hardware configuration.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
20 EIO0000002854.04
About the Book
For reasons of Internet security, for those devices that have a native Ethernet
connection, TCP/IP forwarding is disabled by default. Therefore, you must
manually enable TCP/IP forwarding. However, doing so may expose your network
to possible cyberattacks if you do not take additional measures to protect your
enterprise. In addition, you may be subject to laws and regulations concerning
cybersecurity.
WARNING
UNAUTHENTICATED ACCESS AND SUBSEQUENT NETWORK INTRUSION
• Observe and respect any and all pertinent national, regional and local
cybersecurity and/or personal data laws and regulations when enabling
TCP/IP forwarding on an industrial network.
• Isolate your industrial network from other networks inside your company.
• Protect any network against unintended access by using firewalls, VPN, or
other, proven security measures.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
EIO0000002854.04 21
About the Book
Standard Description
ISO 12100:2010 Safety of machinery - General principles for design - Risk assessment
and risk reduction
EN 60204-1:2006 Safety of machinery - Electrical equipment of machines - Part 1: General
requirements
In addition, terms used in the present document may tangentially be used as they
are derived from other standards such as:
Standard Description
IEC 61158 series Digital data communications for measurement and control – Fieldbus for
use in industrial control systems
Finally, the term zone of operation may be used in conjunction with the description
of specific hazards, and is defined as it is for a hazard zone or danger zone in the
Machinery Directive (2006/42/EC) and ISO 12100:2010.
NOTE: The aforementioned standards may or may not apply to the specific
products cited in the present documentation. For more information concerning
the individual standards applicable to the products described herein, see the
characteristics tables for those product references.
22 EIO0000002854.04
Introduction
What’s in This Part
General Introduction to the EcoStruxure Machine Expert Logic Builder...............24
EcoStruxure Machine Expert Logic Builder User Interface .................................26
Basic Concepts ..............................................................................................47
EIO0000002854.04 23
General Introduction to the EcoStruxure Machine Expert
Logic Builder
Building Projects
The Logic Builder provides different ways (such as Build, Build all, or Clean all)
to build your EcoStruxure Machine Expert project.
24 EIO0000002854.04
General Introduction to the EcoStruxure Machine Expert Logic
Builder
Online Features
The Logic Builder online features allow you to perform the following tasks:
• Online monitoring of values in program code and in Watch views
• Performing online changes
• Online configuration of traces
• Watching traces online
• Interacting with your machine by using built-in visualizations in online mode
for diagnostic and test purposes
• Reading the status of controllers and devices
• Detecting potential programming logic errors by using the debugging function
EIO0000002854.04 25
EcoStruxure Machine Expert Logic Builder User Interface
26 EIO0000002854.04
EcoStruxure Machine Expert Logic Builder User Interface
1 2 3
File Edit View Project System Project ETEST Build Online Debug Tools Window Help
Devices
MyProject
LMC_PacDrive (PacDrive LMC 300/400/402/600
My Controller (TM262L10MESE8T)
POUs
MyProject
Project Information
GlobalTextList
Library Manager
POU (PRG)
Project Information
Project Settings
4 5 6
1 Menu bar
2 Toolbar
3 Multi-tabbed Navigators: Devices tree, Tools tree, Applications tree, Functional tree
4 Messages view
5 Information bar
6 Status bar
Default Components
The Logic Builder screen contains the following components that are visible by
default:
EIO0000002854.04 27
EcoStruxure Machine Expert Logic Builder User Interface
Component Description
Multi-tabbed Navigators The following Navigators are available as tabs where the
different objects of a project are organized in a tree structure:
• Devices tree
• Applications tree
• Tools tree
• Functional tree
For further information, refer to the chapter Multi-Tabbed
Navigators, page 31.
Information bar of the Provides information messages, for example on the license
Messages view status.
Multi-tabbed Catalog view The Catalog view consists of different tabs where the available
hardware and software objects are listed:
• Hardware Catalog
◦ Controller
◦ HMI & iPC
◦ Devices & Modules
◦ Diverse
• Software Catalog
◦ ToolBox
For further information, refer to the chapter Multi-Tabbed Catalog
Views, page 40.
Multi-tabbed editor window Used for creating the particular object in the respective editor.
Status Bar
The bar at the lower border of the Logic Builder screen provides various types of
information:
• Information on the logged-in user.
• If you are working in an editor window: the position of the cursor and the
status of editing mode.
• In offline mode: the status of the program.
• In online mode: the status of the program.
28 EIO0000002854.04
EcoStruxure Machine Expert Logic Builder User Interface
Abbreviation Description
Ch Number of characters.
Double-click to open the dialog box Go To Line. Here you can enter a different
position where the cursor is placed.
The status of the editing mode is indicated by the following abbreviations:
Abbreviation Description
Code unchanged Application not modified. A connection to the controller can be established without
download.
Online change possible Application modified, can be downloaded by an online change.
Code download necessary Application modified, cannot be downloaded by an online change. A full download is
required.
Text Description
Program unchanged Program on device matches the active application in the programming
system.
Program modified Program on device differs from the active application in the
(Online Change) programming system, online change required.
Program modified (Full Program on device differs from the active application in the
download) programming system, full download required.
The following status field is only available if the controller, depending on a setting in the device description, supports cycle-independent
monitoring.
EIO0000002854.04 29
EcoStruxure Machine Expert Logic Builder User Interface
IN CYCLE White Indicates that the values of the monitored expressions are read
within one cycle.
OUT OF CYCLE Red Indicates that the retrieval of the values of the monitored
variables cannot be performed within one cycle.
Switching Windows
EcoStruxure Machine Expert allows you to switch between open views and
editors. To switch between open views and editors, press the Ctrl and Tab keys
simultaneously. A window opens that lists the views and editors that are open. As
long as the Ctrl key is pressed the window stays open. Use the Tab key or the
Arrow keys simultaneously to select a specific view or editor.
30 EIO0000002854.04
EcoStruxure Machine Expert Logic Builder User Interface
Multi-Tabbed Navigators
Overview
The multi-tabbed Navigators are default components of the Logic Builder screen.
By default, the following navigators are available:
• Devices tree: It allows you to manage the devices on which the application is
to run.
• Applications tree: It allows you to manage project-specific as well as global
POUs, and tasks in a single view.
• Tools tree: It allows you to manage project-specific as well as global libraries
or other elements in a single view.
• Functional tree: It allows you to group the content of a controller according to
your individual requirements.
You can access views via the View menu.
Repositioning Objects
To reposition objects, use the clipboard commands (Cut, Copy, Paste, Delete)
from the Edit menu. Alternatively, you can drag the selected object with the
mouse while the mouse-button (plus CTRL key for copying) is pressed. When you
add devices using the copy and paste function, the new device gets the same
name followed by an incrementing number.
EIO0000002854.04 31
EcoStruxure Machine Expert Logic Builder User Interface
32 EIO0000002854.04
EcoStruxure Machine Expert Logic Builder User Interface
1 Root node
2 Programmable device (with applications)
EIO0000002854.04 33
EcoStruxure Machine Expert Logic Builder User Interface
• Each entry in the Devices tree displays the symbol, the symbolic name
(editable), and the device type (= device name as provided by the device
description).
• A device is programmable or configurable. The type of the device determines
the possible position within the tree and also which further resources can be
inserted below the device.
• Within a single project, you can configure one or several programmable
devices - regardless of manufacturer or type (multi-resource, multi-device,
networking).
• Configure a device concerning communication, parameters, I/O mapping in
the device dialog box (device editor). To open the device editor, double-click
the device node in the Devices tree (refer to the description of the device
editor, page 77).
• In online mode, the status of a device is indicated by an icon preceding the
device entry:
◦ Device is running in demo mode for 30 minutes. After this time, the
demo mode expires and the fieldbus stops exchanging data.
34 EIO0000002854.04
EcoStruxure Machine Expert Logic Builder User Interface
does not rely on hardware resources for execution). When you switch to
simulation mode (see EcoStruxure Machine Expert, Menu Commands, Online
Help), an entry in the Devices tree is displayed in italics, and you can log into the
application.
For information on the conversion of device references when opening projects,
refer to the Compatibility and Migration User Guide.
EIO0000002854.04 35
EcoStruxure Machine Expert Logic Builder User Interface
36 EIO0000002854.04
EcoStruxure Machine Expert Logic Builder User Interface
Functional tree
Overview
The Functional tree is available for controllers that have a Functional Model
node in the Devices tree. It allows you to group multiple objects, such as IEC
code or devices, and link them to a function. Once this function is created, you can
reuse it. By creating this modularity, reuse your developments to improve your
vision of the project. You can export / import the Functional tree and reuse it in
another project.
EIO0000002854.04 37
EcoStruxure Machine Expert Logic Builder User Interface
Selecting Controllers
Select controllers for the Functional tree as follows:
1 In the Functional tree, right-click the root node, A new subnode Functional Model
and execute the command Select Controllers. is inserted for each selected
controller in the Devices tree.
2 In the Select Controllers dialog box, select the New controller nodes are added to
controllers you want to add to the Functional the Functional tree below the root
tree, and click OK. node for each selected controller.
Adding Nodes
To group the content of a controller according to your individual requirements, the
Functional tree allows you to create subnodes below the controller nodes.
38 EIO0000002854.04
EcoStruxure Machine Expert Logic Builder User Interface
Functional module A functional module is a group of program Select a parent node (for example, the controller
elements intended to perform an application node), and click the green plus button.
function.
Child object Child objects of the attached objects. Child objects are displayed in the Functional tree.
Deleting Nodes
To delete a node from the Functional tree, right-click on it, and execute the
command Delete from the contextual menu. You are requested to delete the
selected object, with its child objects, only from the Functional tree or from the
whole project.
Child objects cannot be removed from the Functional tree only. If you intend to
delete a child object, you are prompted to confirm that the object is removed from
the whole project.
EIO0000002854.04 39
EcoStruxure Machine Expert Logic Builder User Interface
If you export and import the functional model Then the attached objects are not recreated.
only,
If you copy and paste one or more functional Then the attached objects are not recreated.
modules only,
It is not possible to copy and paste attached objects in the Functional tree.
40 EIO0000002854.04
EcoStruxure Machine Expert Logic Builder User Interface
You can add the elements from the catalogs to the project by drag and drop as
described in the Adding Devices by Drag and Drop chapter, page 52.
Favorites List
Each tab of the catalog view contains a Favorites list. To provide quick access,
you can add frequently used elements to this Favorites list by drag and drop.
EIO0000002854.04 41
EcoStruxure Machine Expert Logic Builder User Interface
View is placed here: the view currently placed at this position and the
new one are arranged as icons.
42 EIO0000002854.04
EcoStruxure Machine Expert Logic Builder User Interface
When you release the mouse-button, the view is placed at the new position.
Views with an Auto Hide button can be placed as independent windows (floating)
anywhere on the screen by moving them and not dragging them on one of the
arrow symbols. In this case, the view looses the Auto Hide button. As an
alternative, execute the commands Dock and Float from the Window menu.
Hiding views: You can hide views with Auto Hide buttons at the border of the
EcoStruxure Machine Expert window. Click the Auto Hide down button in the
upper right corner of the view. The view will be displayed as a tab at the nearest
border of the frame window. The content of the view is only visible as long as the
cursor is moved on this tab. The tab displays the icon and the name of the view.
This state of the view is indicated by the docking button changed to Auto Hide.
Unhiding views: To unhide a view, click the Auto Hide button.
An alternative way of hiding and unhiding a view is provided by the Auto Hide
command that is by default available in the Window menu.
It is not possible to reposition the information and status bar on the lower border of
the user interface, page 27.
Perspectives
A perspective is used to save the layout of EcoStruxure Machine Expert views. It
stores whether the Messages and Watch views are open and at which position
the view windows are located (docked or independent windows).
By default, EcoStruxure Machine Expert provides the following perspectives for
specific use cases in the Window > Switch Perspective menu or in the
perspective table in the toolbar.
EIO0000002854.04 43
EcoStruxure Machine Expert Logic Builder User Interface
Perspective name Use case Navigators (on the left Catalog views (on the Views at the bottom of
side) right side) the screen
Smart Template For working with Smart • Devices – Messages (in Auto Hide
Template modules. • POUs mode)
• Modules
Logic Configuration For adding / creating • Devices tree Hardware catalog Messages (in Auto Hide
logic. • Applications tree • Controller mode)
Step Action
2 Execute the command Save Perspective from the Window menu to save your
modifications to a new perspective.
3 In the Save Perspective dialog box, enter a name for your perspective.
Result: The present view layout is saved. The new perspective is available in the
Window > Switch Perspective menu and in the perspective table in the toolbar.
44 EIO0000002854.04
EcoStruxure Machine Expert Logic Builder User Interface
Zoom
Each editor window provides a zoom function. Click the zoom button in the
lower right corner of the window to open a list. It allows you to choose one of the
zoom levels 25, 50, 100, 150, 200, and 400 percent or to enter a zoom factor of
your choice. A printout always refers to the 100% view.
Customization of the user interface is possible in offline and in online mode.
The Device/Application field contains the device and application to which the
object is associated.
To open the online view of the object, activate the option Online mode and click
OK. To see the offline view, activate the option Offline mode.
If the object is a function block, the Function block instance field contains a list
of the instances currently used in the application.
EIO0000002854.04 45
EcoStruxure Machine Expert Logic Builder User Interface
• Either select one of the instances and activate Online or Offline mode.
• Or select the option Implementation which - independently of the selected
instance - will open the base implementation view of the function block. The
Implementation option has no affect for non-instantiated objects.
For more information on the online views of the particular editors, refer to the
respective editor descriptions.
The status bar, page 27 provides information on the current status of the
application.
Some commands are not visible in the default view. To add a command to a menu
or reorganize the menu structures, use the Tools > Customize dialog box.
Specific commands, for a particular editor for example, are usually available in a
corresponding menu. These commands are only visible when the editor is open.
For example: when you edit an object in the SFC editor, the SFC menu is added to
the menu bar.
For a description of the menus and commands, refer to the separate EcoStruxure
Machine Expert Menu Commands Online Help (see EcoStruxure Machine Expert,
Menu Commands, Online Help).
46 EIO0000002854.04
Basic Concepts
Basic Concepts
What’s in This Chapter
Introduction and Basic Concepts ....................................................................47
Object Orientation
The object-oriented approach is not only reflected by the availability of
corresponding programming elements and features, but also in the structure and
version handling of EcoStruxure Machine Expert and in the project organization.
Multi-device usage of an EcoStruxure Machine Expert project is possible based
on jointly used, instantiated programming units.
Version Handling
A parallel installation of several versions of EcoStruxure Machine Expert
components and working with the desired combination of versions is possible.
This also pertains to the device-specific use of different compiler versions.
Individual functions can be added without having to update the whole version.
For further information, refer to the Compatibility and Migration User Guide.
Project Organization
Project organization is also determined in an object oriented fashion. An
EcoStruxure Machine Expert project contains a controller program composed of
various programming objects and it contains definitions of the resources which are
needed to run instances of the program (application) on defined target systems
(devices, controllers).
So there are two main types of objects in a project:
Programming objects (POUs), These are programs, functions, function blocks, methods,
page 148 interfaces, actions, data type, definitions, and so on.
Resource objects (Devices tree) Device objects are only managed in the Devices tree. To insert
objects in the Devices tree, refer to Adding Elements to the
Navigators section, page 36.
Code Generation
Code generation by integrated compilers and the subsequent use of the resulting
machine code provides for short execution times.
EIO0000002854.04 47
Basic Concepts
48 EIO0000002854.04
Configuration
What’s in This Part
Installing Devices ...........................................................................................50
Managing Devices..........................................................................................52
Common Device Editor Dialogs .......................................................................77
EIO0000002854.04 49
Installing Devices
Installing Devices
What’s in This Chapter
Integration of Sercos Devices from Third-Party Vendors ...................................50
Step Action
3 Select the file type SERCOS III I/O device descriptions (*.xml) and browse your file
system for the SDDML file to open.
Result: The SDDML file is converted and imported into a compatible file format for
EcoStruxure Machine Expert.
NOTE: If the selected SDDML file is not compatible or if the Sercos device of
the third-party vendor is not using a compatible FSP (Function Specific Profile)
type, then a corresponding diagnostic message is indicated in the Messages
view (see EcoStruxure Machine Expert, Menu Commands, Online Help).
50 EIO0000002854.04
Installing Devices
Step Action
2 In the tree structure Installed device descriptions, expand the node Fieldbusses >
Sercos.
3 Expand the subnode Slave to verify whether the Sercos bus interfaces that you
integrated are available in the list.
4 Expand the subnode Module to verify whether the Sercos I/O modules that you
integrated are available in the list.
For further information, refer to the description of the Device Repository dialog
box (see EcoStruxure Machine Expert, Menu Commands, Online Help).
EIO0000002854.04 51
Managing Devices
Managing Devices
What’s in This Chapter
Adding Devices through the Hardware Catalog ..............................................52
Adding Devices by Contextual Menu or Plus Button .........................................54
Updating Devices ..........................................................................................59
Converting Devices .......................................................................................60
Converting Projects .......................................................................................61
Adding Controllers
To add a controller to your project, proceed as follows:
Step Action
1
Open the Hardware Catalog by clicking the Hardware Catalog button in the
EcoStruxure Machine Expert Logic Builder toolbar if it is not already opened.
Result: The controllers suitable for your EcoStruxure Machine Expert project are
displayed in the Hardware Catalog.
3 Select a controller entry in the Controller tab, drag it to the Devices tree and drop it at a
suitable node. You can drop a controller at any empty space inside the Devices tree.
Result: The controller is added to the Devices tree as a new node with different
subnodes depending on the controller type.
Step Action
1
Open the Hardware Catalog by clicking the Hardware Catalog button in the
EcoStruxure Machine Expert Logic Builder toolbar if it is not already opened.
Result: The expansion devices suitable for your EcoStruxure Machine Expert project
are displayed in the Hardware Catalog.
52 EIO0000002854.04
Managing Devices
Step Action
3 Select your expansion device, drag it to the Devices tree and drop it at a suitable
subnode of a controller.
NOTE: Suitable subnodes are expanded and highlighted by EcoStruxure Machine
Expert.
Result: The expansion device is added to the Devices tree below the subnode of the
controller.
4 If the expansion device requires a communication manager, this node is added
automatically to the Devices tree.
If several communication managers are available for your expansion device, a dialog
box is displayed allowing you to select the suitable communication manager.
Step Action
1
Open the Hardware Catalog by clicking the Hardware Catalog button in the
EcoStruxure Machine Expert Logic Builder toolbar if it is not already opened.
Result: The field devices suitable for your EcoStruxure Machine Expert project are
displayed in the Hardware Catalog.
3 Select a field device entry in the Devices & Modules catalog view, drag it to the
Devices tree, and drop it at a suitable subnode of a controller.
NOTE: Suitable subnodes are expanded and highlighted by EcoStruxure Machine
Expert.
Result: The field device is added to the Devices tree below the subnode of the
controller.
4 If the field device requires a communication manager, this node is added automatically
to the Devices tree.
If several communication managers are available for your field device, a dialog box is
displayed allowing you to select the suitable communication manager.
Step Action
1
Open the Hardware Catalog by clicking the Hardware Catalog button in the
EcoStruxure Machine Expert Logic Builder toolbar if it is not already opened.
3 Select the option Device Template at the bottom of the Devices & Modules tab.
Result: The device templates suitable for your EcoStruxure Machine Expert project are
displayed in the Devices & Modules tab.
4 Add them to the Devices tree as described in the Adding Devices from Template
chapter, page 648.
EIO0000002854.04 53
Managing Devices
Adding a Controller
To add a controller to your EcoStruxure Machine Expert project, proceed as
follows:
Step Action
1 Select a project node, right-click the project node and execute the Add Device... command
from the contextual menu.
2 In the Add Device dialog box, select Schneider Electric from the list box Vendor.
Result: The selected controller is added to the project and appears as a new node in the
Devices tree. The Add Device dialog box remains open. You can do the following:
• You can add another controller by going back to step 3
• You can click the Close button to close the Add Device dialog box
54 EIO0000002854.04
Managing Devices
WARNING
UNINTENDED EQUIPMENT OPERATION
• Only use software approved by Schneider Electric for use with this
equipment.
• Update your application program every time you change the physical
hardware configuration.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Step Action
1 Select a controller node and click the green plus button of the node or right-click the controller node and execute the Add
Device... command from the contextual menu.
2 In the Add Device dialog box, select Schneider Electric from the Vendor list.
3 Choose the expansion device you want to add to your controller from the Device list below.
4 Rename your expansion device by typing a name in the text box Name.
NOTE: The name must not contain any space character. If you do not rename the expansion device, a name is given
by default.
Naming the expansion device meaningfully may ease the organization of your project.
Result: The selected expansion device is added to the project and is displayed in the Devices Tree as a new subnode of
your controller.
The Add Device dialog box remains open. You can do the following:
• You can add another expansion device by going back to step 3 of this description
• You can click the Close button
EIO0000002854.04 55
Managing Devices
ASCII Manager Serial line Used to transmit and/or receive data with a simple
device.
Machine Expert-Network • Serial For exchanging data with HMIs.
Manager line
(max.
1)
• Ether-
net
(max.
3)
Modbus IOScanner Serial line Modbus RTU or ASCII protocol manager used to
define implicit exchanges (I/O scanning) with Modbus
slave devices.
Modbus Manager Serial line Used for Modbus RTU or ASCII protocol in master or
slave mode.
CANopen Performance CAN CANopen manager for performance controllers
(M241, M251, M258, and LMC058).
Modbus TCP Slave Device Ethernet Modbus TCP manager for controllers with Ethernet
port.
Industrial Ethernet Network Ethernet For configuring EtherNet/IP and Modbus TCP
scanner services on M241 / M251 controllers with
Ethernet port.
Step Action
1 In the Devices Tree, select the bus interface (Serial Line, CANopen bus / CANbus,
Ethernet) and click the green plus button of the node or right-click the bus interface
node and execute the Add Device... command from the contextual menu.
2 In the Add Device dialog box, select Schneider Electric from the list Vendor.
Note: You can filter the devices by brand by clicking the list Vendor.
Note: Do not use spaces within the name. If you do not rename the device, a name is
given by default.
Naming the device meaningfully may ease the organization of your project.
56 EIO0000002854.04
Managing Devices
Adding Devices
Step Action
1 Select the field device manager node (CANopen or Modbus manager) in the Devices
Tree and click the green plus sign, or right-click the field device manager node and
execute the Add Device... command from the contextual menu.
2 In the Add Device dialog box, select Schneider Electric from the list box Vendor.
Note: You can filter the devices by brand by clicking the list box Vendor.
Naming the device meaningfully may ease the organization of your project.
EIO0000002854.04 57
Managing Devices
WARNING
UNINTENDED EQUIPMENT OPERATION
• Use the g_aNetDiagnosis data structure within the application to monitor
CAN slave responses to configuration commands.
• Verify that the application does not start up or put the machine or process in
an operational state in the event of receiving SDO abort messages from any
of the CAN slaves.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
After adding the CanConfig Extern library to your application, use the Net
Diagnostic definition within your application to test for SDO abort messages from
the CAN slaves.
The following code example illustrates the use of the CAN diagnostic data
structure:
IF g_aNetDiagnosis[CAN_Net_Number].ctSDOErrorCounter = 0
THEN
(* No error is detected in the configuration*)
ELSE
(* An error has been detected during configuration. Get
the latest error information.*)
// node ID of the slave which sent the abort code
ReadLastErrorNodeID := g_aNetDiagnosis[CAN_Net_Number].
usiNodeID;
// index used in the aborted SDO
ReadLastErrorIndex := g_aNetDiagnosis[CAN_Net_Number].
wIndex;
// subIndex used in the aborted SDO
ReadLastErrorSubIndex := g_aNetDiagnosis[CAN_Net_
Number].bySubIndex;
//SDO abort code
ReadLastErrorSdoAbortCode := g_aNetDiagnosis [CAN_Net_
Number].udiAbortCode;
(* Do not allow the start-up or other operation of the
machine or process *)
END_IF
NOTE: In this example, the CAN_Net_Number would be 0 for the CAN0 port
and, if the controller is so equipped, 1 for the CAN1port.
58 EIO0000002854.04
Managing Devices
Updating Devices
Updating Devices
Introduction
The update device function allows you to replace a device selected in the Devices
tree
• By another version of the same device or
• By a different type of device.
Updating Devices
To replace a device of your EcoStruxure Machine Expert project by another
version or by a different device, proceed as follows:
Ste- Action
p
1 Select the device you want to replace in the Devices tree and execute the command
Update Device... from the Project menu.
OR
Right-click the device you want to replace in the Devices tree and execute the command
Update Device... from the contextual menu.
OR
Right-click the device you want to replace in the Devices tree and execute the command
Add Device... from the contextual menu. In the Add Device dialog box select the Action:
Update device.
Result: The Add Device dialog box is converted into the Update Device dialog box.
2 From the Device: list, choose the device that should replace the present device.
To select a specific version of the device, select the options Display all versions (for
experts only) and/or Display outdated versions.
Result: The device that had been selected in the Devices tree is replaced by the new
device type or the new version. The new device type or the new version is now displayed at
the selected node in the Devices tree.
EIO0000002854.04 59
Managing Devices
Converting Devices
Converting Devices
Introduction
EcoStruxure Machine Expert allows you to convert a device that is configured in
your project to a different, but compatible device. EcoStruxure Machine Expert
automatically converts the currently configured device into the selected device
and displays the changes that are made in the Messages view.
The Convert Device command may automatically add or remove modules. These
hardware changes also have influences on the addressing and the libraries.
To help to avoid unintended behavior after a device was converted:
• Verify that the new device supports all functions and communication ports
that are required in your project
• Avoid using direct addresses in your application
• Perform a backup of the project to the PC before converting a device
WARNING
UNINTENDED EQUIPMENT OPERATION
• Verify that any direct addresses used in your application (for example, %IB5)
have been converted correctly after device conversion.
• Verify that the modified project contains the intended configurations and
provides the intended functionality after you have converted the device.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
NOTICE
LOSS OF DATA
Perform a backup of the project to the PC before converting a device.
Failure to follow these instructions can result in equipment damage.
Converting a Device
To convert a device to a compatible device, proceed as follows:
Step Action
1 Perform a backup of the project to the PC by executing the File > Save Project As... command before converting a device.
2 Right-click the device you want to convert in the Devices Tree.
Result: The Convert Device dialog box is displayed. It lists those devices that are compatible with the device you selected
and provides further information on the selected device.
4 Select the device from the list in which you want to convert your currently configured device.
To display the available versions of a device, select the option Display all versions (for experts only).
60 EIO0000002854.04
Managing Devices
Step Action
5
NOTE: If you have not yet performed a backup of your project, click Cancel to stop without changes and perform a
backup before you start the procedure once again.
To start the conversion, click OK.
Result: The currently configured device is converted into the device you selected from the list. The information you entered
is kept if the related modules are still available. Any modifications or configurations that could not be converted are listed in
the Messages view.
6 Verify whether the converted project still contains the intended configurations and provides the intended functions. If not,
adapt the configuration or restore the backup of the unchanged project file.
Converting Projects
Converting SoMachine Basic and Twido Projects
Introduction
With EcoStruxure Machine Expert, you can convert a SoMachine Basic or
TwidoSoft/TwidoSuite project and the configured controller to a selectable
EcoStruxure Machine Expert logic controller, page 750. The controller and the
corresponding logic are converted and integrated in the EcoStruxure Machine
Expert project.
For the conversion process, execute the File > Convert SoMachine Basic
Project or the File > Convert Twido Project command. The Convert
SoMachine Basic Project dialog box or Convert Twido Project dialog box
opens. If the commands are not available, you can insert them in a menu of your
choice by using the Tools > Customize dialog box (see EcoStruxure Machine
Expert, Menu Commands, Online Help).
If you convert a SoMachine Basic project that was created with a SoMachine
Basic version that is newer than the latest supported version, this is indicated by a
message in the Messages view (see EcoStruxure Machine Expert, Menu
Commands, Online Help). You can then continue or cancel the conversion. If you
continue, the application will be converted, but it may not be possible to do so
without encountering errors that will need to be rectified. In this case, review and
verify both the message view and your application before attempting to put it into
service.
NOTE: Verify that the SoMachine Basic or Twido project is valid before you
convert it into EcoStruxure Machine Expert.
NOTE: It is not possible to convert password-protected projects.
To help to avoid unintended behavior after a project was converted, verify that the
target controller supports the functions and communication ports that are required
in your project.
EIO0000002854.04 61
Managing Devices
WARNING
UNINTENDED EQUIPMENT OPERATION
• Verify that the program for the target controller contains the intended
configurations and provides the intended functions after you have converted
the project.
• Fully debug, verify, and validate the functionality of the converted program
before putting it into service.
• Before converting a program, verify that the source program is valid, i.e., is
downloadable to the source controller.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Step Action
1 To start the conversion process, perform one of the three actions in the EcoStruxure Machine Expert Logic Builder (as listed
in the Introduction block of this chapter, page 61).
Result: The Convert SoMachine Basic Project dialog box or Convert Twido Project dialog box opens:
62 EIO0000002854.04
Managing Devices
Step Action
3 Enter the path to the SoMachine Basic or Twido project file in the Project File box, or click the ... button to browse for the
file.
NOTE: If you already browsed for your SoMachine Basic or Twido project in the Open project dialog box, the path has
been entered automatically in the Project File field and cannot be edited.
4 Select the programming language in which the logic will be converted from the Implementation Language list.
5 Select the target controller from the Devices list in which you want to convert your SoMachine Basic or Twido controller.
Further information on the selected device is displayed in the Information area of the dialog box.
Result: The SoMachine Basic or Twido project is converted and integrated in the open EcoStruxure Machine Expert project.
Modifications or configurations that could not be converted are listed in the Messages view (see EcoStruxure Machine
Expert, Menu Commands, Online Help).
7 Consult the category Project Conversion of the Messages view and verify the errors and alerts detected and listed.
8 Verify whether the converted project contains the intended configurations and provides the intended functions. If not, adapt
the configuration.
TwidoEmulationSupport Library
The TwidoEmulationSupport library (see EcoStruxure Machine Expert, Twido
Emulation Support Library, Library Guide) contains functions and function blocks
that provide SoMachine Basic and TwidoSoft/TwidoSuite functionality in an
EcoStruxure Machine Expert application. The TwidoEmulationSupport library is
automatically integrated in the EcoStruxure Machine Expert project with the
converted controller.
EIO0000002854.04 63
Managing Devices
The following restrictions apply for the conversion of the application program
concerning the program structure:
• In EcoStruxure Machine Expert, it is not possible to jump to a label, page 255
in another program.
• It is not possible to define Grafcet steps in a subprogram.
• It is not possible to activate or deactivate Grafcet steps (per # and D#
instruction) in a subprogram.
In EcoStruxure Machine Expert, there is only the memory word area for memory
objects:
64 EIO0000002854.04
Managing Devices
The graphic provides an overview of the different layouts of %MD and %MF
addresses in SoMachine Basic / Twido and EcoStruxure Machine Expert.
%MW Mapped to the same %MW For each %MW object, a global
address variable of type INT is created.
Example
%MD and %MF with even Mapped such that they are For each %MD object, a global
addresses located on the same %MW variable of type DINT is
address as before. created.
The relationship between %KW, %KD, and %KF objects is the same as for %MW, %MD,
and %MF objects. For example, %KD4 / %KF4 are mapped on the same location as
%KW4. Uneven %KD / %KF addresses cannot be mapped.
EIO0000002854.04 65
Managing Devices
Remote Access
Memory objects (%MW, %MD, %MF, and %M) can be accessed by a remote device
through Modbus services:
Counters %C FB_Counter
PID FB_PID
High-speed counter %HSC / %VFC They are converted as described in the section
Conversion of Fast Counters, High-speed
Fast counter %FC Counters (Twido: Very Fast Counters) and Pulse
Generators, page 69 of this chapter.
PLS pulse generator %PLS
MC_MotionTask_PTO
%DATALOG
66 EIO0000002854.04
Managing Devices
EIO0000002854.04 67
Managing Devices
%S21 , %S22 Are only written. Reading is not supported for these variables.
Conversion of Symbols
Symbols defined in a SoMachine Basic / Twido project are automatically
transferred into the EcoStruxure Machine Expert project.
The following restrictions apply to the naming of symbols:
no variable is created for a language object, the name of the symbol is discarded.
a symbol is not used anywhere in the application the name of the symbol may be discarded.
program,
68 EIO0000002854.04
Managing Devices
For the complete list of symbol modifications that were required, refer to the
Messages view.
Restriction Solution
The inputs and outputs used by the converted Take this into account in the wiring of the
high-speed counters and pulse generators may converted controller.
differ from the used inputs and outputs of the
source application. The reassignment of inputs and outputs is
reported in the Messages view (see
EcoStruxure Machine Expert, Menu
Commands, Online Help).
The SoMachine Basic controller may support a You have to adapt your application manually.
different number of counters and pulse
generators than the selected target controller.
The conversion function only converts the
counters and pulse generators that are
supported by the target controller.
Constraints Regarding the Conversion of %FC, %HSC / %VFC, %PLS, and %PWM
For each %FC, %HSC / %VFC, %PLS, and %PWM function block being used in the
SoMachine Basic / Twido application, a single program is created in EcoStruxure
Machine Expert. You can improve this basic implementation according to the
needs of your application.
The following restrictions apply:
EIO0000002854.04 69
Managing Devices
Restriction Solution
The access to function block parameters is If the source application accesses parameters
performed differently in SoMachine Basic and of the function block, you have to extend the
EcoStruxure Machine Expert. converted application accordingly.
The behavior of counters differs in EcoStruxure You have to adapt your application manually.
Machine Expert from SoMachine Basic / Twido
when the preset value is set.
In Twido:
• The down counter continues counting if
zero is reached.
• The up counter continues counting if the
preset value is reached.
In EcoStruxure Machine Expert:
• The down counter stops counting if zero is
reached.
• The up counter starts to count from the
beginning if the preset value is reached.
The following parameters of SoMachine Basic You have to adapt your application manually.
function blocks cannot be converted to
EcoStruxure Machine Expert:
70 EIO0000002854.04
Managing Devices
folder Grafcet This folder contains the following language elements used
for the management of the Grafcet state machine.
data structure GRAFCET_STATES This data structure has one bit element for each allowed
Grafcet state.
EIO0000002854.04 71
Managing Devices
Can have an arbitrary number Must have exactly one initial If the graphical Grafcet POU
of initial steps. step. has several initial steps, then
the converter creates several
initial steps in SFC. This has
the effect, that the converted
application cannot be built
without errors being detected.
Activation of multiple steps of Only one step of an alternative Verify that the converted
an alternative branch is branch can be activated. program is working as
allowed. expected.
The output transitions of a step The transitions of the SFC Verify that the converted
are evaluated right after the program are evaluated after program is working as
step has been executed. the execution of the active expected.
steps.
The layout of steps, transitions, The layout of steps, transitions, The graphical layout is
and branches is relatively free. and branches is more converted to SFC as far as
restricted. possible. The incompatibilities
encountered during the
conversion are reported in the
Messages view.
A graphical Grafcet POU can be initialized by setting the system bit %S21. If this
bit is set in the SoMachine Basic project, the converter activates the implicit
variable SFCInit and uses it to initialize the SFC program.
TM2DAI8DT TM3DI8A –
TM2DDO8UT TM3DQ8U –
TM2DDO8TT TM3DQ8T –
TM2DRA8RT TM3DQ8R –
72 EIO0000002854.04
Managing Devices
TM2DDI16DK TM3DI16K –
TM2DRA16RT TM3DQ16R –
TM2DDO16UK TM3DQ16UK –
TM2DDO16TK TM3DQ16TK –
TM2DDI32DK TM3DI32K –
TM2DDO32UK TM3DQ32UK –
TM2DDO32TK TM3DQ32TK –
TM2DMM8DRT TM3DM8R –
TM2DMM24DRF TM3DM24R –
TM2AMI2HT TM3AI2H –
TM2AMM3HT TM3TM3 –
NOTE: If you are using TM2 as well as TM3 expansion modules in your
EcoStruxure Machine Expert project, note their position in the tree structure: If
TM3 nodes are located below TM2 nodes in the tree structure, this is detected
as a Build error in the Messages view.
EIO0000002854.04 73
Managing Devices
WARNING
UNINTENDED EQUIPMENT OPERATION
• Verify that the program for the target controller contains the intended
configurations and provides the intended functions after you have converted
the project.
• Fully debug, verify, and validate the functionality of the converted program
before putting it into service.
• Before converting a program, verify that the source program is valid, i.e., is
downloadable to the source controller.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Configuration
The IOScanner configuration is completely converted:
• The devices are converted to the Generic Modbus Slave device. The source
device type is not preserved.
• The device configuration is completely converted. This includes initialization
requests, channel settings, and reset variable.
Function Blocks
The drive function blocks for the control of Altivar drives over the Modbus
IOScanner (MC_xxx_ATV) are not converted.
Status Handling
Since the IOScanner status handling differs for SoMachine Basic and EcoStruxure
Machine Expert, these features can only be partly converted. If your application
uses IOScanner status information, verify that this logic still works.
Channel Status (%IWNSx.y) EcoStruxure Machine Expert does not provide status information
for single channels. The channel status is converted to the device
status.
System words and bits:
74 EIO0000002854.04
Managing Devices
Access to all local inputs and outputs. Access only to fast inputs and outputs.
READ_IMM_IN updates the input object (%I0. GetImmediateFastInput only returns the
x). read value but does not update the input
channel.
WARNING
UNINTENDED EQUIPMENT OPERATION
• Verify that the program for the target controller contains the intended
configurations and provides the intended functions after you have converted
the project.
• Fully debug, verify, and validate the functionality of the converted program
before putting it into service.
• Before converting a program, verify that the source program is valid, i.e., is
downloadable to the source controller.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
EIO0000002854.04 75
Managing Devices
76 EIO0000002854.04
Common Device Editor Dialogs
Device Configuration
General Information About Device Editors
Overview
The device editor provides parameters for the configuration of a device, which is
managed in the Devices tree.
To open the device editor for a specific device, do the following:
• Double-click the node of the device in the Devices tree or
• Select device in the Devices tree and execute the Edit Object command via
the contextual menu or via the Project menu.
The Tools > Options > Device editor dialog box allows you to make the generic
device configuration views invisible, page 102.
This chapter describes the main device editor dialogs. Bus-specific configuration
dialogs are described separately.
Tab Description
Synchronized Files, page 104 List of files that are downloaded to the controller with an
application download.
Files, page 105 Configuration of a file transfer between host and controller.
Services Lets you configure the online services of the controller (RTC,
device identification).
EIO0000002854.04 77
Common Device Editor Dialogs
Tab Description
Users and Groups, page 111 User management concerning device access during runtime.
Access Rights, page 117 Configuration of the access rights on runtime objects and files
for the particular user groups.
Symbol Rights, page 121 Access rights of individual user groups to symbols (symbol
sets) on the device.
Task Deployment, page 122 Display of inputs and outputs assigned to the defined task -
used for troubleshooting.
Diagnostic Table Displays the errors detected by the controller. The data can
be accessed using the syntax
NameOfControllerInDeviceTree.NameofParameter. Example:
MyController.SA_NbPowerOn.
Information, page 123 General information on the device (for example: name,
provider, version).
I/O Mapping, page 124 Mapping of the input and output channels of an I/O device on
project (application) variables.
78 EIO0000002854.04
Common Device Editor Dialogs
Button Description
Change Communication Click this button to open the Change Communication Policy
Policy... dialog box, page 98 that allows you to select a new
communication policy for the selected controller.
Optical and acoustical Click this button to cause the selected controller to indicate an
optical and an acoustical signal: It starts to beep and flashes a
control LED. This can help you to identify one controller if
several controllers are used.
EIO0000002854.04 79
Common Device Editor Dialogs
Button Description
Move the cursor over a favorite button in the toolbar to view the
associated controllers as a tooltip.
List of Controllers
The list of controllers in the middle of the Communication Settings tab of the
device editor lists those controllers that have sent a response to the network scan.
It provides information on each controller in several columns. You can adapt the
columns displayed in the list of controllers according to your individual
requirements.
80 EIO0000002854.04
Common Device Editor Dialogs
To achieve this, right-click the header of a column to open the Process columns
dialog box.
You can create your own layout of this table. Click New, and enter a name for your
layout. Shift columns from the list of Possible columns to the list of Current
columns and vice versa by clicking the horizontal arrow buttons. To change the
order of the columns in the Current columns list, click the arrow up and arrow
down buttons.
Step Action
Result: The Edit communication settings dialog box opens with the settings of the
controller.
EIO0000002854.04 81
Common Device Editor Dialogs
Step Action
Carefully manage the IP addresses because each device on the network requires
a unique address. Having multiple devices with the same IP address can cause
unintended operation of your network and associated equipment.
82 EIO0000002854.04
Common Device Editor Dialogs
WARNING
UNINTENDED EQUIPMENT OPERATION
• Verify that all devices have unique addresses.
• Obtain your IP address from your system administrator.
• Confirm that the device’s IP address is unique before placing the system into
service.
• Do not assign the same IP address to any other equipment on the network.
• Update the IP address after cloning any application that includes Ethernet
communications to a unique address.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Managing Favorites
To manage favorites in the list of controllers, proceed as follows:
Step Action
EIO0000002854.04 83
Common Device Editor Dialogs
If a certificate is not available on the Then a message will be displayed when you The login is denied.
controller (prerequisite 2 is not fulfilled) attempt to log into the controller, indicating
that encrypted communication could not be
initialized successfully.
If both prerequisites are fulfilled Then a message will be displayed when you If you confirm with OK:
attempt to log into the controller for the first
• The login will be successful given that
time, requesting you to install the
the user password, if required, is
(untrusted) controller certificate to the local
provided as well.
Controller Certificates store of the PC
running EcoStruxure Machine Expert. • Communication to the controller will
be encrypted.
• The message will not be displayed
again.
If you click Cancel:
• The login will be denied.
• The message will be displayed with
every new attempt to log in.
For further information, refer to the document How To Manage Certificates on the
Controller.
WARNING
UNINTENDED EQUIPMENT OPERATION
• Ensure that all devices have unique nodenames.
• Confirm that the device’s nodename is unique before placing the system into
service.
• Do not assign the same nodename to any other equipment on the network.
• Update the nodename after cloning any application that includes Ethernet
communications to a unique nodename.
• Create a unique nodename for each device that does not create it
automatically, such as M241 and M251 controllers.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
84 EIO0000002854.04
Common Device Editor Dialogs
1 Right-click the controller in the list and execute the command Change device
name... from the contextual menu.
2 In the Change device name dialog box, enter a unique device name in the box New.
Result: The device name you entered is assigned to the controller and is displayed in
the column NodeName of the list.
NOTE: Device name and NodeName are synonymous.
EIO0000002854.04 85
Common Device Editor Dialogs
If an IP address has been entered for the connection mode, the information is
converted to a URL starting with a prefix. For the Connection Mode > IP Address
, the prefix etcp3:// is used. For the Connection Mode > IP Address (Fast
TCP) , the prefix etcp4:// is used. For example, etcp4://<IpAddress>.
NOTE: In the Controller Assistant and the Diagnostics tools, an IP address
can additionally have the prefix etcp2://. This is only available for PacDrive
M controllers.
If a nodename has been entered for the connection mode (for example, when
Connection Mode > Nodename has been selected), the information is converted
to a URL starting with the prefix enodename3://. For example,
enodename3://<Nodename>.
NOTE: This function is not available for all supported controllers. Consult the
Programming Guide specific to your controller to find out whether it supports
the IP Address (Fast TCP) connection mode.
86 EIO0000002854.04
Common Device Editor Dialogs
1 PC
2 NAT router
3 Target device
Example: NAT Address/Port: 10.128.158.106/1105 Target Nodename:
MyM238 (10.128.158.106)
NOTE: Enter a valid IP address (format <Number>.<Number>.<Number>.
<Number>) or a valid host name for the NAT Address.
Enter the port of the NAT router to be used. Otherwise, the default port 1105 is
used.
The information you enter is interpreted as a URL that creates a remote TCP
bridge - using TCP block driver - and then connects by scanning for a controller
with the given nodename on the local gateway.
NOTE: The NAT router can be located on the target controller itself. You can
use it to create a TCP bridge to a controller.
You can also scan a remote network via a remote controller (bridge controller). To
achieve this, enter the NAT Address/Port, and click the refresh button right to the
NAT Address/Port text field. The controllers that send a response to the remote
network scan are listed in the list of controllers. Each of these entries is marked by
the icon REM being displayed in the first column. To fill the list with more detailed
information, right-click a controller entry and execute the command Refresh this
controller. If the controller supports this function, further information on the
controller is added to the list. Consult the Programming Guide specific to your
controller.
EIO0000002854.04 87
Common Device Editor Dialogs
1 Refresh button
2 REM icon
In the following example, the bridge controller, controller 2, and controller 3
are scanned.
1 Local subnet
2 Remote subnet
3 Bridge controller
4 Controller 3
5 Controller 2
6 NAT router
7 PC
1 PC
2 NAT router
3 Target device
88 EIO0000002854.04
Common Device Editor Dialogs
1 Refresh button
2 REM icon
EIO0000002854.04 89
Common Device Editor Dialogs
1 Local subnet
2 Remote subnet
3 Bridge controller
4 Controller 3
5 Controller 2
6 NAT router
7 PC
1 PC / HMI
2 PC / HMI / devices with installed EcoStruxure Machine Expert gateway
3 Target device
Example: Gateway Address/Port: 10.128.156.28/1217Target Nodename:
MyPLC
NOTE: Enter a valid IP address (format <Number>.<Number>.<Number>.
<Number>) or a valid host name for the Gateway Address/Port:.
Enter the port of the gateway router to be used. Otherwise, the default
EcoStruxure Machine Expert gateway port 1217 is used.
Do not use spaces at the beginning or end and do not use commas in the
Target Nodename box.
The information you enter is interpreted as a URL. The gateway is scanned for a
device with the given nodename that is directly connected to this gateway. Directly
connected means in the EcoStruxure Machine Expert gateway topology it is the
root node itself or a child node of the root node.
NOTE: The EcoStruxure Machine Expert gateway can be located on an HMI,
destination PC, or the local PC, making it possible to connect to a device that
has no unique nodename but resides in a subnet behind an EcoStruxure
Machine Expert network.
90 EIO0000002854.04
Common Device Editor Dialogs
The graphic shows an example that allows a connection from the PC to the target
controller 3 (item 4 in the graphic) by using the address of hop PC2 (item 5 in the
graphic) that must have an EcoStruxure Machine Expert gateway installed.
1 Hop PC 1
2 Target controller 1: MyNotUniqueNodename
3 Target controller 2: MyNotUniqueNodename
4 Target controller 3: MyNotUniqueNodename
5 Hop PC 2
6 PC / HMI
7 Router
8 Ethernet
To verify whether the connection to a specific controller can be established, enter
the Gateway Address/Port, and click the Test button. If the controller sends a
response to the network scan, an entry for this controller is added to the list of
controllers. This entry is marked by the icon GAT being displayed in the first
column.
To scan a specific gateway for available controllers, enter the Gateway Address/
Port, and click the refresh button right to the Gateway Address/Port text field.
The controllers that send a response to the gateway scan are listed in the list of
controllers. Each of these entries is marked by the icon GAT being displayed in
the first column. To fill the list with more detailed information, right-click a controller
entry and execute the command Refresh this controller. If the controller
supports this function, further information on the controller is added to the list.
Consult the Programming Guide specific to your controller.
1 Refresh button
2 GAT icon
EIO0000002854.04 91
Common Device Editor Dialogs
The gateway that is scanned can be located on a PC or on an HMI that can reside
in the local or in a remote subnet. In the following example, the bridge target
controller 1 and target controller 2 are scanned.
1 Local subnet
2 Remote subnet
3 Target controller 1
4 Target controller 2
5 Gateway
6 PC
7 Ethernet
You can connect to the listed devices using the gateway.
1 PC / HMI
2 PC / HMI / devices with installed EcoStruxure Machine Expert gateway
3 Target device
Example: Gateway Address/Port: 10.128.156.28/1217Target IP Address:
10.128.156.222
92 EIO0000002854.04
Common Device Editor Dialogs
1 Hop PC 1
2 Target controller 1: 10.128.156.20
3 Target controller 2: 10.128.156.20
4 Target controller 3: 10.128.156.20
5 Hop PC 2
6 PC
7 Router
8 Ethernet
To verify whether the connection to a specific controller can be established, enter
the Gateway Address/Port, and click the Test button. If the controller sends a
response to the network scan, an entry for this controller is added to the list of
controllers. This entry is marked by the icon GAT being displayed in the first
column.
To scan a specific gateway for available controllers, enter the Gateway Address/
Port, and click the refresh button right to the Gateway Address/Port text field.
The controllers that send a response to the gateway scan are listed in the list of
controllers. Each of these entries is marked by the icon GAT being displayed in
the first column. To fill the list with more detailed information, right-click a controller
entry and execute the command Refresh this controller. If the controller
supports this function, further information on the controller is added to the list.
Consult the Programming Guide specific to your controller.
EIO0000002854.04 93
Common Device Editor Dialogs
1 Refresh button
2 GAT icon
The gateway that is scanned can be located on a PC or on an HMI that can reside
in the local or in a remote subnet. In the following example, the bridge target
controller 1 and target controller 2 are scanned.
1 Local subnet
2 Remote subnet
3 Target controller 1
4 Target controller 2
5 Gateway
6 PC
7 Ethernet
You can connect to the listed devices using the gateway.
94 EIO0000002854.04
Common Device Editor Dialogs
1 PC
2 PC / MODEM
3 Target modem
4 Target device
5 Phone line
To establish a connection to the modem, click the MODEM > Connect button. In
the Modem Configuration dialog box, enter the Phone number of the target
modem and configure the communication settings. Click OK to confirm and to
establish a connection to the modem.
If the EcoStruxure Machine Expert gateway is stopped and restarted, any
connection of the local gateway is terminated. EcoStruxure Machine Expert
displays a message that has to be confirmed before the restart process is started.
After the connection to the modem has been established successfully, the
MODEM button changes from Connect to Disconnect. The list of controllers is
cleared and refreshed scanning the modem connection for connected controllers.
You can double-click an item from the list of controllers or enter a nodename in the
Target Nodename: box to connect to a specific controller.
Click the MODEM > Disconnect button to terminate the modem connection and
to stop and restart the EcoStruxure Machine Expert gateway. The list of controllers
is cleared and refreshed scanning the Ethernet network.
EIO0000002854.04 95
Common Device Editor Dialogs
The Communication Settings tab in simple mode contains an illustration of the programming device, the
present gateway, and the target device with the connection status.
Select a gateway and a target device in the selection fields. The list entries you
can select are determined by the Manage gateways and Manage favorite
devices parameters.
You can enter the target device in different ways:
• By the IP address, for example 192.168.101.109
• By the device address, for example [056D]
• By the device name, for example MyDevice
NOTE: To search for a device via the device name, unique device names are
required within the network.
A status bullet at the right bottom of the gateway symbol indicates the
communication status:
Color Description
96 EIO0000002854.04
Common Device Editor Dialogs
Element Description
Scan network... button Opens the Select Device dialog box that lists
the configured gateways and their associated
devices.
Gateway list –
Add new gateway... Opens the Gateway dialog box for adding a
new gateway (see EcoStruxure Machine Expert,
Menu Commands, Online Help).
Device list –
Add current device Adds the defined device to the list of favorite
to favorites devices.
Manage favorite Opens a dialog box showing the list of favorite
devices... devices. In this dialog box, you can add or
remove devices or change the order of the
entries. The device at top of the list defines the
default device.
Rename active Opens a dialog box for renaming the device.
device...
Wink active device The connected controller flashes during login.
EIO0000002854.04 97
Common Device Editor Dialogs
Element Description
Element Description
Communication
Current Policy Displays the selected policy for the encryption
of communication.
New Policy Contains a list to select for the new policy for
encryption:
• No encryption. The controller does not
support encrypted communication.
• Optional encryption: The controller
supports encrypted and unencrypted
communication.
• Enforced encryption: The controller
supports encrypted communication only.
New Policy Contains a list to select for the new policy for
user management:
• Optional user management: The user
management on the device is disabled or
can be disabled manually.
• Enforced user management: The user
management on the device is enabled
and cannot be disabled manually.
98 EIO0000002854.04
Common Device Editor Dialogs
The Communication Settings tab in classic mode provides a tree structure to configure the parameters:
Color Description
EIO0000002854.04 99
Common Device Editor Dialogs
The device nodes consist of a symbol followed by the node name and the node
address. In the right part of the window, the respective Device Name, Device
Address, Number of Channels, Target ID, Target Name, Target Type, Target
Vendor, and Target Version are shown.
In the Select the network path to the controller field, the gateway channel is
specified automatically by selecting the channel in the tree structure.
NOTE: The parameter Number of Channels displays the number of channels
that is supported by the selected controller. You cannot monitor online the
number of channels that are being used.
A channel is a connection to a client (such as Diagnostics, Logic Builder,
WebVisu, OPC, HMI). Depending on the communication service, a client may
occupy more than one channel for a short time. When all channels supported
by the controller are being used, Logic Builder displays the message
Connection denied by device: All available communication channels are
already in use.
Set active path This command sets the selected communication channel as
the active path to the controller. See the description of the Set
Active Path command. Double-clicking the node in the tree
structure has the same effect.
Add gateway... This command opens the Gateway dialog box where you can
define a gateway to be added to the configuration.
Add device... This command opens the Add Device dialog box where you
can manually define a device to be added to the selected
gateway entry (Consider the Scan network functionality).
Edit Gateway... This command opens the Gateway dialog box for editing the
settings of the selected gateway.
Delete selected Device This command removes the selected device from the
configuration tree.
Scan for device by address This command scans the network for devices which have the
address specified here in the configuration tree. Those which
100 EIO0000002854.04
Common Device Editor Dialogs
Scan for device by name This command scans the network for devices which have the
names specified here in the configuration tree (case-sensitive
search). Those which are found will then be represented in the
gateway with the specified name and their unique node
address. The scan refers to devices below that gateway under
which an entry is selected.
Scan for device by IP address This command scans the network for devices which have the
IP address specified here in the configuration tree. Those
which are found will then be represented in the gateway with
the specified node address and their name. The scan refers to
devices below that gateway under which an entry is selected.
Send echo service EcoStruxure Machine Expert implements the echo service that
is similar to the ping tool.
Configure the local gateway This command opens a dialog box for the configuration of a
local gateway and therefore provides an alternative to manual
editing the file Gateway.cfg.
Scan network This command starts a search for available devices in your
local network. The configuration tree of the concerned
gateway will be updated accordingly.
Option Description
Don't store communication Activate this option if the network path definition should not be
settings in project stored in the project, but in the local option settings on your
computer. Therefore, the path setting is restored if the project
is reopened on the same computer. It will have to be redefined
if the project is used on another system.
Confirmed online mode Activate this option if the user should be prompted for
confirmation when selecting one of the following online
commands: Force values, Multiple download, Release
force list, Single cycle, Start, Stop, Write values.
EIO0000002854.04 101
Common Device Editor Dialogs
Configuration
Overview
The Configuration view is only available in the device editor if the option Show
generic device configuration views in the Tools > Options > Device editor
dialog box is activated. The Configuration view shows the device-specific
parameters, and, if allowed by the device description, provides the possibility to
edit the parameter values.
Configuration view of the device editor
Element Description
Parameters
Overview
The Parameters view displays the controller-specific parameters in a table. You
can edit the Value of those parameters that are defined as editable in the device
description. This function is not available for all supported controllers. Consult the
Programming Guide specific to your controller for further information.
The view contains the following elements:
102 EIO0000002854.04
Common Device Editor Dialogs
Element Description
Default Value Indicates the default parameter value as defined in the device
description, not editable
Unit Indicates the unit of the parameter value (for example: ms for
milliseconds), not editable.
Applications
Overview
The Applications view of the device editor serves to scan and to remove
applications on the controller. Information on the content of the application can be
available as well as some details on the application properties.
Element Description
Applications on the PLC This text box lists the names of applications which have been
found on the controller during the last scan (by clicking
Refresh List).
Content If, in the View > Properties > Application build options, the
option Download Application Info is activated for the
application object (see EcoStruxure Machine Expert, Menu
Commands, Online Help), then additional information on the
content of the application is loaded to the controller.
Refresh List Click this button to scan the controller for applications. The list
will be updated accordingly.
EIO0000002854.04 103
Common Device Editor Dialogs
Synchronized Files
Overview
The Synchronized Files view of the device editor lists the files that are
downloaded to the controller when the application is downloaded:
• External files, for example, that were added to an application.
• Implicit files, such as the source code archive file, are displayed only in this
view if the time of download is configured and the option Show implicit files
for application download on the editor of a PLC is selected in the Tools >
Options > Device Editor dialog box (see EcoStruxure Machine Expert,
Menu Commands, Online Help).
This function is not available for all supported controllers. Consult the
Programming Guide specific to your controller for details on this function.
File name Name of the file below the application, or direct archive.prj
name of the implicitly transferred file (for
example, archive.prj).
Time interval Time interval for updating the file on the After download /
controller. online change of the
application.
104 EIO0000002854.04
Common Device Editor Dialogs
Files
Overview
The Files view of the device editor serves to transfer files between the host and
the controller. You can choose any file from a directory of the local network to copy
it to the file directory of the currently connected runtime system, or vice versa.
This view is divided in two parts:
• The left part shows the files on the Host.
• The right part shows the files on the Runtime system.
Element Description
Location Specifies the folder of the respective file system that will be
used for the file transfer.
Select an entry from the list or browse in the file system tree.
For the directories in the file trees there are the following variants:
Element Description
EIO0000002854.04 105
Common Device Editor Dialogs
1 Select the files to be copied in the file Multiple selection is possible. You can
system tree. even select a folder in order to copy the
files contained within.
2 Click the button >> or << to transfer the To transfer in this context means to copy.
selected files to the directory set in the So, if a file is not yet available in the
runtime system. runtime directory, it will be created there.
However, if it already exists, it will be
overwritten.
Log
Overview
The Log view of the device editor is used to display the events which have been
logged on the runtime system of the controller.
This concerns:
• Events at system start or shutdown (loaded components and their versions)
• Application download and boot project download
• Customer-specific entries
• Log entries of I/O drivers
• Log entries of the data server
Element Description
106 EIO0000002854.04
Common Device Editor Dialogs
Element Description
UTC Time Activate this option to display the time stamp of the
runtime system as it is (without conversion). If
deactivated, the time stamp of the local time of the
computer is displayed (according to the time zone of
the operating system).
NOTE: In order to display the time stamp in UTC
(Universal Time Coordinated), you must set the
time of the controller to UTC time beforehand
(also refer to the Services tab of your controller
configuration).
Troubleshooting
In case an error is detected and displays the text *SOURCEPOSITION*, you can
open the function by double-clicking or by executing the command Show source
code in editor from the contextual menu. The cursor marks the relevant position.
You can also use the project archive including the Download information files
and the exported log file for diagnostics. In case of protected functions, the
message The source code is not available for <function name> is displayed.
PLC Settings
Overview
The PLC settings view of the device editor is used to configure general settings
for the controller.
Element Description
Application for I/O handling Define here the application assigned to the device in the
Devices tree that will be monitored for the I/O handling. For
EcoStruxure Machine Expert, there is only one application
available.
PLC settings area
Update IO while in stop Note for PacDrive controllers: Supported by TM5 / TM7 IOs
but not by controls or drive based IOs.
EIO0000002854.04 107
Common Device Editor Dialogs
Element Description
Always update variables Global definition, if the I/O variables are updated in the bus
cycle task. This setting takes effect for the I/O variables of the
slaves and modules only if their update setting is defined as
Disabled.
• Disabled (update only if used in a task): The I/O
variables are only updated if they are used in a task.
• Enabled 1 (use bus cycle task if not used in any
task): The I/O variables are updated in the bus cycle
task if not used in any other task.
• Enabled 2 (always in bus cycle task): The variables
are updated in every cycle of bus cycle task, regardless
of whether they are being used or whether they are
mapped to an input or to an output channel.
You can set this option separately for each device in the I/O
Mapping dialog, page 128.
Bus cycle task The selection list offers the tasks defined in the Task
Configuration of the active application (for example, MAST).
The default setting MAST is entered automatically.
NOTE: Setting the bus cycle task to <unspecified> may cause unintended
behavior of your application. Consult the Programming Guide specific to your
controller.
WARNING
UNINTENDED EQUIPMENT OPERATION
Do not set the Bus cycle task to <unspecified>, unless you understand the
bus cycle task settings of the controller.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
108 EIO0000002854.04
Common Device Editor Dialogs
Additional Settings
Element Description
Generate force variables for IO This setting is only available if supported by the device.
mapping: Consult the Programming Guide specific to your controller for
further information.
Enable diagnosis for device The library CAA Device Diagnosis is added to the project
automatically. For each device, a function block is generated
in the Applications tree. If the function block already exists,
an extended FB is used (for example, EtherCAT) or an
additional function block instance is added. This function block
contains the general implementation for the device
diagnostics. By use of these function block instances, the
status of the devices can be retrieved in the application.
Furthermore, detected errors can be evaluated. The library
also provides functions for the programmatical evaluation of
the Devices tree (for example, search in child devices or jump
to the parent device). For detailed information, see the PDF
document CAA Device Diagnosis which is part of the library.
Show I/O warnings as errors Warnings concerning the I/O configuration are detected as
errors.
IEC Objects
Overview
The IEC Objects view of the device editor lists objects that allow access to the
device from the application. In online mode, it serves as monitoring view.
If a function block instance has been created implicitly for a device, at least this
instance is listed as an object in the table. This instance can be used, for example,
to restart a bus or to poll information from the application. It depends on the device
whether this kind of device instance is available and which access options are
provided. Consult the Programming Guide specific to your controller for details.
The table also contains instances of function blocks that are linked to inputs or
outputs of the device. The mapping of a function block to a channel is defined in
the I/O Mapping view, page 124. This view contains the Go to Instance button
that provides a direct link to the corresponding object in this IEC Objects
table.
You can add objects to this table that are not yet linked with a device channel.
In online mode, you can use the IEC Objects table as a monitoring view. It
indicates the value, the address and the comment for the function block variable at
the channel. It also allows you to write and force values.
EIO0000002854.04 109
Common Device Editor Dialogs
Element Description
Edit
Deletes the selected entry.
Delete
Provides a direct link from the selected entry to
Go to Instance the corresponding mapping in the I/O Mapping
view, page 124.
110 EIO0000002854.04
Common Device Editor Dialogs
EIO0000002854.04 111
Common Device Editor Dialogs
If you want to protect your entire project, activate the option Enable project
file encryption in the Project Settings > Security dialog box (see
EcoStruxure Machine Expert, Menu Commands, Online Help).
If you want to protect only a part of your code inside the project, put this code
inside a compiled library (see EcoStruxure Machine Expert, Menu
Commands, Online Help).
CAUTION
UNAUTHENTICATED, UNAUTHORIZED ACCESS
• Do not expose controllers and controller networks to public networks and the
Internet as much as possible.
• Use additional security layers like VPN for remote access and install firewall
mechanisms.
• Restrict access to authorized people.
• Change default passwords at start-up and modify them frequently.
• Validate the effectiveness of these measures regularly and frequently.
Failure to follow these instructions can result in injury or equipment
damage.
112 EIO0000002854.04
Common Device Editor Dialogs
Element Description
The Import from disk is available when you are in offline mode or
Synchronization is deactivated.
Export to disk When you click the Export to disk button, an Enter Password dialog
box opens requesting you to enter a password for the device user
management file.
NOTE: The password assigned here will be requested during the
Import from disk procedure.
After you have assigned a password, the dialog box for saving a file is
displayed. With EcoStruxure Machine Expert V2.0 and later versions,
only files of type *.dum2 are supported.
Device user Name of the user who is logged into the controller.
EIO0000002854.04 113
Common Device Editor Dialogs
Element Description
The tree structure on the left-hand side lists the defined users and indicates the user groups to
which they are assigned as sub nodes.
Add button Opens the Add User dialog box for creating a new user account.
Import button Opens the Import Users dialog box. It lists the user accounts defined
in the project user management.
Select the entries of your choice (by pressing the Shift key for
selecting more than one) and click OK to import them in the device
user management.
NOTE: For each user to be imported the Enter Password dialog
box is displayed requesting you to enter the password of the
project user account. This password will then also be used for the
corresponding device user account.
Edit button Opens the Edit User <user name> dialog box. It allows you to modify
the settings of the user account.
114 EIO0000002854.04
Common Device Editor Dialogs
Element Description
The tree structure on the left-hand side lists the defined groups and indicates the assigned users as
sub nodes.
Add button Opens the Add Group dialog box for creating a new user group.
1. Enter a name for the group.
2. From the list of users, select the users to assign to the new
group.
3. Click the OK button to confirm and the new group will be
displayed in the tree structure.
Import button Opens the Import Groups dialog box. It displays the user groups
defined in the project user management.
Select the group entries of your choice and click OK to import them in
the device user management.
NOTE: The default group Everyone cannot be imported in the
device user management.
NOTE: After you have successfully imported a group, assign
access rights either:
• By adding the new group to an existing group, or
• By explicitly assigning access rights to the new group.
For further information, refer to Access Rights, page 117.
Edit button Opens the Edit Group <group name> dialog box. It allows you to
modify the definition of the group.
Editing or Viewing the Users and Groups Management Before any Users
and Groups Have Been Established
If the controller supports device Users and Groups management, proceed as
follows during first login:
1 Double-click the controller node in the Devices Result: The device editor opens.
tree.
2 Select the Users and Groups view. –
4 Click Yes to confirm the dialog box and to Result: The Device user login
activate device Users and Groups dialog box opens.
management.
EIO0000002854.04 115
Common Device Editor Dialogs
1 Double-click the controller node in the Devices Result: The device editor opens.
tree.
2 Select the Users and Groups view. –
4 Click the Add button in the Users part of the Result: The Add User dialog box
Users and Groups view. opens.
5 Enter a Name for the new user and select a You can assign the user to other
Default group for the user from the list. groups later.
7 Click OK to confirm and to close the Add User Result: The new user is displayed
dialog box. in the Users part as a new node
and in the Groups part as a new
subnode of the selected default
group.
Loading a Users and Groups Management From a *.dum File, Modifying it,
and Later Downloading it to the Controller
Step Action Comment
1 Double-click the controller node in the Devices Result: The device editor opens.
tree.
2 Select the Users and Groups view. –
3 Click the Edit button, browse to the *.dum file Result: The users and groups
that contains the saved Users and Groups settings that are saved in the file are
management, and click Open to confirm. displayed in the editor.
6 Select the option Download the editor content Result: The Device user login
to the device and overwrite the user dialog box is displayed.
management there.
7 Enter login data in order to log in to the controller. After successful login, the
modifications are transferred to the
controller.
button is activated,
modifications made in the editor are
automatically transferred to the
controller.
116 EIO0000002854.04
Common Device Editor Dialogs
Access Rights
Overview
In the Access Rights view of the device editor, define the device access rights of
device users to objects in the controller.
In order for the Access Rights view to be available in the device editor of
controllers, activate the Show access rights page option in the Tools > Options
> Device Editor dialog box (see EcoStruxure Machine Expert, Menu Commands,
Online Help). Furthermore, Users and Groups management must be set up in
the controller.
Example of an Access Rights view of the device editor
1 Double-click the controller node in the Devices Result: The device editor opens.
tree.
2 Select the Access Rights view. –
EIO0000002854.04 117
Common Device Editor Dialogs
4 In the Objects tree structure on the left-hand Result: In the Rights area on the
side, select the object. right-hand side, the access rights of
the selected object are displayed in
a table for the configured user
groups.
5 In the Rights table, double-click the access right If the selected object has child
you want to modify. objects, a dialog box is displayed,
prompting you whether you want to
modify the access rights for the
child objects at the same time.
6 Click Yes or No to modify the access rights of the Result: The access rights are
child objects and to close the dialog box. switched from allowed to not
allowed or vice versa.
Element Description
Save to disk When you click the Save to disk button in the Access Rights view,
the file type is by default set to Device rights management files (*.drm).
For this file, a password does not have to be assigned before saving.
Device user Name of the user who is logged into the controller.
Objects Area
In the Objects tree structure on the left-hand side, the objects are listed that allow
actions to be executed in runtime mode. The objects are assigned by their object
source. They are partially sorted in object groups. In the Rights area on the right-
hand side, you can configure the access options of the selected object for a user
group.
118 EIO0000002854.04
Common Device Editor Dialogs
On the top level of the Objects tree structure there are two object categories
grouped in folders:
• Runtime objects
• File system objects
Indented below the object categories, there are further subnodes. The subnode
Device, for example, can, in turn, have the following subnodes:
• Logger
• PlcLogic
• Settings
• UserManagement
A description of the objects is provided in the paragraph Overview of the Objects,
page 120.
Rights Area
In general, access rights are inherited from the root node (Device or / ) to the
subnodes. If a permission of a user group is denied or explicitly granted to a
parent object, then this is also applied to the child objects.
In the Rights area on the right-hand side, the access rights of the selected object
are displayed in a table. For every user group, it displays the rights configured for
the possible actions on the selected object.
The following actions can be configured for the object:
• Add/Remove
• Modify
• View
• Execute
The symbols represent the access rights:
Icon Description
The access right has been inherited from the parent object.
Access has not been permitted or denied explicitly, even for the parent
object. No access is possible
Example
The Logger node in the Access Rights tab is created by the logger component
and controls its access rights. It is located directly below the Runtime objects >
Device node.
For this object, you can only grant View access rights.
By default, each object is assigned read access. Thus, every user can read the
logger of a controller.
EIO0000002854.04 119
Common Device Editor Dialogs
To deny this access right for a single user group (Service, for example), set the
View right for the Logger object to .
Object Description
FTP Allows you to configure the access rights to the FTP server on the
controller.
OPC Allows you to configure the access rights to the controller via OPC UA.
USB Allows you to configure the access rights to files on a USB storage
device connected to the controller.
USBExecCmd Allows you to configure the access rights for executing scripts located
on a USB storage device connected to the controller.
WEB Allows you to configure the access rights to the webserver on the
controller.
120 EIO0000002854.04
Common Device Editor Dialogs
Login – – – X
Create X – – –
Delete X – – –
Download / online X – – –
change
Create boot X – – –
application
Read variable – – – X
Write variable – – X X
Force variable – – X X
Set and delete – X X –
breakpoint
Start / Stop – X – –
Reset – X – –
Restore retain – X – –
variables
Save retain variables – – – X
(X) The access right must be set explicitly.
Symbol Rights
Overview
The Symbol Rights view of the device editor is used to configure the access
rights of different user groups (clients) to the individual symbol sets, page 432
available on the controller.
The following prerequisites must be fulfilled:
• User management must be enabled and configured on the controller.
• An application has been downloaded to the controller for which symbol sets
were defined in the EcoStruxure Machine Expert project.
• You have the required login data to gain access to the controller.
EIO0000002854.04 121
Common Device Editor Dialogs
View Description
Symbol Sets The Application node contains the symbol sets whose
definition was downloaded with the application to the
controller.
Rights The table contains the user groups defined in the user
management of the controller.
• : Access granted.
Click the Save to disk button to save the access configuration to an XML file of
type Device symbol management with the extension *.dsm.
Click the Load from disk button to load a *.dsm file from the hard drive.
Task Deployment
Overview
The Task deployment view of the device editor shows a table with inputs/outputs
and their assignment to the defined tasks. Before the information can be
displayed, the project has to be compiled and the code has to be generated. This
information helps in troubleshooting in case that the same input/output is updated
in different tasks with different priorities.
Task deployment of the device editor
Files Log PLC settings Users and Groups Access Rights Licenses Task deployment Statu
I/O deployment for tasks:
I/O channels Main Task (0) Bus Task (1)
BK5120
usiBK5120Out AT %QB0
usiBK5120In AT %IB0
Generic_XN_16DO
usiGenericOut1 AT %QB1
usiGenericOut2 AT %QB2
Generic_XN_16DI
usiGenericIn1 AT %IB1
usiGenericIn2 AT %IB2
Osicoder
udiOsicoderIn AT %ID1
ILB_CO_24_DI16_DO16
PhoenixOut1 AT %QB3
%QB4
%IB8
= Bus cycle task
The table shows the tasks sorted by their task priority. Click the column heading
(Main Task) to display only the variables assigned to this task. To show all
variables again, click the first column (I/O channels).
To open the I/O mapping table of a channel, double-click the input or output.
A blue arrow indicates the task of the bus cycle.
In the example above, the variable usiBK5120Out AT %QB0 is used in 2 different
tasks. In this situation, the output, set by one task, can be overwritten by the other
task: this can lead to an undefined value. Writing output references in more than
one task makes the program difficult to debug and may lead to unintended results
in the operation of your machine or process.
122 EIO0000002854.04
Common Device Editor Dialogs
WARNING
UNINTENDED EQUIPMENT OPERATION
Do not write to an output variable in more than one task.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Status
Overview
The Status view of the device editor shows status information (for example,
Running, Stopped) and specific diagnostic messages from the device; also on
the card and the internal bus system.
Information
Overview
The Information view of the device editor shows some general information on the
device selected in the Devices tree: Name, Vendor, Type, Version number,
Order Number, Description, Image.
Emulation Settings
Overview
The Emulation Settings view of the device editor is available for PacDrive LMC
Pro2 controllers. It is used to configure the emulation via EcoStruxure Machine
Expert Twin and the communication between EcoStruxure Machine Expert
Twin and the controller.
For further information, refer to the EcoStruxure Machine Expert Lexium™ MC
multi carrier Configuration Guide.
EIO0000002854.04 123
Common Device Editor Dialogs
I/O Mapping
I/O Mapping
Overview
The I/O Mapping view of the device editor is named <devicetype> I/O Mapping
(for example, PROFIBUS DP I/O Mapping). It serves to configure an I/O mapping
of the controller. Therefore, project variables used by the application are assigned
to the input, output, and memory addresses of the controller.
Define the application which should handle the I/Os in the PLC settings view,
page 107.
See the following chapters:
• Working with the I/O Mapping Dialog, page 127
• I/O Mapping in Online Mode, page 131
• Implicit Variables for Forcing I/Os, page 132
124 EIO0000002854.04
Common Device Editor Dialogs
EIO0000002854.04 125
Common Device Editor Dialogs
Element Description
Mapping area
Module-wise Select this option to create a variable for each module, not for
the individual bits.
Naming Rule area
126 EIO0000002854.04
Common Device Editor Dialogs
Element Description
Type Data type of the input or output channel, for example: BOOL
If the data type is not standard, but a structure or bit field defined in the
device description, it will be listed only if it is part of the IEC 61131–3
standard. It is indicated as IEC type in the device description.
Otherwise, the entry of the table will be empty.
Default value This column is only available if the option Set all outputs to default is
selected for the parameter Behaviour for outputs in Stop in the PLC
Settings view of the device editor, page 107.
Default value that is assigned to the channel when the controller is set
to STOP mode.
You can edit this field only if you are mapping to a new created
variable or if no mapping is specified. When you are mapping to an
existing variable, the initialization value of the variable is used as the
default value.
NOTE: In case a “new” variable and an “existing” variable (by
using the AT declaration) are mapped to the same output, the
initialization value of the “existing” variable is used as default
value.
Unit Unit of the parameter value, for example: ms for milliseconds
EIO0000002854.04 127
Common Device Editor Dialogs
NOTE: Inputs and outputs that are not used in the application are not read by
the controller in online mode. To indicate that these inputs and outputs are not
used, they are marked with a gray background. Any values that might appear
in these gray lines are invalid.
WARNING
UNINTENDED EQUIPMENT OPERATION
Do not map other user variables in the I/O Mapping tab if you are using libraries
for fieldbus communications that are reading/writing from/to direct addresses (%
I, %Q).
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Consult the documentation of your fieldbus library to see if direct addresses are
used.
If you want to revert the modification of the value, reopen the address edit field,
delete the address entry, and close with Enter. The address and the identified
succeeding addresses will be set back to the values they had before the manual
modification. The M symbol will be removed.
128 EIO0000002854.04
Common Device Editor Dialogs
• When mapping structured variables to outputs, the editor will prevent that
both the structure variable (for example, on %QB0) and particular structure
elements (for example, in this case on %QB0.1 and QB0.2 ) can be entered.
This means: When there is a main output entry with a subtree of bit channel
entries in the mapping table, then either in the line of the main entry a variable
can be entered or in those of the subelements (bit channels) never in both.
• For mapping on an existing variable, specify the complete path. For example:
<application name>.<pou path>.<variable name>';
Example: app1.plc_prg.ivar
For this purpose, it can be helpful to open the input assistant via the ... button.
In the Mapping column, the symbol will be displayed and the address
value will be crossed out. This does not mean that this memory address does
not exist any longer. However, it is not used directly because the value of the
existing variable is managed on another memory location, and, especially in
case of outputs, no other already existing variable should be stored to this
address (%Qxx in the I/O mapping) in order to avoid ambiguities during writing
the values.
See in the following example an output mapping on the existing variable xBool_
4:
NOTE: When you are mapping to an existing variable, the initialization value
of the variable is used as the default value. You can edit the Default value
field only if you are mapping to a new created variable or if no mapping is
specified.
• If you want to define a new variable, enter the desired variable name.
Example: bVar1
In this case, the symbol will be inserted in the Mapping column and the
variable will be internally declared as a global variable. From here, the
variable will be available globally within the application. The mapping dialog
box is another place for the declaration of global variables.
NOTE: Alternatively, an address can also be read or written within a
program code, such as in ST (structured text).
• Considering the possibility of changes in the device configuration, do the
mappings within the device configuration dialog box.
NOTE: If a UNION is represented by I/O channels in the mapping dialog box,
it depends on the device whether the root element is mappable or not.
If a declared variable of a given data type is larger than that to which it is being
mapped, the value of the variable being mapped will be assigned a truncated to
the size of the mapped target variable.
For example, if the variable is declared as a WORD data type, and it is mapped to
a BYTE, only 8 bits of the word will be mapped to the byte.
This implies that, for the monitoring of the value in the mapping dialog box, the
value displayed at the root element of the address will be the value of the declared
variable - as currently valid in the project. In the subelements below the root, the
particular element values of the mapped variable will be monitored. However, only
part of the declared value may be displayed among the subelements.
A further implication is when you map a declared variable to physical outputs.
Likewise, if you map a data type that is larger than the output data type, the output
data type may receive a truncated value such that it may affect your application in
unintended ways.
EIO0000002854.04 129
Common Device Editor Dialogs
WARNING
UNINTENDED EQUIPMENT OPERATION
Verify that the declared data type that is being mapped to physical I/O is
compatible with the intended operation of your machine.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Element Description
Reset mapping Click this button to reset the mapping settings to the
defaults defined by the device description file.
Always update variables Definition if the I/O variables are updated in the bus
cycle task, page 107. The default value is defined in
the device description.
• Use parent device settings: Update according
to the settings of the parent device.
• Enabled 1 (use bus cycle task if not used in
any task): The I/O variables are updated in the
bus cycle task if not used in another task.
• Enabled 2 (always in bus cycle task): The
variables are updated in every cycle of bus cycle
task, regardless of whether they are being used
or whether they are mapped to an input or to an
output channel.
WARNING
UNINTENDED EQUIPMENT OPERATION
Do not write to an output variable in more than one task.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
130 EIO0000002854.04
Common Device Editor Dialogs
Procedure
To map a device and a function block instance, proceed as follows:
EIO0000002854.04 131
Common Device Editor Dialogs
DWORD variable is mapped to this address, then in the root line, as well as in the
bit channel lines indented below, the respective values will be monitored.
Basically, the field in the root line stays empty if the value is composed of multiple
subelements.
Example
If the mapping is completed as shown in figure I/O Mapping tab of the device
editor, page 127, then at a build (F11) of the application, the following variables
are generated and available in the input assistant:
• Digitax_ST_Control_word_QW0_Force : BOOL;
• Digitax_ST_Control_word_QW0_Value : UINT;
• Digitax_ST_Target_position_QD1_Force : BOOL;
• Digitax_ST_Target_position_QD1_Value : DINT;
• Digitax_ST_Status_word_IW0_Force : BOOL;
• Digitax_ST_Status_word_IW0_Value : UINT;
• Digitax_ST_Position_actual_value_ID1_Force : BOOL;
• Digitax_ST_Position_actual_value ID1_Value : DINT;
Restrictions
• Only channels which are mapped on a variable in the I/O Mapping tab (i.e., a
variable has to be defined in the Variable column, no matter whether it is a
new or an existing one) can be forced by the above described implicit
variables.
• Unused inputs / outputs as well as those which are mapped via AT
declaration in an application program cannot be forced.
• The respective I/O channels have to be used in at least one task.
132 EIO0000002854.04
Common Device Editor Dialogs
• Forced I/Os are not indicated in the monitoring (watch view, I/O mapping
dialog box). The value is only used implicitly in the I/O driver for writing onto
the device.
• Forced inputs are displayed correctly by the red force symbol (F), not
however, forced inputs/outputs.
Element Description
Find Text field for entering function block name to search for.
Type Function blocks in the tree structure that match the channel type. The
following nodes are available: application, library name(s).
Documentation Displays the documentation available for the library or the function block of the
library selected in the tree structure.
EIO0000002854.04 133
Cybersecurity
What’s in This Part
General Information...................................................................................... 135
Digital Signature Verification ......................................................................... 136
Connecting to the Controller.......................................................................... 138
Logoff Current Device User ........................................................................... 139
Security for the Project and the Application..................................................... 140
Security for the Runtime System / Controller................................................... 142
Visualization ................................................................................................ 145
FAQ ............................................................................................................ 146
Overview
Cybersecurity best practices and solutions are in constant evolution as a function
of the latest information available. As a design criteria, Schneider Electric
incorporates up-to-date knowledge and techniques to help make products more
resilient to cyberattacks. The security by design approach results in the
implementation of mechanisms to mitigate threats, reduce exploitable
weaknesses, and defend against avoidable data breaches and cyberattacks.
NOTE:
To help keep your Schneider Electric products secure and protected, it is in
your best interest that you implement the cybersecurity best practices as
indicated in the Cybersecurity Best Practices document provided on the
Schneider Electric website.
Due to the rapid rise of networking machines and plants, potential threats are also
quickly rising. Therefore, you must carefully consider all possible security
measures.
Security measures are necessary to help protect data and communication
channels from unauthorized access.
For general information about cybersecurity topics related to Schneider Electric
products, refer to the Cybersecurity Guidelines for Machine Solutions.
This part provides information about the cybersecurity mechanisms provided by
EcoStruxure Machine Expert and the controllers.
134 EIO0000002854.04
General Information
General Information
What’s in This Chapter
Access Protection with Device User Management ......................................... 135
Firewall Settings.......................................................................................... 135
Using Certificates ........................................................................................ 135
Firewall Settings
Firewall Settings on the Controller for Communication Services
Most of the communication services like FTP or OPC UA access the controller by
using the settings of the user rights management. Therefore, make sure that the
firewall settings on the controller allow the services to access the controller file
system. For further information, refer to “How to Configure the Firewall...” for your
specific controller.
Using Certificates
Overview
A certificate is a digital representation of information which contains the following:
• Identifies the certification authority issuing it.
• Names or identifies the subscriber.
• Contains the public key of the subscriber.
• Identifies its operational period.
• Is digitally signed by the certification authority issuing it.
Optionally, a certificate can be created for a specific usage. For example, you
cannot use a controller certificate for protecting a project and vice versa.
The certificate consists of two parts / files:
• Public X.509 certificate (can be issued to anyone).
• Private key that matches the certificate or its public key only (must be kept
secret).
EIO0000002854.04 135
Digital Signature Verification
Verification Level
The following verification levels are defined and can be configured via command
line argument:
Error (default) The dialog box Integrity Verification is The error message is written to the standard
displayed (blocking start-up of your console, such as Logic Builder Shell.
software).
The process is terminated.
You have the choice to continue or
terminate the process.
Warning A notification is displayed via status bar and A notification is written to the standard
is documented in the log file of your console, such as Logic Builder Shell.
software.
The process continues.
The process continues.
Silent The notification is only documented in the The notification is only documented in the
log file of your software. log file of your software.
The verification level is applied per process and is not set globally. Once the
verification level is set, it cannot be changed for a running software process.
Use the command line argument
"--SignatureVerificationWarningLevel=[Error|Warning|Silent]"
to configure the verification level for the running process.
To specify the verification level argument, run your software from console or adapt
the Start menu shortcut.
136 EIO0000002854.04
Digital Signature Verification
EIO0000002854.04 137
Connecting to the Controller
Step Action
4 Click OK to confirm.
Result: You are requested to enter the new credentials for accessing the controller.
138 EIO0000002854.04
Logoff Current Device User
EIO0000002854.04 139
Security for the Project and the Application
140 EIO0000002854.04
Security for the Project and the Application
EIO0000002854.04 141
Security for the Runtime System / Controller
Encrypting Communication
Overview
Communication with the controller connected in the project should be protected
against unauthorized access.
142 EIO0000002854.04
Security for the Runtime System / Controller
EIO0000002854.04 143
Security for the Runtime System / Controller
Including Device User Rights While Cloning the USB Memory Key
The Modicon M258 Logic Controller, and the Modicon LMC058 Motion Controller
provide a clone function that allows you to write the image of the controller to a
USB memory key. Consult the Programming Guide specific to your controller.
144 EIO0000002854.04
Visualization
Visualization
What’s in This Chapter
Visualization ............................................................................................... 145
Visualization
User Management
Visualizations can be protected as described in the CODESYS Visualization –
Configuring User Management part of the EcoStruxure Machine Expert online
help.
Encrypted Communication
For communication between an Internet browser and a Modicon M262 Logic/
Motion Controller running a WebVisu, an HTTPS connection with encryption is
available which helps to protect the integrity of the displayed data. For details,
refer to Firewall Script Commands in the Modicon M262 Logic/Motion Controller
Programming Guide.
EIO0000002854.04 145
FAQ
FAQ
What’s in This Chapter
Frequently Asked Questions (FAQ)............................................................... 146
Step Action
2 In the Communication Settings tab of the device editor, disable the option Encrypted
communication in the Device menu.
As an alternative, you can modify the setting in the Security Screen if the CODESYS
Security Agent is installed.
146 EIO0000002854.04
Program
What’s in This Part
Program Components .................................................................................. 148
Task Configuration ....................................................................................... 199
Managing Applications.................................................................................. 200
EIO0000002854.04 147
Program Components
Program Components
What’s in This Chapter
Program Organization Unit (POU) ................................................................ 148
Function Block ............................................................................................ 166
Application Objects...................................................................................... 179
Application.................................................................................................. 197
POU Management
POUs which are managed in the Global node of the Applications tree are not
device-specific but they can be instantiated for use on a device (application). For
this purpose, program POUs must be called by a task of the respective
application.
But POU also is the name of a certain sub-category of these objects in the Add
Object menu. Here, it just comprises programs, function blocks, and functions.
Therefore, a POU object in general is a programming unit. It is an object which is
managed either non-device-specifically in the Global node of the Applications
tree or directly below an application in the Applications tree. It can be viewed
and edited in an editor view. A POU object can be a program, function or function
block.
It is possible to set certain Properties (such as build conditions, etc.) for each
particular POU object.
For a description on how to create a POU object, refer to the section Adding POU
Objects to an Application, page 149.
Besides the POU objects, there are device objects used for running the program
on the target system (Resource, Application, Task Configuration etc.). They
are managed in the Applications tree.
148 EIO0000002854.04
Program Components
• Program: It returns one or several values during operation. All values are
retained from the last time the program was run until the next. It can be called
by another POU object.
• Function Block: It provides one or more values during the processing of a
program. As opposed to a function, the values of the output variables and the
necessary internal variables shall persist from one execution of the function
block to the next. So invocation of a function block with the same arguments
(input parameters) need not always yield the same output values.
• Function: It yields exactly one data element (which can consist of several
elements, such as fields or structures) when it is processed. The call in
textual languages can occur as an operator in expressions.
Ste- Action
p
1 Right-click the Application node of the controller and choose Add Object > POU.
The two methods are also available in the Applications tree.
2 In the Add POU dialog box, assign a name to your POU object by typing a name in the text
field Name.
NOTE: The name must not contain any space characters. If you do not enter a name, a
name is given by default.
Assigning a meaningful name to a POU may ease the organization of your project.
EIO0000002854.04 149
Program Components
Ste- Action
p
• Function Block:
1. If you want your function block to extend an already existing function block, select
Extends and click the browser to select the function block you want in the Input
Assistant.
2. Click the OK button.
3. If you want your function block to implement an interface, select Implements and
click the browser to select the interface you want in the Input Assistant.
4. Click the OK button.
5. To help prevent deriving access from your function block, activate the option
Final. The function block cannot be extended by another one. Enables optimized
code generation.
6. Activate the option Abstract to indicate that the function block has a an
incomplete or no implementation and cannot be instantiated. The function block
is exclusively used as base function block and the implementation is typically
performed in a derived function block.
7. If your function block implements an interface, in the list box Method
implementation language, select the programming language you want for
editing the methods and properties defined in the implemented interface.
• Function:
1. Click the browse button to select the Return type you want in the Input
Assistant.
2. Click the OK button.
4 From the list box Implementation Language, select the programming language you want
for editing your POU object.
Ste- Action
p
1 Under the node Task Configuration of the controller, double-click the task to which you
want to add your program. In the Configuration tab, click Add Call.
Alternatively, in the Applications tree select the task to which you want to assign your
program and click the green plus button. Execute the command Program Call... from the list.
Click the ... button.
2 In the tab Categories of the Input Assistant dialog box, select Programs.
Calling POUs
POUs can call other POUs. Recursion however is not allowed (a POU that calls
itself).
When a POU assigned to an application calls another POU just by its name
(without any namespace, page 622 added), consider the following order of
browsing the project for the POU to be called:
1. current application
150 EIO0000002854.04
Program Components
If a POU with the name specified in the call is available in a library of the Library
Manager of the application as well as an object in the Global node of the
Applications tree, there is no syntax for explicitly calling the POU in the Global
node of the Applications tree, just by using its name. In this case move the
respective library from the Library Manager of the application to the Library
Manager of the Global node of the Applications tree. Then you can call the POU
from the Global node of the Applications tree just by its name (and, if needed,
that from the library by preceding the library namespace).
Also refer to the chapter POUs for Implicit Checks, page 164.
Program
Overview
A program is a POU object which returns one or several values during operation.
All values are retained from the last time the program was run until the next.
However, there are not separate instances of programs, unlike function blocks.
When calling a function block, only the values in the given instance of the function
block are modified. The modifications are only affected when the same instance is
called again. Program value modifications will be retained until the program gets
called again even if called from another POU.
Adding a Program
To add a program to an existing application, select the application node in the
Applications tree, click the green plus button, and execute the command POU....
As an alternative, right-click the Application node, and execute the command
Add Object > POU from the contextual menu. To add an application-independent
POU, select the Global node of the Applications tree, and execute the same
commands.
In the Add POU dialog box select the Program option, enter a name for the
program, and select the desired implementation language. Click Open to confirm.
The editor view for the new program opens and you can start editing the program.
Declaring a Program
Syntax:
PROGRAM <program name>
This is followed by the variable declarations of input, page 475, output, page 475,
and program variables. Access variables are available as options as well.
EIO0000002854.04 151
Program Components
Example of a program
Calling a Program
A program can be called by another POU. However, a program call in a Function,
page 153 is not allowed. There are no instances of programs.
If a POU has called a program and if the values of the program have been
modified, these modifications will be retained until the program gets called again.
This applies even if it is called from within another POU. Consider that this is
different from calling a function block. When calling a function block, only the
values in the given instance of the function block are modified. The modifications
are only affected when the same instance is called again.
In order to set input and/or output parameters in the course of a program call, in
text language editors (for example, ST), assign values to the parameters after the
program name in parentheses. For input parameters, use := for this assignment,
as with the initialization of variables, page 469 at the declaration position. For
output parameters, use =>. See the following example.
If the program is inserted via the Input Assistant using the option Insert with
arguments in the implementation view of a text language editor, it will be
displayed automatically according to this syntax with all parameters, though you
do not necessarily have to assign these parameters.
152 EIO0000002854.04
Program Components
Function
Overview
A function is a POU which yields exactly one data element (which can consist of
several elements, such as fields or structures) when it is processed. Its call in
textual languages can occur as an operator in expressions.
Adding a Function
To assign the function to an existing application, select the application node in the
Applications tree, click the green plus button, and execute the command POU....
As an alternative, right-click the Application node, and execute the command
Add Object > POU from the contextual menu. To add an application-independent
POU, select the Global node of the Applications tree, and execute the same
commands.
In the Add POU dialog box, select the Function option. Enter a Name (<function
name>) and a Return Data Type (<data type>) for the new function and select the
desired implementation language. To choose the return data type, click the button
... to open the Input Assistant dialog box. Click Open to confirm. The editor view
for the new function opens and you can start editing.
Declaring a Function
Syntax:
FUNCTION <function name> : <data type>
This is followed by the variable declarations of input and function variables.
Assign a result to the function. Therefore, the function name is used as an output
variable.
Do not declare local variables as RETAIN or PERSISTENT in a function because
this will have no effect.
Example of a function in ST: this function takes 3 input variables and returns the
product of the last 2 added to the first one.
EIO0000002854.04 153
Program Components
Calling a Function
The call of a function in ST can appear as an operand in expressions.
In IL, you can position a function call only within actions of a step or within a
transition.
Functions (in contrast to a program or function block) contain no internal state
information, that is, invocation of a function with the same arguments (input
parameters) always will yield the same values (output). For this reason, functions
may not contain global variables and addresses.
Example:
fun(formal1 := actual1, actual2); // -> error message
fun(formal2 := actual2, formal1 := actual1); // same
semantics as the following:
fun(formal1 := actual1, formal2 := actual2);
According to the IEC 61131-3 standard, functions can have additional outputs.
They can be assigned in the call of the function. In ST, for example, according to
the following syntax:
out1 => <output variable 1> | out2 => <output variable 2> | ...further output
variables
Example
Function fun is defined with 2 input variables in1 and in2 and two output
variables out1 and out2. The output values of fun are written to the locally
declared variables loc1 and loc2.
fun(in1 := 1, in2 := 2, out1 => loc1, out2 => loc2);
Method
Overview
A method is a language element similar to a function that can be used in a context
of a function block, page 166. It can be regarded as a function which contains an
154 EIO0000002854.04
Program Components
Inserting a Method
To assign a method to a function block or interface, select the corresponding
function block or interface node in the Applications tree, click the green plus
button and execute the command Method. Alternatively, you can right-click the
function block or interface node and execute the command Add Object > Method
from the contextual menu.
In the Add Method dialog box, enter a Name, the desired Return Type, the
Implementation Language, and the Access Specifier (see below). If the method
does not have an implementation and the implementation is provided by the
derived function block, select the option Abstract. For choosing the return data
type, click the button ... to open the Input Assistant... dialog box.
Access specifier: For compatibility reasons, access specifiers are optional. The
specifier PUBLIC is available as an equivalent for having set no specifier.
Alternatively, choose one of the options from the selection list:
• PRIVATE: The access on the method is restricted to the function block.
• PROTECTED: The access on the method is restricted to the function block
and its derivation.
• INTERNAL: The access on the method is restricted to the present
namespace (the library).
Click Open to confirm. The method editor view opens.
Declaring a Method
Syntax:
METHOD <access specifier> <method name> : <return data type>VAR_INPUT ...
END_VAR
For a description on how to declare interface handling methods, refer to the
Interface chapter, page 159.
EIO0000002854.04 155
Program Components
Calling a Method
Method calls are also named virtual function calls. For further information, refer to
the chapter Method Invocation, page 174.
Note the following for calling a method:
• The data of a method is temporary and only valid during the execution of the
method (stack variables). Therefore, the variables and function blocks
declared in a method are reinitialized at each call of the method.
• Methods defined in an interface, page 159 are only allowed to have input,
output, and input/output variables, but no body (implementation part).
• Methods such as functions can have additional outputs. They must be
assigned during method invocation, page 174.
• The declared access specifier defines how the method can be called:
◦ INTERNAL: The method can be called within its own namespace.
◦ PROTECTED: The method can be called within its own POU and its
derivatives.
◦ PRIVATE: The method can be called within its own POU.
◦ PUBLIC: No restrictions apply for calling the method.
Implementing a Method
Note the following for implementing a method:
• In the body of a method, access to the function block instance variables is
allowed.
• If necessary, use the THIS pointer, page 177 which always points on the
present instance.
• VAR_TEMP variables of the function block cannot be accessed in a method.
• A method can call itself recursively.
Calling a Method
Use the following syntax for calling a method:
<return value variable> := <POU name> . <method name> (
<method input name> := <variable name> (, <further method
input name> := <variable name> )* );
Declaration example:
METHOD PUBLIC DoIt : BOOL
VAR_INPUT
iInput_1 : DWORD;
iInput_2 : DWORD;
sInput_3 : STRING(12);
END_VAR
Call example:
bFinishedMethod := fbInstance.DoIt(sInput_3 :='Hello World
', iInput_2 := 16#FFFF,iInput_1 := 16);
NOTE: When the method is called, the return value of the method is assigned,
for example, to variables declared locally. When you omit the names of the
input variables, make sure to obey the declaration order.
Declaration example:
METHOD PUBLIC DoIt : BOOL
VAR_INPUT
iInput_1 : DWORD;
iInput_2 : DWORD;
sInput_3 : STRING(12);
END_VAR
156 EIO0000002854.04
Program Components
Call example:
bFinishedMethod := fbInstance.DoIt( 16, 16#FFFF,'Hello World
');
NOTICE
UNINTENDED APPLICATION ISSUES
• Only implement recursive algorithms where necessary.
• Be sure to have a solid understanding of recursive implementation
techniques, and document well the supporting code.
Failure to follow these instructions can result in equipment damage.
Properties, page 158 and interface properties, page 161 each consist of a Set
and/or a Get accessor method.
EIO0000002854.04 157
Program Components
Property
Overview
A property in extension to the IEC 61131-3 standard is available as a means of
object-oriented programming. It consists of a pair of accessor methods (Get,
Set). They allow encapsulating a read or write access to variables declared inside
of a POU or a GVL into a function call, while keeping the syntax of a variable
access.
To insert a property as an object below a program, page 151, a function block,
page 166, a GVL, page 180, or an interface, page 159 node, select the node in the
Applications tree, click the green plus button, and execute the command
Property. As an alternative, right-click the node and execute the command Add
Object > Property from the contextual menu.
In the Add Property dialog box specify the Name, Return Type, desired
Implementation Language, and optionally an Access Specifier.
The following access specifiers are available as for methods, page 155:
• PUBLIC
• PRIVATE
• PROTECTED
• INTERNAL
• ABSTRACT
NOTE: Properties can also be declared within interfaces.
EcoStruxure Machine Expert facilitates object-oriented programming using
inheritance within function blocks: When you execute Add Object on a function
block that inherits from another function block, the Action, Method, Property,
and Transition elements used in the base function block are listed for selection:
• Action, Method, Property, and Transition elements with Access specifier
= PUBLIC, PROTECTED, and INTERNAL defined in the base function block
are available for selection. You can adapt the definition for the inherited
object. In the inherited object, the same Access specifier is assigned as to
the source elements.
• Action, Method, Property, and Transition elements with Access specifier
= PRIVATE are not available for selection because access is restricted to the
base function block.
158 EIO0000002854.04
Program Components
A property can have additional local variables but no additional inputs and - in
contrast to a function, page 153 or method, page 154 - no additional outputs.
NOTE: When copying or moving a method or property from a POU to an
interface, the contained implementations are deleted automatically. When
copying or moving from an interface to a POU, you are requested to specify
the desired implementation language.
Monitoring a Property
A property can be monitored in online mode either with help of inline monitoring,
page 306 or with help of a watch list, page 355. The precondition for monitoring a
property is the addition of the pragma {attribute 'monitoring' :=
'variable'} (refer to the chapter Attribute Monitoring, page 512).
Interface
Overview
The use of interfaces is a means of object-oriented programming. An interface
POU defines a set of methods, page 154 and properties, page 158 without an
implementation. An interface can be described as an empty shell of a function
block, page 166. It must be implemented, page 173 in the declaration of the
EIO0000002854.04 159
Program Components
function block in order to get realized in the function block instances. A function
block can implement one or several interfaces.
The same method can be realized with identical parameters but different
implementation code by different function blocks. Therefore, an interface can be
used/called in any POU without the need that the POU identifies the particular
function block that is concerned.
1 or multiple function blocks can now be inserted, implementing the above defined
interface ITF.
Creating a function block implementing an interface
When function block POU is added to the Applications tree, the methods
Method1 and Method2 are automatically inserted below as defined by ITF. Here
they can be filled with function block-specific implementation code.
160 EIO0000002854.04
Program Components
Interface Properties
An interface can also define an interface property, consisting of the accessor
methods Get and/or Set. For further information on properties, refer to the
chapter Property, page 158. A property in an interface like the possibly included
methods is just a prototype that means it contains no implementation code. Like
the methods, it is automatically added to the function block, which implements the
interface. There it can be filled with specific programming code.
Considerations
Consider the following:
• It is not allowed to declare variables within an interface. An interface has no
body (implementation part) and no actions. Just a collection of methods is
defined within an interface and those methods are only allowed to have input
variables, output variables, and input/output variables.
• Variables declared with the type of an interface are treated as references.
• A function block implementing an interface must have assigned methods and
properties which are named exactly as they are in the interface. They must
contain identically named inputs, outputs, and inputs/outputs.
NOTE: When copying or moving a method or property from a POU to an
interface, the contained implementations are deleted automatically. When
copying or moving from an interface to a POU, you are requested to specify
the desired implementation language.
Inserting an Interface
To add an interface to an application, select the Application node in the
Applications tree, click the green plus button and select Add Other Objects... >
Interface. Alternatively, execute the command Add Object > Interface. If you
select the node Global before you execute the command, the new interface is
available for all applications.
In the Add Interface dialog box, enter a name for the new interface (<interface
name>). Optionally you can activate the option Extends: if you want the current
interface to be an extension, page 171 of another interface.
EIO0000002854.04 161
Program Components
Click Add to confirm the settings. The editor view for the new interface opens.
Declaring an Interface
Syntax
INTERFACE <interface name>
For an interface extending another one:
INTERFACE <interface name> EXTENDS <base interface name>
Example
INTERFACE interface1 EXTENDS interface_base
Action
Overview
You can define actions and assign them to function blocks, page 166 and
programs, page 151. An action is an additional implementation. It can be created
in a different language than the basic implementation. Each action is given a
name.
An action works with the data of the function block or program to which it belongs.
It uses the input/output variables and local variables defined and does not contain
its own declarations.
162 EIO0000002854.04
Program Components
In this example, each call of the function block FB1 increases or decreases the
output variable out, depending on the value of the input variable in. Calling
action Reset of the function block sets the output variable out to 0. The same
variable out is written in both cases.
Inserting an Action
To add an action, select the respective program or function block node in the
Applications Tree or in the Global node of the Applications Tree, click the
green plus button, and execute the command Action.... Alternatively, right-click
the program or function block node, and execute the command Add Object >
Action. In the Add Action dialog box, define the action Name and the desired
Implementation Language.
EcoStruxure Machine Expert facilitates object-oriented programming using
inheritance within function blocks: When you execute Add Object on a function
block that inherits from another function block, the Action, Method, Property,
and Transition elements used in the base function block are listed for selection:
• Action, Method, Property, and Transition elements with Access specifier
= PUBLIC, PROTECTED, and INTERNAL defined in the base function block
are available for selection. You can adapt the definition for the inherited
object. In the inherited object, the same Access specifier is assigned as to
the source elements.
• Action, Method, Property, and Transition elements with Access specifier
= PRIVATE are not available for selection because access is restricted to the
base function block.
Calling an Action
Syntax
<Program_name>.<Action_name>
or
<Instance_name>.<Action_name>
Consider the notation in FBD (see the following example).
If it is required to call the action within its own block, that is the program or function
block it belongs to it is sufficient to use the action name.
Examples
This section provides examples for the call of the above described action from
another POU.
Declaration for all examples:
PROGRAM PLC_PRG
EIO0000002854.04 163
Program Components
VAR
Inst : Counter;
END_VAR
Call of action Reset in another POU, which is programmed in IL:
CAL Inst.Reset(In := FALSE)
LD Inst.out
ST ERG
Call of action Reset in another POU, which is programmed in ST:
Inst.Reset(In := FALSE);
Erg := Inst.out;
Call of action Reset in another POU, which is programmed in FBD:
Action in FBD
NOTE: The IEC standard does not recognize actions other than actions of the
sequential function chart (SFC). These actions are an essential part
containing the instructions to be processed at the particular steps of the chart.
Transition
Overview
You can use transition objects as transition elements in a program or function
block implemented in SFC.
For further information, refer to the description of steps and transitions in the
chapter SFC Elements / ToolBox, page 288.
EcoStruxure Machine Expert facilitates object-oriented programming using
inheritance within function blocks: When you execute Add Object on a function
block that inherits from another function block, the Action, Method, Property,
and Transition elements used in the base function block are listed for selection:
• Action, Method, Property, and Transition elements with Access specifier
= PUBLIC, PROTECTED, and INTERNAL defined in the base function block
are available for selection. You can adapt the definition for the inherited
object. In the inherited object, the same Access specifier is assigned as to
the source elements.
• Action, Method, Property, and Transition elements with Access specifier
= PRIVATE are not available for selection because access is restricted to the
base function block.
164 EIO0000002854.04
Program Components
When you insert a check POU, the option is no longer available in the dialog box
to help avoid a double insertion. If the different types of check POUs have been
added below the application, the Add Object dialog box does not provide the
POUs for implicit checks option any longer.
CAUTION
INCORRECT FUNCTIONALITY
Do not modify the declaration part of an implicit check function in order to
maintain its functional integrity.
Failure to follow these instructions can result in injury or equipment
damage.
NOTE: You may, however, add local variables to the declaration part of an
implicit check function.
NOTE: After having removed implicit check function (such as CheckBounds)
from your application, no Online Change is possible, just a download. A
corresponding message is displayed.
EIO0000002854.04 165
Program Components
Function Block
General Information
Overview
A function block is a POU, page 148 which provides 1 or more values during the
processing of a controller program. As opposed to a function, the values of the
output variables and the necessary internal variables shall persist from one
execution of the function block to the next. Therefore, invocation of a function
block with the same arguments (input parameters) need not always yield the same
output values.
In addition to the functionality described by standard IEC11631-3, object-oriented
programming is supported and function blocks can be defined as extensions,
page 171 of other function blocks. They can include interface, page 173
definitions concerning Method invocation, page 174. Therefore, inheritance can
be used when programming with function blocks.
A function block always is called via an instance, page 168, which is a
reproduction (copy) of the function block.
166 EIO0000002854.04
Program Components
Option Description
Extends Enter the name of another function block available in the project,
which should be the base for the current one. For details, refer to
Extension of a Function Block, page 171.
Implements Enter the names of interfaces, page 159 available in the project, which
should be implemented in the current function block. You can enter
several interfaces separated by commas. For details, refer to
Implementing Interfaces, page 173.
Access specifier For compatibility reasons, access specifiers are optional. Specifier
PUBLIC is available as an equivalent for having set no specifier.
Method implementation Choose the desired programming language for all method and
language property objects created via the interface implementation,
independently from that set for the function block itself.
Click Add to confirm the settings. The editor view for the new function block opens
and you can start editing.
EIO0000002854.04 167
Program Components
Example
FBexample shown in the following figure has 2 input variables and 2 output
variables out1 and out2.
out1 is the sum of the 2 inputs, out2 is the result of a comparison for equality.
Example of a function block in ST
Example
Declaration (for example, in the declaration part of a program) of instance
INSTANCE of function block FUB:
INSTANCE: FUB;
The declaration parts of function blocks and programs can contain instance
declarations.
168 EIO0000002854.04
Program Components
Syntax
<instance name>.<variable name>
Considerations
• Only the input and output variables of a function block can be accessed from
outside of a function block instance, not its internal variables.
• Access to a function block instance is limited to the POU, page 148 in which it
was declared unless it was declared globally.
• At calling the instance, the desired values can be assigned to the function
block parameters. See the following paragraph Assigning Parameters at Call.
• The input / output variables (VAR_IN_OUT) of a function block are passed as
pointers.
• In SFC, function block calls can only take place in steps.
• The instance name of a function block instance can be used as an input
parameter for a function or another function block.
• All values of a function block are retained until the next processing of the
function block. Therefore, function block calls do not always return the same
output values, even if done with identical arguments.
NOTE: If at least 1 of the function block variables is a remanent variable, the
total instance is stored in the retain data area.
EIO0000002854.04 169
Program Components
170 EIO0000002854.04
Program Components
By default, the command is not available in the menus. Add this command via the
Tools > Customize menu (see EcoStruxure Machine Expert, Menu Commands,
Online Help).
1 Execute the command View > Online Change Result: The Online Change
Memory Reserve Settings Memory Reserve view opens.
5 From the Function Blocks area, select the entry Result: The function blocks of the
All. application are displayed in the
middle of the Online Change
Memory Reserve view.
6 Select the function block for which you want to If the application has not been
configure a memory reserve. downloaded to the controller yet,
then the input field Memory
reserve (in bytes) is editable.
7 Enter a value for the Memory reserve (in Result: The value you entered is
bytes), and click the Apply for selection button. displayed in the Memory Reserve
cell of the table.
8 Execute the Build command from the Build –
menu.
9 Click the button Scan Application. Result: The values of the cells Size,
Instance Count, Additional
memory for all instances and
Remaining size of memory
reserve Memory Reserve are
updated in the list for the configured
function block.
When you download the application to the controller, the memory size that is
reserved for the function block is calculated by the present size of the function
block plus the memory reserve you configured in the Online Change Memory
Reserve view.
Future modifications to the function block can be downloaded to the controller with
the online change without having to copy all instances of the function block to a
new memory area.
EIO0000002854.04 171
Program Components
Syntax
FUNCTION_BLOCK <function block name> EXTENDS <function block name>
This is followed by the declaration of the variables.
Example
Definition of function block fbA
FUNCTION_BLOCK fbA
VAR_INPUT
x:int;
END_VAR
...
Definition of function block fbB
FUNCTION_BLOCK fbB EXTENDS fbA
VAR_INPUT
ivar: INT := 0;
END_VAR
...
Extension by EXTENDS
Extension by EXTENDS means:
• fbB contains all data and methods which are defined by fbA. An instance of
fbB can now be used in any context where a function block of type fbA is
expected.
• fbB is allowed to override the methods/properties/actions/transitions defined
in fbA. This means: fbB can declare a method with the same name and the
same inputs and output as declared by A.
• fbB is not allowed to declare function block variables with the same name as
used in fbA. In this case, the compiler will generate an error message.
• fbA variables and methods can be accessed directly within an fbB scope by
using the SUPER pointer, page 176 (SUPER^.<method>).
NOTE: A function block can implement multiple interfaces, but it can only
extend a single function block.
Example
FUNCTION_BLOCK FB_Base
VAR_INPUT
END_VAR
VAR_OUTPUT
iCnt : INT;
END_VAR
VAR
END_VAR
THIS^.METH_DoIt();
THIS^.METH_DoAlso();
172 EIO0000002854.04
Program Components
Implementing Interfaces
Overview
In order to support object-oriented programming, a function block can implement
several interfaces, page 159 which allows you to use methods, page 154.
Syntax
FUNCTION_BLOCK <function block name> IMPLEMENTS <interface_1 name>|,
<interface_2 name>, ..., <interface_n name>
A function block that implements an interface must contain all methods and
properties (interface properties, page 161) defined by this interface. This includes
name, inputs, and the output of the particular method or property which must be
exactly the same.
For this purpose - when creating a new function block implementing an interface -
automatically all methods and properties defined in this interface will be inserted
below the new function block in the Applications Tree.
EIO0000002854.04 173
Program Components
NOTE: If afterwards, methods are added to the interface definition, they will
not be added automatically in the concerned function blocks and thus produce
compiler errors. Execute the command Implement interfaces... (see
EcoStruxure Machine Expert, Menu Commands, Online Help) to perform this
update explicitly.
When you use inheritance for function blocks, consider that if methods or
attributes were created by inheritance of an interface, either implement them,
or delete them if the implementation of the base function block is to be used.
Pragma attributes are automatically inserted. They are detected during
compilation and messages are generated to remind you that the inherited
methods or properties have to be verified. Delete the pragma attributes after
you have completely implemented the new function block.
For further information, refer to the description of the Implement interfaces...
command (see EcoStruxure Machine Expert, Menu Commands, Online Help).
Example
INTERFACE I1 includes method GetName:
METHOD GetName : STRING
Function blocks A and B each implement interface I1:
FUNCTION_BLOCK A IMPLEMENTS I1
FUNCTION_BLOCK B IMPLEMENTS I1
Thus in both function blocks the method GetName has to be available and will be
inserted automatically below each when the function blocks are inserted in the
Applications Tree.
Consider a declaration of a variable of type I1:
FUNCTION DeliverName : STRING
VAR_INPUT
l_i : I1;
END_VAR
This input can receive all function blocks that implement interface I1.
Example for function calls:
DeliverName(l_i := A_instance); // call with instance of
type A
DeliverName(l_i := B_instance); // call with instance of
type B
NOTE: A variable of an interface-type must get assigned an instance of a
function block before a method can be called on it. A variable of an interface-
type always is a reference to the assigned function block instance.
Thus a call to the interface method results in a call to the function block
implementation. As soon as the reference is assigned, the corresponding address
is monitored in online mode. Otherwise, if no reference has been assigned yet, the
value 0 is displayed within monitoring in online mode.
For this example see in the implementation part of the function DeliverName:
DeliverName := l_i.GetName(); // in this case it depends on
the "real" type of l_i whether A.GetName or B.GetName is
called
NOTE: See also the possibility to extend a function block, page 171 by using
the keyword EXTENDS in the declaration.
Method Invocation
Overview
Object-oriented programming with function blocks is - besides of the possibility of
extension, page 171 via EXTENDS - supported by the possible use of interfaces,
174 EIO0000002854.04
Program Components
page 173 and inheritance. This requires dynamically resolved method invocations,
also called virtual function calls.
Virtual function calls need some more time than normal function calls and are
used when:
• a call is performed via a pointer to a function block (pfub^.method)
• a method of an interface variable is called (interface1.method)
• a method calls another method of the same function block
• a call is performed via a reference to a function block
• VAR_IN_OUT of a base function block type can be assigned an instance of a
derived function block type
Virtual function calls make possible that the same call in a program source code
will invoke different methods during runtime.
For more information and in-depth view, refer to:
• Method, page 154 for further information on methods.
• THIS Pointer, page 177 for using THIS pointer.
• SUPER Pointer, page 176 for using SUPER pointer.
Calling Methods
According to the IEC 61131-3 standard, methods such as normal functions, page
153 can have additional outputs. They can be assigned in the method call
according to syntax:
<method>(in1:=<value> |, further input assignments, out1 => <output variable 1> |
out2 => <output variable 2> | ...further output variables)
This has the effect that the output of the method is written to the locally declared
variables as given within the call.
Example
Assume that function blocks fub1 and fub2 EXTEND function block fubbase
and IMPLEMENT interface1. Method method1 is contained.
Possible use of the interfaces and method calls:
PROGRAM PLC_PRG
VAR_INPUT
b : BOOL;
END_VAR
VAR
pInst : POINTER TO fubbase;
instBase : fubbase;
inst1 : fub1;
inst2 : fub2;
instRef : REFERENCE to fubbase;
END_VAR
IF b THEN
instRef REF= inst1; (* Reference to fub1 *)
pInst := ADR(instBase);
ELSE
instRef REF= inst2; (* Reference to fub2 *)
pInst := ADR(inst1);
END_IF
pInst^.method1(); (* If b is true, fubbase.
method1 is called, else fub1.method1 is called *)
instRef.method1(); (* If b is true, fub1.
method1 is called, else fub2.method1 is called *)
Assume that fubbase of the upper example contains 2 methods method1 and
method2. fub1 overrides method2 but not method1.
EIO0000002854.04 175
Program Components
SUPER Pointer
Overview
For each function block that extends a base function block, a pointer with name
SUPER is automatically available. It points to the base function block instances.
This provides an effective solution for the following issue:
• SUPER offers access to methods of the base function block implementation.
With the keyword SUPER, a method can be called which is valid in the base
(parent) class instance. Thus, no dynamic name binding takes place.
SUPER may only be used in methods and in the associated function block
implementation.
Because SUPER is a pointer to the base function block, you have to dereference it
to get the address of the function block: SUPER^.METH_DoIt
ST SUPER^.METH_DoIt();
FBD/CFC/LD
NOTE: The functionality of SUPER is not yet implemented for Instruction List.
Example
Use of SUPER and THIS pointers.
FUNCTION_BLOCK FB_Base
VAR_OUTPUT
iCnt : INT;
END_VAR
METHOD METH_DoIt : BOOL
iCnt := -1;
176 EIO0000002854.04
Program Components
SUPER^.METH_DoAlso();
iBase := SUPER^.iCnt;
PROGRAM PLC_PRG
VAR
myBase: FB_Base;
myFB_1: FB_1;
iTHIS: INT;
iBase: INT;
END_VAR
myBase();
iBase := myBase.iCnt;
myFB_1();
iTHIS := myFB_1.iCnt;
THIS Pointer
Overview
For each function block, a pointer with name THIS is automatically available. It
points to its own function block instance.
This provides an effective solution for the following issues:
• If a locally declared variable in the method hides a function block variable.
• If you want to refer a pointer to its own function block instance for using in a
function.
THIS may only be used in methods/properties/actions/transitions and in the
associated function block implementation.
THIS must be written in capital letters. Other spellings are not accepted.
Because THIS is a pointer to the function block, you have to dereference it to
access an element of the function block: THIS^.METHDoIt.
ST THIS^.METH_DoIt();
FBD/CFC/LD
NOTE: The functionality of THIS is not yet implemented for Instruction List.
Example 1
Local variable iVarB shadows the function block variable iVarB.
FUNCTION_BLOCK fbA
VAR_INPUT
iVarA: INT;
EIO0000002854.04 177
Program Components
END_VAR
iVarA := 1;
PROGRAM PLC_PRG
VAR
MyfbB: fbB;
END_VAR
Example 2
Function call that needs a reference to its own instance.
FUNCTION funA
VAR_INPUT
pFB: fbA;
END_VAR
...;
FUNCTION_BLOCK fbA
VAR_INPUT
iVarA: INT;
END_VAR
...;
PROGRAM PLC_PRG
VAR
MyfbB: fbB;
END_VAR
MyfbB(iVarA:=0 , iVarB:= 0);
MyfbB.DoIt();
178 EIO0000002854.04
Program Components
Application Objects
Data Type Unit (DUT)
Overview
Along with the standard data types, you can define your own data types. You can
create structures, page 549, enumeration types, page 550, and references, page
536 as data type units (DUTs) in a DUT editor, page 325.
For a description of the particular standard and the user-defined data types, refer
to the description of the data types, page 529.
Example
The following example contains 2 DUTS, defining structures struct1 and
struct2; struct2 extends struct1, which means that you can use struct2.
a in your implementation to access variable a.
TYPE struct1 :
STRUCT
a:INT;
b:BOOL;
END_STRUCT
END_TYPE
TYPE struct2 EXTENDS struct1 :
STRUCT
c:DWORD;
d:STRING;
END_STRUCT
END_TYPE
EIO0000002854.04 179
Program Components
180 EIO0000002854.04
Program Components
Select the library in the upper part of the Library Manager to get the module tree.
Select Param in order to open the tab Library Parameters showing the
declarations. Select the cell in column Value (editable) and use the empty space
to open an edit field. Enter the desired new value for g_c_Arraysize. It will be
applied to the current, local scope of the library after having closed the edit field.
EIO0000002854.04 181
Program Components
182 EIO0000002854.04
Program Components
NOTE: Only arrays whose bounds are defined by a literal or a constant are
transferred to the remote application. Constant expressions in this case are
not allowed for bounds definition. Example: arrVar : ARRAY[0..g_
iArraySize-1] OF INT ; is not transferred arrVar : ARRAY[0..10] OF
INT ; is transferred
For further information, refer to the Network Communication chapter, page
682.
EIO0000002854.04 183
Program Components
1 In the Applications tree, select the Application node of the The Properties dialog box of the network variable list
controller Dev_Sender and click the green plus button. (sender) is displayed.
Execute the command Add other objects > Network
Variable List (Sender).
2 Enter the Name GVL_Sender and click Add to create a new The GVL_Sender node appears below the Application
global variable list. node in the Applications tree and the editor opens on the
middle of the EcoStruxure Machine Expert screen.
Step 2: Define the network properties of the network variable list (sender):
1 In the Applications tree, select the GVL_Sender node, The Properties - GVL_Sender dialog box is displayed.
click the green plus button, and execute the command
Properties...
2 –
Open the Network properties tab and configure the
parameters as indicated in the graphic:
3 Click OK. The dialog box is closed and the network variable list
(sender) network properties are set.
184 EIO0000002854.04
Program Components
1 In the Applications tree, select the Application node of the The Add Global Network Variable List dialog box is
controller Dev_Receiver, click the green plus button, and displayed.
execute the command Global Network Variable List....
2 This global network variable list is the counterpart of the
Configure the parameters as indicated in the graphic. network variable list (sender) defined for the sender
controller.
3 Click Open.
The dialog box is closed and the GNVL_Receiver appears
below the Application node of the Dev_Receiver controller:
Step 2: View and / or modify the network settings of the network variable list
(receiver):
1 In the Devices tree, right-click the GNVL_Receiver node The Properties - GNVL_Receiver dialog box is displayed.
and select the command Properties....
EIO0000002854.04 185
Program Components
1 Under the Application node of the controller Dev_Sender, The editor for prog_sender opens on the right-hand side.
double-click the POU prog_sender.
2 –
Enter the following code for the variable iglobvar:
3 Under the Application node of the controller Dev_ The editor for prog_rec opens on the right-hand side.
Receiver, double-click the POU prog_rec.
4 –
Enter the following code for the variable ivar_local:
5 Log on with sender and receiver applications within the The variable ivar_local in the receiver gets the values of
same network and start the applications. iglobvar as currently displayed in the sender.
Persistent Variables
Overview
This object is a global variable list (GVL), which only contains persistent variables
of an application. Thus it has to be assigned to an application. For this purpose, it
has to be inserted in the Applications tree via selecting the respective node,
clicking the green plus button, and selecting Add Other Objects > Persistent
Variables....
Consult the Programming Guide specific to your controller for information on the
behavior of remanent variables.
Only those variables which are declared with VAR PERSISTENT and which are
contained in this list are persistent. The Add all Instance Paths command (see
EcoStruxure Machine Expert, Menu Commands, Online Help) adds all
PERSISTENT declarations found in other POUs to the list.
Variables declared with VAR PERSISTENT are also retain variables. Retain
variables have the capacity to keep their values after executing a Reset warm
command (see EcoStruxure Machine Expert, Menu Commands, Online Help).
The difference is, that persistent variables are only reinitialized upon executing the
Reset origin command (see EcoStruxure Machine Expert, Menu Commands,
Online Help) or by a new application download (after the application had been
removed from the controller). An exception is made if you modified their names or
data types.
186 EIO0000002854.04
Program Components
For further information, refer to the description of remanent variables, page 479.
Also refer to the description of the special commands for handling persistent
variables (see EcoStruxure Machine Expert, Menu Commands, Online Help).
Edit a persistent variable list in the persistence editor, which corresponds to the
GVL editor, page 326. The VAR_GLOBAL PERSISTENT RETAIN is already preset
in the first line.
Step Action
1 Select the respective application node in the Applications tree, click the green plus button,
and select Add Other Objects > Persistent Variables....
Alternatively, you can right-click the application node, and execute the command Add
Object > Persistent Variables....
2 In the Add Persistent Variables dialog box type a name for this list in the Name text box.
3 Click Add.
Result: A persistent variable node is created in the Applications tree. For an example,
refer to the Overview paragraph in this chapter.
External File
Overview
To add an external file to the Global node of the Applications Tree or Tools Tree,
select the Global node, click the green plus button and execute the commands
Add other objects > External File....
An external file inserted in the POUs tree is not downloaded to the controller.
Click the ... button to open the dialog box for browsing a file. The path of this file is
entered in the File path text box. In the Name text box, the name of the chosen
file is entered automatically without extension. You can edit this field to define
another name for the file under which it should be handled within the project.
EIO0000002854.04 187
Program Components
Option Description
Remember the link The file will be available in the project only if it is available in the
defined link path
Remember the link and A copy of the file will be stored internally in the project but also
embed into project the link to the external file will be recalled. As long as the external
file is available as defined, the defined update options will be
implemented accordingly. Otherwise just the file version stored in
the project will be available.
Embed into project Just a copy of the file will be stored in the project. There will be
no further connection to the external file.
Option Description
Reload the file automatically The file is updated within the project as soon as it has been
changed externally.
Prompt whether to reload the A dialog box pops up as soon as the file has been changed
file externally. You can decide whether the file is updated also within
the project.
Do nothing The file remains unchanged within the project, even when it is
changed externally.
188 EIO0000002854.04
Program Components
Display File Properties... This button opens the dialog box for the properties of a file. This
dialog box also appears when you select the file object in the
Applications Tree or Tools Tree and execute the command
Properties. In the tab External file of this dialog box, you can
view and modify the properties (also refer to the Menu
Commands Online Help (see EcoStruxure Machine Expert,
Menu Commands, Online Help)).
Add After you have completed the settings, click the Add button to
add the file to the Global node of the Applications Tree or Tools
Tree. It is opened in that tool which is defined as default for the
given file format.
Text List
Overview
A text list is an object managed globally in the Global node of the Applications
Tree or assigned to an application in the Applications Tree.
It serves the following purposes:
• Multi-language support for static, page 190 and dynamic, page 191 texts and
tooltips in visualizations and in the alarm handling
• Dynamic text exchange
Text lists can be exported and (re-) imported, page 193. Export is necessary, if a
language file in XML format has to be provided for a target visualization, but is
also useful for translations, page 193.
Possible formats of text lists:
• Text
• XML
You can activate support of Unicode, page 192.
Each text list is uniquely defined by its namespace. It contains text strings which
are uniquely referenced within the list by an identifier (ID, consisting of any
sequence of characters) and a language identifier. The text list to be used is
specified when configuring the text for a visualization element.
Depending on the language which is set in the visualization, the corresponding
text string is displayed in online mode. The language used in a visualization is
changed by a Change the language input. This is accomplished by a mouse
action that you have configured on the given visualization element. Each text list
must at least contain a default language, and optionally in other languages that
you choose to define. If no entry is found which matches the language currently
set in EcoStruxure Machine Expert, the default language entry of the text list is
used. Each text can contain formatting definitions, page 193.
Basic structure of a text list
EIO0000002854.04 189
Program Components
Example of a GlobalTextList
Create Global Text List
190 EIO0000002854.04
Program Components
NOTICE
UNINTENDED MODIFICATION OF IDENTIFIERS
Do not modify the identifiers when editing the exported list.
Failure to follow these instructions can result in equipment damage.
Detailed Example
This example explains how to configure a visualization element, which displays
the corresponding message when an error is detected in an application that
processes error events identified via numeric IDs assigned to an integer variable
ivar_err.
Provide a dynamic textlist named ErrorList where the message texts for error IDs
0 to 4 are defined in languages German, English, and Default:
Within a table cell, you can add a line break by pressing the keyboard shortcut
Ctrl + Enter.
EIO0000002854.04 191
Program Components
To use the error IDs in the visualization configuration, define a STRING variable,
for example strvar_err. To assign the integer value of ivar_err to strvar_
err, use strvar_err:=INT_TO_STRING(ivar_err);.
strvar_err can be entered as Textindex parameter in the configuration of the
Dynamic texts properties of a visualization element. This element will display the
appropriate message in online mode.
The next example is for processing the error ID using project variables and
configuration of a visualization element (Properties), which should display the
appropriate message:
192 EIO0000002854.04
Program Components
Formatting of Texts
The texts can contain formatting definitions (%s,%d,…), which allow to include the
present values of variables in a text. For the possible formatting strings, see the
Visualization part of the EcoStruxure Machine Expert online help.
When using text with formatting strings, the replacement is done in the following
order:
• The actual text string to be used is searched via list name and ID.
• If the text contains formatting definitions, these are replaced by the value of
the respective variable.
EIO0000002854.04 193
Program Components
Image Pool
Overview
Image pools are tables defining the file path, a preview, and a string ID for each
image. By specifying the ID and (for unique accessing) additionally the image file
name, the image can be referenced, for example, when being inserted in a
visualization (configuration of the properties of an image element, refer to Using
Images Which are Managed in Image Pools, page 196 ).
In a library project, you can create an image pool. If you then declare the library to
be a symbol library, you can use the images it contains inside your project
visualizations. To achieve this, right-click the ImagePool node of the library
project, select Properties, and set the Symbol library settings in the Image
Pool tab (by clicking the button Mark library as symbol library and optionally
selecting a Text list for symbol translation).
After you have added the library to your project, the image pool will appear (as you
named it) in the ToolBox when a visualization editor is active.
NOTE: Reduce the size of an image file as much as possible before adding it
to an image pool. Otherwise, the project size and the loading and storing
efforts of visualization applications, including images, can become large.
194 EIO0000002854.04
Program Components
Element Description
If the image file is stored in the directory for image files (as defined in
Tools > Options > Visualization, you only have to enter the file
name in this text box.
Image Preview of the image.
Link type Information on how the image file is linked to the project.
Specify the Link type when you add the image file manually in the
dialog box Select image. Refer to the description Creating and Editing
an Image Pool, page 195.
NOTE: If the target system does not support images in the vector image
format SVG, they are automatically converted to the format PNG during
download. For information on the supported image formats, refer to the device
descriptions provided by your hardware manufacturer.
EIO0000002854.04 195
Program Components
By executing the command Insert Image 1. Put the focus into the image pool editor.
2. Execute the Insert Image command (see
EcoStruxure Machine Expert, Menu
Commands, Online Help) from the
contextual menu.
Result: A unique ID is entered
automatically, which is editable.
3. Double-click the field File name in the
new line to specify the path of the image
file.
4. For this purpose, you can open the dialog
By directly entering the file name In the editor of the image pool, double-click the
field File name of the first empty line. Enter - as
described above for the first option (executing
the command Insert Image) - the path of the
desired image file.
Element Description
Image File
Enter the path of the image file or click the button for getting the
standard dialog box for browsing the local file system. Select the
desired file or files. Multiple selection is possible.
196 EIO0000002854.04
Program Components
Application
Application
Overview
An application is a set of objects which are needed for running a particular
instance of the controller program on a certain hardware device (controller). For
this purpose, independent objects managed in the Global node of the
Applications tree are instantiated and assigned to a device. This meets the
concept of object-orientated programming. However, you can also use purely
application-specific POUs.
An application is represented by an application object in the Applications tree.
Below an application entry, insert the objects defining the application resource set.
One application is available for each controller. It is not possible to add further
applications.
A part of each application is the Task Configuration controlling the run of a
program (POU instances or application-specific POUs). Additionally, it can have
assigned resource objects like global variable lists, libraries, and so on. These - in
contrast to those managed in the Global node of the Applications tree - can only
EIO0000002854.04 197
Program Components
be used by the particular application and children. For the rules, refer to the
description of arranging and configuring objects in the Devices tree, page 36.
Consideration
When going to log in with an application on a target device (controller or simulation
target), two checks are performed: Which application is currently in the controller?
Are the application parameters in the controller matching those in the application
within EcoStruxure Machine Expert? Corresponding messages indicate
mismatches and offer some ways to continue in this case. Also you have the
possibility to delete the application in the controller. Refer to the description of the
Login command, page 202 for more details.
198 EIO0000002854.04
Task Configuration
Task Configuration
What’s in This Chapter
Task Configuration ...................................................................................... 199
Adding Tasks .............................................................................................. 199
Task Configuration
Overview
The Task Configuration defines 1 or several tasks for controlling the processing
of an application program.
It is a resource object for an application, page 197. It has to be inserted in the
Applications tree below an application node. A task can call an application-
specific program POU, which is only available in the Applications tree below the
application. It can also call a program which is managed in the Global node of the
Applications tree. In the latter case, the program that is available globally will be
instantiated by the application.
You can edit a task configuration in the Task Configuration editor, page 346.
In online mode, the Task Configuration editor provides a monitoring view that
presents information on cycles, cycle times, and task status.
As an additional functionality of the task configuration, if supported by the device,
the monitoring view allows a dynamic analysis of the POUs which are controlled
by a task. It supplies information about the cycle times, the quantity of function
block calls and the unused code lines.
Adding Tasks
Introduction
You can add tasks to your application via the Applications tree.
Procedure
Step Action
1 In the Applications tree, select the Task Configuration node, click the green plus button,
and execute the command Task....
Alternatively, you can right-click the Task Configuration node, and select Add Object >
Task... from the contextual menu.
2 In the Add Task dialog box, enter a name in the Name: text box.
Note: The name must neither contain any space nor exceed a length of 32 characters.
3 Click Add.
EIO0000002854.04 199
Managing Applications
Managing Applications
What’s in This Chapter
General Information..................................................................................... 200
Building and Downloading Applications ......................................................... 201
Running Applications................................................................................... 213
Maintaining Applications .............................................................................. 214
General Information
Introduction
Introduction
To run an application, you must first connect the PC to the controller, then
download the application to the controller.
NOTE: Due to memory size limitation, some controllers are not able to store
the application source but only a built application that is executed. Therefore,
you are not able to upload the application source from the controller to a PC.
WARNING
UNINTENDED EQUIPMENT OPERATION
• Confirm that you have entered the correct device designation or device
address in the Communication Settings dialog when downloading an
application.
• Confirm that machine guards and tags are in place such that any potential
unintended machine operation will not result in personal injury or equipment
damage.
• Read and understand all user documentation of the software and related
devices, as well as the documentation concerning equipment or machine
operation.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Preconditions
Verify that your application meets the following conditions before downloading it to
the controller:
• the active path is set for the correct controller,
• the application you want to download is active,
• the application is free of compilation errors,
• the Online > Operating Mode is set to Debug. For further information, refer
to the Operating Modes chapter in the Menu Commands Online Help.
Boot Application
The boot application is the application that is launched on controller start. This
application is stored in the controller memory. To configure the download of the
boot application, right-click the Application node in the Applications tree and
select the Properties command.
At the end of a successful download of a new application, a message is displayed
asking you if you want to create the boot application.
200 EIO0000002854.04
Managing Applications
EIO0000002854.04 201
Managing Applications
Login
Overview
The Online > Login command connects the application to the target device
(controller or simulation target) and thus changes into the online mode.
The default shortcut is Alt + F8.
WARNING
UNINTENDED EQUIPMENT OPERATION
• Confirm that you have entered the correct device designation or device
address in the “Communication Settings” dialog when downloading an
application.
• Confirm that machine guards and tags are in place such that any potential
unintended machine operation will not result in personal injury or equipment
damage.
• Read and understand all user documentation of the software and related
devices, as well as the documentation concerning equipment or machine
operation.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
If there is an online user management (also refer to the chapter Users and
Groups, page 111) established on the target device, at login you are prompted to
enter the user name and password. For this purpose, the dialog box Device User
Logon opens.
NOTE: The layout of EcoStruxure Machine Expert views can change when
you connect to the target device because the Online perspective, page 43 is
automatically selected when you switch to online mode.
NOTE: If the communication with the controller is encrypted or secured using
user management functions, refer to the How to Manage Certificates on the
Controller User Guide for further information.
Selecting the View of the Communication Settings Tab in the Device Editor
Depending on the option selected for Communication page in the Tools >
Options > Device editor dialog box (see EcoStruxure Machine Expert, Menu
Commands, Online Help), the Communication Settings tab of the device editor
is displayed in three different modes. Refer to the description of the different tabs
for details:
Login Procedure
The steps of the login procedure are identical. They only differ in the presentation
of the Communication Settings tab.
For a successful login, the code generation must have been completed without
detecting errors (refer to the chapter Build Process Before Login, page 203).
202 EIO0000002854.04
Managing Applications
Step Action
1
Execute the command Online > Login, or click the Login button from the toolbar,
or press ALT + F8.
Result: Since no target address has been set before, the Communication Settings tab
of the device editor opens in the mode you selected. A message box is displayed
indicating that a valid address has not been defined.
2 If only one controller has been detected by EcoStruxure Machine Expert, this controller
is used as target device.
If several controllers have been detected, double-click the controller you want to log in.
NOTE: In controller selection mode and in classic mode, only those controllers are
listed that have the same Target ID as the selected controller. To display all
controllers in the list, set the Filter criterion to None.
3
Execute the command Online > Login, or click the Login button from the toolbar,
or press ALT + F8.
4 Click Cancel to abort the login operation or press ALT + F to confirm the message and
to log in to the selected controller.
Result: If you press ALT + F the connection to the controller is established, and you can
download the application, page 203.
Unsuccessful Login
If... Then ... Comment
If an error is detected during Then the operation is aborted In the error message, you can
login to the controller, and an error message is display the error details.
displayed.
If an exception has occurred Then you can execute the This command opens the
containing the text command Show source code function in the editor with the
SOURCEPOSITION in the log in editor. cursor at the position where
message, the error was detected.
Downloading an Application
Introduction
To run an application, first connect the PC to the controller, then download the
application to the controller.
EIO0000002854.04 203
Managing Applications
Downloading a project allows you to copy the current project from EcoStruxure
Machine Expert to the controller memory.
NOTE: Due to memory size limitation, some controllers are not able to store
the application source but only a built application that is executed. Therefore,
you are not able to upload the application source from the controller to a PC.
WARNING
UNINTENDED EQUIPMENT OPERATION
• Confirm that you have entered the correct device designation or device
address in the Communication Settings dialog when downloading an
application.
• Confirm that machine guards and tags are in place such that any potential
unintended machine operation will not result in personal injury or equipment
damage.
• Read and understand all user documentation of the software and related
devices, as well as the documentation concerning equipment or machine
operation.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Preconditions
Verify that your application meets the following conditions before downloading it to
the controller:
• The active path is set for the correct controller.
• The application you want to download is active.
• The application is free of compilation errors.
• The Online > Operating Mode is set to Debug. For further information, refer
to the Operating Modes chapter in the Menu Commands Online Help.
Boot Application
The boot application is the application that is launched on controller start. This
application is stored in the controller memory. To configure the download of the
boot application, right-click the Application node in the Devices view and select
the Properties command.
At the end of a successful download of a new application, a message is displayed
asking you if you want to create the boot application.
You can manually create a boot application in the following ways:
• In offline mode: Click Online > Create boot application to save the boot
application to a file.
• In online mode, with the application being in STOP mode: Click Online >
Create boot application to download the boot application to the controller.
Operating Modes
The download method differs depending on the relationship between the loaded
application and the application you want to download. The 3 cases are:
• Case 1: The application in the controller is the same as the one you want to
load. In this case, no download occurs, you just connect EcoStruxure
Machine Expert to the controller.
204 EIO0000002854.04
Managing Applications
• Case 2: Modifications have been made to the application that is loaded in the
controller in comparison to the application in EcoStruxure Machine Expert. In
this case, you can specify if you want to download all or parts of the modified
application or keep the application in the controller as it is.
• Case 3: A different or a new version of application is already available on the
controller. In this case, you are asked whether this application should be
replaced.
• Case 4: The application is not yet available on the controller. In this case, you
are asked to confirm the download.
Step Action
1 To connect to the controller, select Online > Login to ’Application[YourApplicationName; Plc Logic]’.
2 You are connected to the controller.
Step Action
1 To connect to the controller, select Online > Login to ’Application[YourApplicationName; Plc Logic]’.
2
In case you modified your application, and you want to reload it into the controller, the following message appears:
Login with online change Only the modified parts of an already running project is reloaded to the controller.
Login with download The whole modified application is reloaded to the controller.
In this case, monitoring of variables is possible, but the logic flow may be confusing because the values on function
block outputs may not match to the values on the inputs.
Examples
In LD, contact states are monitored based on the affected variables. This may have the effect that a blue animated contact
followed by a blue link (meaning true) is shown, although the coil connected to this contact shows it as false.In ST logic flow,
an IF statement or a loop seems to be executed, but it is actually not executed because the condition expression is different
in the project and on the controller.
EIO0000002854.04 205
Managing Applications
Step Action
1 To connect to the controller, select Online > Login to ’Application[YourApplicationName; Plc Logic]’.
2a
In case, the controller is not in RUN mode, and you want to load a different application than the one currently in the
controller, the following message appears:
Refer to the hazard messages below before you click Yes to download the new application to the controller, or No to cancel
the operation.
2b
In case, the controller is in RUN mode, and you want to load a different application than the one currently in the controller,
the following message appears:
Refer to the build messages below before you click Yes to download the new application to the controller, or No to cancel
the operation.
WARNING
UNINTENDED EQUIPMENT OPERATION
Verify that you have the correct application before confirming the download.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
If you click Yes, the application running in your controller will be overwritten.
206 EIO0000002854.04
Managing Applications
Step Action
1 To connect to the controller, select Online > Login to ’Application[YourApplicationName; Plc Logic]’.
2
In case the application is not yet available on the controller, you are asked to confirm the download. For this purpose, a
dialog box with the following text displays:
Click Yes to download the application to the controller, or No to cancel the operation.
Online Change
The Online Change command modifies the running application program and
does not affect a restart process:
• The program code can behave other than after a complete initialization
because the machine keeps its state.
• Pointer variables keep their values from the last cycle. If there is a pointer on
a variable, which has changed its size due to an online change, the value will
not be correct any longer. Verify that pointer variables are reassigned in each
cycle.
WARNING
UNINTENDED EQUIPMENT OPERATION
Thoroughly test your application code for proper operation before placing your
system into service.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
EIO0000002854.04 207
Managing Applications
Element Description
Login with online change This option is selected per default. If you confirm the dialog box
by clicking OK, the modifications will be loaded and
immediately displayed in the online view (monitoring) of the
respective object or objects.
Login with download Activate this option to load and initialize the application project
completely.
Login without any change Activate this option in order to keep the program running on the
controller unchanged. Afterwards, an explicit download can be
performed, thus loading the complete application project. It is
also possible that you are asked again whether an online
change should be performed at the next relogin.
208 EIO0000002854.04
Managing Applications
EIO0000002854.04 209
Managing Applications
210 EIO0000002854.04
Managing Applications
EIO0000002854.04 211
Managing Applications
212 EIO0000002854.04
Managing Applications
7. Extract the project archive on PC2 with the same information options
activated as listed in step 5.
NOTE: For login without online change, make sure that you use the
EcoStruxure Machine Expert version that was used to create and download
the application in the controller.
Running Applications
Running Applications
Introduction
This part defines how to start/stop an application.
EIO0000002854.04 213
Managing Applications
Maintaining Applications
Monitoring
Overview
In online mode, there are various possibilities to display the current values of the
objects in the controller:
• You can see the values of the objects in a program editor screen while online.
For details, see the description of the respective editor.
• You can view object values in the online view of the declaration editor. For
details, refer to the description of the declaration editor, page 319.
• You can view objects independently in lists through the command Watch. For
details, refer to the description of the watch view / watch list editor, page 355.
You can insert a variable in a watch view by selecting it and executing the
command Add watchlist from the contextual menu.
• You can view values via trace sampling: recording and displaying of variable
values from the controller. For details, refer to the description of the trace
object functionality, page 383.
• You can view object values that are contained in recipes: User-defined set of
variables for writing and watching these variables on the controller. Refer to
the description of the recipe manager, page 366.
For information on monitoring of properties that are inserted beneath POUs or
function blocks, refer to the chapter Property, page 158.
For information on monitoring of function calls, refer to the chapter Attribute
Monitoring, page 512.
NOTE: If a value is not valid (for example, the result of calculating the square
root of a negative number), the result may be displayed as NaN (not a number)
or INF (infinite value) depending on the operation, the object, and the
particular controller platform. Consult the Programming Guide specific to your
controller for more information.
Debugging
Overview
To evaluate potential programming errors, you can use the debugging
functionality.
For testing purposes, an application can also run in simulation (see EcoStruxure
Machine Expert, Menu Commands, Online Help) without any required link to an
actual target device. While simulation avoids the need to connect to physical
hardware, there are limitations to which you may need to complete debugging
online.
214 EIO0000002854.04
Managing Applications
Conditional Breakpoints
The stop at the breakpoint can be dependent on the following conditions:
• At the time, a specific boolean expression is TRUE.
• Which cycle number is running.
• Which task is executing.
• When the value of a variable is modified (data breakpoint).
Declaring a specific debug task can help to avoid that several tasks are affected
by the error check (refer to the Breakpoints and Stepping in Applications with
Multiple Tasks paragraph, page 217).
Execution Points
In online mode, the Breakpoints dialog box (see EcoStruxure Machine Expert,
Menu Commands, Online Help) allows you to change a breakpoint and data
breakpoint in such a way that it becomes an execution point. Then the program
does not stop at the position, but the code processing is initiated.
Symbols
Symbol Description
Breakpoint enabled.
Breakpoint disabled.
Stop at breakpoint.
EIO0000002854.04 215
Managing Applications
Symbol Description
216 EIO0000002854.04
Managing Applications
Data Breakpoints
Data breakpoints allow you to stop program execution when the value of a
variable changes.
This function is not available for all supported controllers. Consult the
Programming Guide specific to your controller.
The number of data breakpoints you can define depends on the controller you are
using. A message is displayed when you attempt to set a data breakpoint and the
maximum number has been reached.
The following options exist for data breakpoints as for normal breakpoints:
• Linking the halt at the data breakpoint to an additional condition, refer to
Conditional Breakpoints, page 215.
• Redefining a data breakpoint to a data execution point where the program
does not halt, but processes specific code, refer to Execution Points, page
215.
EIO0000002854.04 217
Managing Applications
Core Dump
Core Dump for Exceptions
A core dump is a memory snapshot of the application data. When supported by
the runtime system, a core dump is automatically saved to a file <application_
name>.core in the application directory on the controller when an exception is
detected.
In online mode, you can also generate a core dump explicitly if the application is
currently stopped at breakpoint or if an exception has been detected. In this case,
the core dump file is saved only in the project directory and not on the controller.
In offline mode, you can load the core dump of the application from the controller
to the EcoStruxure Machine Expert project. Then the application is displayed in its
online view with the data and values at the time when the exception was detected
and the core dump was created.
In addition, the log file of the controller can be displayed from the time the core
dump was created in the project.
NOTE: The firmware must support the functionality in order to display the
variable values in the core dump view correctly. In the online view of the
application that is created by loading the core dump into the project, menu
commands are displayed as available but do not have any effect in this status.
When choosing one of these commands, a message is displayed.
Refer to your controller programming manual to verify whether it supports the
core dump functionality.
NOTE: Exception handling in the runtime system may overwrite parts of the
variable values in the call stack. As a result, original values may be lost and
important information may no longer be displayed when monitoring for
variables in functions and methods.
Consider the following, for creating a project archive:
If... Then...
If you created a core dump explicitly by choosing then an option is automatically available in the
the command Create Core Dump, archive configuration.
If you copied the core dump from the controller, then you can add it to a project archive only by
choosing the function Additional files.
NOTE: A project archive with a core dump must include the download
information; otherwise the dump is unusable.
218 EIO0000002854.04
Managing Applications
Step Action
1 Load the core dump from the controller by executing the command Debug > Load
Core Dump.
Result: An online view of the application is displayed. You see the variable values and
call stack from the time when the error has been detected. This also includes the values
of the I/O variables in the mapping dialog of the device configurator and the task
configuration. The message Core dump loaded is displayed in the status line. The core
dump file is copied as <project_name>.<device_name>.<application_name>.
<application-Guid>.core to the local project directory.
2 Execute the command Debug > Load device log from Core Dump to load the device
log from the time the error has been detected into the project.
Result: The log view opens (as in online mode of the device configurator) displaying the
events at the time the core dump was created.
3 After you have completed the core dump analysis, execute the command Debug >
Close Core Dump.
Result: The core dump view of the application closes and the project returns to its views
in normal offline mode.
Step Action
EIO0000002854.04 219
Managing Applications
Programming Support
Overview
EcoStruxure Machine Expert offers settings, dialogs and functionalities, which
facilitate the input of program code and indicate detected errors at an early stage.
For further information, refer to the descriptions of the following functions:
• Input Assistant, page 360
• Intelli-sense, page 527
• Auto Declare... (see EcoStruxure Machine Expert, Menu Commands, Online
Help)
• Smart Coding (see EcoStruxure Machine Expert, Menu Commands, Online
Help)
• Static Analysis Light, page 224
Refactoring
Overview
Generally refactoring is the process of restructuring and improving existing
software code without changing its behavior.
Refactoring in EcoStruxure Machine Expert provides functionalities for renaming
object names and variable names. It allows you to show all usage locations of
changed objects and variables and to get renamed all those at once, or only
individual ones. You can configure whether and at which locations you should get
asked for performing refactoring. Explicitly you can use the command
Refactoring > Rename.
For further information, also refer to Options, Refactoring (see EcoStruxure
Machine Expert, Menu Commands, Online Help).
Command Rename
The command Refactoring > Rename is used for a global, project wide renaming
of object names, and variable names.
It is available in the contextual menu if you set the cursor on a variable name in
the declaration or if you right-click one of the following objects in a navigator:
• Functions
• POUs
• GVLs
• Methods
• Properties
• Devices
The command is also available if you select variables and unit conversions within
the editor for unit conversions.
The command is not available in online mode.
Process of Renaming
After you have executed the Refactoring > Rename command, a dialog is
displayed. It shows the locations where the concerned name is used: In the right
part of the window the particular locations, in the left part the navigation tree where
the concerned object is marked.
220 EIO0000002854.04
Managing Applications
You can select the following commands for each location individually:
• Reject/accept this change: Reject/accept single changes in the right
window.
• Reject/accept this object: Reject/accept all changes in the concerned
object.
• Reject/accept whole project: Reject/accept all changes in the project.
Accepted changes are displayed with a yellow background, rejected changes with
gray background.
Option Description
Add inputs with Select this option to insert the standard placeholder text _REFACTOR_
placeholder text whenever the new variable occurs in the implementation code. You
can search for this standard text later in order to identify the affected
locations.
Add inputs with the Select this option to insert an initialization value whenever the new
following value variable occurs in the implementation code. Enter the initialization
value in the text box on the right-hand side of the option Add inputs
with the following value.
EIO0000002854.04 221
Managing Applications
222 EIO0000002854.04
Managing Applications
in : DUT;
bvar : BOOL;
invar3 : INT;
Proceed as follows to change the order of declarations:
Step Action
1 Right-click the declaration part and execute the command Refactoring > Reorder
Variables.
Result: The Reorder dialog box opens with a list of VAR_INPUT variables.
2 Drag the invar1 : INT; entry to the position before the invar2. entry.
Result: The Refactoring dialog box opens. The affected elements are marked in
yellow.
4 Click OK to accept the new order of parameters of the function block. Have in mind that
the modified order of the parameters will be reflected also at the call usages of the
POUs.
1 Execute the command Tools > Options.... Result: The Options dialog box
opens.
5 Select a variable in the declaration of fb_A, for As an alternative, you can place the
example, iA. cursor before or in the variable.
6 Execute the command Edit > Auto Declare.... As an alternative, use the shortcut
Shift + F2.
7 Edit the Name and change iA into iCounter_A. Result: The Refactoring -
Renaming from iA to iCounterA
dialog box opens. The POUs where
the variable is used are highlighted
in the tree structure.
8 Click OK to apply the renaming and to close the –
dialog box.
EIO0000002854.04 223
Managing Applications
224 EIO0000002854.04
Managing Applications
Step Action
EIO0000002854.04 225
Managing Applications
3.) Upload the project (sources) from the controller by executing the Online >
Source Upload... command (see EcoStruxure Machine Expert, Menu
Commands, Online Help).
226 EIO0000002854.04
Logic Editors
What’s in This Part
Common Features of Graphic Editors ............................................................ 228
FBD/LD/IL Editor .......................................................................................... 230
Continuous Function Chart (CFC) Editor ........................................................ 264
Sequential Function Chart (SFC) Editor ......................................................... 281
Structured Text (ST) Editor............................................................................ 305
EIO0000002854.04 227
Common Features of Graphic Editors
2 Panning tool The pointer gets the shape of crossed arrows. You can click somewhere in the editor
window and - while keeping the mouse-button pressed - shift the visible area of the
chart within the window.
3 Magnifier tool This function is useful when you have zoomed down the displayed chart to less than
100%. It opens a subwindow in the lower right corner of the editor window. As long as
you move the pointer over your chart, this subwindow shows the respective part of
the chart in 100% size.
If you now click the window, the subwindow closes and that segment of the chart
which was shown in the subwindow, is displayed in 100% size. So, if you want to
keep the previously set zoom factor, use the Back to standard editing mode button
to get back to the normal editing mode.
4 Zooming tool The zoom button opens a submenu where you can select one of the given zoom
factors for the chart. To specify another value, click the ... button to open an edit
dialog box. The current zoom factor is displayed to the left of the button.
To zoom by mouse wheel, press the Ctrl key while scrolling the mouse wheel. The
current zoom level is increased or decreased in steps of 10 percent.
228 EIO0000002854.04
Common Features of Graphic Editors
You can drag function block declarations from the declaration part in the FBD and
LD graphical editors to the editor view. To do this, select the full declaration
(variable name and data type) and drag it to a suitable position in the editor view.
In the ladder diagram, you can also drag Boolean declarations to the editor and
insert them as contacts.
EIO0000002854.04 229
FBD/LD/IL Editor
FBD/LD/IL Editor
What’s in This Chapter
Information on the FBD/LD/IL Editor ............................................................. 230
FBD/LD/IL Elements.................................................................................... 252
LD Elements ............................................................................................... 262
230 EIO0000002854.04
FBD/LD/IL Editor
FBD networks
EIO0000002854.04 231
FBD/LD/IL Editor
Each instruction is primarily based on the loading of values into the accumulator
by using the LD operator. After that the operation is executed with the first
parameter taken out of the accumulator. The result of the operation is available in
the accumulator, from where you should store it with the ST instruction.
In order to program conditional executions or loops, IL supports both comparing
operators such as EQ, GT, LT, GE, LE, NE and jumps. The latter can be
unconditional (JMP) or conditional (JMPC / JMPCN). For conditional jumps, the
value of the accumulator is referenced for TRUE or FALSE.
Syntax
An instruction list (IL) consists of a series of instructions. Each instruction begins
in a new line and contains an operator and, depending on the type of operation, 1
or more operands separated by commas. You can extend the operator by a
modifier.
In a line before an instruction, there can be an identification mark (label) followed
by a colon (:) (ml: in the example shown below). A label can be the target of a
jump instruction (JMPC m1 in the example shown below).
Place a comment as last element of a line.
You can insert empty lines between instructions.
Example
LD BVar1
ST tonInst1.IN
CAL tonInst1(
PT:=t1,
ET=>tOut2)
LD toninst1.Q
JMPC mark1
ST tonInst2.IN
___________________________________________________________
markl:
LD iVar2
ADD 230
For further information, refer to:
• Working in the IL Editor View, page 240
• Modifiers and operators in IL, page 232
C with JMP, CAL, RET: The instruction will only be executed if the result of the
preceding expression is TRUE.
N with JMPC, CALC, RETC: The instruction will only be executed if the result of the
preceding expression is FALSE.
232 EIO0000002854.04
FBD/LD/IL Editor
( with operators according to To be used for complex operands. For details, refer to the
the Operators table below (( list of use cases for complex operands, page 234.
(left parenthesis) in Modifiers
column)
NOTE: Generally, it is not good practice to use the statement CALC (/RETC/
JMPC) directly after an STN, S or R operator, as those instructions arbitrarily
modify the value of the accumulator and thus could lead to difficult-to-find
programming errors.
Operators
The table shows which operators can be used in combination with the specified
modifiers.
The accumulator stores the current value, resulting from the preceding operation.
EIO0000002854.04 233
FBD/LD/IL Editor
See also IEC operators, page 562 and Work in IL editor, page 240 for how to use
and handle multiple operands, complex operands, function / method / function
block / program / action calls and jumps.
Example
Example IL program using some modifiers:
LD TRUE load TRUE to accumulator
ANDN bVar1 execute AND with negative value of bVar1
JMPC m1 if accum. is TRUE, jump to label “m1”
LDN bVar2 store negated value of bVar2...
ST bRes ... in bRes
___________________________________________________________
m1:
LD bVar2 store value of bVar2...
ST bRes ... in bRes
Using Operands
The table lists use cases for operands:
234 EIO0000002854.04
FBD/LD/IL Editor
LEN
Enter the right parenthesis in SUB 1
the first column in a separate )
row followed by the operand CONCAT( stRotate,
entries in the following rows. LEFT 1
)
ST stRotate
Function block Row 1: CAL POUToCall(
call, program iCounter:=1,
• Column 1:
call iDecrement:=1000,
Operator CAL or CALC wError:=wResult)
• Column 2:
LD POUToCall.bError,
Name of the function ST bErr
block instance or the
program and left
parenthesis (. If no
parameters follow, the
right parenthesis ) is
entered here.
Following rows:
• Column 1:
Parameter name
followed by:
◦ := for input
parameters
◦ => for output
parameters
• Column 2:
Parameter value followed
by a comma , if followed
by further parameters.
Enter the right
parenthesis ) after the
last parameter.
According to the IEC standard
complex expressions are not
allowed here. Assign such
constructs to the function block
or the program before it is
called.
Function call Row 1: LD X7
GeomAverage 25
• Column 1:
ST Ave
LD
• Column 2:
Input variable
Row 2:
• Column 1:
Function name
• Column 2:
Further input parameters,
separated by commas
The return value is written to
the accumulator.
Row 3:
• Column 1:
ST
• Column 2:
Variable to which the
return value is written
EIO0000002854.04 235
FBD/LD/IL Editor
Tooltip
Tooltips contain information on variables or box parameters.
The cursor being placed on the name of a variable or box parameter will prompt a
tooltip. It shows the respective type. In case of function block instances the scope,
name, datatype, initial value, and comment will be displayed. For IEC operators
SEL, LIMIT, and MUX a short description on the inputs will display. If defined, the
address and the symbol comment will be shown as well as the operand comment
(in quotation marks in a second line).
236 EIO0000002854.04
FBD/LD/IL Editor
• You can use the cut, copy, paste, and delete commands, available in the Edit
menu, to arrange elements. You can also copy an element by drag and drop:
select the element within a network by a mouse-click, press the CTRL key
and while keeping the mouse button and the key pressed, drag the element to
the target position. As soon as that is reached (green position marker), a plus-
symbol will be added to the cursor symbol. Then, release the mouse-button to
insert the element.
• For possible cursor positions, refer to Cursor Positions in FBD, LD, and IL,
page 244.
• Inserting of EN/ENO boxes is handled diversely in the FBD and LD editor.
Refer to the description of the Insert Box command for further information
(Inserting of EN/ENO boxes is not supported in the IL editor).
EIO0000002854.04 237
FBD/LD/IL Editor
Selecting
• You can select an element, also a network, via taking the respective cursor
position by a mouse-click or using the arrow or tab keys. Selected elements
are indicated as red-shaded. Also refer to Cursor Positions in FBD, LD, and
IL, page 244.
• In the LD editor, you can also select the lines between elements in order to
execute commands, for example, for inserting a further element at that
position.
Selected line in LD editor
238 EIO0000002854.04
FBD/LD/IL Editor
FBD editor
LD editor
EIO0000002854.04 239
FBD/LD/IL Editor
Tooltip
Tooltips contain information on variables or box parameters.
Refer to Working in the FBD and LD Editor View, page 236.
240 EIO0000002854.04
FBD/LD/IL Editor
Each program line is written in a table row, structured in fields by the table
columns:
3 address This field contains the address of the operand as defined in the
declaration part. You cannot edit this field. Use the option Show
symbol address to switch it on or off.
4 symbol This field contains the comment as defined for the operand in the
comment declaration part. You cannot edit this field. Use the option Show
symbol address to switch it on or off.
5 operand This field contains the comment for the current line. It is editable and
comment can be switched on or off via option Show operand comment.
EIO0000002854.04 241
FBD/LD/IL Editor
Complex Operands
If a complex operand is to be used, enter an opening bracket before, then use the
following lines for the particular operand components. Below them, in a separate
line, enter the closing bracket.
Example: Rotating a string by 1 character at each cycle.
Corresponding ST code:
stRotate := CONCAT(RIGHT(stRotate, (LEN(stRotate) - 1)),
(LEFT(stRotate, 1)));
LD stRotate
RIGHT( stRotate
LEN
SUB 1
)
CONCAT( stRotate
LEFT 1
)
ST stRotate
Function Calls
Enter the function name in the operator field. Give the (first) input parameter as an
operand in a preceding LD operation. If there are further parameters, give the next
one in the same line as the function name. You can add further parameters in this
line, separated by commas, or in subsequent lines.
The function return value will be stored in the accumulator. The following
restriction concerning the IEC standard applies.
NOTE: A function call with multiple return values is not possible. Only 1 return
value can be used for a succeeding operation.
Example: Function GeomAverage, which has 3 input parameters, is called. The
first parameter is given by X7 in a preceding operation. The second one, 25, is
given with the function name. The third one is given by variable tvar, either in the
same line or in the subsequent one. The return value is assigned to variable Ave.
Corresponding ST code:
Ave := GeomAverage(X7, 25, tvar);
Function call in IL:
LD X7
GeomAverage 25
tvar
ST Ave
242 EIO0000002854.04
FBD/LD/IL Editor
Action Call
To be performed like a function block or program call, the action name is to be
appended to the instance name or program name.
Example: Call of action ResetAction.
Corresponding ST code:
Inst.ResetAction();
Action call in IL:
CAL Inst.ResetAction()
EIO0000002854.04 243
FBD/LD/IL Editor
Method Call
To be performed like a function call, the instance name with appended method
name is to be entered in the first column (operator).
Example: Call of method Home.
Corresponding ST code:
Z := IHome.Home(TRUE, TRUE, TRUE);
Method call in IL:
LD TRUE
IHome.Home TRUE
TRUE
ST Z
Jump
A jump, page 255 is programmed by JMP in the first column (operator) and a label
name in the second column (operand). The label is to be defined in the target
network in the label, page 255 field.
The statement list preceding the unconditional jump has to end with one of the
following commands: ST, STN, S, R, CAL, RET, or another JMP.
This is not the case for a conditional jump, page 255. The execution of the jump
depends on the value loaded.
Example: Conditional jump instruction; in case bCallRestAction is TRUE, the
program should jump to the network labeled with Cont.
Conditional jump instruction in IL:
LDN bCallResetAction
JMPC Cont
244 EIO0000002854.04
FBD/LD/IL Editor
In the left image, the possible cursor positions are marked by a red-frame. The
right image shows a box with the cursor being placed in the AND field. Keep in
mind the possibility to enter addresses instead of variable names if configured
appropriately in the FBD, LD and IL editor Options dialog box.
(2) Every input:
(5) Just before the lined cross above an assignment before a jump or a return
instruction:
(6) The right-most cursor position in the network or anywhere else in the network
besides the other cursor positions. This will select the whole network:
EIO0000002854.04 245
FBD/LD/IL Editor
(11) The connecting line between the contacts and the coils:
You can add new networks on the left-most side of the editor. The insertion of a
new network before an existing network is only possible before network 1.
246 EIO0000002854.04
FBD/LD/IL Editor
You can add contacts and function blocks at the begin of a network on the field
Start here. You can add the elements return, jump, and coil at the end of a
network on the field Add output or jump here.
FBD/LD/IL Menu
Overview
When the cursor is placed in the FBD/LD/IL Editor, page 230 window, the FBD/LD/
IL menu is available in the menu bar, providing the commands for programming in
the currently set editor view.
FBD/LD/IL menu in FBD editor view:
EIO0000002854.04 247
FBD/LD/IL Editor
Monitoring
If the inline monitoring is not explicitly deactivated in the Options dialog box, it will
be supplemented in FBD or LD editor by small monitoring windows behind each
variable or by an additional monitoring column showing the actual values (inline
monitoring). This is even the case for unassigned function block inputs and
outputs.
The inline monitoring window of a variable shows a little red triangle in the upper
left corner if the variable is currently forced, page 250, a blue triangle in the lower
left corner if the variable is currently prepared for writing or forcing. In LD, for
contacts and coils the currently prepared value (TRUE or FALSE) will be displayed
down right below the element.
Example for a variable which is currently forced and prepared for releasing the
force
Example for a contact variable which is currently prepared to get written or forced
with value TRUE
248 EIO0000002854.04
FBD/LD/IL Editor
EIO0000002854.04 249
FBD/LD/IL Editor
Forcing/Writing of Variables
In online mode, you can prepare a value for forcing or writing a variable either in
the declaration editor, page 323 or within the editor. Double-click a variable in the
editor to open the following dialog box:
Dialog box Prepare Value
You find the name of the variable completed by its path within the device tree
(Expression), its type, and current value. By activating the corresponding item,
you can do the following:
• Preparing a new value which has to be entered in the edit field.
• Removing a prepared value.
• Releasing the forced variable.
• Releasing the forced variable and resetting it to the value it was assigned to
just before forcing.
The selected action will be carried out on executing the menu command Force
values (in the Online menu) or by pressing F7.
250 EIO0000002854.04
FBD/LD/IL Editor
For information on how the current state of a variable (forced, prepared value) is
indicated at the respective element in the network, refer to the section Monitoring,
page 248.
1 breakpoint set
2 breakpoint reached
As soon as a breakpoint position is reached during stepping or program
processing, a yellow arrow will be displayed in the breakpoint symbol and the red
shaded area will change to yellow.
EIO0000002854.04 251
FBD/LD/IL Editor
FBD/LD/IL Elements
FBD/LD/IL Toolbox
Overview
The FBD/LD/IL Editor, page 230 provides a toolbox which offers the programming
elements for being inserted in the editor window by drag and drop. Open the
toolbox by executing the command ToolBox which is in the View menu.
It depends on the currently active editor view which elements are available for
inserting (see the respective description of the insert commands).
The elements are sorted in categories: General (general elements such as
Network, Assignment and so on), Boolean operators, Math operators, Other
operators (for example, SEL, MUX, LIMIT, and MOVE), Function blocks (for
example, R_TRIG, F_TRIG, RS, SR, TON, TOF, CTD, CTU), Ladder elements,
and POUs (user-defined).
The POUs category lists all POUs which have been defined below the same
application as the FBD/LD/IL object which is open in the editor. If a POU has been
assigned a bitmap in its properties, then this will be displayed before the POU
name. Otherwise, the standard icon for indicating the POU type will be used. The
list will be updated automatically when POUs are added or removed from the
application.
The category Other operators contains among SEL, MUX, LIMIT, and MOVE
operators a conversion placeholder element. You can drag and drop this element
to the desired position of the network. The conversion type is set automatically,
dependent on the required type of the insert position. In some situations however
the required conversion type cannot be determined automatically. Change the
element manually in this case.
To unfold the category folders, click the button showing the respective category
name. See in the following image: The category General is unfolded, the others
252 EIO0000002854.04
FBD/LD/IL Editor
are folded. The image shows an example for inserting an Assignment element by
drag and drop from the toolbox.
Only the section General in the toolbox is unfolded:
Insert from toolbox
Network in FBD/LD/IL
Overview
A network is the basic entity of an FBD, page 230 or LD, page 231 program. In the
FBD/LD editor, the networks are arranged in a vertical list. Each network is
designated on the left side by a serial network number and has a structure
consisting of either a logical or an arithmetic expression, a program, function or
function block call, and possibly jump or return instructions.
The IL Editor, page 231, due to the common editor base with the FBD and LD
editors, also uses the network element. If an object initially was programmed in
FBD or LD and then is converted to IL, the networks will be still present in the IL
program. Vice versa, if you start programming an object in IL, you need at least 1
network element which might contain all instructions, but you can also use further
networks to structure the program.
A network optionally can get assigned a title, a comment and a label, page 255.
You can switch the visibility of the title, the comment fields, and the network
separator on and off in the FBD, LD and IL editor options dialog box. If the option
is activated, click in the network directly below the upper border to open an edit
field for the title. For entering a comment, correspondingly open an edit field
directly below the title field. The comment can be multi-lined. Press ENTER to
insert line breaks. Press CTRL + ENTER to terminate the input of the comment
text.
EIO0000002854.04 253
FBD/LD/IL Editor
Whether and how a network comment is displayed in the editor, is defined in the
FBD, LD, and IL editor options dialog box.
To add a label, page 255, which then can be addressed by a jump, page 255, use
the command Insert label . If a label is defined, it will be displayed below the title
and comment field or - if those are not available - directly below the upper border
of the network.
Comments and label in a network
You can set a network in comment state. This indicates that the network is not
processed but displayed and handled as a comment. To achieve this, use the
command Toggle network comment state.
On a currently selected network (cursor position 6, page 245), you can apply the
default commands for copying, cutting, inserting, and deleting.
NOTE: Right-clicking (cursor position 6, page 245) titles, comments, or labels
will select this entry only instead of the whole network. So the execution of the
default commands does not affect the network.
To insert a network, use command Insert Network or drag it from the toolbox,
page 252. A network with all belonging elements can also be copied or moved,
page 236 by drag and drop within the editor.
You can also create subnetworks, page 256 by inserting branches.
RET Network
In online mode, an additional empty network will be displayed below the existing
networks. Instead of a network number, it is identified by RET.
It represents the position at which the execution will return to the calling POU and
provides a possible halt position, page 248.
Assignment in FBD/LD/IL
Overview
Depending on the selected cursor position, page 244 in FBD or LD, an
assignment will be inserted directly in front of the selected input (cursor position 2,
254 EIO0000002854.04
FBD/LD/IL Editor
page 245), directly after the selected output (cursor position 4, page 245) or at the
end of the network (cursor position 6, page 245). In an LD network, an assignment
will be displayed as a coil, page 263. Alternatively, drag the assignment element
from the toolbox, page 252 or copy or move, page 236 it by drag and drop within
the editor view.
After insertion, the text string ??? can be replaced by the name of the variable that
is to be assigned. For this, use the ... button to open the Input Assistant.
In IL, page 231, an assignment is programmed via LD and ST instructions. Refer
to Modifiers and Operators in IL, page 232.
Jump in FBD/LD/IL
Overview
Depending on the selected cursor position, page 244 in FBD, page 230 or LD,
page 231, a jump will be inserted directly in front of the selected input (cursor
position 2), directly after the selected output (cursor position 4) or at the end of the
network (cursor position 6). Alternatively, drag the jump element from the toolbox,
page 252 or copy or move, page 236 it by drag and drop within the editor.
After insertion, you can replace the automatically entered ??? by the label to
which the jump should be assigned.
In IL, page 231, a jump is inserted via a JMP instruction. See in this context the
description of the operators and modifiers in IL, page 232.
Label in FBD/LD/IL
Overview
Below the network comment field each FBD, page 230, LD, page 231 or IL
network have a text input field for defining a label. The label is an optional
identifier for the network and can be addressed when defining a jump, page 255. It
can consist of any sequence of characters.
Position of a label in a network
See the Tools > Options > FBD, LD and IL editor dialog box for defining the
display of comment and title.
Boxes in FBD/LD/IL
Overview
A box, insertable in an FBD, page 230, LD, page 231, or IL, page 231 network, is
a complex element and can represent additional functions like timers, counters,
arithmetic operations, or also programs, IEC functions and IEC function blocks.
A box can have one or more inputs and outputs and can be provided by a library
or can be programmed by the user.
EIO0000002854.04 255
FBD/LD/IL Editor
You can group the inputs and outputs of a function block in its declaration via the
attribute pingroup. In the display of the function block in an FBD or LD
editor, the groups can then be faded out and in. For further information, refer to the
Attribute pingroup chapter, page 520.
If provided with the respective module and if the option Show box icon is
activated, an icon is displayed within the box.
Use in FBD, LD
You can position a box in a LD network or in an FBD network by using the
command Insert Box, Insert Empty Box. Alternatively, you can insert it from the
toolbox, page 252 or copy or move it within the editor via drag and drop. For
further information, refer to the description of the Insert Box command.
Use in IL
In an IL, page 231 program, a CAL, page 232 instruction with parameters will be
inserted in order to represent a box element.
You can update the box parameters (inputs, outputs) - in case the box interface
has been modified - with the current implementation without having to reinsert the
box by executing the Update parameters command.
In IL, the RET, page 232 instruction is used for the same purpose.
256 EIO0000002854.04
FBD/LD/IL Editor
Branch markers
In FBD, insert a branch via command Insert branch. Alternatively, drag the
element from the toolbox, page 252. For the possible insert positions, refer to the
description of the Insert branch command.
NOTE: Cut and paste is not implemented for subnetworks.
A branch has been inserted at the SUB box output in the example shown below.
This created 2 subnetworks, each selectable by their subnet marker. After that, an
ADD box was added in each subnetwork.
Network in FBD with inserted branch
To delete a subnetwork, first remove all elements of the subnetwork, that is all
elements which are positioned to the right of the marker of the subnetwork. Then
select the marker and execute the standard Delete command or press the DEL
key.
In the following image, the 3-input-OR element has to be deleted before you can
select and delete the marker of the lower subnetwork.
EIO0000002854.04 257
FBD/LD/IL Editor
IL (Instruction List)
The IL, page 231 does not support networks with branches. They will stay in the
original representation.
Parallel Branches
You can use parallel branches for setting up parallel branch, page 258 evaluation
in ladder networks.
In contrast to the open branch (without the junction point), the parallel branches
are closed. They have common split and junction points.
Parallel Branch
Overview
A parallel branch allows you to implement a parallel evaluation of logical elements.
This is accomplished via a methodology described as Short Circuit Evaluation
(SCE). SCE allows you to by-pass the execution of a function block with a boolean
output if certain parallel conditions are evaluated to be TRUE. The condition can
be represented in the LD editor by a parallel branch to the function block branch.
The SCE condition is defined by 1 or several contacts within this branch,
connected parallel or sequentially.
The vertical connections of short circuit evaluation branches executed in parallel
are represented by a double line in order to differentiate them from OR constructs
that are represented by a single line (see the figure Parallel branch for SCE in a
ladder network).
NOTE: The term branch is also used for another element that splits off a
signal flow. This branch, page 256 as opposed to the parallel branch has no
junction point.
The parallel branch works as follows: first it will be parsed for the branches not
containing a function block. If 1 of such branches is evaluated to be TRUE, then
the function block in the parallel branch will not be called and the value at the input
of the function block branch will be passed to the output. If the SCE condition is
evaluated to be FALSE, then the function block will be called and the boolean
result of the function block execution call will be passed on.
If all branches contain function blocks, then they will be evaluated in top-to-bottom
order and the outputs of them will be combined with logical OR operations. If there
258 EIO0000002854.04
FBD/LD/IL Editor
are no branches containing a function block call, then the normal OR operation will
be performed.
To insert a parallel branch with SCE function, select the function block box and
execute the command Insert Contact Parallel above or Insert Contact Parallel
below. This is only possible if the first input and the main output of the function
block are of type BOOL.
Below is an example of the generated language model for the given network.
1 The double vertical connection lines indicate a construct that is subject to an SCE.
2 The single vertical connection line indicates an OR construct.
The processing is as shown in the following, whereby P_IN and P_OUT represent
the boolean value at the input (split point) and output (junction point) of the parallel
branch, respectively.
P_IN := b1 AND b2;
IF ((P_IN AND cond1) AND (cond2 OR cond3)) THEN
P_OUT := P_IN;
ELSE
x1(IN := P_IN, PT := {p 10}t#2s);
tElapsed := x1.ET;
P_OUT := x1.Q;
END_IF
bRes := P_OUT AND b3;
The following images show the dataflow (blue) in case the function block is
executed (condition resulting from cond1, cond2 and cond3 is FALSE) or
bypassed (condition is TRUE).
Condition=FALSE, function block is executed:
EIO0000002854.04 259
FBD/LD/IL Editor
Set/Reset in FBD/LD/IL
FBD and LD
A boolean output in FBD, page 230 or correspondingly an LD, page 231 coil can
be set or reset. To change between the set states, use the respective command
Set/Reset from the contextual menu when the output is selected. The output or
coil will be marked by an S or an R.
Set If value TRUE arrives at a set output or coil, this output/coil will become TRUE and
remain TRUE. This value cannot be overwritten at this position as long as the
application is running.
Reset If value TRUE arrives at a reset output or coil, this output/coil will become FALSE and
remain FALSE. This value cannot be overwritten at this position as long as the
application is running.
In the LD editor, you can insert set and reset coils by drag and drop. To perform
this action, use either the ToolBox, category Ladder elements, or the S and R
elements from the tool bar.
Example:
Set coil, reset coil
260 EIO0000002854.04
FBD/LD/IL Editor
IL
In an Instruction List, use the S and R, page 233 operators to set or reset an
operand.
Set/Reset Coil
Overview
Coils, page 263 can also be defined as set or reset coils.
You can recognize a set coil by the S in the coil symbol: (S). A set coil will not
overwrite the value TRUE in the appropriate boolean variable. That is, the variable
once set to TRUE remains TRUE.
You can recognize a reset coil by the R in the coil symbol: (R). A reset coil will not
overwrite the value FALSE in the appropriate boolean variable. That is, the
variable once set to FALSE will remain FALSE.
In the LD editor, you can insert set coils and reset coils directly via drag and drop
from the ToolBox, category Ladder elements. In doing so, you can also replace
already inserted coil elements by others.
Set coil, reset coil
Execute
Overview
The Execute element is a block with EN/ENO that you can insert in an FBD or LD
network and that you can fill with ST code. The ST code is executed when the
block is activated for processing with a TRUE signal at the EN input.
Drag the Execute element from the toolbox, page 252 into the network or
execute the FBD/LD/IL > Execute command (see EcoStruxure Machine Expert,
Menu Commands, Online Help) to insert the element.
Entering ST Code
Step Action Comment
1 Click the input field with the text Enter ST-Code The ST editor, page 305 opens
here... in the box. providing the usual functionalities.
Online Mode
In online mode, you can open the ST editor by clicking the plus sign under the EN
input on the function block. The usual online functionalities (monitoring,
debugging) are available in the editor.
EIO0000002854.04 261
FBD/LD/IL Editor
Example
Examples for an Execute block in the FBD network.
Offline mode, ST program inserted
LD Elements
Contact
Overview
This is an LD element.
In LD, page 231 in its left part, each network contains 1 or several contacts.
Contacts are represented by 2 vertical, parallel lines.
262 EIO0000002854.04
FBD/LD/IL Editor
A negated contact passes on the incoming condition (TRUE or FALSE) only if the
assigned boolean variable is FALSE.
You can insert a contact in an LD network via one of the commands Insert
Contact or Insert Contact (right) Insert Contact Parallel (above), Insert
Contact Parallel (below), Insert Rising Edge Contact, or Insert Falling Edge
Contact which are part of the LD menu. Alternatively, you can insert the element
via drag and drop from the ToolBox, page 252 or from another position within the
editor (drag and drop).
You can replace an already inserted contact by a new contact or a negated
contact. For this purpose, drag a contact or a negated contact from the toolbox,
page 252 onto an existing contact and drop it there.
FBD and IL
If you are working in FBD, page 230 or IL, page 231 view, the command will not be
available. But contacts and coils inserted in an LD network will be represented by
corresponding FBD elements or IL instructions.
Coil
Overview
This is an LD element.
On the right side of an LD network, there can be any number of coils which are
represented by parentheses.
They can only be arranged in parallel. A coil transmits the value of the connections
from left to right and copies it to an appropriate boolean variable. At the entry line,
the value ON (TRUE) or the value OFF (FALSE) can be present.
Coils can also be negated. This is indicated by the slash in the coil symbol.
In this case the negated value of the incoming signal will be copied to the
appropriate boolean variable.
You can insert a coil in a network via one of the commands Insert Coil, Insert Set
Coil, Insert Reset Coil, or Insert Negated Coil in the LD menu. Alternatively, you
can insert the element via drag and drop from the ToolBox (Ladder elements) or
via drag and drop from another position within the editor. Also refer to Set and
Reset Coils, page 261.
FBD and IL
If you are working in FBD, page 230 or IL, page 231 view, the command will not be
available. But contacts and coils inserted in an LD network will be represented by
corresponding FBD elements or IL instructions.
EIO0000002854.04 263
Continuous Function Chart (CFC) Editor
CFC Editor
Overview
The CFC editor is a graphical editor available for programming objects in the
continuous function chart (CFC) programming language , page 264, which is an
extension to the IEC 61131-3 programming languages. Choose the language
when you add a new program organization unit (POU) object to your project. For
large projects, consider using the page-oriented version, page 279.
The editor will be available in the lower part of the window which opens when
opening a CFC POU object. This window also includes the declaration editor,
page 319 in its upper part.
264 EIO0000002854.04
Continuous Function Chart (CFC) Editor
CFC editor
The CFC editor in contrast to the FBD / LD editor allows free positioning, page 271
of the elements, which allows direct insertion of feedback paths. The sequence of
processing is determined by a list which contains all currently inserted elements
and can be modified.
The following elements are available in a toolbox, page 267 and can be inserted
via drag and drop:
• box (operators, functions, function blocks, and programs)
• input
• output
• jump
• label
• return
• composer
• selector
• connection marks
• comments
You can connect the input and output pins of the elements by drawing a line with
the mouse. The path of the connecting line will be created automatically and will
follow the shortest possible route. The connecting lines are automatically adjusted
as soon as the elements are moved. For further information, refer to the
description of inserting and arranging elements, page 271. For complex charts,
you can use connection marks, page 268 instead of lines. You may also consider
the possibility of modifying the routing.
It may happen that elements get positioned in a way that they cover already
routed connections. These collisions are indicated by red connection lines. If there
are any collisions in the chart, the button in the upper right corner of the editor
view gets a red outline: . To edit the collisions step by step, click this button
and execute the command Show next collision. Then the next found concerned
connection will be selected.
EIO0000002854.04 265
Continuous Function Chart (CFC) Editor
For complex charts, you can use connection marks, page 268 instead of lines. You
may also wish to use the page-oriented version of the CFC editor.
A zoom function allows you to change the dimension of the editor window: Use the
button in the lower right corner of the window and choose between the listed
zoom factors. Alternatively, you can select the entry ... to open a dialog box where
you can type in any arbitrary factor.
You can call the commands for working in the CFC editor from the contextual
menu or from the CFC menu which is available as soon as the CFC editor is
active.
266 EIO0000002854.04
Continuous Function Chart (CFC) Editor
EIO0000002854.04 267
Continuous Function Chart (CFC) Editor
Select the desired element in the toolbox and insert, page 271 it in the editor
window via drag and drop.
CFC Elements
Name Symbol Description
page The number of the page is given automatically according to its position. You
can enter the name (Overview in this example) in the orange field at the top
of the page.
control point A control point is needed to fix a manually modified connection line routing.
This helps to prevent the modification from being reverted by the command
Route all Connections. By 2 control points you can mark a definite segment
of a line for which you want to modify the routing.
input You can select the text offered by ??? and replace it by a variable or
constant. The input assistance serves to select a valid identifier.
output
box You can use a box to represent operators, functions, function blocks, and
programs. You can select the text offered by ??? and replace it by an
operator, function, function block, or program name. The input assistance
serves to select one of the available objects.
If you insert a function block, another ??? will be displayed above the box.
Replace the question marks by the name of the function block instance. If a
function block with constant input parameters is instantiated, then the box
element shows a field Parameters... in the bottom left corner of the box.
Click this button to open a dialog box for editing the input parameters. Refer
to the Edit Parameters... chapter (see EcoStruxure Machine Expert, Menu
Commands, Online Help).
If you replace an existing box by another (by modifying the entered name)
and the new one has a different minimum or maximum number of input or
output pins, the pins will be adapted correspondingly. If pins are to be
removed, the lowest one will be removed first.
jump Use the jump element to indicate at which position the execution of the
program should continue. This position is defined by a label (see below).
Therefore, replace the text offered by ??? by the label name.
268 EIO0000002854.04
Continuous Function Chart (CFC) Editor
label A label marks the position to which the program can jump (see the element
jump).
In online mode, a return label for marking the end of POU is automatically
inserted.
return In online mode, a return element is automatically inserted in the first column
and after the last element in the editor. In stepping, it is automatically jumped
to before execution leaves the POU.
composer Use a composer to handle an input of a box which is of type of a structure.
The composer will display the structure components and thus make them
accessible in the CFC for the programmer. For this purpose name the
composer like the concerned structure (by replacing ??? by the name) and
connect it to the box instead of using an input element.
connection You can use connection marks instead of a connection line, page 272
mark – between elements. This can help to clear complex charts.
source
For a valid connection, assign a connection mark – source element at the
connection output of an element and assign a connection mark – sink (see below) at the
mark – sink input of another element. Assign the same name to both marks (no case-
sensitivity).
Naming:
To use a connection mark in the chart, drag it from the toolbox to the editor
window and then connect its pin with the output or input pin of the respective
element. Alternatively you can convert an existing normal connection line by
using the command Connection Mark. This command allows you to change
connection marks back to normal connection lines as well.
input pin Depending on the box type, you can add an additional input. For this
purpose, select the box element in the CFC network and draw the input pin
element on the box.
You can drag an input or output connection to another position at the box
while keeping pressed the Ctrl key.
output pin – Depending on the box type, you can add an additional output. For this
purpose, select the box element in the CFC network and draw the output pin
element on the box.
You can drag an input or output connection to another position at the box
while keeping pressed the Ctrl key.
Example of a Composer
A CFC program cfc_prog handles an instance of function block fublo1, which
has an input variable struvar of type structure. Use the composer element to
access the structure components.
EIO0000002854.04 269
Continuous Function Chart (CFC) Editor
1 composer
2 function block with input variable struvar of type structure stru1
Example of a Selector
A CFC program cfc_prog handles an instance of function block fublo2, which
has an output variable fbout of type structure stru1. Use the selector element
to access the structure components.
Structure definition stru1:
TYPE stru1 :
STRUCT
ivar:INT;
strvar:STRING:='hallo';
END_STRUCT
END_TYPE
Declaration and implementation of function block fublo1:
FUNCTION_BLOCK fublo2
VAR_INPUT CONSTANT
fbin1:INT;
fbin2:DWORD:=24354333;
fbin3:STRING:='hallo';
270 EIO0000002854.04
Continuous Function Chart (CFC) Editor
END_VAR
VAR_INPUT
fbin : INT;
END_VAR
VAR_OUTPUT
fbout : stru1;
fbout2:DWORD;
END_VAR
VAR
fbvar:INT;
fbvar2:STRING;
END_VAR
Declaration and implementation of program cfc_prog:
VAR
intvar: INT;
stringvar: STRING;
fbinst: fublo1;
erg1: INT;
erg2: STRING;
fbinst2: fublo2;
END_VAR
The illustration shows a selector element where the unused pins have been
removed by executing the command Remove Unused Pins.
Inserting
To insert an element, select it in the ToolBox, page 267 by a mouse-click, keep
the mouse-button pressed and drag the element to the desired position in the
editor window. During dragging, the cursor will be displayed as an arrow plus a
rectangle and a plus-sign. When you release the mouse-button, the element will
be inserted.
Selecting
To select an inserted element for further actions such as editing or rearranging,
click an element body to select the element. It will be displayed by default as red-
EIO0000002854.04 271
Continuous Function Chart (CFC) Editor
shaded. By additionally pressing the SHIFT key, you can click and select further
elements. You can also press the left mouse-button and draw a dotted rectangle
around all elements which you want to select. As soon as you release the button
the selection will be indicated. By command Select all , all elements are selected
at once.
By using the arrow keys you can shift the selection mark to the next possible
cursor position. The sequence depends on the execution order or the elements,
which is indicated by element numbers, page 273.
When an input pin is selected and you press CTRL + LEFT ARROW, the
corresponding output will be selected. When an output pin is selected and you
press CTRL + LEFT ARROW, the corresponding outputs will be selected.
Replacing Boxes
To replace an existing box element, replace the currently inserted identifier by that
of the desired new element. The number of input and output pins will be adapted if
necessary due to the definition of the POUs and thus some existing assignments
could be removed.
Moving
To move an element, select the element by clicking the element body (see
possible cursor positions, page 266) and drag it, while keeping the mouse-button
pressed, to the desired position. Then release the mouse-button to place the
element. You also can use the Cut and Paste commands for this purpose.
Connecting
You can connect the input and output pins of 2 elements by a connection line or
via connection marks.
Connection line: You can either select a valid point of connection that is an input or
output pin of an element (refer to Cursor Positions in CFC, page 266), and then
draw a line to another point of connection with the mouse. Or you can select 2
points of connection and execute the command Select connected pins. A
selected possible point of connection is indicated by a red filled square. When you
draw a line from such a point to the target element, you can identify the possible
target point of connection. When you then position the cursor over a valid
connection point, an arrow symbol is added to the cursor when moving over that
point, indicating the possible connection.
The following figure provides an example: After a mouse-click on the input pin of
the var1 element, the red rectangle is displayed showing that this is a selected
connection point. By keeping the mouse button pressed, move the cursor to the
output pin of the ADD box until the cursor symbol appears as shown in the figure.
Now release the mouse button to establish the connection line.
272 EIO0000002854.04
Continuous Function Chart (CFC) Editor
The shortest possible connection is created taking into account the other elements
and connections.
You can drag an input or output connection to another position at the box while
keeping pressed the Ctrl key.
Connection marks: you could as well use connection marks instead of connection
lines in order to simplify complex charts. Refer to the description of connection
marks, page 268.
Copying
To copy an element, select it and use the Copy and Paste commands.
Editing
After you have inserted an element, by default the text part is represented by ???.
To replace this by the desired text (POU name, label name, instance name,
comment, and so on), click the text to obtain an edit field. Also the button ... will be
available to open the Input Assistant.
Deleting
You can delete a selected element or connection line by executing the command
Delete, which is available in the contextual menu or press the DEL key.
EIO0000002854.04 273
Continuous Function Chart (CFC) Editor
Data Flow
In general, the term data flow describes the chronological order of reading or
writing which data when and how in which programming object. A POU can
process an arbitrary number of data flows. These data flows can also be executed
independently of each other.
274 EIO0000002854.04
Continuous Function Chart (CFC) Editor
Programming objects recently created in CFC have selected the option Auto Data
Flow Mode. The optimum execution order of the programming objects is defined
internally.
4 Execute the command CFC > Result: The execution order of the object is displayed: The boxes and inputs are
Execution Order > Display numbered according to the chronological processing order. This temporary display is
Execution Order. removed as soon as you click again in the CFC editor.
EIO0000002854.04 275
Continuous Function Chart (CFC) Editor
2 Select an element within the Result: The selected element is highlighted red.
feedback.
3 Execute the command CFC > Result: The selected element is assigned number 0 (the lowest number of the
Execution Order > Set Start of
Feedback. feedback) and is indicated by the symbol. At runtime, this POU is processed first.
To display the execution order by data flow, execute the command CFC >
Execution Order > Display Execution Order.
1 In the Devices or POUs tree, right-click a CFC The Properties dialog box opens.
object and execute the command Properties.
2 Select the CFC Execution Order tab. The Execution order list displays
the selected mode.
276 EIO0000002854.04
Continuous Function Chart (CFC) Editor
4 Click OK to confirm and to close the dialog box. • The Explicit Execution
Order Mode is activated.
• The networks are numbered in
the CFC editor.
• The following commands are
available in the CFC >
Execution Order menu:
◦ Display Execution Order
command (see
EcoStruxure Machine
Expert, Menu Commands,
Online Help)
◦ Set Start of Feedback
command (see
EcoStruxure Machine
Expert, Menu Commands,
Online Help)
6 Select a numbered element and execute the The execution order is resorted and
command CFC > Execution Order > Send to the selected element is assigned
Front. the number 0.
Monitoring
The actual values are displayed in small monitoring windows behind each variable
(inline monitoring).
EIO0000002854.04 277
Continuous Function Chart (CFC) Editor
Note for the online view of a function block POU, that monitoring is only possible in
an instance view. In the base implementation of the function block POU, no values
are displayed. The column Value contains the text Value of the expression and
the inline monitoring fields in the implementation part show three question marks
each.
Boolean connections are monitored in the colors TRUE = blue and FALSE =
black.
Forcing/Writing Variables
In online mode, you can prepare a value for forcing or writing a monitored variable
either in the declaration editor or - if the option Prepare values in
implementation part is activated - also in the implementation part. For working in
the declaration editor, refer to the chapter Declaration Editor in Online Mode, page
323. In the implementation part, click the monitoring box next to the respective
element or directly the element to open the Prepare Value dialog box, page 306.
For boolean variables, no dialog box opens, but clicking the value currently
displayed next to the variable directly toggles between the possible values to be
forced or written. In the monitoring box of a currently forced variable a red F is
displayed.
Forced value in the implementation part
If the CFC option Prepare values in implementation part is enabled, then the
value currently prepared for writing or forcing is displayed behind the current value
in angle brackets in the monitoring field of a variable.
278 EIO0000002854.04
Continuous Function Chart (CFC) Editor
EIO0000002854.04 279
Continuous Function Chart (CFC) Editor
CFC pagination
To change the size of the page execute the command Edit Page Size.
Execution Order
The execution order of the pages is from top to the bottom. Within a page, the
order follows the rules of the standard CFC editor (refer to further information of
execution order, element numbers, page 273 and to the chapter Execution Order
in CFC, page 274). You can change the execution order of elements only within
the associated page. You cannot change the execution order of elements on
different pages.
280 EIO0000002854.04
Sequential Function Chart (SFC) Editor
SFC Editor
Overview
The SFC editor is available for programming objects in the IEC 61131-3
programming language SFC - Sequential Function Chart, page 282. Choose the
language when you add a new POU object to the project.
The SFC editor is a graphical editor. Perform general settings concerning behavior
and display in the Options > SFC editor dialog box.
The SFC editor is available in the lower part of the window which opens when you
edit an SFC POU object. This window also includes the Declaration Editor, page
319 in the upper part.
SFC editor
EIO0000002854.04 281
Sequential Function Chart (SFC) Editor
Example
Example for a sequence of steps in an SFC module:
282 EIO0000002854.04
Sequential Function Chart (SFC) Editor
When you click a text cursor position, the string will become editable.
Select action name for editing:
When you click a shadowed area, the element is selected. It gets a dotted frame
and is displayed as red-shaded (for multiple selection, refer to Working in the SFC
Editor, page 284 ).
EIO0000002854.04 283
Sequential Function Chart (SFC) Editor
Navigating
Use the arrow keys to jump to the next or previous element in the chart.
Inserting Elements
To insert the particular SFC elements, page 287, execute the respective
commands from the SFC menu. For further information, refer to the description of
the SFC editor commands (see EcoStruxure Machine Expert, Menu Commands,
Online Help). Double-click an already inserted step, transition, or action element,
which does not yet reference a programming object, to open a dialog box for
assigning one.
Selecting Elements
Select an element or text field by clicking a possible cursor position. You can also
give the selection to an adjacent element by using the arrow keys. The element
will change color to red. For example, see the chapter Cursor Positions in SFC,
page 283.
NOTE: In contrast to previous versions of EcoStruxure Machine Expert, you
can select and thus also move (cut, copy, paste) or delete steps and
transitions separately.
For multiple selection, the following possibilities are available:
• Keep the SHIFT key pressed and then click the particular elements to be
selected.
• Press the left mouse-key and draw a rectangle (dotted line) around the
elements to be selected.
• Execute the command Select All, by default from the Edit menu.
284 EIO0000002854.04
Sequential Function Chart (SFC) Editor
Editing Texts
Click a text cursor position to open the edit field, where you can edit the text. If a
text area has been selected via the arrow keys, open the edit field explicitly by
using the SPACE bar.
Deleting Elements
Select the elements and execute the command Delete or press the DEL key.
Consider the following:
• Deleting a step also deletes the associated action list.
• Deleting the initial step automatically sets the following step to be the initial
one. This option Initial step will be activated in the properties of this step.
EIO0000002854.04 285
Sequential Function Chart (SFC) Editor
• Deleting the horizontal line preceding a branched area will delete all
branches.
• Deleting all particular elements of a branch will delete the branch.
Common Properties
Property Description
Specific Properties
Specific Property Description
Duplicate on copy This option is available for steps that contain a step
action (entry action, main action, or exit action), and for
transitions that are linked to a transition object.
286 EIO0000002854.04
Sequential Function Chart (SFC) Editor
Step entry This action will be executed after the step has become
active.
Step active This action will be executed when the step is active
and possible entry actions have already been
processed.
EIO0000002854.04 287
Sequential Function Chart (SFC) Editor
Step / Transition
To insert a single step or a single transition, execute the command Step or
Transition from the ToolBox. Steps and transitions can also be inserted in
combination, via command Insert step-transition ( ) or Insert step-transition
after ( ) from the toolbar.
A step is represented by a box primarily containing an automatically generated
step name. It is connected to the preceding and subsequent transition by a line.
The box frame of the first step within an SFC, the initial step, is double-lined.
The transition is represented by a small rectangle. After inserting it has a default
name, Trans<n>, whereby n is a running number.
Example for step and subsequent transition:
About Transitions
A transition has to provide the condition on which the subsequent step shall
become active as soon as the condition value is TRUE. Therefore, a transition
condition must have the value TRUE or FALSE.
A transition condition can be defined in the following 2 ways:
288 EIO0000002854.04
Sequential Function Chart (SFC) Editor
direct inline Replace the default transition name by one of the following elements:
• boolean variable
• boolean address
• boolean constant
• instruction having a boolean result (example: (i<100) AND b).
You cannot specify programs, function blocks, or assignments here.
The object like an inline transition can contain the following elements:
• boolean variable
• address
• constant
• instruction
• multiple statements with arbitrary code
EIO0000002854.04 289
Sequential Function Chart (SFC) Editor
Examples of transitions:
290 EIO0000002854.04
Sequential Function Chart (SFC) Editor
Action
An action can contain one or more statements written in one of the valid
programming languages. It is assigned to a step and, in online mode, it will be
processed according to the defined sequence of processing, page 301 .
Each action to be used in SFC steps must be available as a valid POU within the
SFC POU or the project ( ).
If you add IEC actions to a step as action association (see EcoStruxure Machine
Expert, Menu Commands, Online Help), you can also specify a Boolean variable
instead of an action object. The value of these variables is toggled between
FALSE and TRUE each time the action is executed.
NOTE: When associating a boolean variable to an IEC step action, do not use
this boolean variable at another place throughout this SFC POU.
Step names must be unique in the scope of the parent POU. An action may not
contain a step having the same name as the step to which it is assigned;
otherwise, an error will be detected during the build process.
Example of an action written in ST
The IEC conforming and the IEC extending step actions are described in the
following paragraphs.
EIO0000002854.04 291
Sequential Function Chart (SFC) Editor
• A further difference to the normal step actions is that each IEC step action is
provided with a control flag. This permits that, even if the action is called also
by another step, the action is executed always only once at a time. This is not
the case with the normal step actions.
• An IEC step action is represented by a bipartite box connected to the right of
a step via a connection line. In the left part, it shows the action qualifier, in the
right part the action name. You can both edit inline.
• IEC step actions are associated to a step via the Insert action association
command. You can associate one or multiple actions with a step. The position
of the new action depends on the current cursor position and the command.
The actions have to be available in the project and be inserted with a unique
action name (for example, plc_prg.a1).
IEC conforming step action list associated to a step:
Each action box in the first column shows the qualifier and in the second the
action name.
step entry action (step activated) This type of step action will be The action is associated to a It is represented by an E in the
processed as soon as the step step via an entry in the Step lower left corner of the
has become active and before entry field of the step respective step box.
the step active action. properties, page 286.
step active action (step action) This type of step action will be The action is associated to a It is represented by a small
processed when the step has step via an entry in the Step triangle in the upper right corner
become active and after a active field of the step of the respective step box.
possible step entry action of this properties, page 286.
step has been processed.
However, in contrast to an IEC
step action (see above) it is not
executed again when it is
deactivated and cannot get
assigned qualifiers.
step exit action (step An exit action will be executed The action is associated to a It is represented by an X in the
deactivated) once when the step becomes step via an entry in the Step exit lower right corner of the
deactivated. However, this field of the step properties, page respective step box.
execution will not be done in the 286.
same, but at the beginning of
the subsequent cycle.
292 EIO0000002854.04
Sequential Function Chart (SFC) Editor
Branches
A sequential function chart (SFC) can diverge; that is the processing line can be
branched into 2 or several further lines (branches). Parallel branches, page 294
will be processed parallel (simultaneously). In the case of alternative branches,
page 293, only one will be processed depending on the preceding transition
condition. Each branching within a chart is preceded by a horizontal double
(parallel) or simple (alternative) line and also terminated by such a line or by a
jump, page 295.
EIO0000002854.04 293
Sequential Function Chart (SFC) Editor
Parallel Branch
A parallel branch has to begin and end with a step. Parallel branches can contain
alternative branches or other parallel branches.
The horizontal lines before and after the branched area are double-lines.
Processing in online mode: If the preceding transition (t2 in the example shown
on the left) is TRUE, the first steps of all parallel branches will become active
(Step11 and Step21). The particular branches will be processed in parallel to
one another before the subsequent transition (t3) will be recognized.
To insert a parallel branch, select a step and execute the command Insert branch
right.
You can transform parallel and alternative branches to each other by executing
the commands Parallel or Alternative.
Automatically a branch label is added at the horizontal line preceding the
branching which is named Branch<n> whereby n is a running number starting
with 0. You can specify this label when defining a jump target, page 295.
Alternative Branch
The horizontal lines before and after the branched area are simple lines.
An alternative branch has to begin and end with a transition. Alternative branches
can contain parallel branches and other alternative branches.
If the step which precedes the alternative beginning line is active, then the first
transition of each alternative branch will be evaluated from left to right. The first
transition from the left whose transition condition has value TRUE, will be opened,
and the following steps will be activated.
To insert alternative branches, select a transition and execute the command
Insert branch right.
294 EIO0000002854.04
Sequential Function Chart (SFC) Editor
You can transform parallel and alternative branches from one another by
executing the commands Parallel or Alternative.
Jump
A jump is represented by a vertical connection line plus a horizontal arrow and the
name of the jump target. It defines the next step to be processed as soon as the
preceding transition is TRUE. You can use jumps to avoid that processing lines
cross or lead upward.
Besides the default jump at the end of the chart, a jump may only be used at the
end of a branch. To insert a jump, select the last transition of the branch and
execute the command Insert jump.
The target of the jump is specified by the associated text string which can be
edited. It can be a step name or the label of a parallel branch.
Macro
Main SFC editor view
EIO0000002854.04 295
Sequential Function Chart (SFC) Editor
Available Qualifiers
Qualifier Long Form Description
S0 set (stored) The action will be started when the step becomes
active and will be continued after the step is
deactivated until the action is reset.
L time limited The action will be started when the step becomes
active. It will continue until the step becomes
inactive or a set time has passed.
D time delayed A delay timer will be started when the step becomes
active. If the step is still active after the time delay,
the action will start and continue until it is
deactivated.
296 EIO0000002854.04
Sequential Function Chart (SFC) Editor
The qualifiers L, D, SD, DS, and SL need a time value in the TIME constant
format. Enter it directly after the qualifier, separated by a blank space, for example
L T#10s.
NOTE: When an IEC action has been deactivated, it will be executed one
more time. The implication is that each action will execute at least twice. This
also applies to actions with P qualifier.
EIO0000002854.04 297
Sequential Function Chart (SFC) Editor
Symbol generation
In the element properties, page 286 of a step or an action, you can define if a
symbol definition should be added to a possibly created and downloaded symbol
configuration for the step or action name flag. For this purpose, make an entry for
the desired access right in column Symbol of the element properties view.
NOTE: If you use the boolean flag <stepname>.x to force a certain status
value for a step (for setting a step active), be aware that this will affect
uncontrolled states within the SFC.
WARNING
UNINTENDED EQUIPMENT OPERATION
Do not use the boolean flag <stepname>.x to force a status value for setting a
step active.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
298 EIO0000002854.04
Sequential Function Chart (SFC) Editor
SFCInit BOOL If this variable becomes TRUE, the sequential function chart
will be set back to the Init step, page 287. All steps and
actions and other SFC flags will be reset (initialization). The
initial step will remain active, but not be executed as long as
the variable is TRUE. Set back SFCInit to FALSE in order to
get back to normal processing.
SFCReset BOOL This variable behaves similarly to SFCInit. Unlike the latter
however, further processing takes place after the initialization
of the initial step. Thus, in this case, a reset to FALSE of the
SFCReset flag could be done in the initial step.
SFCError BOOL As soon as any timeout occurs at 1 of the steps in the SFC,
this variable will become TRUE. Precondition:
SFCEnableLimit must be TRUE.
SFCEnableLimit BOOL You can use this variable for the explicit activation (TRUE)
and deactivation (FALSE) of the time control in steps via
SFCError. Therefore, if this variable is declared and activated
(SFC Settings) then it must be set TRUE in order to get
SFCError working. Otherwise, any timeouts of the steps will
not be registered. The usage can be reasonable during start-
ups or at manual operation. If the variable is not defined,
SFCError will work automatically.
SFCTipSFCTip- BOOL These variables allow using the inching mode within the
Mode current chart. When this mode has been switched on by
EIO0000002854.04 299
Sequential Function Chart (SFC) Editor
SFCErrorAnaly- – Table that contains the variables contributing to the total value
zationTable TRUE of SFCError (timeout in one step). As a prerequisite,
SFCError must be activated.
The following figure provides an example of some SFC detected error flags in
online mode of the editor.
A timeout has been detected in step s1 in SFC object POU by flag SFCError.
Accessing Flags
For enabling access on the flags for the control of SFC execution (timeouts, reset,
tip mode), declare and activate the flag variables as described above (Control of
SFC Execution, page 298).
Syntax for accessing from an action or transition within the SFC POU:
<stepname>.<flag>
or
_<actionname>.<flag>
Examples:
status:=step1._x;
checkerror:=SFCerror;
Syntax for accessing from another POU:
<SFC POU>.<stepname>.<flag>
or
300 EIO0000002854.04
Sequential Function Chart (SFC) Editor
<SFC POU>._<actionname>.<flag>
Examples:
status:=SFC_prog.step1._x;
checkerror:=SFC_prog.SFCerror;
Consider the following in case of write access from another POU:
• The implicit variable additionally has to be declared explicitly as a VAR_
INPUT variable of the SFC POU
• or it has to be declared globally in a GVL (global variable list).
Example: Local declaration
PROGRAM SFC_prog
VAR_INPUT
SFCinit:BOOL;
END_VAR
Example: Global declaration in a GVL
VAR_GLOBAL
SFCinit:BOOL;
END_VAR
Accessing the flag in PLC_PRG:
PROGRAM PLC_PRG
VAR
setinit: BOOL;
END_VAR
SFC_prog.SFCinit:=setinit; //Write access to SFCinit in
SFC_prog
Analyzation of Expressions
The Analyzation library allows to analyze expressions. It can be used, for
example, in the SFC diagram to examine the result of the flag SFCError. This flag
is used to monitor timeouts in the SFC diagram.
You can use the flags SFCErrorAnalyzation and SFCErrorAnalyzationTable to
determine the components of the expression that contributes to the value TRUE of
the SFCError.
Definition of Terms
The following terms are used:
Term Description
initial step In the first cycle after an SFC POU has been called, the initial
step automatically becomes active and the associated step
action, page 291 is executed.
EIO0000002854.04 301
Sequential Function Chart (SFC) Editor
Term Description
Processing Order
Processing order of elements in a sequence:
Step Description
1. Reset of the IEC Actions All action control flags of the IEC actions, page 291 get reset (not,
however, the flags of IEC actions that are called within actions).
2. Step exit actions (step All steps are checked in the order which they assume in the
deactivated) sequence chart (top to bottom and left to right) to determine
whether the requirement for execution of the step exit action is
provided.If that is the case, it will be executed. An exit action will be
executed if the step is going to become deactivated, page 288. This
means if the entry and step actions - if existing - have been
executed during the last cycle, and if the transition for the following
step is TRUE.
3. Step entry actions(step All steps are tested in the order which they assume in the sequence
activated) to determine whether the requirement for execution of the step
entry action is provided. If that is the case, it will be executed. An
entry action will be executed if the step-preceding transition
condition is TRUE and thus the step has been activated.
4. Timeout check, step active For non-IEC steps, the corresponding step active action is now
actions executed in the order in which they are positioned in the sequence
(top -> down and left -> right).
5. IEC actions IEC actions, page 291 that are used in the sequence are executed
in alphabetical order. This is done in 2 passes through the list of
actions. In the first pass, all the IEC actions that are deactivated in
the current cycle are executed. In the second pass, all the IEC
actions that are active in the current cycle are executed.
6. Transition check, Transitions, page 288 are evaluated. If the step in the current cycle
activating next steps was active and the following transition returns TRUE (and if
applicable the minimum active time has already elapsed), then the
following step is activated.
302 EIO0000002854.04
Sequential Function Chart (SFC) Editor
WARNING
UNINTENDED EQUIPMENT OPERATION
Do not call IEC actions from multiple other IEC actions in the same cycle.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
NOTE: Use implicit variables, page 297 for determining the status of steps
and actions or the execution of the chart.
Monitoring
Active steps are displayed as filled with blue color. The display of step attributes
depends on the set SFC editor options.
EIO0000002854.04 303
Sequential Function Chart (SFC) Editor
304 EIO0000002854.04
Structured Text (ST) Editor
Further Information
To select blocks, press the ALT key and select the desired text area with the
mouse.
The editor will be available in the lower part of a window which also includes the
declaration editor, page 319 in the upper part.
If syntactic errors are detected during editing, the corresponding messages will be
displayed in the Precompile Messages window. This window is updated each
time you reset the focus to the editor window (for example, place your cursor in
another window and then back to the editor window).
1 Press the keys Ctrl + Shift + i. An input field at the bottom edge of
the ST editor opens.
EIO0000002854.04 305
Structured Text (ST) Editor
Monitoring
If the Enable inline monitoring option is activated in the Monitoring tab of the
Tools > Options > Text editor dialog box, small monitoring boxes will be
displayed behind each variable showing the actual value.
Online view of a program object PLC_PRG with monitoring:
Forcing of Variables
In addition to the possibility of entering a prepared value for a variable within the
declaration of any editor, the ST editor offers double-clicking the monitoring box of
a variable within the implementation part (in online mode). Enter the prepared
value in the dialog box that appears.
306 EIO0000002854.04
Structured Text (ST) Editor
WARNING
UNINTENDED EQUIPMENT OPERATION
• You must have a thorough understanding of how forcing will affect the
outputs relative to the tasks being executed.
• Do not attempt to force I/O that is contained in tasks that you are not certain
will be executed in a timely manner, unless your intent is for the forcing to
take affect at the next execution of the task whenever that may be.
• If you force an output and there is no apparent affect on the physical output,
do not exit the online mode without removing the forcing.
• If the online mode was interrupted while forcing was active, re-establish the
connection with the controller and remove the forcing.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
You find the name of the variable completed by its path within the Devices Tree
(Expression), its type, and current value.
By activating the corresponding item, you can choose the following options:
• preparing a new value which has to be entered in the edit field
• removing a prepared value
• releasing the variable that is being forced
• releasing the variable that is being forced and resetting it to the value it was
assigned before forcing
To carry out the selected action, execute the command Debug > Force values
(item Online) or press the F7 key.
EIO0000002854.04 307
Structured Text (ST) Editor
At the beginning of the line. Keep in mind that assignments as expressions, page
309 define no further breakpoint positions within a line.
FOR-loop:
1. before the initialization of the counter
2. before the test of the counter
3. before a statement
{BP} FOR i := 12 TO {BP} x {BP} BY 1 DO
{BP} [statement1]
...
{BP} [statementn-2]
END_FOR
WHILE-loop:
1. before checking the condition
2. before an instruction
{BP} WHILE i < 12 DO
{BP} [statement1]
...
{BP} [statementn-1]
END_WHILE
REPEAT-loop:
• before checking the condition
REPEAT
{BP} [statement1]
...
{BP} [statementn-1]
{BP} UNTIL i >= 12
END_REPEAT
Call of a program or a function block:
At the beginning of the line.
{{BP} POU( );
At the end of a POU:
When stepping through, this position will also be reached after a RETURN
instruction.
Breakpoint display in ST
308 EIO0000002854.04
Structured Text (ST) Editor
Structured Text ST
Structured Text ST
Overview
Structured Text is a textual high-level programming language, similar to PASCAL
or C. The program code is composed of expressions, page 309 and instructions,
page 310. In contrast to IL (Instruction List), you can use numerous constructions
for programming loops, thus allowing the development of complex algorithms.
Example
IF value < 7 THEN
WHILE value < 8 DO
value:=value+1;
END_WHILE;
END_IF;
Expressions
Overview
An expression is a construction which after its evaluation returns a value. This
value is used in instructions.
Expressions are composed of operators, page 562, operands, page 628, and/or
assignments. An operand can be a constant, a variable, a function call, or another
expression.
Examples
33 (* Constant *)
ivar (* Variable *)
a AND b (* Expression *)
(x*y) / z (* Expression *)
Order of Operations
The evaluation of an expression is performed by processing the operators
according to certain rules. The operator with the highest order of operation is
processed first, then the operator with the next operating level, and so on, until all
operators have been processed.
Below you find a table of the ST operators in the order of their ordinal operating
level:
negate – ............
EIO0000002854.04 309
Structured Text (ST) Editor
multiply * ..........
divide / .........
add + .......
subtract – ......
equal to = ....
Assignment as Expression
As an extension to the IEC 61131-3 standard (ExST), assignments can be used
as an expression.
Examples:
Instructions
Overview
Instructions describe what to do with the given expressions, page 309.
The following instructions can be used in ST:
Instruction Example
Calling a function block, page 312 and using the CMD_TMR(IN := %IX5, PT := 300);
function block output A:=CMD_TMR.Q
310 EIO0000002854.04
Structured Text (ST) Editor
Instruction Example
END_IF;
Assignment Operators
Default Assignment
On the left side of an assignment, there is an operand (variable, address) to which
the value of the expression on the right side is assigned by the assignment
operator :=.
Also refer to the description of the MOVE operator, page 570 which has the same
function.
For an example with assignment, refer to the Example of a Call with Assignments
paragraph, page 170 of the Calling a Function Block chapter.
Example
a:= b;
a gets the value of b.
Set operator S=
The value will be set: if it is once set to TRUE, it will remain TRUE.
Example
a S= b;
a is set to TRUE if b is TRUE while processing the assignment.
If b is FALSE while processing the assignment, the value of a will not be modified.
Reset operator R=
The value will be reset: if it is once set to FALSE, it will remain FALSE.
EIO0000002854.04 311
Structured Text (ST) Editor
Example
a R= b;
a is set to FALSE as soon as b = TRUE.
NOTE: In case of a multiple assignment, set and reset assignments refer to
the last member of the assignment.
Example
a S= b R= fun1(par1,par2)
In this case, b will be the reset output value of fun1. But a does not get the set
value of b, but gets the set output value of fun1.
Consider that an assignment can be used as an expression, page 309. This is an
extension to the IEC 61131-3 standard.
Assignment operator REF
This operator generates a reference to a value.
Syntax
<variable name> REF= <variablename> ;
Example
refA : REFERENCE TO DUT;
B : DUT;
C : DUT;
A REF= B; // corresponds to A := ADR(B);
A := C; // corresponds to A^ := C;
RETURN Instruction
You can use the RETURN instruction to leave a POU.
Syntax
RETURN;
Example
IF b=TRUE THEN
RETURN;
END_IF;
a:=a+1;
If b is TRUE, instruction a:=a+1; will not be executed. As a result, the POU will
be left immediately.
312 EIO0000002854.04
Structured Text (ST) Editor
IF Instruction
With the IF instruction you can test for a condition, and, depending upon this
condition, execute instructions.
Syntax
IF <boolean_expression1> THEN
<IF_instructions>
{ELSIF <boolean_expression2> THEN
<ELSIF_instructions1>
..
..
ELSIF <boolean_expression n> THEN
<ELSIF_instructions-1>
ELSE
<ELSE_instructions>}
END_IF;
The segment in brackets {} is optional.
If the <boolean_expression1> returns TRUE, then only the <IF_instructions> are
executed and, as a result, none of the other instructions. Otherwise, the boolean
expressions, beginning with <boolean_expression2>, are evaluated one after the
other until 1 of the expressions returns TRUE. Then only those instructions after
this boolean expression and before the next ELSE or ELSIF are evaluated. If none
of the boolean expressions produce TRUE, then only the <ELSE_instructions>
are evaluated.
Example
IF temp<17
THEN heating_on := TRUE;
ELSE heating_on := FALSE;
END_IF;
Here, the heating is turned on when the temperature sinks below 17 degrees.
Otherwise, it remains off.
CASE Instruction
With the CASE instruction, you can combine several conditioned instructions with
the same condition variable in one construct.
Syntax
CASE <Var1> OF
<value1>: <instruction 1>
<value2>: <instruction 2>
<value3, value4, value5>: <instruction 3>
<value6..value10>: <instruction4>
..
..
<value n>: <instruction n>
ELSE <ELSE instruction>
EIO0000002854.04 313
Structured Text (ST) Editor
END_CASE;
A CASE instruction is processed according to the following model:
• If the variable in <Var1> has the value <Value I>, then the instruction
<Instruction I> will be executed.
• If <Var 1> has none of the indicated values, then the <ELSE Instruction> will
be executed.
• If the same instruction is to be executed for several values of the variables,
then you can write these values one after the other separated by commas
and thus condition the common execution.
• If the same instruction is to be executed for a value range of a variable, you
can write the initial value and the end value separated by 2 dots. Therefore,
you can condition the common condition.
Example
CASE INT1 OF
1, 5: BOOL1 := TRUE;
BOOL3 := FALSE;
2: BOOL2 := FALSE;
BOOL3 := TRUE;
10..20: BOOL1 := TRUE;
BOOL3:= TRUE;
ELSE
BOOL1 := NOT BOOL1;
BOOL2 := BOOL1 OR BOOL2;
END_CASE;
FOR Loop
With the FOR loop, you can program repeated processes.
Syntax
INT_Var:INT;
FOR <INT_Var> := <INIT_VALUE> TO <END_VALUE> {BY <step size>} DO
<instructions>
END_FOR;
The segment in brackets {} is optional.
The <instructions> are executed as long as the counter <INT_Var> is not greater
than the <END_VALUE>. This is checked before executing the <instructions> so
that the <instructions> are not executed if <INIT_VALUE> is greater than <END_
VALUE>.
When <instructions> are executed, <INT_Var> is increased by <Step size>. The
step size can have any integer value. If it is missing, then it is set to 1. The loop
will terminate when <INT_Var> is greater than the <END_VALUE>.
Example
FOR Counter:=1 TO 5 BY 1 DO
Var1:=Var1*2;
END_FOR;
Erg:=Var1;
Assuming that the default setting for Var1 is 1. Then it will have the value 32 after
the FOR loop.
NOTE: If <END_VALUE> is equal to the limit value for the data type of <INT_
Var> (Counter in the above example), you will produce an infinite, or endless,
loop. If Counter is of type SINT, for example, and the <END_VALUE> is 127
(the maximum positive value for a SINT type variable), then the loop can
never terminate because adding 1 to this maximum value would result in the
variable becoming negative and never exceeding the limits imposed by the
FOR instruction.
314 EIO0000002854.04
Structured Text (ST) Editor
WARNING
ENDLESS LOOP
Ensure that the variable type used in FOR instructions is of a sufficient capacity
to account for the <END_VALUE> + 1.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
You can use the CONTINUE instruction within a FOR loop. This is an extension to
the IEC 61131-3 standard.
WHILE Loop
An alternative to the FOR loop is the WHILE loop, which executes the loop if, and
for as long as, a boolean condition is, and remains, TRUE. If the condition is not
initially TRUE, the loop is not executed. If the condition which was initially TRUE
becomes FALSE, the loop is terminated.
Syntax
WHILE <boolean expression> DO
<instructions>
END_WHILE;
Evidently, the initial and ongoing boolean expression must assume a value of
FALSE at some point within the instructions of the loop. Otherwise, the loop will
not terminate, resulting in an infinite, or endless, loop condition.
WARNING
ENDLESS LOOP
Ensure that the WHILE loop will be terminated within the instructions of the loop
by creating a FALSE condition of the boolean expression controlling the WHILE
loop.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
REPEAT Loop
The REPEAT loop is another alternative to the FOR loop, as it is for the WHILE
loop. The REPEAT loop differs from the WHILE loop in that the exit condition is
evaluated only after the loop has been executed at least once, at the end of the
loop.
Syntax
REPEAT
<instructions>
UNTIL <boolean expression>
EIO0000002854.04 315
Structured Text (ST) Editor
END_REPEAT;
The <instructions> are carried out repeatedly as long as the <boolean
expression> returns TRUE. If <boolean expression> is produced already at the
first UNTIL evaluation, then <instructions> are executed only once. The <boolean
expression> must assume a value of TRUE at some point within the instructions of
the loop. Otherwise, the loop will not terminate, resulting in an infinite, or endless,
loop condition.
WARNING
ENDLESS LOOP
Ensure that the REPEAT loop will be terminated within the instructions of the
loop by creating a TRUE condition of the boolean expression.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
CONTINUE Instruction
As an extension to the IEC 61131-3 standard, the CONTINUE instruction is
supported within FOR, WHILE, and REPEAT loops. CONTINUE makes the
execution proceed with the next loop cycle.
Example
FOR Counter:=1 TO 5 BY 1 DO
INT1:=INT1/2;
IF INT1=0 THEN
CONTINUE; (* to avoid division by zero *)
END_IF
Var1:=Var1/INT1; (* only executed, if INT1 is not "0" *)
END_FOR;
Erg:=Var1;
EXIT Instruction
The EXIT instruction terminates the FOR, WHILE or REPEAT loop in which it
resides without regard to any condition.
JMP Instruction
You can use the JMP instruction for an unconditional jump to a code line marked
by a jump label.
Syntax
JMP <label>;
The <label> is an arbitrary, but unique identifier that is placed at the beginning of a
program line. The instruction JMP has to be followed by the indication of the jump
destination that has to equal a predefined label.
316 EIO0000002854.04
Structured Text (ST) Editor
WARNING
ENDLESS LOOP
Ensure that the use of the JMP instruction is conditional.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Comments in ST
There are 2 possibilities to write comments in a structured text object:
• Start the comment with (* and close it with *). This allows you to insert
comments which run over several lines. Example: (*This is a comment.*)
• Single-line comments as an extension to the IEC 61131-3 standard: //
denotes the start of a comment that ends with the end of the line. Example: //
This is a comment.
You can place the comments everywhere within the declaration or implementation
part of the ST editor.
Nested comments: You can place comments within other comments.
Example
(*
a:=inst.out; (* to be checked *)
b:=b+1;
*)
In this example, the comment that begins with the first bracket is not closed by the
bracket following checked, but only by the last bracket.
EIO0000002854.04 317
Object Editors
What’s in This Part
Declaration Editors ....................................................................................... 319
Device Type Manager (DTM) Editor ............................................................... 324
Data Unit Type (DUT) Editor.......................................................................... 325
Global Variables List (GVL) Editor.................................................................. 326
Motion Design Object Editor.......................................................................... 327
Network Variables List (NVL) Editor ............................................................... 330
Task Editor................................................................................................... 346
Watch List Editor .......................................................................................... 355
Tools Within Logic Editors ............................................................................. 358
318 EIO0000002854.04
Declaration Editors
Declaration Editors
What’s in This Chapter
Textual Declaration Editor ............................................................................ 319
Tabular Declaration Editor ............................................................................ 320
Declaration Editor in Online Mode ................................................................ 323
Overview
The textual declaration editor serves to create the declaration part of a POU
object. It can be supplemented by a tabular view. Any modification made in one of
the views is immediately applied to the other one.
Depending on the current settings in the declaration editor options, either only the
textual or only the tabular view will be available. You can toggle between both via
buttons (Textual / Tabular) at the right border of the editor window.
Usually, the declaration editor is used in combination with the programming
language editors. Therefore, it will be placed in the upper part of the window which
opens when you are going to edit or view (monitor) an object in offline or online
mode. The declaration header describes the POU type (for example: PROGRAM,
FUNCTION_BLOCK, FUNCTION). It can be extended by POU-global pragma
attributes.
The online mode of the declaration editor, page 323 is structured like that of a
Watch view.
Variable declaration is also performed in Global Variable Lists and Data Unit
Types, which are created in separate editors.
Also refer to the Variables Declaration chapter, page 461.
Behavior and appearance are determined by the respective current text editor
settings in the Options and Customize dialog boxes. There you can define the
default settings for highlight coloring, line numbers, tabs, indenting, and many
more options. The usual editing functions are available such as copy and paste.
Block selection is possible by pressing the ALT key while selecting the desired text
area with the mouse.
EIO0000002854.04 319
Declaration Editors
The tabular view of the editor provides columns for the usual definitions for
variable declaration, page 461: Scope, Name, Address, Data type,
Initialization, Comment and (pragma) Attributes. The particular declarations are
inserted as numbered lines.
To add a new line of declaration above an existing one, first select this line and
execute the command Insert from the toolbar or the contextual menu.
To add a new declaration at the end of the table, click beyond the last existing
declaration line and also use the Insert command.
The newly inserted declaration by default first uses scope VAR and the recently
entered data type. The input field for the obligatory variable Name opens
automatically. Enter a valid identifier and close the field by pressing the Enter key
or by clicking another part of the view.
Double-click a table cell to open the respective possibilities to enter a value.
Double-click the Scope to open a list from which you can choose the desired
scope and scope attribute keyword (flag).
Type in the Data type directly or click the > button to use the Input Assistant or
the Array wizard.
Type in the Initialization value directly or click the ... button to open the
Initialization value dialog box, page 321. This is useful especially in case of
arrays and structured variables.
Each variable is declared in a separate line where the lines are numbered.
You can change the order of lines (line numbers) by selecting a line and move it
one up or down by the Move up or Move down command from the toolbar
or the contextual menu.
You can sort the list of declarations according to each of the columns by clicking
the header of the respective column.
To delete one or several declarations, select the respective lines and press the
Del key or execute the Delete command from the contextual menu or click the
button in the toolbar.
Declaration of Arrays
For the declaration of array variables, use the arrow button > at the right side of
the Type field and select Array Wizard. The Array dialog box opens.
Fill at least the fields marked with a red exclamation mark icon. Define the
Dimensions by entering the lower and upper limits, and the Base Type of the
variable. You can click the arrow button to open the Input Assistant dialog box or
another Array Wizard for declaring the base type.
320 EIO0000002854.04
Declaration Editors
You can define an array of variable length with [*,*,*]. Arrays of variable length
can only be used in VAR_IN_OUT declarations of function blocks, methods, and
functions. To declare an array of variable length, enter an asterisk * for each
dimension. This results in ARRAY [*..*] OF INT. After you have confirmed with
OK, adapt the dimension string to [*] (one asterisk only).
Example for a two-dimensional array of variable length:
ARRAY [*,*]
The Result area of the dialog box provides a preview of the configured array
declaration.
For further information, refer to the Arrays description, page 540.
Click OK to close the declaration dialog box. The variable declaration appears in
the declaration editor in accordance to the IEC syntax.
Initialization Value
Initialization value dialog box
The Expressions of the variable are displayed with the present initialization
values. Select the desired variables and edit the initialization value in the field
below the listing. Then click the Apply value to selected lines button. To restore
the default initializations, click the Reset selected lines to default values button.
Press Ctrl + Enter to insert line breaks in the Comment entry.
EIO0000002854.04 321
Declaration Editors
The Edit Declaration Header dialog box provides the following elements:
Element Description
Declaration Insert type (from the selection list) and name of the POU
object.
Attributes
In the Edit Declaration Header dialog box, click the Attributes... button to open
the Attibutes dialog box. It allows you to enter multiple attributes and pragmas in
text format. Insert them without enclosing {} braces, use a separate line per each.
For the example shown in the following image, see the corresponding textual view
above in the graphic of the textual editor view, page 319.
Attributes dialog box
322 EIO0000002854.04
Declaration Editors
EIO0000002854.04 323
Device Type Manager (DTM) Editor
DTM Editor
Overview
The DTM editor view depends on the device type manager.
For further information on DTMs, refer to the Device Type Manager (DTM) User
Guide (see EcoStruxure Machine Expert, Device Type Manager (DTM), User
Guide).
For a list of the DTM versions currently supported by EcoStruxure Machine
Expert, refer to the Release Notes of your EcoStruxure Machine Expert
installation.
324 EIO0000002854.04
Data Unit Type (DUT) Editor
EIO0000002854.04 325
Global Variables List (GVL) Editor
GVL Editor
Overview
The GVL editor is a Declaration Editor for editing Global Variables Lists. The
GVL editor works as does the Declaration Editor and corresponds to the options,
both offine and online, set for the text editor. The declaration starts with VAR_
GLOBAL and ends with END_VAR. These keywords are provided automatically.
Enter valid declarations of global variables between them.
GVL editor
326 EIO0000002854.04
Motion Design Object Editor
Element Description
Target instance Click the browse button (...) to select one of the
supported function blocks or enter it directly into
the field on the left-hand side.
Device object Select a device object from the controller
configuration that implements one of the
interfaces of a motion design object, such as a
Lexium 32 S standalone servo drive.
Generate global instance A global variable of a motion design object
interface is created. It can be accessed by IEC
code by using the name of the object.
EIO0000002854.04 327
Motion Design Object Editor
Element Description
Motion components List of the components used for the virtual axis,
indicating the Position, Velocity, and
Acceleration values.
328 EIO0000002854.04
Motion Design Object Editor
• Click the Write Online button to write the values to the controller. If errors are
detected during this operation, a message box is displayed. After the values
have been successfully written to the controller, the dialog box is closed.
• Click the Write Offline button to save the values to the EcoStruxure Machine
Expert project. The dialog box is closed.
EIO0000002854.04 329
Network Variables List (NVL) Editor
330 EIO0000002854.04
Network Variables List (NVL) Editor
WARNING
LOSS OF CONTROL
• The designer of any control scheme must consider the potential failure
modes of control paths and, for certain critical control functions, provide a
means to achieve a safe state during and after a path failure. Examples of
critical control functions are emergency stop and overtravel stop, power
outage and restart.
• Separate or redundant control paths must be provided for critical control
functions.
• System control paths may include communication links. Consideration must
be given to the implications of unanticipated transmission delays or failures
of the link.
• Observe all accident prevention regulations and local safety guidelines.1
• Each implementation of this equipment must be individually and thoroughly
tested for proper operation before being placed into service.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
1For additional information, refer to NEMA ICS 1.1 (latest edition), "Safety
Guidelines for the Application, Installation, and Maintenance of Solid State
Control" and to NEMA ICS 7.1 (latest edition), "Safety Standards for Construction
and Guide for Selection, Installation and Operation of Adjustable-Speed Drive
Systems" or their equivalent governing your particular location.
EIO0000002854.04 331
Network Variables List (NVL) Editor
You can use Diagnostic (see EcoStruxure Machine Expert, Network Variable
Configuration, SE_NetVarUdp Library Guide) and Error Management (see
EcoStruxure Machine Expert, Network Variable Configuration, SE_NetVarUdp
Library Guide) function blocks as well as network properties parameters to
monitor the health, status and integrity of communications using this feature. This
feature was designed for data sharing and monitoring and cannot be used for
critical control functions.
332 EIO0000002854.04
Network Variables List (NVL) Editor
NVL Considerations
The following table shows the list of controllers that support the network variables
list (NVL) functionality:
LMC Pro2
Network Variables List Yes Yes Yes
NOTE: Since the exchange of network variables is performed via UDP, adjust
the firewall settings of your controller accordingly. For further information, refer
to the How to Configure the Firewall for PacDrive LMC Controllers User Guide
and to the Programming Guide of your controller.
The figure shows a network consisting of one sender and the maximum of seven
receivers:
Controller Sender A: Sender with the NVL (sender) and receiver controller with
network variables lists (NVL (receiver))
Controller Receiver 1...7: Receivers (with NVL (receiver)) from A and sender
controller (NVL (sender)) only for A
Step Action
EIO0000002854.04 333
Network Variables List (NVL) Editor
Step Action
NOTE: In order to maintain performance transparency, you should set the task
priority of the dedicated NVL task to something greater than 25, and regulate
communications to avoid saturating the network unnecessarily.
Description of parameters
To change the Broadcast Address and the Port, click the Settings... button.
Task MAST Select the task you configured below the Task Configuration item for executing
NVL code.
List identifier 1 Enter a unique number for each NVL (sender) on the network. It is used by the
receivers for identifying the variables list (see EcoStruxure Machine Expert,
Network Variable Configuration, SE_NetVarUdp Library Guide).
Pack variables activated With this option activated, the variables are bundled in packets (datagrams) for
transmission.
Transmit checksum deactivated Activate this option to add a checksum to each packet of variables during
transmission.
Receivers will then check the checksum of each packet they receive and will reject
those with a non-matching checksum. A notification will be issued with the
334 EIO0000002854.04
Network Variables List (NVL) Editor
Acknowledgement deactivated Activate this option to prompt the receiver to send an acknowledgement message
for each data packet it receives.
Cyclic transmission activated Select this option for cyclic data transmission at the defined Interval.
• Interval
This Interval should be a multiple of the cycle time you defined in the task for
executing NVL code to achieve a precise transmission time of the network
variables.
Transmit on change deactivated Select this option to transmit variables whenever their values have changed.
• Minimum gap • T#20ms NOTE: After the first download or using of Reset Cold or Reset Warm
command in Online Mode the receiver controllers are not updated and keep
their last value, whereas the sender controller value becomes 0 (zero).
The Minimum gap parameter defines a minimum time span that has to elapse
between the data transfer.
Transmit on event deactivated Select this option to transmit variables as long as the specified Variable equals
• Variable • – TRUE. The variable is checked with every cycle of the task for executing NVL
code.
Port 1202 Enter a unique port number (≥ 1202) for each NVL (sender).
Broadcast Address 255.255.255.255 Enter a specific broadcast IP address for your application.
EIO0000002854.04 335
Network Variables List (NVL) Editor
To create the NVL (receiver), define the following parameters in the Add Object >
Global Network Variable List dialog box:
Description of parameters
Task task defined in the Select a task from the list of tasks which will receive the frames from the sender
Task Configuration that are available under the Task Configuration node of the receiver controller.
node of this
Application
Sender 1 of the NVL (sender) Select the NVL (sender) from the list of the NVL (sender) with network properties
available in the project available in the project.
Select the entry Import from file from the list to use an NVL (sender) from another
project. This activates the Import from file: parameter below.
Import from file: – This parameter is only available after you selected the option Import from file for
the parameter Sender.
The ... opens a Windows Explorer window that allows you to browse to the export
file *.gvl you created from an NVL (sender) in another project.
For further information, refer to the How to Add an NVL (Receiver) From a Different
Project paragraph below.
336 EIO0000002854.04
Network Variables List (NVL) Editor
Number Rule
1 Data transmission from one NVL (sender) to one NVL (receiver) should not exceed 200 bytes.
2 Data exchange between several NVL (sender) of one controller and their associated NVL (receiver) should not exceed
1000 bytes of variables.
1 Limit the number of received datagrams per When the limit is exceeded, the remaining datagrams are treated in the
cycle to 20. next cycle. A notification Received overflow is raised in the diagnostics
data (see EcoStruxure Machine Expert, Network Variable Configuration,
SE_NetVarUdp Library Guide) when the limit is reached.
One datagram can contain up to 256 bytes. That means that you should
not exceed the limit of 5120 bytes of data transmitted to one receiver.
2 Limit the number of transmitted datagrams per When the limit is exceeded, the remaining datagrams are treated in the
cycle to 20. next cycle. A notification Transmit overflow is raised in the diagnostics
data (see EcoStruxure Machine Expert, Network Variable Configuration,
SE_NetVarUdp Library Guide) when the limit is reached.
One datagram can contain up to 256 bytes. That means that you should
not exceed the limit of 5120 bytes of data transmitted by one sender
controller.
If the number of received / transmitted datagrams per cycle exceeds the limit
several times, the following may happen:
• Loss of UDP (user datagram protocol) datagrams
• Incoherent or inconsistent exchange of variables
Adapt the following parameters according to your needs:
• Cycle time of sender controller
EIO0000002854.04 337
Network Variables List (NVL) Editor
NOTICE
LOSS OF DATA
Thoroughly test your application for proper transmission and reception of UDP
datagrams prior to placing your system into service.
Failure to follow these instructions can result in equipment damage.
NOTICE
LOSS OF COMMUNICATION
Ensure that the list identifier in the network is only used by one IP address.
Failure to follow these instructions can result in equipment damage.
338 EIO0000002854.04
Network Variables List (NVL) Editor
Sender Receiver
RUN RUN Network variables are exchanged between the sender and
the receiver.
STOP RUN The sender is no longer sending variables to the receiver.
The network variables are not exchanged between sender
and receivers.
RUN STOP The receiver is not processing network variables from the
sender.
Example
Overview
In the following example, a simple network variables exchange is established. In
the sender controller, an NVL (sender) is created. In the receiver controller, the
corresponding NVL (receiver) is created.
Perform the following preparations in a standard project, where a sender controller
Dev_Sender and a receiver controller Dev_Receiver are available in the Devices
tree:
• Create a POU (program) prog_sender below the Application node of Dev_
Sender.
• Under the Task Configuration node of this application, add the task Task_S
that calls prog_sender.
• Create a POU (program) prog_rec below the Application node of Dev_
Receiver.
• Under the Task Configuration node of this application, add the task Task_R
that calls prog_rec.
NOTE: The two controllers must be configured in the same subnet of the
Ethernet network.
EIO0000002854.04 339
Network Variables List (NVL) Editor
1 In the Devices tree, right-click the Application node of the The Add Global Variable List dialog box is displayed.
controller Dev_Sender and execute the command Add
Object > Global Variable List....
2 Enter the Name NVL_Sender and click Open to create a The NVL_Sender node appears below the Application
new global variable list. node in the Devices tree and the editor is opened on the
right-hand side.
1 In the Devices tree, right-click the NVL_Sender node and The Properties - NVL_Sender dialog box is displayed.
execute the command Properties....
2 –
Open the Network properties tab and configure the
parameters as shown in the graphic:
3 Click OK. The dialog box is closed and the NVL (sender) network
properties are set.
340 EIO0000002854.04
Network Variables List (NVL) Editor
1 In the Devices tree, right-click the Application node of the The Add Global Network Variable List dialog box is
controller Dev_Receiver and execute the command Add displayed.
Object > Global Network Variable List....
3 Click Open.
The dialog box is closed and the GNVL_Receiver appears
below the Application node of the Dev_Receiver controller:
Step 2: View and / or modify the network settings of the NVL (receiver):
1 In the Devices tree, right-click the GNVL_Receiver node The Properties - GNVL_Receiver dialog box is displayed.
and execute the command Properties....
EIO0000002854.04 341
Network Variables List (NVL) Editor
1 Under the Application node of the controller Dev_Sender, The editor for prog_sender is opened on the right-hand
double-click the POU prog_sender. side.
2 –
Enter the following code for the variable iglobvar:
3 Under the Application node of the controller Dev_ The editor for prog_rec is opened on the right-hand side.
Receiver, double-click the POU prog_rec.
4 –
Enter the following code for the variable ivar_local:
5 Log on with sender and receiver applications within the The variable ivar_local in the receiver gets the values of
same network and start the applications. iglobvar as currently shown in the sender.
Compatibility
Introduction
Even if the controllers work with applications of different versions of the
programming system (for example, V2.3 and V3.x), communication via network
variables is possible.
However, the file formats of the different export files between versions (*.exp
versus *.gvl) makes it impossible to simply import and export these files between
projects.
If an NVL (receiver) is set up in the latest version (for example, V3.x), the required
network parameters configuration must be provided by a sender of the latest
version (for example, V3.x). An export file *.exp created from a sender by an
earlier version (for example, V2.3) does not contain this information.
A solution for exchanging network variables between applications of different
programming system versions is provided in the following paragraphs.
342 EIO0000002854.04
Network Variables List (NVL) Editor
1 Re-create the network variables list To achieve this, add an NVL (sender) with
(NVL) that is already available in the network properties, containing the same
earlier version (V2.3) in the latest variables declarations as in the NVL of the
version (V3.x). earlier version (V2.3).
Example
In this example, the variable trans23, that is defined in a V2.3 application, is
made available for a later version (V3.x).
The following conditions are defined:
EIO0000002854.04 343
Network Variables List (NVL) Editor
Condition Description
1 In the earlier programming system version (V2.3) the project 23.pro contains a global variables list GVL_23 with the
following declaration:
VAR_GLOBAL
trans23:INT;
END_VAR
2
The network properties of GVL_23 are configured as follows:
NOTE: The export of this GVL_23 creates a *.exp file, that only contains the following variable declaration:
VAR_GLOBAL
trans23:INT;
END_VAR
The *.exp file does not contain any configuration settings.
The following table shows the next steps to be executed for re-creating GVL_23 in
the latest version (V3.x):
344 EIO0000002854.04
Network Variables List (NVL) Editor
6 Add an NVL (receiver) object in the V3.x This serves to read the variable trans23 from the controller of the earlier
project from the 23.gvl export file (with the programming system (V.2.3).
Import from file: command).
If both, the project from the earlier version (V2.3) as well as the application
from the latest version (V3.x), are running within the network, the application
from the latest version (V3.x) can read variable trans23 from project 23.
pro.
EIO0000002854.04 345
Task Editor
Task Editor
What’s in This Chapter
Information on the Task Configuration ........................................................... 346
Properties Tab ........................................................................................... 347
System Events Tab .................................................................................... 347
Monitor Tab................................................................................................ 349
Variable Usage Tab .................................................................................... 350
Configuration of a Specific Task.................................................................... 351
Task Processing in Online Mode................................................................... 353
Tasks
A task, page 351 is used to control the processing of an IEC program. It is defined
by a name, a priority and by a type determining which condition will trigger the
start of the task. You can define this condition by a time (cyclic, freewheeling) or by
an internal or external event which will trigger the task; for example, the rising
edge of a global project variable or an interrupt event of the controller.
For each task, you can specify a series of program POUs that will be started by
the task. If the task is executed in the present cycle, these programs will be
processed for the length of 1 cycle.
The combination of priority and condition will determine in which chronological
order, page 353 the tasks will be executed.
346 EIO0000002854.04
Task Editor
For each task, you can configure a time control (watchdog). The possible settings
depend on the specific controller platform.
Properties Tab
Overview
When the Task Configuration, page 346 node is selected, the Properties tab will
be opened in the Task Configuration editor.
Task configuration, Properties tab, example
Add Event Handler... Opens the Add Event Handler dialog box that
allows you to define an assignment between an
event and the function it calls.
Remove Event Handler Deletes the selected list assignment.
Open Event Function Opens the editor of the new function for the
selected assignment.
EIO0000002854.04 347
Task Editor
Column Description
The list of the System Events tab displays additional information in online mode.
Consult the Programming Guide specific to your controller for controller-specific
information on the supported system events.
Column Description
Button Description
348 EIO0000002854.04
Task Editor
System Events
The table lists the system events that can be displayed:
Exception The event is sent if an During an IEC exception, the Depends on the task.
exception has been detected in event is called from the system
the context of an application. exception task or the task with
the exception itself.
Monitor Tab
Overview
If it is supported by the target system, the monitoring functionality is allowed. This
is a dynamic analysis of the execution time and the number of the calls which are
controlled by a task. In online mode, the task processing can be monitored.
EIO0000002854.04 349
Task Editor
IEC-Cycle Count Number of run cycles since having started the application; 0 if
the function is not supported by the target system.
Cycle Count Number of already run cycles (depending on the target system,
this can be equal to the IEC Cycle Count, or bigger if cycles are
even counted when the application is not running.)
* jitter: Time that passes after the task has been started until the operating system indicates that it is
running.
To reset the values to 0 for a task, place the cursor on the task name field and
execute the Reset command available in the contextual menu.
350 EIO0000002854.04
Task Editor
Column Description
Priority
Priority (0...31) A number from 0...31; 0 is the highest priority, 31 is the lowest
Type
The target device defines which task types are supported. Not all types are available for some target
devices. Consult the Programming Guide specific to your controller for more information.
Cyclic The task will be processed cyclic according to the time definition (task
cycle time) given in the field Interval (see below).
Event The task will be started as soon as the variable defined in the Event field
gets a rising edge.
Freewheeling The task will be processed as soon as the program is started and at the
end of one run it will automatically be restarted in a continuous loop.
There is no cycle time defined.
EIO0000002854.04 351
Task Editor
Type
External The task will be started as soon as the system event, which is defined in
the External Event field, occurs. It depends on the target, which events
will be supported and offered in the selection list. (Not to be mixed up
with system events.)
Status The task will be started if the variable defined in the Event field is TRUE.
When you set the task cycle time, consider the bus system used by the application.
For example, on a CAN bus system, you can set the Bus cycle task in the
CANopen I/O Mapping tab. The task cycle time must match the transmission rate
and the number of frames used on the bus. Additionally, the times set for heartbeat,
nodeguarding and sync always should be a multiple of the task cycle time.
Otherwise, CAN frames may go unrecognized. For further information, refer to the
Device Editor part of the EcoStruxure Machine Expert online help.
Deviations of the task from the configured task cycle time are displayed at runtime
as periodic jitter in the Monitor tab, page 349
A global boolean variable which will trigger the start of the task as soon as a rising
edge is detected. Use button ... or the Input Assistant to get a list of all available
global event variables.
NOTE: If the event that is driving a task stems from an entry, there must be at
least one task which is not driven by events. Otherwise, the I/Os will never get
updated and the task will never get started.
NOTE: Only internal IEC variables and values of onboard touchprobes and
digital inputs (controller) are permitted. Referencing a property (including
system parameter) in an event task will lead to a watchdog exception error,
page 353 being detected during download.
Behavior at Point: 1 2 3 4
Status No start Start Start Start
Event No start Start No start No start
because the
event
changed too
fast from
TRUE to
FALSE and
back to TRUE
352 EIO0000002854.04
Task Editor
Watchdog Settings
For each task, you can configure a timeout control (watchdog).
The default watchdog settings depend on your controller.
When the Enable option is activated (check mark is set), the watchdog is enabled.
When the task watchdog is enabled, an Exception error is raised if the execution
time of the task exceeds the defined task time limit (Time) given in the defined
Sensitivity.
When the exception is detected, the application is stopped. If option Update IO
while in stop is enabled in the controller settings dialog box, the outputs are set to
the pre-defined default values depending upon the particular controller platform.
NOTE: This function is not available for all supported controllers. Consult the
Programming Guide specific to your controller.
The defined Sensitivity is taken into account when determining when to raise an
exception error. The Sensitivity allows you to adjust for variations in cycle times
in the execution of the task. The Sensitivity can be defined as follows:
• After consecutive timeouts:
◦ Sensitivity set to 0 or 1: exception in the first cycle after time expires
◦ Sensitivity set to 2: exception in the second cycle after time expires
◦ Sensitivity set to n: exception in the nth cycle after time expires
• After a single timeout: exception if the cycle time of the present cycle is longer
than (task time limit * sensitivity).
NOTE: The watchdog function is not available in simulation mode.
Consult the Programming Guide specific to your controller, chapter System and
Task Watchdog, for information on task time, sensitivity and other possible
watchdog parameters.
POUs
The POUs which are controlled by the task are listed here in a table with the POU
name and an optional Comment. Above the table there are commands for editing:
• In order to define a new POU, open the Input Assistant dialog box via the
command Add Call. Choose 1 of the programs available in the project. You
can also add POUs of type program to the list by drag and drop from the
Applications tree.
• In order to replace a program call by another 1, select the entry in the table,
open the Input Assistant via command Change Call.. and choose another
program.
• In order to delete a call, select it in the table and use the command Remove
Call.
• The command Open POU opens the selected program in the corresponding
editor.
The sequence of the listed POU calls from top to bottom determines the sequence
of execution in online mode. You can shift the selected entry within the list via the
commands Move up and Move down.
EIO0000002854.04 353
Task Editor
in a library or project-globally in the Global node of the Applications tree, the one
will be executed that is directly declared below in the Applications tree.
Consult the Programming Guide specific to your controller for more information on
task scheduling.
354 EIO0000002854.04
Watch List Editor
Online Mode
In online mode, the current variable value is shown in the column Value. Like at
other monitoring positions, you can define Prepared Values and force or write
them. For further information, refer to the chapters Force Values, Prepare Value
Dialog Box (see EcoStruxure Machine Expert, Menu Commands, Online Help)
and Monitoring, page 214.
EIO0000002854.04 355
Watch List Editor
In online mode, you can add a currently focused expression to the watch list by
executing the command Add Watch.
NOTE: In online mode you can add expressions to the watch list by use of the
command Add Watch.
356 EIO0000002854.04
Watch List Editor
EIO0000002854.04 357
Tools Within Logic Editors
358 EIO0000002854.04
Tools Within Logic Editors
The FFB Finder dialog box contains the following elements for finding a function
or function block:
Element Description
Find what In the Find what textbox, enter the name of the function or function block you want to insert
into your programming code.
As wildcards you can use a question mark (?), which replaces exactly one character, or an
asterisk (*), which can replace several characters or no character at all.
Company If you know the company that created the library which includes the function block you are
searching for, you can select the companies from the Company list.
Match case Check the Match case check box to perform a case-sensitive search.
Include comments in search Check the Include comments in search check box to search for the entered string not
only in the names of functions and function blocks but also in the comments that are saved
with them.
Search in project Libraries only Check the Search in project libraries only check box to limit the search to those libraries
that are used in the current application.
By default, this check box is not selected and the find operation includes all libraries that
are installed on the EcoStruxure Machine Expert PC.
Find Click the Find button or press the ENTER key to start searching for the function or function
block.
EIO0000002854.04 359
Tools Within Logic Editors
Input Assistant
Overview
The Input Assistant dialog box and the corresponding command Input
Assistant (by default in the Edit > Smart Coding menu) are only available if the
cursor is placed in a text editor window. The dialog box offers the available project
items for being inserted at the current cursor position.
Default shortcut: F2
360 EIO0000002854.04
Tools Within Logic Editors
Element Description
Filter You can set a Filter for the category Variables. To display a
certain type of variable, select an entry from the list, such as
Local variables, Global variables, Constants.
Items area
Name, Type, Address, Origin The Items area shows the available items and - depending on
the category - also their data Type, Address, and Origin for
the category selected in the Categories area.
The Origin is shown for I/O variables (path within the Devices
Tree) and library-defined variables (library name and
category).
Structured view If the option Structured view is selected, the project items are
displayed in a structure tree supplemented with icons.
If the option is not selected, the project items are arranged flat.
Each project item is displayed with the POU it belongs to
(example: GVL1.gvar1).
NOTE: If there are objects with the same name available in the Global node
of the Applications Tree as well as below an application (Applications Tree),
only 1 entry is offered in the Input Assistant because the usage of the object
is determined by the usual call priorities (first the application-assigned object,
then the global one).
EIO0000002854.04 361
Tools Within Logic Editors
Element Description
Insert with arguments If this option is selected, items which include arguments, for
example functions, are inserted with those arguments.
Example:
Insert with namespace prefix If this option is selected, the item is inserted with the prefixed
namespace.
362 EIO0000002854.04
Tools
What’s in This Part
Data Logging ............................................................................................... 364
Recipe Manager........................................................................................... 366
Trace Editor ................................................................................................. 383
Trend Recording .......................................................................................... 398
Alarm Configuration...................................................................................... 407
Unit Conversion ........................................................................................... 421
Symbol Configuration Editor.......................................................................... 425
EcoStruxure Machine Expert Controller - HMI Data Exchange ......................... 434
Cam Motion Editor........................................................................................ 444
Script Hook Manager.................................................................................. 457
EIO0000002854.04 363
Data Logging
Data Logging
What’s in This Chapter
Introduction to Data Logging ........................................................................ 364
The figure shows an application that includes the 2 function blocks, LogRecord
and Dump. The LogRecord function block writes data to the buffer, which empties
into the data log file (.log) located into the controller memory. The buffer dumping
is automatic when 80% full or it can be forced by the Dump function. As a standard
FTP client, a PC can access this data log file when the controller acts as an FTP
server. It is also possible to upload the file with EcoStruxure Machine Expert.
NOTE: Only controllers with file management functionality can support data
logging. Refer to your controller programming manual to see if it supports file
management.
364 EIO0000002854.04
Data Logging
Implementation Procedure
First declare and configure the data log files in your application before starting to
write your program.
EIO0000002854.04 365
Recipe Manager
Recipe Manager
What’s in This Chapter
Recipe Manager ......................................................................................... 366
Recipe Definition ......................................................................................... 369
RecipeManCommands ................................................................................ 373
Loading Recipe Values from the Controller .................................................... 381
Memory Usage by Recipes .......................................................................... 382
Recipe Manager
Overview
The Recipe Manager provides the functionality for handling user-defined lists of
project variables, named recipe definitions, and definite value sets for these
variables within a recipe definition, named recipes.
You can use recipes to modify or read recipe values for a specific set of variables
(recipe definition) on the controller. They can also be loaded from and saved to
files. These interactions are possible by using visualization elements which you
have to configure appropriately (input configuration execute command). You can
also use certain recipe commands in the application, page 373.
When you have selected a recipe, validate that the recipe is appropriate for the
process that will be controlled.
WARNING
UNINTENDED EQUIPMENT OPERATION
• Conduct a safety analysis for the application and equipment installed.
• Verify that recipe is appropriate for the process and equipment or function in
the installation.
• Supply appropriate parameters, particularly for limits and other safety-
related elements.
• Verify that all sensors and actuators are compatible with the recipe selected.
• Thoroughly test all functions during verification and commissioning.
• Provide independent paths for critical control functions (emergency stop,
over-limit conditions etc.) according to the safety analysis and applicable
codes and regulations.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
366 EIO0000002854.04
Recipe Manager
variables contained in the recipes. Reading and writing of the variables is done
synchronously. By calling g_RecipeManager.LastError after reading/writing, you
may verify if the transmission has been carried out successfully (g_
RecipeManager.LastError=0 in this case).
Parameter Description
File Path Specify the location where the recipe is to be saved in the controller or
in the local file system.
NOTE: For recipe managers that work in simulations, the file path
must start with a dot (.), for example, ./Rcp.
Parameter Description
Separator In case of textual storage, the columns selected for storage will be
separated by a separator. Select 1 of the 6 options proposed.
Available Columns All columns of the recipe definition, represented by the respective
header.
Selected Columns Selected columns of the recipe definition, that is, the columns to be
stored.
arrow buttons The other columns can be shifted to the right or to the left by selecting
the respective entry and clicking the arrow buttons. You can also shift
all entries from one side to the other at once by using the double arrow
buttons.
EIO0000002854.04 367
Recipe Manager
Parameter Description
Up and Down buttons Click these buttons to adjust the order of the selected columns, which
represents the order of the columns in the storage file.
Save as default Click the Save as default button to use the settings made within this
dialog box as default settings for each further recipe manager inserted.
NOTE: Floating point values (type REAL/LREAL) are stored in the textual
recipe files in decimal format as well as in hexadecimal format. (Because the
hexadecimal value represents the exact value whereas the decimal REAL
value represents the value to the seventh decimal place.)
Example: PLC_PRG.realVar:=22.0F16#1600000H-5
For manually modifying a value in the recipe file, edit the decimal value and
remove the subsequent hexadecimal entry. (If both values are available, the
hexadecimal value is loaded.)
Recipe Management in If the recipe manager is not needed on the controller because no
the PLC recipes are to be handled during run time of the application, you can
deactivate this option so that the manager is not downloaded.
Save recipe
Save recipe changes to This option is available only if the option Recipe Management in the
recipe files PLC is selected.
automatically
Select the Save recipe changes to recipe files automatically option
to update recipe files automatically in runtime mode whenever a recipe
is changed.
Load recipe If the option Recipe Management in the PLC is activated, the
following two options are available to configure the download from the
controller.
Load only by exact Select the option to load recipe files only if the file contains all variables
match of the variable available in the variable list of the recipe definition of the application.
list The variables in the file must be in the same order as in the variable
list. Additional entries at the end are ignored. Otherwise, the recipe
cannot be loaded and the return value, page 375 ERR_RECIPE_
MISMATCH is set (RecipeManCommands.GetLastError).
Load matching Select the option to load only variables with matching variable names
variables by variable from the recipe file. No error status is set when the variable list in the
name file is different from the list in the recipe definition of the application.
Thus, recipe files can also be loaded if variables in the file or in the
recipe definition have been deleted.
Write recipe
Limit the variable to Select the option to write the defined minimum or maximum value to
min/max when recipe the controller if the recipe contains a value that is beyond the value
value is out of the range range.
Do not write to a Select the option to prevent a value from being written to the controller
variable when the if the recipe contains a value that is beyond the value range. The value
recipe value is out of that is present in the controller will be retained.
the min/max range
368 EIO0000002854.04
Recipe Manager
Parameter Description
Read recipe
Select the option to read the variable values present in the controller
into the recipe with each method call. Only if the values have changed,
the recipe file is overwritten with the present values. As this procedure
generates additional code for comparing the old and the present
values, consider that it has an impact on the performance.
Recipe Definition
Overview
The recipe manager, page 366 handles 1 or several recipe definitions. A recipe
definition contains a list of variables and 1 or several recipes (value sets) for these
variables. You can save a recipe to a file or write recipe files to the controller. By
using different recipes, you can assign another set of values to a set of variables
on the controller in one stroke. There is no limitation of the number of recipe
definitions, recipes, and variables per recipe.
NOTE: The recipe management reads the values of the variables that are
defined in the recipe definition at the end of the initialization phase of the
application. Since the initial values of the application variables have all been
set at this point, missing values from recipe files can be correctly initialized.
Recipe Definition
You can add one or several Recipe Definition objects to a Recipe Manager node
in the Tools tree. To achieve this, click the green plus button of the Recipe
Manager node and execute the command Recipe Definition....
Double-click the node to view and edit recipe definitions including the particular
recipes in a separate editor view.
Recipe definition editor view
EIO0000002854.04 369
Recipe Manager
Parameter Description
Variable In the table, you can enter several project variables for which you want
to define 1 or several recipes. For this purpose, you can use the
command Insert Variable when the cursor is in any field of any line.
Alternatively, you can double-click a Variable field, or you can select it
and press the spacebar to get into editor mode. Enter the valid name
of a project variable, for example plc_prg.ivar. You can click the ...
button to open the Input Assistant.
You can also specify a POU, for example, a program like PLC_PRG
shown in the figure above. In this case, all variables defined within the
POU are added to the recipe definition automatically when you close
the input field. The same applies to data types or function blocks.
You can toggle between the normal and the structured view using the
buttons on the right side.
Type The Type field is filled automatically. Optionally, you can define a
symbolic Name.
Comment Enter additional information, such as the unit of the value recorded in
the variable.
Minimal Value and You can optionally specify these values which should be permissible
Maximal Value for being written on this variable.
You can remove a variable (line) from the table by pressing the DEL key when one
of its cells is selected. You can select multiple lines by keeping the CTRL key
pressed while selecting cells. You can copy the selected lines by copy and paste.
The paste command inserts the copied lines above the selected line. In doing so,
recipe values are inserted in the matching recipe column, if available.
To add a recipe to the recipe definition, execute the Add a new recipe command
(see EcoStruxure Machine Expert, Menu Commands, Online Help) when the
focus is in the editor view. For each recipe, an own column is created, titled with
the recipe name (example: R1 and R2 in the figure above).
In online mode, a recipe can be changed either by an appropriately configured
visualization element (input configuration execute command) or by using the
appropriate methods of the function block RecipeManCommands of the Recipe_
Management.library.
For a list of methods available in the contextual menu of a recipe column in the
recipe definition editor view, refer to Using Recipes in Online Mode, page 371.
See in the following paragraphs how the recipes behave in the particular online
states. It is a good practice to set the option Save recipe changes to recipe files
automatically (in order to get the usual behavior of a recipe management).
Recipe
You can add or remove a recipe offline or online. In offline mode, use the
commands Add a new recipe (see EcoStruxure Machine Expert, Menu
Commands, Online Help) and Remove recipes (see EcoStruxure Machine
Expert, Menu Commands, Online Help) within the recipe manager editor. In online
mode, either configure an input on an appropriately configured visualization
370 EIO0000002854.04
Recipe Manager
Online Reset Warm The recipes of all recipe Dynamically created recipes
definitions get set with the remain unchanged.
Online Reset Cold values out of the open project.
Download
Online Reset Origin The application is removed from the controller. If a new download
is done afterwards, the recipes will be restored like on an Online
Reset Warm.
Shut down and restart the After the restart, the recipes are reloaded from the automatically
controller created files. So the status before shutdown will be restored.
Online Change The recipe values remain unchanged. During run time, a recipe
can only be modified by the commands of the
RecipeManCommands function block.
NOTE: Floating point values (type REAL/LREAL) are stored in the textual
recipe files in decimal format as well as in hexadecimal format. (Because the
hexadecimal value represents the exact value whereas the decimal REAL
value represents the value to the seventh decimal place.)
Example: PLC_PRG.realVar:=22.0F16#1600000H-5
For manually modifying a value in the recipe file, edit the decimal value and
remove the subsequent hexadecimal entry. (If both values are available, the
hexadecimal value is loaded.)
Recipe handling in online mode if Save recipe changes to recipe files
automatically is NOT activated:
Online Reset Warm The recipes of all recipe Dynamically created recipes
definitions get set with the get lost.
Online Reset Cold values out of the open project.
However, these are only set in
Download the memory. In order to store
the recipe in a file, the save
command must be used
explicitly.
Shut down and restart the After the restart the recipes are reloaded from the initial values
controller which had been created at download from the values out of the
project. So the status as it was before shutdown will not be
restored.
EIO0000002854.04 371
Recipe Manager
Online Change The recipe values remain unchanged. During run time, a recipe
can only be modified by the commands of the
RecipeManCommands function block.
Further information:
• Concerning the storage of recipes in files, which are reloaded at a restart of
the application, refer to the description of the Recipe Manager Editor, Storage
Tab, page 367.
• For a description of the particular RecipeManCommands methods, page 373,
refer to the documentation within the library.
• For the input configuration of a visualization element, refer to the help page
(category Input > execute command).
The following actions on recipes are possible:
Actions Description
Create recipe (= Add a A new recipe is created in the specified recipe definition.
new recipe)
Read recipe The values of the variables of the specified recipe definition are read
from the controller and are written to the specified recipe. Therefore,
the values will be stored implicitly (in a file on the controller). They will
also be monitored immediately in the recipe definition table in the
Recipe Manager. In other words, the recipe managed in the Recipe
Manager gets updated with the actual values from the controller.
Write recipe The values of the given recipe, as visible in the recipe manager, are
written to the variables on the controller.
Save Recipe The values of the specified recipe are written to a file with extension *.
txtrecipe or * .rcp, the name of which you have to define. For this
purpose, the dialog box for saving a file in the local file system opens.
NOTE: The implicitly used recipe files, necessary as a buffer for
reading and writing of the recipe values, may not get overwritten.
Therefore, the name for the new recipe file must be different from
<recipe name>.<recipe definition name>.txtrecipe / .rcp.
Load Recipe The recipe which has been stored in a file (see the Save Recipe
description) can be reloaded from this file. The dialog box for browsing
for a file opens for this purpose. The filter is automatically set to
extension *.txtrecipe / * .rcp. After reloading the file, the recipe values
will be updated accordingly in the recipe manager. For further
information, refer to the description of the Load Recipe command in
the Menu Commands Online Help (see EcoStruxure Machine Expert,
Menu Commands, Online Help).
Delete recipe (= Remove The specified recipe is removed from the recipe definition.
recipe)
Change recipe The value of the project variables can be changed. With a following
write recipe action, the project variables are written with the new
values.
NOTE:
When using recipe files (create, read, write, delete), create specific tasks,
page 351 with low priority and with the Watchdog function disabled.
372 EIO0000002854.04
Recipe Manager
RecipeManCommands
Overview
When calling a recipe command, internal data access is performed. Depending on
the device type, this takes a few milliseconds. Verify that these calls are not
performed by the MAST task or by a task with a configured watchdog or a real-
time task. This may lead to an application error and the controller will enter the
HALT state.
Consider that the option Save recipe changes to recipe files automatically also
performs a file access with each modification of the recipe. Deactivate this option
if the storage of the recipe is triggered by the application.
Return Values
For possible return values for recipe commands, refer to the Recipe Management
Library Documentation of the EcoStruxure Machine Expert Online Help.
CreateRecipe
This method creates a new recipe in the specified recipe definition and afterwards
reads the controller values into the new recipe. At the end, the new recipe is
stored in the default file.
CreateRecipeNoSave
This method creates a new recipe in the specified recipe definition and afterwards
reads the controller values into the new recipe.
EIO0000002854.04 373
Recipe Manager
DeleteRecipe
This method deletes a recipe from a recipe definition.
DeleteRecipeFile
This method deletes the default recipe file from a recipe.
LoadAndWriteRecipe
This method loads a recipe from the default recipe file and afterwards writes the
recipe into the controller variables.
LoadFromAndWriteRecipe
This method loads a recipe from the specified recipe file and afterwards writes the
recipe into the controller variables.
374 EIO0000002854.04
Recipe Manager
LoadRecipe
This method loads a recipe from the default recipe file. The default recipe file
name is <recipe>.<recipe definition>.<recipeextension>.
ReadAndSaveAs
This method reads the controller values from the variables of the recipe definitions
and afterwards stores the data set to a file recipe without modifying the default
recipe file <recipe.recipe definition.extension>.
RecipeDefinitionName: STRING Name of the recipe definition. The variables defined in the recipe
definition are read.
FileName: STRING[255] Name of the file in which the read data set is saved as a recipe.
ReadAndSaveRecipe
This method reads the controller values into the recipe and afterwards stores the
recipe into the default recipe file.
ReadAndSaveRecipeAs
This method reads the controller values into the recipe and afterwards stores the
recipe into the specified recipe file. The content of an existing file would be
overridden.
EIO0000002854.04 375
Recipe Manager
SaveRecipe
This method stores the recipe into the default recipe file. The content of an
existing file would be overridden. The default recipe file name is <recipe>.
<recipedefinition>.<recipeextension>.
ReadRecipe
This method reads the controller values into the recipe.
WriteRecipe
This method writes the recipe into the controller variables.
ReloadRecipes
This method reloads the list of recipes from the file system.
376 EIO0000002854.04
Recipe Manager
GetRecipeCount
This method returns the number of recipes from the corresponding recipe
definition.
GetRecipeNames
This method returns the recipe names from the corresponding recipe definition.
pStrings : POINTER TO ARRAY [] OF The strings where the recipe values should be stored.
STRING
iSize : INT The size of an array of strings.
iStartIndex : INT The start index; can be used for a scrolling function.
EIO0000002854.04 377
Recipe Manager
GetRecipeValues
This method returns the recipe variable values from the corresponding recipe.
pStrings : POINTER TO ARRAY [] OF The strings where the recipe values are to be stored.
STRING
iSize : INT The size of an array of strings.
iStartIndex : INT The start index; can be used for a scrolling function.
378 EIO0000002854.04
Recipe Manager
GetRecipeVariableNames
This method returns the variable name of the corresponding recipe.
pStrings : POINTER TO ARRAY [] OF The strings where the recipe values should be stored.
STRING
iSize : INT The size of an array of strings.
iStartIndex : INT The start index; can be used for a scrolling function.
EIO0000002854.04 379
Recipe Manager
SetRecipeValues
This method sets the recipe values into the corresponding recipe.
pStrings : POINTER TO ARRAY [] OF The strings where the recipe values should be stored.
STRING
iSize : INT The size of an array of strings.
iStartIndex : INT The start index; can be used for a scrolling function.
GetLastError
This method of data type DWORD returns the last detected error of the previous
operations.
Return values, page 373: ERR_NO_RECIPE_MANAGER_SET, ERR_OK
ResetLastError
This method of data type DWORD resets the last detected error.
Return values, page 373: ERR_NO_RECIPE_MANAGER_SET, ERR_OK
380 EIO0000002854.04
Recipe Manager
SetStoragePath
This method allows you to set the storage path for the recipe file. It overwrites the
File Path configured in the Recipe Manager dialog box, page 366.
stPath STRING The method returns TRUE if the path is set, as for example: D:/
recipefiles/.
3 Log in to the controller and download the Result: The recipe file R1.RecDef1.
application. txtrecipe is saved to the directory
Recipes of the controller.
8 Edit the R2.RecDef1.txtrecipe file and modify the Result: On the controller, there are
recipe values: now two recipes, R1 and R2.
EIO0000002854.04 381
Recipe Manager
382 EIO0000002854.04
Trace Editor
Trace Editor
What’s in This Chapter
Trace Object ............................................................................................... 383
Trace Configuration ..................................................................................... 387
Trace Editor in Online Mode ......................................................................... 395
Keyboard Operations for Trace Diagrams...................................................... 396
Trace Object
Trace Basics
Trace Functionality
The trace functionality allows you to capture the progression of the values of
variables on the controller over a certain time, similar to a digital sampling
oscilloscope. Additionally, you can set a trigger to control the data capturing with
input (trigger) signals. The values of trace variables are steadily written to an
EcoStruxure Machine Expert buffer of a specified size. They can be observed in
the form of a two-dimensional graph plotted as a function of time.
NOTE: The tracing of data is continued when you log off the controller.
If PC processor-consuming tasks are executed in EcoStruxure Machine Expert or
on the PC running EcoStruxure Machine Expert while a trace is running, it may
happen that variable values are not captured by the trace.
NOTICE
LOSS OF DATA
Avoid executing actions and/or PC applications that lead to a high processor
load while running a trace.
Failure to follow these instructions can result in equipment damage.
EIO0000002854.04 383
Trace Editor
Configuration
Configure the trace data as well as the display settings of the trace data in the
Configuration. It provides commands for accessing the configuration dialog
boxes. Several variables can be traced and displayed at the same time, in
different views such as multi-channel mode. Record traces of variables with
different trigger settings in their own trace object. You can create any number of
trace objects.
Tools tree with several trace objects
Commands for modifying the settings of the display are described in the Features
paragraph, page 385. Zooming functionalities and a cursor are available as well
as commands for running the trace so that the graph can be compressed or
stretched.
To integrate the readout of a trace within a visualization, use the visualization
element Trace.
For further information on trace configuration for data recording, refer to the
Record Settings, page 391.
384 EIO0000002854.04
Trace Editor
Configuration
Newly created trace with contextual menu:
Features
For running the trace, use the following commands:
• Add variable (see EcoStruxure Machine Expert, Menu Commands, Online
Help)
• Download Trace (see EcoStruxure Machine Expert, Menu Commands,
Online Help)
• Start/Stop Trace (see EcoStruxure Machine Expert, Menu Commands,
Online Help)
• Reset Trigger (see EcoStruxure Machine Expert, Menu Commands, Online
Help)
For customizing the view of the graphs, use the following commands:
• Cursor (see EcoStruxure Machine Expert, Menu Commands, Online Help)
• Mouse Zooming (see EcoStruxure Machine Expert, Menu Commands,
Online Help)
EIO0000002854.04 385
Trace Editor
Getting Started
In order to start the trace in online mode, download the trace configuration to the
controller by executing the Download Trace command. The graphs of the trace
variables are displayed in the trace editor window where you can store them to an
external file. This file can be reloaded to the editor. Also refer to the chapter Trace
Editor in Online Mode, page 395.
Step Action
2 Download trace
Result: The trace graphs are immediately displayed according to the trace
configuration.
3 Arrange the trace graphs, store the trace data, stop/start tracing.
Example
The trace editor shows an example of tracing in online mode. Four variables have
been selected for display in the variables tree in the right part of the dialog.
386 EIO0000002854.04
Trace Editor
Trace Configuration
Trace Configuration - Tree Views
Overview
The Trace Configuration dialog box provides two different tree views on the left-
hand side:
• Trace Record tree view
• Presentation (diagrams) tree view
EIO0000002854.04 387
Trace Editor
Command Description
A diagram name is selected The settings for the coordinate system of the
diagram and a preview are displayed.
The node Y axis is selected. The Display mode view, page 392 is displayed
on the right-hand side. It allows you to specify
the axis display.
A trace variable is selected below the Shown The Variable Settings view, page 389 on the
variables node. right-hand side that allows you to configure the
trace variables.
Command Description
Add new variable Adds a new trace variable and opens the
Variable Settings view, page 389 on the right-
hand side.
388 EIO0000002854.04
Trace Editor
Variable Settings
Overview
The Trace Configuration dialog box with Variable Settings opens when you
select a trace variable in the trace tree. It allows you to configure which variables
should be traced and how they are displayed.
Trace Configuration dialog box with Variable Settings
The trace variables are displayed in the left part of the window in a tree structure.
The top node is titled with the trace name.
Command Description
In the right part of the dialog box, the settings of the new
variable are ready for configuration.
EIO0000002854.04 389
Trace Editor
Parameter Description
Variable Enter the name (path) of the signal to specify the signal that is
traced.
Graph color Select a color from the color selection list in which the trace
curve for the variable is displayed.
Line type Specify the way samples are connected in the graph. Use
Line for large volumes of data. It is also the default value.
Point type Specify how the values themselves are drawn in the graph.
Activate Minimum Warning If this option is activated, the trace graph is displayed in the
color defined in Warning minimum color as soon as the
variable exceeds the value defined in Critical lower limit.
Critical lower limit If the value of the variable entered here has fallen below and
Activate minimum warning is active, the values of the curve
changes in the following specified color.
Warning minimum color Color value for the activated lower limit.
Activate Maximum Warning If this option is activated, the trace graph is displayed in the
color defined in Warning maximum color as soon as the
variable exceeds the value defined in Critical upper limit.
Critical upper limit If the value of the variable entered here is exceeded and
Activate maximum warning is active, the values of the
curve changes in the following specified color.
Warning maximum color Color value for the activated upper limit.
Multi-Selection of Variables
By using the keyboard shortcuts Shift + mouse-click or Ctrl + mouse-click, you
can select several variables for editing. Then the modifications made in the dialog
box Variable Settings are applied to all selected variables. The same can be
achieved with Shift + Up Arrow/Down Arrow or Ctrl + Up Arrow/Down Arrow.
390 EIO0000002854.04
Trace Editor
Record Settings
Overview
The Trace Configuration dialog box with Record Settings opens if you execute
the command Configuration or if you double-click a trace variable in the trace
tree. The configuration command is also available in the contextual menu of the
trace tree on the right part of the main trace editor window.
NOTE: The settings completed in the dialog box Trace Configuration dialog
box with Record Settings are valid for all variables of the trace graph.
Trigger Basics
In most situations, it is not desired that tracing and displaying the input signals
starts at random moments, such as immediately after the previous measurement,
or when the user presses the start button. Most of the time it is preferred that the
tracing is done when a trigger is fired for the configured number of records (post
trigger). This is called triggering and has to be defined here.
The following ways are used for triggering input signals:
• by configuring a trigger variable
• by configuring a record condition
• or both
Enable Trigger Select the checkbox to enable the trigger system. It can be
turned on or off independently of the lower settings. If the
trigger system is disabled, the trace is free-running.
Trigger Variable Assign a variable. Specify which signal will be used as trigger
by entering the name (and path) of the signal.
EIO0000002854.04 391
Trace Editor
Parameter Description
Post Trigger Enter a number of records per trace signal, which are
recorded after the trigger is fired.
Default value: 50
Range: 0...4,294,967,295
If IEC code is used, then you can also enter an arbitrary IEC
expression of a type that is convertible to that of the trigger
variable.
Task From the list of available tasks, select the one where
capturing of the input signals takes place.
Record condition If you want to start the record by a condition, enter here a
variable. If the trace is started before, for example by pressing
the start button, and the variable assigned here becomes
TRUE, the data capturing is started and the traced graph will
be displayed.
For each captured signal, pairs of value and time stamp are
stored and transmitted to the programming system. The
transmitted time stamps are relative and refer to the start of
the tracing.
Automatic restart Set this option if the trace configuration and the last content of
the RTS trace buffers is to be stored persistently on the target
device.
NOTE: If you want to capture and display a trace signal with a different time
base, you have to do a record configuration in a separate trace object.
Display Mode
Overview
The Display mode view opens on the right-hand side when you select an axis
(time or Y axis) in the Presentation (diagrams) tree view.
The parameters displayed depend on the axis that is selected:
392 EIO0000002854.04
Trace Editor
Parameter Description
Element Description
Font button Click the Font button to open the Font dialog
box and configure the font for the selected axis.
If a trace is selected in the Trace Record tree view, the following elements are
available:
Element Description
Add variable link Click the link to add a new trace variable to the
Trace Record tree view.
Delete variable link Click the Delete variable link to delete the
selected trace variable from the Trace Record
tree view.
EIO0000002854.04 393
Trace Editor
Preview
The preview of the diagram you defined in the Display mode view is displayed
when you click the Preview link in the Display mode view.
Underneath the preview of the diagram, the following elements are available:
Element Description
Reset display settings link Click the Reset display settings link to reset
the display settings of the selected diagram or
the selected y-axis to the default values.
You configure the buffer size by defining a number of samples. Using settings from
the task configuration, EcoStruxure Machine Expert calculates time intervals
according to the number of samples. The calculation is possible only if the task
cycle time is determinable. The result is displayed on the right, outside the table in
a standardized style, for example, 1h1m1s1ms .
394 EIO0000002854.04
Trace Editor
Measure in every n- Defines how often a data record is For example, the scanning interval
th cycle taken (every cycle, every second of the data recording is every 10
cycle,...). This is the scanning rate. ms.
Recommended The maximum number of samples Maximum length of the time interval
runtime buffer size that EcoStruxure Machine Expert during which the runtime system
(samples) calculates and that the runtime collects data, for example, 2 s (if
system can store per trace variable. Refresh interval = 500 ms and
EcoStruxure Machine Expert Measure in every n-th cycle = 1).
calculates the number in the task
cycle time from the value in
Refresh interval and the value in
Measure in every n-th cycle.
Download Trace
In order to start the trace in online mode, download explicitly the trace to the
controller with the Trace > Download Trace menu command (see EcoStruxure
Machine Expert, Menu Commands, Online Help) while the application is logged in.
The graphs of the trace signals will be displayed in the trace editor window.
While doing logins and logouts on the application without changing it, the traces
are running without a new download.
If the application code is changed, then it depends on the login mode, in what
happens with the traces:
• Login with online change or Login without any change: The traces are
still running.
• Login with download: The traces in the controller are deleted and a new
download of them is necessary.
EIO0000002854.04 395
Trace Editor
Scroll the trace graph No trace cursor: Scroll the graph by drag and
horizontally along the time • ARROW LEFT/RIGHT drop. This is indicated by a
axis. different view of the mouse
• With greater distances: cursor.
CTRL + ARROW LEFT/
RIGHT
1 or 2 trace cursors:
• ALT + ARROW LEFT/
RIGHT
• With greater distances:
CTRL + ALT + ARROW
LEFT/RIGHT
Scroll the trace graph vertically ARROW UP/DOWN Use CTRL + drag and drop.
along the Y-axis.
With greater distances: CTRL
+ ARROW UP/DOWN
Zoom to a rectangle (window) – Use the command Mouse
that is selected with the Zooming (see EcoStruxure
mouse. Machine Expert, Menu
Commands, Online Help).
Shift the black trace cursor. ARROW LEFT/RIGHT Click the black triangle of the
trace cursor, drag it along the
With greater distances: CTRL X-axis until you drop it.
+ LEFT/RIGHT ARROW
Shift the gray trace cursor. SHIFT + ARROW LEFT/ Click the gray triangle of the
RIGHT trace cursor, drag it along the
X-axis until you drop it.
With greater distances: CTRL
+ SHIFT + ARROW LEFT/
RIGHT
Compress the time axis. – Use the mouse wheel.
396 EIO0000002854.04
Trace Editor
EIO0000002854.04 397
Trend Recording
Trend Recording
What’s in This Chapter
Trend Recording Objects ............................................................................. 398
Trend Recording Configuration..................................................................... 399
Recording Trend Data.................................................................................. 405
NOTICE
LOSS OF DATA
Stop the trend function and save the trend data before changing state of the
controller from the run state.
Failure to follow these instructions can result in equipment damage.
This function is not available for all supported controllers. Consult the
Programming Guide specific to your controller as to whether it supports trend
recording.
398 EIO0000002854.04
Trend Recording
EIO0000002854.04 399
Trend Recording
Record Settings
Overview
The Trend Recording dialog box with Record Settings opens when you select
the top node in the tree view of the Trend Recording Editor.
The recording of data is performed using the function of the runtime component
that is also used for tracing, page 391. The settings that appear here are the
same. The parameters that are related to trigger settings are not required during
trend recording and are therefore grayed out.
Element Description
Task parameter From the list, select the task in which data acquisition is
executed. In general, the trend recording runs in the same
task as the main program, for example, PLC_PRG.
Record condition parameter Refers to a variable of the type BOOL, to a bit or to a property.
The data acquisition is executed if the value is TRUE. The
setting is optional.
Trend storage... button Click this button to open the Trend storage dialog box. It
allows you to configure further parameters that concern the
behavior of the trend recording at runtime.
Advanced... button Click this button to open the Advanced Trend Settings
dialog box, page 401. It allows you to configure parameters
that concern the acquisition and storage of data.
400 EIO0000002854.04
Trend Recording
Parameter Description
Maximum number of variables Defines the maximum number of trend variables that are
managed in the database. If you modify this value,
EcoStruxure Machine Expert updates the database on the
controller by forcing a download during next login to the
controller. The database will then be uploaded from the
controller, the variables of the database will be increased or
decreased according to this new setting, and will be
downloaded to the controller.
Store every N milliseconds Number of ms defining the time interval at which the recorded
data is temporarily stored in a local buffer before being stored
persistently in the database. The time interval is converted
internally to the number of task cycles. The duration of a task
cycle is defined in the task configuration.
Use this option only for testing purposes, as using this setting
will eventually exhaust the file space in the controller if not
regularly maintained.
Maximum This option defines the maximum number of data records that
number of are stored in the database. Each data record consists of time
records stamp and the values of the trend variables.
NOTE: If this limit is reached, trend recording is stopped.
Maximum This option defines the maximum memory size reserved for
storage size trend storage. The number of records that can be stored
within this memory depends on the size of the individual
records.
Parameter Description
Measure in every n-th cycle Defines how often data is acquired by the runtime system,
depending on the number of cycles completed.
Additional Runtime Buffer for Defines the time, in ms, that the runtime system can use an
additional “overflow” buffer for recording data.
Example: 1000 ms
NOTE: This additional buffer can help to avoid loss of
data if a delay occurs during storage of the trend data.
EIO0000002854.04 401
Trend Recording
Variable Settings
Overview
The Trend Recording dialog box with Variable Settings opens when you select a
trend variable in the tree view of the Trend Recording Editor. It allows you to
configure which variables and parameters should be recorded and how they are
displayed.
The Trend Configuration dialog box with Variable Settings corresponds to the
dialog box for tracing, page 389. The trend variables are displayed in the left part
of the window in a tree structure. The top node is titled with the trend name.
Parameter Description
Variable / Parameter Enter the IEC variable from which values shall be acquired. The
variable / parameter must have a valid type.
Controllers that support trend recording provide a list if you click the
Variable: parameter. If you want to create the trend of a device
parameter, select the item Parameter from this list. Then you can find
one with the help of the Input Assistant. Edit or verify the variable
settings.
Attached y axis Y-axis of the trend diagram that displays the Variable. The list provides
the default Y-axis and the configured Y-axes.
Display variable name If the option is selected, the name of the IEC variable is displayed by
the visualization in the trend diagram in runtime mode.
Description Enter text that is displayed instead of the variable name in the Legend
assigned to the trend visualization element by having selected a
Legend in the Properties view. This text is inserted in the
GlobalTextList object where it can be localized.
If you do not enter text in this Description box, the option Display
variable name is selected by default, and only the name of the
variable is displayed.
Example: PLC_PRG.iSensor_A
Line type Defines how the acquired values are displayed as a line chart. Use the
option Line for large amounts of data. As a prerequisite, the Curve
type must be set to Line.
402 EIO0000002854.04
Trend Recording
Parameter Description
Example: 1
Transparency Enter a value between 0...255 for defining the transparency of the
selected color.
Activate minimum If this option is activated, a message is displayed when the variable
warning value is under the lower limit.
Critical lower limit If the value of the trend variable falls below the limit, the variable is
displayed in the Color defined for values below the limit.
Warning minimum color Color in which the variable is displayed when under the lower limit.
Activate maximum If this option is activated, a message is displayed when the variable
warning value is above the upper limit.
Critical upper limit If the value of the trend variable exceeds the limit, the variable is
displayed in the Color defined for values above the limit.
Warning maximum Color in which the variable is displayed when above the upper limit.
color
A valid trend variable can be an IEC variable, a property, a reference, the contents
of a pointer, an ARRAY element, or an enumeration, as long as the type is not
STRING, WSTRING, or ARRAY.
EIO0000002854.04 403
Trend Recording
Assigning Task
Define the task in which the trend recording is to be executed. In general, the
trend recording runs in the same task as the main program, for example, PLC_
PRG.
Step Action
Result: The Record Settings are displayed on the right-hand side of the dialog box.
3 Open the Task list and select the task in which the associated application runs.
Step Action
2 Execute the Add variable command, which is located below the tree view.
Result: A new variable is inserted and the corresponding variable settings are
displayed.
3 Enter a valid IEC variable from the Variable list, or select the entry Parameters and
enter a valid parameter.
Also refer to the Variable Settings of the Trace Configuration, page 389.
404 EIO0000002854.04
Trend Recording
Result: The Record Settings are displayed on the right-hand side of the dialog box.
Result: The Record Settings are displayed on the right-hand side of the dialog box.
Before you stop the controller or perform a download (execute the Online change
command (see EcoStruxure Machine Expert, Menu Commands, Online Help)),
stop the trend recording process to save the trend data to the database.
EIO0000002854.04 405
Trend Recording
NOTICE
LOSS OF DATA
Stop the trend function and save the trend data before changing state of the
controller from the run state.
Failure to follow these instructions can result in equipment damage.
Step Action
Result: The Record settings are displayed on the right-hand side of the dialog box.
4 Select the application that contains the trend recording and execute the command
Application > Login.
406 EIO0000002854.04
Alarm Configuration
Alarm Configuration
What’s in This Chapter
General Information..................................................................................... 407
Configuration of the Alarm Management ....................................................... 409
Calling Event Alarms in the Program............................................................. 411
Alarm Management Objects ......................................................................... 412
General Information
Alarm Management
Overview
You can configure an alarm management system in an application to monitor
critical conditions of your machine by triggering alarms.
Alarms are defined as part of alarm groups. For each alarm, configure the
following parameters:
• The monitoring criteria
• An optional user-defined deactivation variable
• An alarm class
• A message
• An optional pending time
Moreover, you can assign latch variables to lock (or mark) an alarm so that it can
be filtered according to the latch values.
EIO0000002854.04 407
Alarm Configuration
Defining Alarms
Overview
An alarm definition consists of the following components:
• General description (such as ID, message text)
• Description of the cause of the alarm (such as expression to be monitored,
limits, minimum pending time)
• Description of the effects of the alarm (such as actions, display properties,
confirmation method) as part of the associated alarm class
Acknowledging Alarms
The main reason for the use of alarms is to inform the user about an alarm
situation. To help ensure that the user has taken the alarm information into
account, EcoStruxure Machine Expert allows you to configure different actions in
the alarm class. The user must acknowledge the alarm to delete it from the alarm
list. The different types of alarm acknowledgment are described in the status
diagrams as status transitions, page 413.
408 EIO0000002854.04
Alarm Configuration
1 In the Tools tree, right-click the Applications node and execute the command Add Object > Alarm Configuration....
Result: The Add Alarm Configuration dialog box opens.
Result: The alarm management is created for your application. By default, it consists of the root node Alarm
Configuration and the subnodes for Error, Warning and Info alarm classes and Alarm Storage.
1 In the Tools tree, right-click the Alarm Configuration node and execute the command Add Object > Alarm Class....
Result: The Add Alarm Class dialog box opens.
2 Enter a Name (for example, PartsShortage) and click the Add button.
Result: The alarm class PartsShortage is added as new subnode of the Alarm Configuration node and the
PartsShortage alarm class editor opens on the right-hand side.
3 In the PartsShortage alarm class editor, configure the following parameters that belong to this class group:
• Set Priority to 10.
• Select the Archiving option.
• For Acknowledgment method select REP_ACK.
• Select the Acknowledge separately option.
In the next steps, configure that the variable bPartsShortage gets the value TRUE when alarm messages are generated:
EIO0000002854.04 409
Alarm Configuration
Step Action
4 In the Notification Actions section of the editor, double-click the Action column, select the option Variable from the list
and press Enter.
5 Deselect the options Confirm and Deactivate. (Keep the Activate option selected.)
In the Active row select from the Background Color the entry Red.
8 In the Display Options for Alarm Table / Alarm Banner section of the editor:
In the Waiting for confirmation row select from the Background Color the entry Yellow.
Result: All messages in the PartsShortage class will now set the variable bPartsShortage to TRUE. Active messages
are highlighted in red in the Alarm Table visualization element. Deactivated messages that are not acknowledged are
highlighted in yellow.
1 In the Tools tree, right-click the AlarmStorage node and execute the command Properties....
2 In the Properties dialog box, change the name from AlarmStorage to, for example, DatabaseFileAlarmStorage
and click the OK button.
3 Double-click the node DatabaseFileAlarmStorage from the Tools tree.
4 In the DatabaseFileAlarmStorage alarm storage editor on the right-hand side, configure the following parameters:
• The Subdirectory field is by default empty and the default directory /usr/Alarms is set on the controller for the alarm
SQLite files. If you enter a name, a subfolder of this name is created in the default directory.
• In the Limit section, select the option Maximum number of records and enter a value, for example, 1000.
410 EIO0000002854.04
Alarm Configuration
Step Action
1 In the Tools tree, right-click the Alarm Configuration node and execute the command Add Object > Alarm Group....
Result: The Add Alarm Group dialog box opens.
Results:
• The alarm group PartsShortage is added as new subnode of the Alarm Configuration node and the
PartsShortage alarm group editor opens on the right-hand side.
• A PartsShortage text list is automatically created.
3 In the PartsShortage alarm group editor, set the parameter Archiving to (none).
4 Double-click the Observation Type column and select the option Digital from the list.
7 From the Archiving list, select DatabaseFileAlarmStorage which you have configured with the alarm storage, page 410.
Results:
If the variable bPart1Empty switches to TRUE, EcoStruxure Machine Expert
triggers a message. The value of the variable iFillLevel is issued with the
message. The acknowledgment response and the display are executed according
to the PartsShortage alarm class. The alarm will be archived.
EIO0000002854.04 411
Alarm Configuration
1 Create an Alarm Group named AlarmGroup1 as described in Configuring an Alarm Group, page 410.
3 In the column Class, select an alarm class with the acknowledgment method ACK or create a new alarm class. For details
refer to Configuring an Alarm Class, page 409.
1 Place the cursor at the position in the POU where the function block for triggering the alarm is to be called.
2 Type AlarmManager followed by a period to use the RaiseEvent function from the AlarmManager library.
3 Select AlarmGlobals and enter a period. Insert the elements g_AlarmHandler and RaiseEvent accordingly.
4 Connect the transfer variables for the parameters AlarmGroup_ID and Alarm_ID by entering a left parenthesis.
6 Select the Categories tab and select the category Variables from the list on the left-hand side.
8 Enter a comma and insert the alarm ID variable ('Alm_AlarmGroup1_Alarm_IDs.ID_0' in this example) and enter a right
parenthesis and a semicolon.
412 EIO0000002854.04
Alarm Configuration
Alarm Class
Overview
An alarm class describes the general properties of an alarm. The configured alarm
classes are available for selection in the Class column of the editor of the alarm
group. They serve as a core configuration of an alarm and define the following:
• Specific acknowledgment method (how the user must confirm the alarm).
• Action execution (what happens automatically if an alarm conditions occurs).
• Display options for the Alarm Table or the Alarm Banner (how the alarms
are visualized).
For further information, refer to Configuration of the Alarm Management, page
409.
Priority Specifies the priority of the alarm condition in this class (0...255).
Acknowledgment section
Acknowledge If selected, the user cannot acknowledge the alarm together with other alarms during operation but must
separately acknowledge it separately. This helps to prevent the user from inadvertently acknowledging an alarm with other
alarms.
NOTE: If this option is selected, the Acknowledge all visible button of the Alarm Table element in the
visualization does not acknowledge all alarms.
EIO0000002854.04 413
Alarm Configuration
Element Description
REP
ACK
REP_ACK
ACK_REP
ACK_REP_ACK
Alarm status:
• 1 - Normal No alarm situation.
• 2 - Active An alarm situation has been detected.
• 3 - Waiting for confirmation The alarm situation no longer applies, an acknowledgment has not been performed.
• 4 - Active, Acknowledged The alarm situation still applies, the alarm has been acknowledged.
Status transitions:
• 5 - Activate An alarm situation is detected (“alarm coming”).
• 6 - Deactivate The alarm situation no longer applies (“alarm going”).
• 7 - Confirm Acknowledgment of an alarm that no longer applies.
• 8 - ACK Acknowledgment of an alarm that still applies.
NOTE: The status transition Confirm and ACK can be also managed by the
Acknowledge selected and Acknowledge all visible buttons of the Alarm
Table element in the visualization. However, with the ACK status transition the
alarm is still active.
For details, refer to:
• CODESYS Online Help: Visualization Element “Alarm Table” - Element
property “Control variables”
• CODESYS Online Help: Visualizing Alarm Management
Element Description
Action Click the Action column and select one of the following actions:
• Variable: A value is assigned to a variable.
• Execute: A program is executed.
• Call: A function block instance is called.
Activate If selected, the action is executed with the status transition.
Deactivate The available status transitions depend on the Acknowledgment method that has been selected.
Confirm
Details
414 EIO0000002854.04
Alarm Configuration
Element Description
Details Displays a summary of the action. Define the action in the section below the table (the Details section of the
selected Variable, Execute or Call) or edit the action directly in this row.
Action Elements
Variable Contains the variable to which you assign a value or an expression on the left-hand side and the assigned
variable or expression on the right-hand side.
The structure must consist of scalar components or components of the type POINTER TO. User-defined data
types or ARRAY data types are unsupported.
NOTE: You can mark structure members as mandatory parameters by using the attribute {attribute
'AlarmManagerMandatoryParameter'}.
Elements of the Alarm Class Editor — Display Options for Alarm Table /
Alarm Banner Section
Defines how the individual alarm state is displayed in the alarm visualization
element Alarm Table or Alarm Banner.
Element Description
State The available alarm states depend on the Acknowledgment method that has been selected.
Font Click the browse ... button to open the default dialog box for selecting the text font and color.
Background Color Select the background color for the alarm message from the list.
If no image file is assigned to this ID yet, the default file open dialog box is displayed. After you have selected a
file, the bitmap is added to the GlobalImagePool.
Transparent color This parameter only applies if the option Transparent is selected: Select the color that shall be displayed
transparently.
EIO0000002854.04 415
Alarm Configuration
Alarm Group
Overview
Use alarm groups for organizing individual alarms in the alarm management of an
application. Assign each alarm to only one alarm group. To configure an alarm
group, insert an Alarm Group object below an Alarm Configuration object in the
Tools tree. The alarm group editor allows you to define settings for an entire
group of alarms (such as the archiving type, a shared deactivation variable, and a
shared text list). You can create a hierarchical structure of alarm groups in the
Tools tree by using folder elements.
The alarm group editor provides a table listing the alarms of the group and the
properties of each alarm. You can edit the values in the list. An export and import
function to and from a CSV file is also available, page 418.
For further information, refer to Configuration of the Alarm Management, page
409.
Text list Name of the text list where the alarm message text is saved (also refer to the parameter Message in the next
paragraph). It is created automatically when an alarm group is added. The text list can be used for the
localization of the messages. You can also select another text list from the list.
Archiving If you select an alarm storage object from this list, alarm storage is automatically activated.
Deactivation Enter or select a Boolean variable that deactivates all alarms in this group. When this variable is applied, the
alarms will no longer be triggered even if the alarm condition is fulfilled. Alarms that are already active are not
affected.
Column Description
ID This unique ID corresponds to the ID in the associated text list. You can change the ID in the ID field of the
table. The ID must always be unique within the alarm group. A change of the ID in the alarm table directly
changes the ID in the text list and vice versa.
Observation Type Select an observation type from the list. Depending on the type, different editing fields are available below the
table that define the condition for the alarm. The fields define an expression that triggers the alarm. Refer to the
table describing the observation types, page 417.
Details Displays the configuration settings for the selected alarm type. Define the settings in the section below the table
for the selected Observation Type: Digital, Upper limit, Lower limit, Outside range, Inside the range,
Change or Event or edit the action directly in this Details field. If you enter an expression that does not match
the selected Observation Type, the expression is automatically adapted.
416 EIO0000002854.04
Alarm Configuration
Column Description
Latch Var 1 The latch variables are used to record additional values when the alarm becomes active. A latch variable must
be a scalar type (8-byte) or a STRING or WSTRING type. A latch variable or a latch expression is recorded
Latch Var 2 when the alarm becomes active. This allows you to provide additional information about the alarm.
NOTE: The Alarm table or Alarm banner elements allow you to filter the alarms in the visualization by the
contents of the latch variable. See how to include latch variables in the alarm Message in the list of
supported placeholders, page 418.
Example: When monitoring a motor speed, the temperature and the current are additionally recorded.
By default, columns are available for two latch variables. You can add more columns from the contextual menu
which is available in the Data type property for column configuration of the Alarm table and Alarm banner
visualization elements if configured via the Tools > Customize dialog box.
Higher Prio. Alarm When the alarm is triggered, it can be acknowledged by triggering another alarm.
Example: When monitoring a temperature, an alarm of class Warning should be triggered at a temperature >
60 °C and an alarm of type Error at a temperature > 90 °C.
If the temperature rises, the alarm of class Warning is displayed starting at 60 °C. At 90 °C and higher, the
alarm of type Error is triggered which automatically acknowledges the 60 °C alarm.
Digital Enter the Expression to be monitored on the left-hand side and the expression for the comparison on the right-
hand side. In the middle, select the comparison operator = or <>.
Upper limit(1) Enter the (left and right) Expression as described for the Digital type and select the comparison operator > or
>=.
Lower limit(1) Enter the (left and right) Expression as described for the Digital type and select the comparison operator < or
<=.
Area: The alarm is triggered when the monitored expression is outside the range defined here. The left field
defines an expression for the lower limit of this range. The right field defines an expression for the upper limit.
The expression to be monitored is displayed in the field in the middle. Set the comparison operators < or
<=accordingly.
Area: The alarm is triggered when the monitored expression is within the range defined here. The left field
defines an expression for the lower limit of this range. The right field defines an expression for the upper limit.
The expression to be monitored is displayed in the field in the middle. Set the comparison operators < or
<=accordingly.
Change Enter the Expression to be monitored. An alarm is triggered when the value changes.
Event The Event alarm is triggered via a function block call from the library AlarmManager.library. For further
information, refer to Calling Event Alarms in the Program, page 411.
(1) For these Observation Types, you can monitor the specified expression as absolute or relative. Absolute means that the limit value is
defined by a fixed value or a variable that returns a fixed value. Relative means that the limit value depends on an expression.
Hysteresis in %: When you specify a hysteresis, the alarm condition is fulfilled until a certain deviation from the specified limit value is
reached. The size of the deviation is specified as a percentage [%] of the limit value.
Example: Upper limit: i_temp >= 30 Hysteresis: 10% The alarm is active when the variable i_temp reaches or exceeds the value 30.
The alarm becomes inactive when the value falls below 27.
EIO0000002854.04 417
Alarm Configuration
Placeholder Description
<EXPRESSION> Expression (defined within the alarm) that triggered the alarm.
<LATCH2>(1) Value of the second latch variable at the time when the alarm was triggered.
<STATE> Alarm status: 0 = Normal, 1 = Active, 2 = WaitingForConfirmation, 3 = ActiveAcknowledged (still active and
already acknowledged)
(1) For <TRIGGERVALUE>, <CURRENTVALUE> and <LATCHn> you can also use formatting specifications, such as those that are valid for
the C function printf (for example: The value is <CURRENTVALUE %d>).
418 EIO0000002854.04
Alarm Configuration
Alarm Storage
Overview
The Alarm Storage object allows you to configure the settings for the database
file where EcoStruxure Machine Expert saves the alarms that are detected. You
can insert the object only once below an Alarm Configuration node.
There is exactly one storage file located in a database. The default directory for
the alarm SQLite files is: /usr/Alarms. You cannot change the name of this file as it
is derived from the application name according to the following convention:
<application name>.alarmstorage.sqlite. The alarm classes and alarm
groups define whether or not the storage file should be used.
For further information, refer to Configuration of the Alarm Management, page
409.
NOTICE
LOSS OF DATA
Backup the alarm storage file before executing the Reset origin command as
this command clears the contents of the file.
Failure to follow these instructions can result in equipment damage.
Subdirectory Optionally, enter a name of a subdirectory on the controller where the storage file can be stored.
Maximum number of When selected, enter a number of recorded entries that are stored. When this number is reached and a new
records entry is queued in the circular buffer, the oldest entry is deleted.
Maximum storage size When selected, enter the maximum size of the storage file and select the corresponding unit (B...MB) from the
list. Internally the size is implicitly converted into an approximate maximum number of entries that can be saved
in the file (circular buffer).
Circular buffer This option is unavailable as it is selected by the No limit option which is not supported.
The records that are stored in the database can be displayed in the Alarm Table
visualization element.
Element Description
Alarms to Export
EIO0000002854.04 419
Alarm Configuration
Element Description
Export alarms of Define a time range for the export of the listed alarms. This refers to the time stamp when the alarm was
timestamp range activated. The From and To parameters indicate the minimum/maximum time stamps that are available in the
(timestamp activate) alarm storage or that were the last time stamps that were used in an export.
When selecting the time range, the smallest unit is one second.
Language Select a language from the list. It provides all languages that are available in text lists for alarm messages in
addition to the default language (default).
Ascending Select the sort order by the time stamp when the alarm was activated.
Descending
File Format
Formatted values and When selected, the time stamps are formatted with the date and time format as defined below. REAL and
timestamps LREAL values are formatted in numerical format.
Raw data of alarm When selected, the time stamps and values are written as unformatted text to the CSV file as they appear in the
storage file alarm storage. Alarms, alarm groups, and alarm classes are written to the CSV file as internal IDs.
Formatting Options
Defines the formatting of the entries in the CSV file. The variables are only available if the option Formatted values and timestamps is
selected.
REAL format (printf Default value: %.1f
syntax)
Use possible formats according to the printf syntax for floating point values.
Date format When selected, the settings from the control panel (regional settings) are applied.
Time format When selected, the settings from the control panel (regional settings) are applied.
Separator Character
Semicolon When selected, the entries in the CSV file are separated by a semicolon.
Comma When selected, the entries in the CSV file are separated by a comma.
TAB When selected, the entries in the CSV file are separated by a tab character.
Local time This option is only available if the option Formatted values and timestamps is selected.
When selected, the time stamps are written to the CSV file using local time.
When not selected, the time stamps are written to the CSV file using universal time coordinated (UTC).
420 EIO0000002854.04
Unit Conversion
Unit Conversion
What’s in This Chapter
Unit Conversion Configuration...................................................................... 421
Usage in IEC Editors ................................................................................... 423
You can define various conversions for your project. Enter a Name and choose
the Type for each. The respective conversion formula is automatically displayed in
the Setting column. Enter a Condition to determine when the conversion should
be executed. Depending on the selected Type, define specific parameters in the
area below the table.
The editor provides the following conversion types:
• Calculation with an offset: Single shifting (offset), page 422
• Calculation with a factor: Single scaling (factor), page 422
• Calculation with a factor and an offset: Linear scaling 1 (factor and offset),
page 422
• Calculation with the base range and target range: Linear scaling 2 (base
and target range), page 423
EIO0000002854.04 421
Unit Conversion
Conditions
You can select 3 conditions to define when the calculation is executed:
Condition Description
Parameter Description
Parameter Description
Parameter Description
422 EIO0000002854.04
Unit Conversion
Parameter Description
Example
Base start value: 0
Base end value: 1024
Target start value: 4.0
Target end value: 20.0
User-Defined Conversion
Use this conversion if you want to calculate the input value by a user-defined
expression. Use the variable rValue as input value. In this expression, all IEC
operands can be used.
Parameter Description
Switchable Conversion
Use this conversion if you want to use different conversions, depending on the
language or a variable value. All defined conversions can be used.
Method Description
Example in ST
In this example, Conv_4_20 is the name of the conversion.
EIO0000002854.04 423
Unit Conversion
VAR
rValue : REAL;
rConvertedValue : REAL;
END_VAR
rConvertedValue := Conv_4_20.convert(rValue);
Reverse calculation back to the input value.
rValue := Conv_4_20.reverse(rConvertedValue);
Example in CFC
In the CFC editor, enter the instance name of the conversion above the element.
In the element, the method is defined.
Example in CFC method Convert:
424 EIO0000002854.04
Symbol Configuration Editor
View button The View button allows you to set the following filters to reduce the number
of displayed variables:
Unconfigured from Also variables from libraries, not yet added to the
Libraries symbol configuration, but available for this purpose
in the project, are displayed.
Build button The Build button allows you to build the project. The build run refreshes the
variables view in the configuration editor.
Settings button The Settings button allows you to activate the following options:
Include node flags This has the effect that the flags that contain the
in XML namespace are also exported to the symbol file.
They provide additional information on the origin of
the node in the namespace when OPC UA is active.
EIO0000002854.04 425
Symbol Configuration Editor
Element Description
426 EIO0000002854.04
Symbol Configuration Editor
Element Description
Tools button Save XML Scheme Opens the dialog box for saving a file in the file
File... system. Allows you to create an XSD (XML Schema
Definition) format of the symbol file, for use in
external programs.
Column Description
Symbols The column shows a list of POUs. You can select variables to be
exported. If you select variables of a structured data type, all members
of the structure will be exported.
You may also select only particular member variables in the dialog box
Symbol Configuration for Data Type. Click the browse ... button in
the Members column to open this dialog box. For further information,
refer to the description of the Members column.
Access Rights To modify the access rights for a selected item, click the Access
Rights column.
• : write-only
• : read-only
• none
Maximal Shows the maximum access rights.
Members Click the ... button in the Members column to open the Symbol
Configuration for Data Type dialog box. It allows you to select only
particular member variables. In case of nested types, this dialog box
again provides a button to open another Symbol Configuration for
Data Type dialog box.
This selection applies to all instances of this data type for which
symbols are exported. If not all members of a structured type are
exported, then an asterisk (*) is displayed in the check boxes of the
members to indicate that all exportable members of that type are
exported.
Comment Shows any comments which have been added in the declaration of the
variable.
EIO0000002854.04 427
Symbol Configuration Editor
NOTE: With the POU property Link Always, an uncompiled POU can be
forced to be downloaded to the controller. If this property is set in the Build tab
of the Properties dialog box of the selected POU, then all variables declared
in this POU are available, even if those variables are not referenced by other
code. Alternatively, you can use the pragma {attribute linkalways}, page 511 to
make not compiled variables available in the symbol configuration.
Variables which are configured to be exported but which are not valid in the
application, for example because their declaration has been removed, are shown
in red. This also applies to the concerned POU or library name.
By default, a symbol file is created with a code generation run. This file is
transferred to the device with the next download. If you want to create the file
without performing a download, use the command Generate code, by default
available in the Build menu.
NOTE: Variables of a global variable list (GVL) will only be available in the
symbol configuration if at least one of them is used in the programming code.
Element Description
Opens the Add a New Symbol Set dialog box for specifying a
name for this set.
Opens the Rename the Selected New Symbol Set dialog box
for specifying another name for the set selected in the list.
Opens a dialog box prompting whether the set selected in the list
should be deleted.
Configure Symbol Rights Opens the Symbol Rights view of the device editor, page 121.
Element Description
428 EIO0000002854.04
Symbol Configuration Editor
Element Description
These parameters are only available if one of the Include comments options is activated.
These parameters are only available if one of the Include attributes options is activated.
Include all attributes (“foo”, “bar”, “foo.bar”) Select the options to determine the attributes
that are saved in the symbol configuration.
Match simple identifiers (“foo”, “bar”)
EIO0000002854.04 429
Symbol Configuration Editor
If you intend to use the Configure synchronisation with IEC tasks... option,
consider the following points when you define the variable lists that are read and
written:
• Configure synchronous and consistent access only for those variables for
which it is necessary.
• Create separate lists for consistent variables and for variables that may be
inconsistent.
• Create several small lists containing consistent variables instead of one large
list.
• Define the time intervals for cyclically reading values as large as possible.
The option Configure synchronisation with IEC tasks... is available at two
different locations in EcoStruxure Machine Expert:
• In the Symbol configuration editor, as an option of the Settings button. (If a
symbol configuration is available in the application.)
• In the Options tab of the Properties dialog box of the selected controller.
NOTE: In order for the setting to take effect, perform a Download or Online
Change of the applications on the controller and update the boot applications.
Symbol Configuration
Overview
The symbol configuration is used to create symbols, provided with specific access
rights. They allow project variables to be accessed externally, for example by
Vijeo-Designer, EcoStruxure Operator Terminal Expert, or OPC server. The
description of the symbols will be available in an XML file (symbol file) in the
project directory. It will be downloaded to the controller together with the
application.
Symbol Information
The symbols defined for an application are exported to an XML file in the project
directory (symbol file) when the application is downloaded to the controller. This
file is named according to the following syntax:
<project name>.<device name>.<application name>.xml
Example: proj_xy.PLC1.application.xml
Symbols for input addresses and variables that are mapped to input channels
allow read-only access. Write access is only allowed for testing purposes in
simulation mode.
NOTE: In case a download to the controller is not possible, you can create the
symbol configuration file by executing the command Generate code.
Further on the symbol information is downloaded to the controller with the
application. Depending on the device description, it will be included in the
application or a separate child application will be generated. This will also be listed
with the name <application name>._symbols in the Applications view of the device
editor, page 103.
If the symbol configuration has been modified in online mode, you can reload it to
the controller by clicking the button Download in the editor window, page 427.
For example, concerning the maximum number of applications on a controller, the
symbol application has to be handled as a normal application.
If your controller has user management active, you can grant individual access
rights to a symbol for different user groups (clients). To achieve this, place the
430 EIO0000002854.04
Symbol Configuration Editor
same symbol in different symbol sets and allow or deny access to this symbol set
for the individual user groups (clients).
EIO0000002854.04 431
Symbol Configuration Editor
Step Action
1 Select the Application node in the Tools tree, click the green plus button, and select
the command Add other objects > Symbol configuration....
2 In the Add Symbol configuration dialog box, optionally configure settings like
whether to include comments or not. The settings can be modified later in the Symbol
configuration editor, page 425.
Result: A Symbol configuration node is created under the Application node in the
Tools tree. The Symbol configuration is displayed on the right-hand side.
NOTE: Only one symbol configuration node can be created per device.
For details on the variables interchange between the controller and HMI part, refer
to the chapter EcoStruxure Machine Expert Controller-HMI Data Exchange, page
434.
4 In the toolbar of the Add a New Symbol Set Result: The symbols available in
the project are displayed.
dialog box, click the button.
6 Click the Configure Symbol Rights button. Result: The Symbol Rights view of
the device editor, page 121 opens.
432 EIO0000002854.04
Symbol Configuration Editor
9 Select the Users and Groups view of the device Result: The Device User Login
editor, page 111, click the Synchronization dialog box opens.
10 Log in. If you log in for the first time, execute the Result: After successful login, the
steps as described in the Users and Groups configuration of the device user
chapter, page 115. management is displayed in the
Users and Groups and Access
Rights views, page 117.
◦ : access is granted
EIO0000002854.04 433
EcoStruxure Machine Expert Controller - HMI Data Exchange
Overview
NOTE: EcoStruxure Operator Terminal Expert can exchange data by using
system projects. For further information, refer to the document How To
Exchange Data Between Tools (see How To Exchange Data Between Tools,
User Guide).
Step Action
2 Select the entry Vijeo-Designer from the list on the left-hand side.
434 EIO0000002854.04
EcoStruxure Machine Expert Controller - HMI Data Exchange
Step Action
3
On the right-hand side, enable the check box Disable automatic symbol export.
NOTE: Activating the Disable automatic symbol export function inhibits the
automatic export of EcoStruxure Machine Expert variables defined as
Symbols to Vijeo-Designer. In order to perform this transfer manually, right-
click the Symbol configuration node in the Devices window and execute the
Export Symbols to Vijeo-Designer command. If you do not perform this
manual transfer, Vijeo-Designer may not show the correct symbols which, in
turn, may lead to errors being detected in the project.
WARNING
UNINTENDED EQUIPMENT OPERATION
Execute the Export Symbols to Vijeo-Designer command if you have activated
the Disable automatic symbol export before you start working in Vijeo-Designer.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Variable type EcoStruxure Variable type Vijeo- Variable type EcoStruxure Comment
Machine Expert Designer Operator Terminal Expert
EIO0000002854.04 435
EcoStruxure Machine Expert Controller - HMI Data Exchange
Variable type EcoStruxure Variable type Vijeo- Variable type EcoStruxure Comment
Machine Expert Designer Operator Terminal Expert
LINT – LINT –
ULINT – ULINT –
LREAL – LREAL –
Non-zero based array – Non-zero based array In Vijeo-Designer, you cannot import
an array that is defined, example:
myArray[1..100]..
TIME – TIME –
DATE – DATE –
TOD – TOD –
436 EIO0000002854.04
EcoStruxure Machine Expert Controller - HMI Data Exchange
Variable type EcoStruxure Variable type Vijeo- Variable type EcoStruxure Comment
Machine Expert Designer Operator Terminal Expert
DT – DT –
REFERENCE TO <Type> <Type> (<Type> being one of <Type> (<Type> being one of Do not share references to ARRAYs or
the supported types in this the supported types in this structured variables containing an
list)] list)] ARRAY in the symbol configuration
editor, as their values will not be
displayed correctly on the HMI.
NOTE: The variables from the PLC_R structures of the PLCSystem library
cannot be shared via the Symbol Configuration with the Vijeo-Designer and
EcoStruxure Operator Terminal Expert application of HMI targets (including
HMI controllers).
For further information on variable types for EcoStruxure Machine Expert - HMI
data exchange, see the Vijeo-Designer and EcoStruxure Operator Terminal
Expert online help.
Identifier Length
In Vijeo-Designer, the maximum length of the Symbol name is limited to 32
characters.
Variable names longer than 32 characters produce an error message and are not
imported.
Step Action
1 Create a Symbol Configuration node under the Application node in the Tools tree as described in the Adding a Symbol
Configuration chapter, page 431.
2 Double-click the Symbol Configuration node to open the Symbol configuration editor.
EIO0000002854.04 437
EcoStruxure Machine Expert Controller - HMI Data Exchange
Step Action
3
In the Symbol configuration editor, select those elementary variables that you wish to publish for communication with 1 or
several HMI terminals by selecting or deselecting the check box in the Symbols column:
You can also assign read/write access rights to each variable individually in the Access Rights column. For further
information, refer to the description of the Symbol configuration editor, page 425.
For using symbol sets, refer to Creating Symbol Sets Allowing Different Access Rights for Different Control Clients, page
432.
Note: Only variables on elementary data types are available for interchange with HMI terminals.
4 For your settings to become valid, click the Download link in the Symbol configuration editor.
438 EIO0000002854.04
EcoStruxure Machine Expert Controller - HMI Data Exchange
• DINT
• INT
• UINT
• UDINT
• Integer
• REAL
• STRING
Procedure
To publish the above mentioned variable types, proceed as follows:
Step Action
1 In the Vijeo-Designer Variable Editor, select those variables you want to publish.
2
Right-click the selected variable(s) and execute the command Move to SoMachine from the contextual menu.
EIO0000002854.04 439
EcoStruxure Machine Expert Controller - HMI Data Exchange
Step Action
3 In the Move to SoMachine dialog box open the subfolders of the devices defined in EcoStruxure Machine Expert to see the
levels where variables are defined (POU or GVL).
4
Select the POU or GVL to which you want to add the selected Vijeo-Designer variable(s) and click OK.
Result: The selected variable(s) has / have been moved to the selected EcoStruxure Machine Expert POU or GVL and is /
are available throughout the EcoStruxure Machine Expert project.
Parameter Value
Physical Medium RS485
440 EIO0000002854.04
EcoStruxure Machine Expert Controller - HMI Data Exchange
Parameter Value
Parity none
Data bits 8
Stop bits 1
Parameter Value
Physical Medium RS485
Data bits 8
Stop bits 1
Configuration of XBTGC:
Device Configuration
EIO0000002854.04 441
EcoStruxure Machine Expert Controller - HMI Data Exchange
• Reduce the number of variables per HMI panel because only the variables on
the active panel are refreshed. It is a good practice to create several HMI
panels with reduced number of variables in Vijeo-Designer instead of creating
one HMI panel that shows many variables.
• Add only those variables to the Symbol configuration that are used in the
HMI.
1 Time in seconds
2 Number of variables
3 XBTGT2330 + M••• controller
4 XBTGT4330 + M••• controller
442 EIO0000002854.04
EcoStruxure Machine Expert Controller - HMI Data Exchange
Chapter Errors → Message List → Editor Error Messages→ 1300 - 1999→ Error
1301:
Error 1301: [Target] [target name] too many variables. Variable limit is [8000 or
12000].
NOTE: The Vijeo-Designer online help indicates that the total number of
elements in an array must not exceed 2048 (refer to the chapter Creating
Variables → Array Variables). This limits the size of (single or
multidimensional) array variables that are shared via the EcoStruxure
Machine Expert Symbol Configuration. To overcome this limit, consider
sharing an array of DUT (for example, ARRAY[0..99] OF DUT_30, where
DUT_30 is a user-defined type containing 30 distinct INT variables, resulting
in 3000 variables). In any case, the Error 1301 will be issued if the maximum
number of variables per target (8000 or 12000) is exceeded.
EIO0000002854.04 443
Cam Motion Editor
You double-click the The Motion Editor tab opens in the multi-tabbed editor view and
Segment node highlights the selected segment with a green background in the
diagram.
444 EIO0000002854.04
Cam Motion Editor
ST_Multicam PacDriveLib
EIO0000002854.04 445
Cam Motion Editor
MyMultiCam.MultiCamData.astCamPoint[1].lrLambda := 0.5;
MyMultiCam.MultiCamData.astCamPoint[1].lrC := 1;
MyMultiCam.MultiCamData.astCamPoint[1].etCamType := ET_
CAMTYPE.SimplSin;
In this example, MyMultiCam.MultiCamData is configured as target data
structure.
The generated data is based on cam diagrams that were edited in offline mode.
They are not updated in online mode.
446 EIO0000002854.04
Cam Motion Editor
As long as the online mode is enabled and a cam data structure is defined as
target, the values and graphs displayed in the Motion Editor tab represent the
online values of the selected target structure.
You can select a segment, but you cannot modify anything:
• You cannot modify the segment data.
• You cannot specify a variable as target.
• You cannot modify the axis-diagram allocation.
NOTE: Some, especially user-defined, profiles are not supported by the editor.
This is indicated by segments being grayed and position, velocity,
acceleration, jerk lines not being displayed.
Online Change
The cam motion editor supports the Online change function, page 207.
After a cam data structure has been downloaded to the controller, the individual
segments will be editable as soon as you have switched to offline mode.
When switching back to online mode, the modifications are detected and you will
be prompted to decide whether you want to log in and perform the online change,
page 205. If you confirm this message with OK, the cam data structure will be
updated.
For the modifications to become effective, the FB_MultiCam / MC_Cam_ID
function blocks must be switched to the adequate mode to take into account the
modified cam data structure.
You can achieve this by setting the input parameter (for example, iq_xNewCam...)
via the Debug > Force values command. For further information, refer to the
description of FB_MultiCam in the PD_PacDriveLib or FB_MultiCam / MC_Cam_
ID in the CommonMotionType library guide.
EIO0000002854.04 447
Cam Motion Editor
Dialog Boxes
Motion Editor
Motion Editor Tab
The graphic displays the Motion Editor tab.
Start condition The condition that applies at the start point of • Dwell
the selected cam segment. • Velocity
• Return
• Motion
End condition The condition that applies at the end point of the • Dwell
selected cam segment. • Velocity
• Return
• Motion
448 EIO0000002854.04
Cam Motion Editor
Motionprofile The motion law describes the profile of the • Straight line
segment. The available motion profile depends • Quadratic parabola
on the Start condition and End condition
selected. Refer to the table Motion Profiles • Polynomial of 5th degree
Available for Combinations of Start and End • Simple sinus
Conditions, page 451.
• Modified sinus
• Modified acceleration trapezoid
• General polynomial of the 5th degree
• Sinus-straight line combination
• The user-defined motion profiles
Spline interpolation mode This parameter is only available for user-defined • Natural spline
motion profiles. It defines how the edge • Spline on base of the slope of the
condition at the start point and end point of the borders
profile is resolved.
• Periodic spline
Input parameters Select from the list the parameters which you The values listed in the table depend on the
will configure. Result: The corresponding text Motionprofile you selected. Refer to the
fields will become editable. The remaining following tables that list the parameters that are
parameter will be calculated by EcoStruxure available per motion law.
Machine Expert.
Slope The slope of the position curve at the start point Decimal number
of the selected cam segment. This is the value
of s’. Unit: Position / φ
Curvature The curvature of the position curve at the start Decimal number
point of the selected cam segment. This is the
value of s’’. Unit: Position / φ2
Slope The slope of the position curve at the end point Decimal number
of the selected cam segment. This is the value
of s’. Unit: Position / φ
Curvature The curvature of the position curve at the end Decimal number
point of the selected cam segment. This is the
value of s’’. Unit: Position / φ2
EIO0000002854.04 449
Cam Motion Editor
450 EIO0000002854.04
Cam Motion Editor
Designation Description
Examples:
Dwell Straight line Quadratic parabola General polynomial of the General polynomial of the
5th degree 5th degree
(v=0, a=0) Quadratic parabola Polynomial of 5th degree
Velocity Quadratic parabola Straight line General polynomial of the General polynomial of the
5th degree 5th degree
(v<>0, a=0) Polynomial of 5th degree General polynomial of the
5th degree
Simple sinus
Modified sinus
Modified acceleration
trapezoid
(Lambda = 0)
EIO0000002854.04 451
Cam Motion Editor
Return General polynomial of the 5th degree Sinus straight combination General polynomial of the
5th degree
(v=0, a<>0) General polynomial of the
5th degree
(v<>0, a<>0)
452 EIO0000002854.04
Cam Motion Editor
* Use the Input parameters list to select two out of six parameters as
editable. The remaining four parameters are calculated by EcoStruxure
Machine Expert.
EIO0000002854.04 453
Cam Motion Editor
The table lists the parameters that are available for the motion law General
polynomial of the 5th degree and the values they can have in accordance with
the selected Start condition=Motion together with several End condition
values:
Slope start User input User input User input User input
Curvature start User input User input User input User input
The table lists the parameters that are available for the motion law General
polynomial of the 5th degree and the values they can have in accordance with
the selected Start condition=Return together with several End condition
values:
Curvature start User input User input User input User input
The table lists the parameters that are available for the motion law General
polynomial of the 5th degree and the values they can have in accordance with
the selected Start condition=Velocity together with several End condition
values:
454 EIO0000002854.04
Cam Motion Editor
Slope start User input User input User input User input
Configuration
Configuration Tab
The Configuration tab allows you to select a target structure for its generation
and to define the properties.
The Configuration tab allows you to do the following:
• Select a target structure for source code generation.
• Define properties for this structure.
EIO0000002854.04 455
Cam Motion Editor
Element Description
Target technology The Target technology section allows you to select a target structure
(cam data structure) for source code generation.
Select a structure or click the browse button (...) to open the Input
Assistant dialog box.
After a target structure has been defined, cam data is written into this
target structure whenever the application program is started.
From the target defined, it is detected whether the data structures are
CommonMotionType or PacDriveLib structures and configuration is
performed accordingly.
456 EIO0000002854.04
Script Hook Manager
1 Right-click the Global node of the Applications tree and Result: The Add Script Hook Manager dialog box
execute the command Add Object > Script Hook Manager. opens.
2 Select the suitable option for creating a Python script. • Select the New Script option to create a new
Python script from scratch in Logic Builder.
• Select the From Template option and select a
Python template that is delivered with EcoStruxure
Machine Expert as a basis for creating your Python
script. The use cases that are covered by the
different templates are described by the comments
in the scripts themselves.
• Select the From Existing Script option to open a
Python script file that you programmed in another
tool. Click the Select button to open a File open
dialog box to browse for the .py file.
EIO0000002854.04 457
Script Hook Manager
The Declaration Syntax section provides the signature of the method that is
called by the system after the event or command has been executed by
EcoStruxure Machine Expert. Click the Copy Code button to insert the code into
your Python code in the Python Script editor and extend this method by the
Python commands you want to execute.
The Rename Function button allows you to modify the name of the Python
function in a separate dialog box. After you have saved a different name, make
sure that you use the exact string of the modified name in your Python code.
The Parameters section lists the parameters that are available inside the Python
method when it is executed.
458 EIO0000002854.04
Script Hook Manager
def after_device_logout():
print("after_device_logout")
session_store.set("loginHandled", False)
pass
EIO0000002854.04 459
Programming Reference
What’s in This Part
Variables Declaration.................................................................................... 461
Data Types .................................................................................................. 529
Programming Guidelines .............................................................................. 555
Operators .................................................................................................... 562
Operands .................................................................................................... 628
460 EIO0000002854.04
Variables Declaration
Variables Declaration
What’s in This Chapter
Declaration ................................................................................................. 461
Variable Types ............................................................................................ 475
Method Types ............................................................................................. 483
Pragma Instructions .................................................................................... 487
Attribute Pragmas ....................................................................................... 495
The Smart Coding Functionality.................................................................... 527
Declaration
General Information
Overview
You can declare variables:
• in the Declaration Editor of a POU, page 319
• via the Auto Declare dialog box, page 470
• in a GVL editor
• in the PersistentVars editor, page 186
The kind (in the tabular declaration editor it is named Scope) of the variables to be
declared is specified by the keywords embracing the declaration of one or several
variables. In the textual declaration editor, page 319, the common variable
declaration is embraced by VAR and END_VAR.
For further variable declaration scopes, refer to:
• VAR_INPUT
• VAR_OUTPUT
• VAR_IN_OUT
• VAR_GLOBAL
• VAR_TEMP
• VAR_STAT
• VAR_INST
• VAR_EXTERNAL
• VAR_CONFIG
The variable type keywords may be supplemented by attribute keywords, page
479.
Example: RETAIN (VAR_INPUT RETAIN)
Syntax
Syntax for variable declaration:
<Identifier> {AT <address>}:<data type> {:=<initialization>};
The parts in braces {} are optional.
Identifier
The identifier is the name of a variable.
EIO0000002854.04 461
Variables Declaration
462 EIO0000002854.04
Variables Declaration
AT <address>
You can link the variable directly to a definite address, page 471 using the
keyword AT.
In function blocks, you can also specify variables with incomplete address
statements. In order that such a variable can be used in a local instance, an entry
has to exist for it in the variable configuration.
Type
Valid data type, page 529, optionally extended by an :=< initialization>, page 469.
Pragma Instructions
Optionally, you can add pragma instructions, page 487 in the declaration part of
an object in order to affect the code generation for various purposes.
Hints
Automatic declaration, page 470 of variables is also possible.
For faster input of the declarations, use the shortcut mode, page 471.
Variable Names
For naming variables in applications and libraries, follow the Hungarian notation
as far as possible.
Find for each variable a meaningful, short description. This is used as the base
name. Use a capital letter for each word of the base name. Use small letters for
the rest (example: FileSize).
EIO0000002854.04 463
Variables Declaration
464 EIO0000002854.04
Variables Declaration
POINTER – – – p –
ARRAY – – – a –
Structure – – – st –
Function block – – – fb –
Interface – – – if (itf) –
Union – – – ut –
* intentionally for boolean variables x is chosen as a prefix in order to differentiate from BYTE and also in order to accommodate the
perception of an IEC programmer (see addressing %IX0.0).
Simple declaration
Examples for simple declarations:
bySubIndex: BYTE;
sFileName: STRING;
udiCounter: UDINT;
Nested declaration
Example for a nested declaration where the prefixes are attached to each other in
the order of the declarations:
pabyTelegramData: POINTER TO ARRAY [0..7] OF BYTE;
Function block instances and variables of user-defined data types
Function block instances and variables of user-defined data types get a shortcut
for the function block or the data type name as a prefix (for example: stSDO).
Example
stSDOReceivedTelegram: ST_SDOTelegram;
TYPE ST_SDOTelegram :
STRUCT
wIndex:WORD;
bySubIndex:BYTE;
byLen:BYTE;
aby: ARRAY [0..3] OF BYTE;
END_STRUCT
END_TYPE
Local constants
Local constants (c) start with prefix c and an attached underscore, followed by the
type prefix and the variable name.
Example
VAR CONSTANT
c_uiSyncID: UINT := 16#80;
END_VAR
Global variables and global constants
Global variables are prefixed by G_ (g_) and global constants are prefixed by Gc_
(gc_).
Example
VAR_GLOBAL
G_iTest: INT;
END_VAR
VAR_GLOBAL CONSTANT
Gc_dwExample: DWORD;
END_VAR
EIO0000002854.04 465
Variables Declaration
466 EIO0000002854.04
Variables Declaration
POUs in Libraries
Structure
For creating method names, the same rules apply as for actions. Enter comments
for possible inputs of a method. Add a short description of a method to its
declaration. Start interface names with prefix IF_ (I); for example, IF_
CANDevice.
NOTE: Consider the usage of the namespace when using POUs declared in
libraries.
Shadowing Rules
Overview
In general, there are no restrictions in EcoStruxure Machine Expert that prevent
you from using the same identifier for different elements. You can, for example,
assign the same name to a local function block instance and to a function.
In the following “bad practice” example, it is unclear whether the instance or the
function is called in the program:
FUNCTION YYY : INT
;
END_FUNCTION
FUNCTION_BLOCK XXX
;
END_FUNCTION_BLOCK
PROGRAM PLC_PRG
VAR
YYY : XXX;
END_VAR
YYY();
END_PROGRAM
To help prevent creating ambiguous code, make frequent use of the following
good practices:
• Follow naming conventions, for example, by using certain prefixes for
variables. For further information, refer to the Best Practices for the Naming of
Identifiers, page 463.
• Use the Machine Code Analysis component provided with EcoStruxure
Machine Expert for verifying the naming of variables.
• Make consistent use of the qualified_only attribute, page 524 for
enumerations and global variable lists.
• Use the library namespace prefix, page 560 to access elements of the library.
EIO0000002854.04 467
Variables Declaration
Stage Description
5 Global variables in a parent application if the qualified_only attribute is not set in the
variable list where the global variables are declared.
6 Global variables in referenced libraries when neither the library nor the variable list
requires qualified access.
7 POU or type names from the application (such as names of global variable lists,
function blocks).
10 Namespaces of locally referenced libraries and libraries that are published by libraries.
11 Global variables in the Applications tree if the qualified_only attribute is not set in the
variable list where they are declared.
12 POU or type names from the Applications tree (such as names of global variable lists,
function blocks).
NOTE: Libraries that are inserted in the Library Manager that is a subnode of
the Global node of the Tools tree are available in all applications in the
project with the placeholder resolution. These libraries then form a common
namespace with the libraries in the application. Therefore, there is no
shadowing of libraries in the pool by libraries in the application.
Stage Description
5 Global variables in referenced libraries when neither the library nor the variable list
requires qualified access.
6 POU or type names from the local library (such as names of global variable lists,
function blocks).
8 Namespaces of locally referenced libraries and libraries that are published by locally
referenced libraries.
468 EIO0000002854.04
Variables Declaration
global variable lists that do not require qualified access. If such a case is detected,
the compiler reports the error: ambiguous use of the name XXX. To help avoid
this, use qualified access, for example by adding the name of the global variable
list (example: GVL.XXX).
Use qualified access to help avoid shadowing:
• Use the name of the global variable list to provide unique access to a variable
in the list.
• Use the name of a library to provide unique access to elements in the library.
• Use the THIS pointer to provide unique access to variables in a function block
even if a local variable with the same name exists in a method of the function
block.
To find the declaration location of an identifier, execute the Edit > Browse > Go to
Definition command (see EcoStruxure Machine Expert, Menu Commands,
Online Help).
In the second instance, the compiler evaluates whether access to the element is
allowed (the variable may only be locally accessible, or a method may be private).
If access is not allowed, an error message is generated.
Variables Initialization
Default Initialization Value
The default initialization value is 0 for all declarations, but you can add user-
defined initialization values in the declaration of each variable and data type.
EIO0000002854.04 469
Variables Declaration
Further Information
For further information, refer to the following descriptions:
• initializing arrays, page 540
• initialization of structures, page 549
• initialization of a variable with a subrange type, page 552
NOTE: Variables of global variables lists (GVL) are initialized before local
variables of a POU.
NOTE: As from SoMachine version 4.0, variables in a function block are
initialized in the following order: First, the constants in accordance with the
order of their declarations, then the other variables in accordance with the
order of their declarations.
For further information regarding initialization order, refer to the Attribute global_
init_slot, page 505.
Declaration
Declaration Types
You can declare variables manually by using the textual or tabular declaration
editor, page 319 or automatically like explained in this chapter.
Automatic Autodeclaration
You can define in the Options dialog box, category Text editor > Editing, that the
Auto Declare dialog box should open as soon as a not yet declared string is
entered in the implementation part of an editor and the ENTER key is pressed.
This dialog box supports the declaration of the variable, page 461.
Manual Autodeclaration
To open the Auto Declare dialog box manually:
• execute the command Auto Declare, which by default is available in the Edit
menu or
• press the keys SHIFT+F2
If you select an already declared variable before opening the Auto Declare dialog
box (see EcoStruxure Machine Expert, Menu Commands, Online Help), you can
edit the declaration of this variable.
470 EIO0000002854.04
Variables Declaration
Shortcut Mode
Overview
The declaration editor, page 319 and the other text editors where declarations are
performed support the shortcut mode.
Activate this mode by pressing CTRL+ENTER when you end a line of declaration.
It allows you to use shortcuts instead of completely typing the declaration.
Supported Shortcuts
The following shortcuts are supported:
• All identifiers up to the last identifier of a line will become declaration variable
identifiers.
• The type of declaration is determined by the last identifier of the line.
In this context, the following replacements are performed:
Examples
Example Shortcut Resulting Declaration
No.
1 A A: BOOL;
2 ABI2 A, B: INT := 2;
5 B! B: BOOL;
AT Declaration
Overview
In order to link a project variable with a definite address, you can assign variables
to an address in the I/O Mapping view of a device in the controller configuration
(device editor). Alternatively you can enter this address directly in the declaration
of the variable.
EIO0000002854.04 471
Variables Declaration
Syntax
<variable name> AT <address> : <data type>;
<address> : %<memory area prefix> ( <size prefix> )? <memory
position
A valid address has to follow the keyword AT. For further information, refer to the
Address description, page 637. Consider possible overlaps in case of byte
addressing mode.
This declaration allows assigning a meaningful name to an address. Any changes
concerning an incoming or outgoing signal may only be done in a single place (for
example, in the declaration).
Consider the following when choosing a variable to be assigned to an address:
• Variables requiring an input cannot be accessed by writing. The compiler
intercepts this detecting an error.
• AT declarations only can be used with local or global variables. They cannot
be used with input and output variables of POUs.
• AT declarations are not allowed in persistent variable lists.
• If AT declarations are used with structure or function block members, all
instances will access the same memory location of this structure / function
block. This corresponds to static variables in classic programming languages
such as C.
• The memory layout of structures is determined by the target as well.
Examples
xCounterHeat7 AT %QX0.0: BOOL;
xLightCabinetImpulse AT %IX7.2: BOOL;
xDownload AT %MX2.2: BOOL;
Note
If boolean variables are assigned to a BYTE, WORD or DWORD address, they
occupy 1 byte with TRUE or FALSE, not just the first bit after the offset.
The memory size for input, output, and memory data (declarations with AT %I, %Q
and %M) is predefined by the target device and can be overwritten in the properties
of an application object (see EcoStruxure Machine Expert, Menu Commands,
Online Help) for PacDrive controllers (PacDrive LMC Eco, PacDrive LMC Pro/
Pro2).
Keywords
Overview
Write keywords in uppercase letters in the editors.
The following strings are reserved as keywords. They cannot be used as
identifiers for variables or POUs:
• -
• &
• (
• )
• *
• ,
• .
472 EIO0000002854.04
Variables Declaration
• ..
• /
• :
• :=
• ;
• [
• ]
• ^
• __CATCH
• __CHECKLICENSE
• __CHECKLICENSEBIT
• __DELETE
• __ENDTRY
• __FINALLY
• __ISVALIDREF
• __MEMORYBARRIER
• __NEW
• __QUERYINTERFACE
• __QUERYPOINTER
• __THROW
• __TRY
• __XADO
• Ι
• +
• <
• <=
• <>
• =
• >=
• >
• =>
• ABS
• ACOS
• ADR
• AND
• AND_THEN
• ASIN
• ATAN
• BITADR
• BY
• CASE
• CONTINUE
• COS
• DO
• ELSE
• ELSIF
• END_CASE
EIO0000002854.04 473
Variables Declaration
• END_FOR
• END_IF
• END_REPEAT
• END_WHILE
• EXIT
• EXP
• EXPT
• FALSE
• FOR
• IF
• INI
• LIMIT
• LN
• LOG
• LOWER_BOUND
• MAX
• MIN
• MOD
• MOVE
• MUX
• NOT
• OR
• OR_ELSE
• R=
• REF=
• REPEAT
• RETURN
• ROL
• ROR
• S=
• SEL
• SHL
• SHR
• SIN
• SIZEOF
• SQRT
• SUPER
• TAN
• THEN
• THIS
• TO
• TRUE
• TRUNC
• TRUNC_INT
• UNTIL
• UPPER_BOUND
• WHILE
474 EIO0000002854.04
Variables Declaration
• XOR
Additionally, the conversion operators as listed in the Input Assistant are handled
as keywords.
Variable Types
Variable Types
Overview
This chapter provides further information on the following variable types:
• VAR local variables, page 475
• VAR_INPUT input variables, page 475
• VAR_OUTPUT output variables, page 475
• VAR_IN_OUT input and output variables, page 476
• VAR_IN_OUT CONSTANT transfer variable, page 476
• VAR_GLOBAL global variables, page 477
• VAR_TEMP temporary variables, page 477
• VAR_STAT static variables, page 478
• VAR_EXTERNAL external variables, page 478
• VAR_INST instance variables, page 478
EIO0000002854.04 475
Variables Declaration
Example
VAR_OUTPUT
iOut1:INT; (* 1. Outputvariable*)
END_VAR
Output variables in functions and methods:
According to IEC 61131-3 draft 2, functions (and methods) can have additional
outputs.You can assign them in the call of the function as shown in the following
example.
Example
fun(iIn1 := 1, iIn2 := 2, iOut1 => iLoc1, iOut2 => iLoc2);
476 EIO0000002854.04
Variables Declaration
VAR_IN_OUT
sReadWrite : STRING(16); (* Can be read or written here
in POU *)
dwVarReadWrite : DWORD; (* Can be read or written here
in POU *)
END_VAR
VAR_IN_OUT CONSTANT
c_sReadOnly : STRING(16); (* Constant string variable
can only be read here in POU *)
END_VAR
sReadWrite := 'String_from_POU';
dwVarReadWrite := STRING_TO_DWORD(c_sReadOnly);
PROGRAM PRG_A
VAR
sVarFits : STRING(16);
sValFits : STRING(16) :='1234567890123456';
dwVar: DWORD;
END_VAR
// The following line of code causes the compiler error
C0417:
// C0417: VAR_IN_OUT parameter 'sReadWrite' needs a variable
with write access as input.
funManipulate(sReadWrite:='1234567890123456', c_sReadOnly:
='1234567890123456', dwVarReadWrite := dwVar);
// Correct code
funManipulate(sReadWrite := sValFits, c_sReadOnly := '23',
dwVarReadWrite := dwVar);
funManipulate(sReadWrite := sVarFits, c_sReadOnly :=
sValFits, dwVarReadWrite :=dwVar);
In the code example, strings are passed to the funManipulate function via different
VAR_IN_OUT variables:
• When passing a string literal to a VAR_IN_OUT variable, a compiler error is
issued.
• When passing a constant variable to a VAR_IN_OUT CONSTANT variable,
correct code is generated. This even applies for passing string variables.
EIO0000002854.04 477
Variables Declaration
478 EIO0000002854.04
Variables Declaration
Retain Variables
Variables declared as retain variables are stored in a nonvolatile memory area. To
declare this kind of variable, use the keyword RETAIN in the declaration part of a
POU or in a global variable list.
Example
VAR RETAIN
iRem1 : INT; (* 1. Retain variable*)
END_VAR
Retain variables maintain their value even after an unanticipated shutdown of the
controller as well as after a normal power cycle of the controller (or when
executing the Online command Reset Warm). At restart of the program, the
retained values will be processed further on. The other (non-retain) variables are
newly initialized, either with their initialization values or with their default
initialization values (in case no initialization value was declared).
For example, you may want to use a retained value when an operation, such as
piece counting in a production machine, should continue after a power outage.
Retain variables, however, are reinitialized when executing the Online command
Reset origin and, in contrast to persistent variables, when executing the Online
command Reset cold or in the course of an application download.
EIO0000002854.04 479
Variables Declaration
NOTE: Only the specific variables defined as VAR RETAIN are stored in
nonvolatile memory. However, local variables defined as VAR RETAIN in
functions are NOT stored in nonvolatile memory. Defining VAR RETAIN locally
in functions is of no effect.
Using interfaces or function blocks out of System Configuration libraries in the
retain program section (VAR_RETAIN) will cause system exceptions, which may
make the controller inoperable, requiring a re-start.
WARNING
UNINTENDED EQUIPMENT OPERATION
• Do not use interfaces out of the SystemConfigurationItf library in the retain
program section (VAR_RETAIN).
• Do not use function blocks out of the SystemConfiguration library in the
retain program section (VAR_RETAIN).
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Persistent Variables
Persistent variables are identified by keyword PERSISTENT (VAR_GLOBAL
PERSISTENT). They are only reinitialized when executing the Online command
Reset origin. In contrast to retain variables, they maintain their values after a
download.
NOTE: Do not use the AT declaration in combination with VAR PERSISTENT.
Application example:
A counter for operating hours, which should continue counting even after a power
outage or a download. Refer to the synoptic table on the behavior of remanent
variables, page 481.
You can only declare persistent variables in a special global variable list of object
type persistent variables, which is assigned to an application. You can add only
one such list to an application.
NOTE: A declaration with VAR_GLOBAL PERSISTENT has the same effect as
a declaration with VAR_GLOBAL PERSISTENT RETAIN or VAR_GLOBAL
RETAIN PERSISTENT.
NOTE: Instant paths are added for variables that are marked with the
PERSISTENT keyword outside the persistent list editor. For further
information, refer to the Add all instance paths command (see EcoStruxure
Machine Expert, Menu Commands, Online Help).
Like retain variables, the persistent variables are stored in a separate memory
area.
Example
VAR_GLOBAL PERSISTENT RETAIN
iVarPers1 : DINT; (* 1. Persistent+Retain Variable App1 *)
bVarPers : BOOL; (* 2. Persistent+Retain Variable App1 *)
END_VAR
NOTE: Persistent variables can only be declared inside the Persistent list
object. If they are declared elsewhere, they will behave like retain variables
and they will be reported as a detected Build error in the Messages view.
(Retain variables can be declared in the global variable lists or in POUs.)
480 EIO0000002854.04
Variables Declaration
At each reload of the application, the persistent variable list on the controller will
be checked against that of the project. The list on the controller is identified by the
application. In case of inconsistencies, you will be prompted to reinitialize all
persistent variables (see EcoStruxure Machine Expert, Menu Commands, Online
Help) of the application. Inconsistency can result from renaming or removing or
other modifications of the existing declarations in the list.
NOTE: Carefully consider any modifications in the declaration part of the
persistent variable list and the effect of the results regarding reinitialization.
You can add new declarations only at the end of the list. During a download, these
are detected as new and will not demand a reinitialization of the complete list. If
you modify the name or data type of a variable, this is handled as a new
declaration and provokes a reinitialization of the variable at the next online change
or download.
NOTE: If one variable in a function block is marked with PERSISTENT, then
the function block instance with its variables is stored in remanent memory,
but only the one variable is treated as persistent.
Constants - CONSTANT
Constants are identified by the keyword CONSTANT. You can declare them locally
(programming object unit) or globally (global variable list). Constant variables can
be accessed read-only in the implementation part of a POU.
Syntax
<scope> CONSTANT <identifier>:<type> := <initialization>;
END_VAR
With <scope> : VAR | VAR_INPUT | VAR_STAT | VAR_GLOBAL
Make sure to assign an initialization value when declaring a constant variable.
Example
VAR CONSTANT
c_iCon1:INT:=12; (* 1. Constant*)
END_VAR
Refer to the Operands chapter, page 628 for a list of possible constants.
Typed Literals
Basically, in using IEC constants, the smallest possible data type will be used. If
another data type has to be used, this can be achieved with the help of typed
literals without the necessity of explicitly declaring the constants. For this, the
constant will be provided with a prefix which determines the type.
Syntax
<type>#<literal>;
possible entries: BOOL, SINT, USINT, BYTE, INT, UINT, WORD, DINT,
UDINT, DWORD, REAL, LREAL
Enter data that fits within the data type specified under <type>.
EIO0000002854.04 481
Variables Declaration
Example
iVar1:=DINT#34;
If the constant cannot be converted to the target type without data loss, a
message is issued.
You can use typed literals wherever normal constants can be used.
Identifier Syntax
<identifier> AT %<I|Q>* : <data type>
Example of the use of incompletely defined addresses:
FUNCTION_BLOCK locio
VAR
xLocIn AT %I*: BOOL := TRUE;
xLocOut AT %Q*: BOOL;
END_VAR
In this example, 2 local I/O variables are defined: a local input (%I*) and a local
output variable (%Q*).
Define the addresses in the variable configuration in a global variable list (GVL) as
follows:
Step Action
3 Enter the declarations of the instance variables with the definite addresses between the
keywords VAR_CONFIG and END_VAR.
482 EIO0000002854.04
Variables Declaration
Method Types
FB_Init, FB_Reinit, and FB_Exit Methods
General Purpose of the Methods
You can explicitly use the methods FB_Init and FB_Reinit to influence the
initialization of function block variables as well as the behavior when exiting
function blocks.
This chapter describes the methods, and the applications and effects of the
methods in different conditions that require variable initialization.
FB_Init
By default, the FB_Init method is available implicitly. It is used by EcoStruxure
Machine Expert to initialize a function block or a structure.
In order to influence the initialization, you can explicitly declare the FB_Init
method by extending the given default initialization code. This allows you to
evaluate the return value.
FB_Reinit
The FB_Reinit method must be declared explicitly.
If the FB_Reinit method is available, it is called after the instance of the
corresponding function block has been copied (during an online change, page 484
after modifications in the function block declaration). It reinitializes the new
EIO0000002854.04 483
Variables Declaration
instance module. The return value is not evaluated. In order to achieve that the
base function block is reinitialized, call FB_Reinit explicitly for that function block.
This allows you to evaluate the return value.
FB_Exit
The FB_Exit method must be declared explicitly.
If there is an implementation, then the method is called before the controller
removes the code of the function block instance (implicit call). The return value is
not evaluated.
The following paragraphs provide use cases of these methods for different
operating conditions.
First Download
When you download an application to a controller that is in default state, the
memory locations of the variables are set to the desired initial state. The data
areas of function blocks are set to the desired values. You can influence this
process by explicitly implementing FB_Init for function blocks in the program code
of the application.
The method parameters bInCopyCode set to FALSE and bInitRetains set to TRUE
indicate that a first download is being executed.
Online Change
When an Online Change command (see EcoStruxure Machine Expert, Menu
Commands, Online Help) is executed, the methods FB_Exit, FB_Init, and FB_
Reinit can be used to influence the initialization of function blocks.
During online change, the modifications made to the application in offline mode
are downloaded to the controller. The instances of function blocks are updated by
the new instances as follows:
If you have only made changes in the implementation part of the function block
and not in the declaration part, the data areas are not replaced. The methods FB_
Init, FB_Reinit, and FB_Exit are not called.
If you have made changes in the declaration part of a function block, the copy
process described in the FB_Reinit paragraph, page 483 is performed when the
Online Change command (see EcoStruxure Machine Expert, Menu Commands,
Online Help) is executed. A list of the objects that have been changed since the
last download is provided in the Application Information dialog box, page 207.
Open this dialog box by clicking the Details... button in the dialog box where you
select the option Login with online change.
The FB_Init and FB_Reinit method parameters bInCopyCode set to TRUE and
bInitRetains set to FALSE indicate that an online change is being executed.
CAUTION
INVALID POINTER
Verify the validity of the pointers when using pointers on addresses and
executing the Online Change command.
Failure to follow these instructions can result in injury or equipment
damage.
484 EIO0000002854.04
Variables Declaration
It prepares the data for the next copy process and influences the
state of the new instance.
4 FB_Reinit new_inst.FB_Reinit();
The FB_Reinit method is called after the copy operation. It sets
the variables of the function block instance to defined values.
NOTE: If you add the pragma, page 517 {attribute no_copy} to a variable of a
function block, this variable will not be copied during online change; it will only
be initialized.
Starting an Application
Before the first cycle of the tasks of an application is executed, the initial
assignments are processed.
Example:
T1 : TON := (PT:=t#500ms);
The assignments are executed after FB_Init has been called. To be able to verify
the impacts of these assignments, attach the {attribute call_after_init} pragma,
page 498 to a function block and a method of a function block (for example, called
EIO0000002854.04 485
Variables Declaration
MyInit). Insert this attribute above the declaration part of the function block and
above the declaration part of the corresponding method. Attach this pragma also
to function blocks that extend other function blocks which are using the {attribute
call_after_init} pragma. It is a good practice to assign the same name, the same
signature, and the same attribute to the corresponding method. To achieve this,
call SUPER^.MyInit. Select a method name of your choice (except FB_Init, FB_
Reinit, and FB_Exit). The method is called after the initial assignments have been
processed and before the tasks of an application are started.
NOTE: When the explicitly defined initialization code is executed, then the
function block has already been initialized completely via the implicit
initialization code. Due to this, calling SUPER^.FB_Init is not allowed.
486 EIO0000002854.04
Variables Declaration
Example for the Call Order of Derived Function Blocks for FB_Exit and
FB_Init
The following is assumed for the POUs named in this list: SubFB EXTENDS
MainFB and SubSubFB EXTENDS SubFB:
Step Action
1 fbSubSubFb.FB_Exit(...);
2 fbSubFb.FB_Exit(...);
3 fbMainFb.FB_Exit(...);
4 fbMainFb.FB_Init(...);
5 fbSubFb.FB_Init(...);
6 fbSubSubFb.FB_Init(...);
Pragma Instructions
Pragma Instructions
Overview
A pragma instruction is used to affect the properties of one or several variables
concerning the compilation or precompilation (preprocessor) process. Therefore,
a pragma influences the code generation.
NOTE: Consider that the available pragmas are not 1:1 implementations of C
preprocessor directives. They are handled as normal statements and
therefore can only be used at statement positions. They must not be used
within an expression and not in the declaration part of editors.
A pragma can determine whether a variable will be initialized, monitored, added to
a parameter list, added to the symbol list, page 525, or made invisible in the
Library Manager. It can force message outputs during the build process. You can
use conditional pragmas to define how the variable should be treated depending
on certain conditions. You can also enter these pragmas as definitions in the
compile properties of a particular object.
You can use a pragma in a separate line, or with supplementary text in an
implementation or declaration editor line. Within the FBD/LD/IL editor, execute the
command Insert Label and replace the default text Label: in the arising text field
by the pragma. In case you want to set a label as well as a pragma, insert the
pragma first and the label afterwards.
The pragma instruction is enclosed in curly brackets.
Syntax
{ <instruction text> }
The opening bracket can immediately come after a variable name. Opening and
closing brackets have to be in the same line.
EIO0000002854.04 487
Variables Declaration
{ELSE}
y :=13;
{END_IF}
END_IF
{ELSE}
IF x = 12 THEN
{IF defined(cde)}
y := 12;
{ELSE}
y :=13;
{END_IF}
END_IF
Further Information
Depending on the type and contents of a pragma, the pragma operates on the
subsequent statement, respectively all subsequent statements, until one of the
following conditions is met:
• It is ended by an appropriate pragma.
• The same pragma is executed with different parameters.
• The end of the code is reached.
The term code in this context refers to a declaration part, implementation part,
global variable list, or type declaration.
NOTE: Pragma instructions are case-sensitive.
If the compiler cannot meaningfully interpret the instruction text, the entire pragma
is handled as a comment and is skipped.
Refer to the following pragma types:
• Message Pragmas, page 488
• Attribute Obsolete, page 522
• Attribute Pragmas, page 495
• Conditional Pragmas, page 490
• Region Pragmas, page 495
• Attribute Symbol, page 525
Message Pragmas
Overview
You can use message pragmas to force the output of messages in the Messages
view (by default in the Edit menu) during the compilation (build) of the project.
You can insert the pragma instruction in an existing line or in a separate line in the
text editor of a POU. Message pragmas positioned within currently not defined
488 EIO0000002854.04
Variables Declaration
sections of the implementation code will not be considered when the project is
compiled. For further information, refer to the example provided with the
description of the defined (identifier) in the chapter Conditional Pragmas, page
490.
NOTE: For messages of types information, alert, and detected error, you can
reach the source position of the message - that is where the pragma is placed
in a POU - by executing the command Next Message. This is not possible for
the text type.
EIO0000002854.04 489
Variables Declaration
Conditional Pragmas
Overview
The ExST (Extended ST) language supports several conditional Pragma
Instructions, page 487, which affect the code generation in the precompile or
compile process.
NOTE: Do not use any conditional pragmas in the declaration part. They are
not regarded.
The implementation code which will be regarded for compilation can depend on
the following conditions:
• Is a certain data type or variable declared?
• Does a type or variable have a certain attribute?
• Does a variable have a certain data type?
• Is a certain POU or task available or is it part of the call tree, etc...
NOTE: It is not possible for a POU or GVL declared in the POUs Tree to use a
{define...} declared in an application. Definitions in applications will only
affect interfaces inserted below the respective application.
You can also use these expressions as well as the definition completed by
{define} in the Compiler defines: text field in the Properties dialog box of an
object (View > Properties > Build).
490 EIO0000002854.04
Variables Declaration
defined (identifier)
This operator affects that the expression gets value TRUE, as soon as the
identifier has been defined with a {define} instruction and has not been
undefined later by an {undefine} instruction. Otherwise its value is FALSE.
Example on defined (identifier):
Precondition: There are 2 applications App1 and App2. Identifier pdef1 is defined
in App2, but not in App1.
{IF defined (pdef1)}
(* this code is processed in App1 *)
{info 'pdef1 defined'}
hugo := hugo + SINT#1;
{ELSE}
(* the following code is only processed in application
App2 *)
{info 'pdef1 not defined'}
hugo := hugo - SINT#1;
{END_IF}
Additionally, an example for a message pragma, page 488 is included:
Only information pdef1 defined will be displayed in the Messages view when
the application is compiled because pdef1 is defined. The message pdef1 not
defined will be displayed when pdef1 is not defined.
defined (variable:variable)
When applied to a variable, its value is TRUE if this particular variable is declared
within the current scope. Otherwise it is FALSE.
Example on defined (variable:variable):
Precondition: There are 2 applications App1 and App2. Variable g_bTest is
declared in App2, but not in App1.
{IF defined (variable:g_bTest)}
(* the following code is only processed in application App2
*)
g bTest := x > 300;
{END_IF}
defined (type:identifier)
When applied to a type identifier, its value is TRUE if a type with that particular
name is declared. Otherwise it is FALSE.
Example on defined (type:identifier) :
Precondition: There are 2 applications App1 and App2. Data type DUT is defined
in App2, but not in App1.
{IF defined (type:DUT)}
EIO0000002854.04 491
Variables Declaration
defined (pou:pou-name)
When applied to a POU name, its value is TRUE if a POU or an action with that
particular POU name is defined. Otherwise it is FALSE.
Example on defined (pou: pou-name):
Precondition: There are 2 applications App1 and App2. POU CheckBounds is
available in App2, but not in App1.
{IF defined (pou:CheckBounds)}
(* the following code is only processed in application App1
*)
arrTest[CheckBounds(0,i,10)] := arrTest[CheckBounds(0,i,10)]
+ 1;
{ELSE}
(* the following code is only processed in application App2
*)
arrTest[i] := arrTest[i]+1;
{END_IF}
492 EIO0000002854.04
Variables Declaration
EIO0000002854.04 493
Variables Declaration
NOT operator
The expression gets value TRUE when the inverted value of operator is TRUE.
operator can be one of the operators described in this chapter.
Example on NOT operator:
Precondition: There are 2 applications App1 and App2. POU PLC_PRG1 is used
in App1 and App2. POU CheckBounds is only available in App1:
{IF defined (pou: PLC_PRG1) AND NOT (defined (pou:
CheckBounds))}
(* the following code line is only executed in App2 *)
bANDNotTest := TRUE;
{END_IF}
AND operator
The expression gets value TRUE if both operators are TRUE. operator can be
one of the operators listed in this table.
494 EIO0000002854.04
Variables Declaration
OR operator
The expression is TRUE if one of the operators is TRUE. operator can be one of
the operators described in this chapter.
Example on OR operator:
Precondition: POU PLC_PRG1 is used in applications App1 and App2. POU
CheckBounds is only available in App1:
{IF defined (pou: PLC_PRG1) OR (defined (pou: CheckBounds))}
(* the following code line will be processed in applications
App1 and App2, because both contain at least one of the POUs
"PLC_PRG1" and "CheckBounds" *)
bORTest := TRUE;
{END_IF}
(operator)
(operator) braces the operator.
Region Pragmas
Overview
Use region pragmas to group several lines into one block in a text editor. You can
assign a name to the block. Region pragmas can be nested.
The figure shows a program code that contains a region pragma in the extended and in the collapsed view.
Region pragmas can be used in the ST editor and in the declaration editors.
Attribute Pragmas
Attribute Pragmas
Overview
You can assign attribute pragmas, page 487 to a signature in order to influence
the compilation or pre-compilation that is the code generation.
EIO0000002854.04 495
Variables Declaration
There are user-defined attributes, page 496, which you can use in combination
with conditional pragmas, page 490.
Attributes are defined within the declaration part. An exception is made for the
action and transition objects which do not have a declaration part. You can define
the attributes at the beginning of the implementation part.
There are also the following predefined standard attribute pragmas:
• attribute displaymode, page 503
• attribute ExpandFully, page 504
• attribute global_init_slot, page 505
• attribute hide, page 506
• attribute hide_all_locals, page 507
• attribute initialize_on_call, page 508
• attribute init_namespace, page 508
• attribute init_On_Onlchange, page 508
• attribute instance-path, page 509
• attribute linkalways, page 511
• attribute monitoring, page 512
• attribute no_check, page 516
• attribute no_copy, page 517
• attribute no-exit, page 517
• attribute noinit, page 518
• attribute no_virtual_actions, page 518
• attribute obsolete, page 522
• attribute pack_mode, page 523
• attribute qualified_only, page 524
• attribute reflection, page 524
• attribute subsequent, page 525
• attribute symbol, page 525
• attribute warning disable, page 527
User-Defined Attributes
Overview
You can assign arbitrary user-defined or application-defined attribute pragmas to
POUs, type declarations, or variables. This attribute can be queried before
compilation by conditional pragmas, page 490.
Syntax
{attribute 'attribute'}
This pragma instruction is valid for the subsequent POU declaration or variable
declaration.
You can assign a user-defined attribute to:
• a POU or action
• a variable
• a data type
496 EIO0000002854.04
Variables Declaration
Example on Variables
Attribute DoCount for variable ivar :
PROGRAM PLC_PRG
VAR
{attribute 'DoCount'};
ivar:INT;
bvar:BOOL;
END_VAR
Example on Types
Attribute aType for data type DUT_1:
{attribute 'aType'}
TYPE DUT_1 :
STRUCT
a:INT;
b:BOOL;
END_STRUCT
END_TYPE
For the usage of conditional pragmas, refer to the chapter Conditional Pragmas,
page 490.
Attribute call_after_global_init_slot
Overview
All functions and programs containing this attribute in an own line above their
declaration part are called after the global initialization (GlobalInit). The calling
sequence is determined by the attribute value.
NOTE: Compile errors will be detected (during code generation) if VAR_
INPUT declarations are used in functions or methods that contain this
attribute. The reason is that the input variables are unknown when the function
is called implicitly during online change.
Syntax
{attribute 'call_after_global_init_slot' := '<slot>'}
Replace <slot> by an integer value defining the priority within the calling
sequence: The lower the value, the earlier the call. In case of several signatures
carrying the same value for the attribute, the sequence of their initialization
remains undefined.
If a method is provided with the attribute, then it is called for all instances of the
concerned function block. All instances are called within the specified slot;
however, you cannot control the order among the instances themselves.
EIO0000002854.04 497
Variables Declaration
Attribute call_after_init
Overview
Use the pragma {attribute call_after_init} to define a method that is
called implicitly after the initialization of a function block instance. For performance
reasons, attach the attribute both to the function block itself and to the instance
method to be called. The method has to be called after FB_Init, page 486 and
after having applied the variable values of an initialization expression in the
instance declaration.
NOTE: Compile errors will be detected if VAR_INPUT declarations are used in
methods that contain this attribute. The reason is that the input variables are
unknown when the method is called implicitly during online change.
Syntax
{attribute 'call_after_init'}
Example
With the following definition:
{attribute 'call_after_init'}
FUNCTION_BLOCK FB
... <functionblock definition>
{attribute 'call_after_init'}
METHOD FB_AfterInit
... <method definition>
... declaration like the following:
inst : FB := (in1 := 99);
... will result in the following order of code processing:
inst.FB_Init();
inst.in1 := 99;
inst.FB_AfterInit();
So, in FB_Afterinit, you can react on the user-defined initialization.
Attribute call_after_online_change_slot
Overview
All functions and programs containing this attribute in an own line above their
declaration part are called after an online change. The calling sequence is
determined by the attribute value.
NOTE: Compile errors will be detected (during code generation) if VAR_
INPUT declarations are used in functions or methods that contain this
attribute. The reason is that the input variables are unknown when the function
is called implicitly during online change.
Syntax
{attribute 'call_after_online_change_slot' := '<slot>'}
Replace <slot> by an integer value defining the priority within the calling
sequence: The lower the value, the earlier the call. If several modules have the
same priority value for the attribute, then the order in which they are called
remains undefined.
498 EIO0000002854.04
Variables Declaration
If a method is provided with the attribute, then it is called for all instances of the
concerned function block. All instances are called within the specified slot;
however, you cannot control the order among the instances themselves.
NOTE: As the application cannot run during an online change, each code
executed in this situation can effect jitter. For this reason, minimize the code to
be executed.
Attribute call_before_global_exit_slot
Overview
All functions and programs containing this attribute in an own line above their
declaration part are called after the GlobalExit. The GlobalExit is executed
before a new download, at a reset, or during an online change and affects
modules which are provided with an FB_exit method. The calling sequence is
determined by the attribute value.
NOTE: Compile errors will be detected (during code generation) if VAR_
INPUT declarations are used in functions or methods that contain this
attribute. The reason is that the input variables are unknown when the function
is called implicitly during online change.
Syntax
{attribute 'call_before_global_exit_slot' := '<slot>'}
Replace <slot> by an integer value defining the priority within the calling
sequence: The lower the value, the earlier the call. If several modules have the
same priority value for the attribute, then the order in which they are called
remains undefined.
If a method is provided with the attribute, then it is called for all instances of the
concerned function block. All instances are called within the specified slot;
however, you cannot control the order among the instances themselves.
Attribute call_on_type_change
Overview
Attach the Attribute call_on_type_change pragma to methods of a function block A
in order to achieve that this method is called when the data type is changed for
one or more function blocks B, C, etc. that are referenced by A. The function
blocks can be referenced by pointers, page 537 or references, page 536.
Syntax
{attribute 'call_on_type_change':= '<name of the first referenced function block>|
<name of the second referenced function block>|<name of the nth referenced
function block>'}
Insert the Attribute call_on_type_change above the first line in the method
declaration.
Examples
Example of a function block with references:
FUNCTION_BLOCK FB_A
...
EIO0000002854.04 499
Variables Declaration
VAR
var_pt: POINTER TO FB_B;
var_ref: REFERENCE TO FB_C;
END_VAR
...
Example of a method that is called when data types are changed in the referenced
function blocks FB_B and FB_C:
{attribute 'call_on_type_change' := 'FB_B,
FB_C'}
METHOD METH_react_on_type_change : INT
VAR_INPUT
...
Attribute conditionalshow
Overview
The function block that contains this attribute is not displayed in the user interface
if the integrated library is installed as *.compiled-library.
If the integrated library is available as *.library in the repository, the function block
is visible in the user interface.
If you use conditionalshow as a command-line option, such as
LogicBuilder.exe --conditionalshow="libdeveloper", the function
blocks are visible in the user interface. This option may be useful for library
developers when testing libraries.
Syntax
{attribute 'conditionalshow' := 'SomeText'}
or
{attribute 'conditionalshow'}
Insert Location
Insert this pragma in the first line of the declaration part of the function block.
Example
{attribute 'conditionalshow' := 'SomeText'}
//{attribute 'conditionalshow'}
FUNCTION_BLOCK FB_Test
VAR_INPUT
END_VAR
Attribute conditionalshow_all_locals
Overview
The local variables are not displayed in the user interface if the integrated library is
installed as *.compiled-library.
If the integrated library is available as *.library in the repository, the local variables
of the function block are visible in the user interface.
500 EIO0000002854.04
Variables Declaration
Syntax
{attribute 'conditionalshow_all_locals' :='SomeText'}
or
{attribute 'conditionalshow_all_locals'}
Insert Location
Insert this pragma in the first line of the declaration part of the function block.
Example
{attribute 'conditionalshow_all_locals' := 'SomeText'}
//{attribute 'conditionalshow_all_locals'}
FUNCTION_BLOCK FB_Test
VAR_INPUT
END_VAR
VAR_OUTPUT
eErrorID : ERROR;
VAR
iLocal : INT;
END_VAR
Syntax
{attribute 'const_replaced'}
{attribute 'const_non_replaced'}
Example
The constants iTestCon and bTestCon are available in the Symbol
Configuration because Replace constants is deactivated by pragmas.
VAR_GLOBAL CONSTANT
EIO0000002854.04 501
Variables Declaration
{attribute 'const_non_replaced'}
iTestCon : INT := 12;
{attribute 'const_non_replaced'}
bTestCon : BOOL := TRUE;
rTestCon : REAL := 1.5;
END_VAR
VAR_GLOBAL
iTestVar : INT := 12;
bTestVar : BOOL := TRUE;
END_VAR
Attribute 'dataflow'
Overview
The pragma {attribute 'dataflow'} enables you to control the dataflow when
processing function blocks in the FBD/LD/IL editor. The attribute defines the input
or output of a function block that is used as the connection to the next or previous
function block.
You can assign this attribute to only one input and one output in the declaration of
the function block.
For function blocks without the {attribute 'dataflow'}, the dataflow is determined
automatically as follows:
The connection is established between an output and an input of the same type.
The uppermost input and output variables of the function block are used first. If
there are no variables with the same data type, then the uppermost output is
connected to the uppermost input of the next function block.
You can also change the control flow in the editor by using the pointer to connect
the connector pins of the function block to other positions. For further information,
refer to the description of Inserting, Arranging, and Replacing Elements, page
237.
Syntax
{attribute 'dataflow'}
Example
The FB and the previous function block are connected using the input variable i1.
The FB and the next function block are connected using the output variable
outRes1.
FUNCTION_BLOCK FB
VAR_INPUT
r1 : REAL;
{attribute 'dataflow'}
i1 : INT;
i2 : INT;
r2 : REAL;
END_VAR
VAR_OUTPUT
{attribute 'dataflow'}
outRes1 : REAL;
out1 : INT;
g1 : INT;
g2 : REAL;
END_VAR
502 EIO0000002854.04
Variables Declaration
Attribute displaymode
Overview
Use the pragma {attribute displaymode} to define the display mode of a single
variable. This setting will overwrite the global setting for the display mode of all
monitoring variables done via the commands of the submenu Display Mode (by
default in the Online menu).
Position the pragma in the line above the line containing the variable declaration.
Syntax
{attribute 'displaymode':=<displaymode>}
The following definitions are possible:
- to display in binary format
{attribute 'displaymode':='bin'}
{attribute 'displaymode':='binary'}
- to display in decimal format
{attribute 'displaymode':='dec'}
{attribute 'displaymode':='decimal'}
- to display in hexadecimal format
{attribute 'displaymode':='hex'}
{attribute 'displaymode':='hexadecimal'}
Example
VAR
{attribute 'displaymode':='hex'}
dwVar1: DWORD;
END_VAR
Attribute enable_dynamic_creation
Overview
The pragma enable_dynamic_creation is required for using the __NEW
operator, page 611 for function blocks.
Syntax
{attribute 'enable_dynamic_creation'}
Insert the pragma in the first line in the declaration of the function block.
Attribute estimated-stack-usage
Overview
The pragma {attribute 'estimated-stack-usage' := '<estimated stack size in bytes>'}
helps to prevent runtime systems with an active stack check from issuing a
message (C0298: Calculation of stack usage incomplete because of
recursive calls) indicating that there is insufficient space in the stack. This
EIO0000002854.04 503
Variables Declaration
check is performed during the code generation. For recursive methods, you may
want to reduce the number of messages.
Syntax
{attribute 'estimated-stack-usage' := '<estimated stack size
in bytes>'}
Insert Location
Insert this pragma in the line above the METHOD declaration in the declaration
section of the relevant method.
Example
{attribute 'estimated-stack-usage' := '99'}
METHOD PUBLIC m_Temp : UDINT
VAR_INPUT
uiN : UINT;
END_VAR
m_Temp := 1;
IF uiN > 1 THEN
m_Temp := uiN * THIS^.m_Temp(uiN := (uiN- 1));
RETURN;
ELSE
RETURN;
END_IF
Attribute ExpandFully
Overview
Use the pragma {attribute 'ExpandFully'} to make all members of arrays
used as input variables for referenced visualizations accessible within the
Visualization Properties dialog box.
Syntax
{attribute 'ExpandFully'}
Example
Visualization visu is intended to be inserted in a frame within visualization visu_
main.
As input variable arr is defined in the interface editor of visu and will later be
available for assignments in the Properties dialog box of the frame in visu_
main.
In order to get the available particular components of the array in the Properties
dialog box, insert the attribute ExpandFully in the interface editor of visu directly
before arr.
Declaration in the interface editor of visu:
VAR_INPUT
{attribute 'ExpandFully'}
arr : ARRAY[0..5] OF INT;
504 EIO0000002854.04
Variables Declaration
END_VAR
Resulting Properties dialog box of frame in visu_main:
Attribute global_init_slot
Overview
The pragma {attribute 'global_init_slot'} defines the sequence of
initialization of POUs or global variable lists.
Variables in a list (GVL or POU) are initialized from top to bottom.
If there are several global variable lists available, then the sequence of
initialization is not defined.
The sequence of initialization is irrelevant for literal values, such as 1, ‘hello’,
3.6, or for constants of base data types. However, if there are dependencies
between the different lists, you must define the sequence of initialization by
yourself. To achieve this, you can assign a defined initialization slot to a GVL or a
POU using the attribute global_init_slot.
Constants are initialized before the variables and in the same order as the
variables. During initialization, the POUs are sorted according to the value for
<slot>. Then the code for initializing the constants is generated. After that, the
code for initializing the variables is generated.
Syntax
{attribute 'global_init_slot' := '<slot>'}
Replace <slot> by an integer value that defines the position in the initialization
order. The default value for a POU (program, function block) is 50,000. The default
value for a GVL is 49,990. A lower value provokes an earlier initialization. In case
of several POUs or GVLs carrying the same value for the attribute global_
init_slot, the sequence of their initialization remains undefined. This will be
indicated as a detected programming error in the Build category of the Messages
view (see EcoStruxure Machine Expert, Menu Commands, Online Help).
The pragma {attribute 'global_init_slot'} is valid for the entire GVL or
POU and must therefore be located above the VAR_GLOBAL or POU declaration.
EIO0000002854.04 505
Variables Declaration
Example
The example includes 2 global variable lists GVL_1 and GVL_2 and a program
PLC_PRG that uses variables from both lists.
GVL_1 uses the variable B for initializing a variable A which is initialized in the
GVL_2 with a value of 1000.
GVL_1:
VAR_GLOBAL //49990
A : INT := GVL_2.B*100;
END_VAR
GVL_2:
VAR_GLOBAL //49990
B : INT := 1000;
C : INT := 10;
END_VAR
PLC_PRG:
PROGRAM PLC_PRG //50000
VAR
ivar: INT := GVL_1.A;
ivar2: INT;
END_VAR
ivar:=ivar+1;
ivar2:=GVL_2.C;
When building this example, a programming error is issued in the Build category
of the Messages view (see EcoStruxure Machine Expert, Menu Commands,
Online Help) because GVL_2.B is used for initializing GVL_1.A before GVL_2 has
been initialized. To avoid this, use the attribute global_init_slot in order
to position GVL_2 before GVL_1 in the sequence of initialization.
GVL_2 must have a slot value of 49989 or lower to achieve the earliest
initialization within the program.
GVL_2:
{attribute 'global_init_slot' := '100'}
VAR_GLOBAL
B : INT := 1000;
C : INT := 10;
END_VAR
You can even use GVL_2.C in the implementation part of PLC_PRG without a
pragma because both GVLs are initialized before the program in either case.
Attribute hide
Overview
The pragma {attribute hide} helps you to prevent variables or even whole
signatures from being displayed within the functionality of listing components,
page 527 or the input assistant or the declaration part in online mode. Only the
variable subsequent to the pragma will be hidden.
If you know the instance path to a variable, you can address it in the code even if
the {attribute hide} is assigned.
Syntax
{attribute 'hide'}
To hide all local variables of a signature, use the attribute hide_all_locals, page
507.
506 EIO0000002854.04
Variables Declaration
Example
The function block myPOU is implemented using the attribute:
FUNCTION_BLOCK myPOU
VAR_INPUT
a:INT;
{attribute 'hide'}
a_invisible: BOOL;
a_visible: BOOL;
END_VAR
VAR_OUTPUT
b:INT;
END_VAR
In the main program 2 instances of function block myPOU are defined:
PROGRAM PLC_PRG
VAR
POU1, POU2: myPOU;
END_VAR
When assigning an input value to POU1, the functionality of listing components,
page 527 that works on typing POU1 in the implementation part of PLC_PRG will
display the input variables a and a_visible (and the output variable b). The
hidden input variable a_invisible will not be displayed.
Attribute hide_all_locals
Overview
The pragma {attribute 'hide_all_locals'} helps you to prevent all local variables of a
signature from being displayed within the functionality of listing components, page
527 or the input assistant. This attribute is identical to assigning the attribute hide,
page 506 to each particular of the local variables.
Syntax
{attribute 'hide_all_locals'}
Example
The function block myPOU is implemented using the attribute:
{attribute 'hide_all_locals'}
FUNCTION_BLOCK myPOU
VAR_INPUT
a:INT;
END_VAR
VAR_OUTPUT
b:BOOL;
END_VAR
VAR
c,d:INT;
END_VAR
In the main program 2 instances of function block myPOU are defined:
PROGRAM PLC_PRG
VAR
POU1, POU2: myPOU;
END_VAR
When assigning an input value to POU1, the functionality of listing components,
page 527 that works on typing POU1 in the implementation part of PLC_PRG will
display the variables a and b. The hidden local variables c or d will not be
displayed.
EIO0000002854.04 507
Variables Declaration
Attribute initialize_on_call
Overview
You can add the pragma {attribute initialize_on_call} to input variables. An input of
a function block with this attribute will be initialized at any call of the function block.
If an input expects a pointer and if this pointer has been removed due to an online
change, then the input will be set to NULL.
Syntax
{attribute 'initialize_on_call'}
Attribute init_namespace
Overview
A variable of type STRING or WSTRING, which is declared with the pragma
{attribute init_namespace} in a library, will be initialized with the current
namespace of that library. For further information, refer to the description of the
library management (see EcoStruxure Machine Expert, Functions and Libraries
User Guide).
Syntax
{attribute 'init_namespace'}
Example
The function block POU is provided with all necessary attributes:
FUNCTION_BLOCK POU
VAR_OUTPUT
{attribute 'init_namespace'}
myStr: STRING;
END_VAR
Within the main program PLC_PRG an instance fb of the function block POU is
defined:
PROGRAM PLC_PRG
VAR
fb:POU;
newString: STRING;
END_VAR
newString:=fb.myStr;
The variable myStr will be initialized with the current namespace, for example
MyLib.XY. This value will be assigned to newString within the main program.
Attribute init_On_Onlchange
Overview
To initialize variables on online change, proceed as follows:
508 EIO0000002854.04
Variables Declaration
Step Action
2 Open the Build tab of the Properties dialog box of the application (see EcoStruxure
Machine Expert, Menu Commands, Online Help) and enter the string no_fast_
online_change in the Compiler defines box.
Syntax
{attribute 'init_on_onlchange' }
Insert Location
Insert this pragma in the line above the declaration of the variables.
Attribute instance-path
Overview
You can add the pragma {attribute instance-path} to a local string
variable. This local string variable will be initialized with the Applications tree
path of the POU to which this string variable belongs. Applying this pragma
presumes the use of the attribute reflection, page 524 for the corresponding POU
and the additional attribute noinit, page 518 for the string variable.
Syntax
{attribute 'instance-path'}
Example
Assume the following function block POU being equipped with the attribute
'reflection':
{attribute 'reflection'}
FUNCTION_BLOCK POU
VAR
{attribute 'instance-path'}
{attribute 'noinit'}
str: STRING;
END_VAR
In the main program PLC_PRG an instance myPOU of function block POU is called:
PROGRAM PLC_PRG
VAR
myPOU:POU;
myString: STRING;
END_VAR
myPOU();
myString:=myPOU.str;
After initialization of instance myPOU, the string variable str gets assigned the
path of instance myPOU, for example: PLC.Application.PLC_PRG.myPOU. This
path will be assigned to variable myString within the main program.
NOTE: The length of a string variable may be arbitrarily defined (even >255).
However, the string will be cut (from its back end) if it gets assigned to a string
variable of a shorter length.
EIO0000002854.04 509
Variables Declaration
Syntax
{attribute 'io_function_block'}
{attribute 'io_function_block_mapping'}
Insert Location
Insert these parameters in the line above the first line in the declaration part of the
function block, or in the line above the parameter declaration.
Example
{attribute 'io_function_block'}
FUNCTION_BLOCK Scale_Output_Int
VAR_INPUT
iInput : INT;
iNumerator : INT;
iDenominator : INT :=1;
iOffset : INT := 0;
END_VAR
VAR_OUTPUT
{attribute 'io_function_block_mapping'}
iOutput : INT;
END_VAR
VAR
Attribute is_connected
Overview
The is_connected attribute marks a Boolean variable of a function block to
provide the information when the function block instance is called about whether
the associated input of the POU has an assignment.
As a prerequisite, the reflection attribute, page 524 must be assigned to the
respective function block.
Syntax
{attribute 'is_connected' := '<input variable>'}
510 EIO0000002854.04
Variables Declaration
Example
In the function block FB, a local variable is declared for each input variable (in1
and in2). Each input variable is prefixed by the attribute is connected and the
name of the input variable. The function block is assigned the pragma attribute
reflection.
If an instance of the function block is called, the local variable is set to TRUE
provided that the assigned input receives an assignment.
{attribute 'reflection'}
FUNCTION_BLOCK FB
VAR_INPUT
in1: INT;
in2: INT;
END_VAR
VAR
{attribute 'is_connected' := 'in1'}
in1_connection_info: BOOL;
{attribute 'is_connected' := 'in2'}
in2_connection_info: BOOL;
END_VAR
Assumption: When the function block instance is called, in1 receives an external
assignment and in2 does not receive an assignment. This results in the following
code:
in1_connection_info := TRUE;
in2_connection_info := FALSE;
Attribute linkalways
Overview
Use the pragma {attribute 'linkalways'} to mark a POU or a library POU for the
compiler in a way so that they are always included into the compile information.
During the build, objects with this option are compiled and become part of the
application code. With a download, the POUs are downloaded to the controller.
The POU can be valid for the project (if located in the POUs tree) or for the
application (if located in the Devices tree).
The compiler option Link always has the same effect.
Syntax
{attribute 'linkalways'}
Insert the pragma in the fist line of the declaration part of a POU or a library POU.
When you use the symbol configuration editor, the marked POUs are used as a
basis for the selectable variables for the symbol configuration.
Example
The global variable list MoreSymbols GVL is implemented making use of the
attribute 'linkalways'. The variables declared are included in the application code,
no matter whether they are accessed or not.
MoreSymbols GVL
{attribute 'linkalways'}
VAR_GLOBAL
g_iAlpha: INT;
g_iBravo: INT;
g_iCharlie: INT;
END_VAR
EIO0000002854.04 511
Variables Declaration
Attribute monitoring
Overview
This attribute pragma allows you to get properties and function call results
monitored in the online view of the IEC editor or in a watch list.
Monitoring of Properties
Add the pragma in the line above the property definition. Then the name, type, and
value of the variables of the property will be displayed in the online view of the
POU using the property or in a watch list. Therein, you can also enter prepared
values to force variables belonging to the property.
Example of property prepared for variable monitoring
512 EIO0000002854.04
Variables Declaration
EIO0000002854.04 513
Variables Declaration
Attribute namespace
Overview
In combination with the attribute symbol, page 525, the pragma {attribute
namespace} allows you to redefine the namespace of project variables. You can
apply it on complete POUs, like GVLs or programs, but not on particular variables.
The concerned variables will be exported with the new namespace definition to a
symbol file and after a download of this file be available on the controller.
This also allows you to access variables from POUs or visualizations which
originally have got different namespaces. For example, it allows you to run a
previous EcoStruxure Machine Expert visualization also in a later EcoStruxure
Machine Expert environment.
For further information, refer to the description of the symbol configuration. A new
symbol file will be created at a download or online change of the project. It is
downloaded to the controller together with the application.
Syntax
{attribute 'namespace' := '<namespace>'}
514 EIO0000002854.04
Variables Declaration
The replacements shown in the table result in the following entries in the symbol
file:
<NodeList>
<Node name="">
<Node name="Var07" type="T_INT" access="ReadWrite">
</Node>
</NodeList>
<NodeList>
<Node name="Ext">
<Node name="Var02 " type="T_INT" access="ReadWrite"></
Node>
</Node>
</NodeList>
<NodeList>
<Node name="App1">
<Node name="GVL2">
<Node name="Var02 " type="T_INT" access="ReadWrite"></
Node>
</Node>
</Node>
</NodeList>
EIO0000002854.04 515
Variables Declaration
The pragma 'no_assign_warning' has the same functions as the pragma 'no
assign' but issues detected alerts as category warnings in the Messages view
(see EcoStruxure Machine Expert, Menu Commands, Online Help).
Attribute no_check
Overview
You can add the pragma {attribute 'no_check'} to the declaration of a POU in order
to suppress the call of any POUs for implicit checks. As checking functions may
influence the performance, apply this attribute to POUs that are frequently called
or already approved.
NOTE: This attribute has an automatic effect also on the child objects of a
POU.
Example: In programs with this attribute, no check functions are executed. Not
even for actions that are assigned to this program.
Syntax
{attribute 'no_check'}
516 EIO0000002854.04
Variables Declaration
Attribute no_copy
Overview
Generally, an online change will require a reallocation of instances, for example of
POUs. The value of the variables within this instance will get copied.
If, however, the pragma {attribute no_copy} is added to a variable, an online
change copy of this variable will not be performed; this variable will be initialized
instead. This can be reasonable in case of local pointer variable, pointing on a
variable actually shifted by the online change (and thus having a modified
address).
Syntax
{attribute 'no_copy'}
Attribute no-exit
Overview
If a function block provides an FB_exit method, page 484 , you can suppress its
call for a special instance with the help of assigning the pragma {attribute no-exit}
to the function block instance.
Syntax
{attribute 'no-exit'}
Example
Assume the method FB_Exit being added to a function block named POU:
EIO0000002854.04 517
Variables Declaration
Attribute no_init
Overview
Variables provided with the pragma {attribute no_init} will not be initialized
implicitly. The pragma belongs to the variable declared subsequently.
Syntax
{attribute 'no_init'}
also possible
{attribute 'no-init'}
{attribute 'noinit'}
Example
PROGRAM PLC_PRG
VAR
A : INT;
{attribute 'no_init'}
B : INT;
END_VAR
If a reset is performed on the associated application, the integer variable A will be
again initialized implicitly with 0, whereas variable B maintains the value it is
currently assigned to.
Attribute no_instance_in_retain
Overview
The pragma {attribute 'no_instance_in_retain'} helps to avoid that the instance of a
certain function block instance is stored in the retain memory area.
Insert it as first line of the declaration of the function block. This has the effect that
a message is created in case any instance of the POU is declared as a RETAIN
variable.
Syntax
{attribute 'no_instance_in_retain'}
Attribute no_virtual_actions
Overview
This attribute is valid for function blocks, which are derived from a base function
block implemented in SFC, and which are using the main SFC workflow of the
base class. The actions called therein show the same virtual behavior as methods.
Therefore, the base class actions may be overridden by specific implementations
related to the derived classes.
In order to help to prevent the action of the base class from being overridden, you
can assign the pragma {attribute 'no_virtual_actions'} to the base
class.
518 EIO0000002854.04
Variables Declaration
Syntax
{attribute 'no_virtual_actions'}
Example
In the following example, the function block POU_SFC provides the base class to
be extended by the function block POU_child.
By use of the keyword SUPER, the derived class POU_child calls the workflow of
the base class that is implemented in SFC.
The exemplary implementation of this workflow is restricted to the initial step. This
is followed by 1 single step with associated step action ActiveAction concerned
with the assignment of the output variables:
an_int:=an_int+1; // counting the action calls
test_act:='father_action'; // writing string variable test_
act
METH(); // Calling method METH for writing
string variable test_meth
In case of the derived class POU_child, the step action will be overwritten by a
specific implementation of ActiveAction. It differs from the original one by
assigning the string 'child_action' instead of 'father_action' to variable
test_act.
Likewise, the method METH, assigning the string 'father_method' to variable
test_meth within the base class, will be overwritten such that test_meth will
be assigned to 'child_method' instead.
EIO0000002854.04 519
Variables Declaration
The main program PLC_PRG will execute repeated calls to Child (an instance of
POU_child). As expected, the actual value of the output string report the call to
action and method of the derived class:
You can observe a different behavior if the base class is preceded by the attribute
'no_virtual_actions'
{attribute 'no_virtual_actions'}
FUNCTION_BLOCK POU_SFC...
Whereas method METH will still be overwritten by its implementation within the
derived class, a call of the step action will now result in a call of action
ActiveAction of the base class. Therefore, test_act will be assigned to string
'father_action'.
Attribute pingroup
Overview
Insert the pragma {attribute 'pingroup' := '<groupname>'} in the declaration of a
function block, for grouping the input pins or output pins (parameters). Then, in the
respective box of the FBD and LD editor, each pin group can be displayed, folded,
or unfolded. Multiple groups are possible and are differentiated by their names.
The particular state (folded/unfolded) per box is saved in the project options.
Inputs and outputs without attribute pingroup are always displayed above any
possible group or groups.
Syntax
{attribute 'pingroup' := '<groupname>'}
Example
Two groups are defined:
• general (i1, out1)
• group1 (i2, g1)
r1, r2, outRes1 and g2 are always displayed.
FUNCTION_BLOCK FB
VAR_INPUT
r1 : REAL;
{attribute 'pingroup' := 'general'}
i1 : INT;
{attribute 'pingroup' := 'group1'}
520 EIO0000002854.04
Variables Declaration
i2 : INT;
r2 : REAL;
END_VAR
VAR_OUTPUT
outRes1 : REAL;
{attribute 'pingroup' := 'general'}
out1 : INT;
{attribute 'pingroup' := 'group1'}
g1 : INT;
g2 : REAL;
END_VAR
Pingroups in FBD editor
Attribute pin_presentation_order_inputs/outputs
Overview
The pragmas define the order in which the inputs and outputs of a function block
are displayed in graphical language editors.
Syntax
{attribute 'pin_presentation_order_inputs' :=
'<input_k>,<input_l>,*,<input_m>'}
{attribute 'pin_presentation_order_outputs' :=
'<output_k>,<output_l>,*,<output_m>'}
The * character is the separator between the beginning and the end of the sorted
list of input or output parameters. The separator is replaced by undefined input or
output parameters. If the separator is not available, then the input or output
parameters that are not defined explicitly in the pragma will be added to the end of
the sorted list.
The pragmas are inserted in the first line in the declaration part of a function block.
NOTE: The pragmas attribute 'pin_presentation_order_inputs and attribute
'pin_presentation_order_outputs are not evaluated when the pragma pingroup
is used.
Example
{attribute 'pin_presentation_order_inputs' :=
'input_2,*,input_1'}
{attribute 'pin_presentation_order_outputs' :=
'output_2, output_1}
FUNCTION_BLOCK POU_BASE
VAR_INPUT
input_1 : BOOL;
EIO0000002854.04 521
Variables Declaration
input_2 : INT;
input_3 : INT;
input_4 : INT;
END_VAR
VAR_OUTPUT
output_1 : BOOL;
output_2 : INT;
output_3 : INT;
output_4 : BOOL;
END_VAR
This sample pragma definition leads to the following order of the input and output
pins of the POU_Base function block:
Attribute obsolete
Overview
You can add an obsolete pragma to a data type definition in order to cause a user-
defined alert during a build, if the respective data type (structure, function block,
and so on) is used within the project. Thus, you can announce that the data type is
not used any longer.
Unlike a locally used message pragma, page 488, this alert is defined within the
definition and thus global for all instances of the data type.
This pragma instruction is valid for the current line or - if placed in a separate line -
for the subsequent line.
Syntax
{attribute 'obsolete' := 'user-defined text'}
Example
The obsolete pragma is inserted in the definition of function block fb1:
{attribute 'obsolete' := 'datatype fb1 not valid!'}
FUNCTION_BLOCK fb1
VAR_INPUT
i:INT;
END_VAR
...
If fb1 is used as a data type in a declaration, for example, fbinst: fb1; the
following alert will be dumped when the project is built:
'datatype fb1 not valid'
522 EIO0000002854.04
Variables Declaration
Attribute pack_mode
Overview
The pragma {attribute 'pack_mode'} defines the mode a data structure is
packed while being allocated. Set the attribute on top of a data structure. It
influences the packing of the whole structure.
Syntax
{attribute 'pack_mode' := '<value>'}
The placeholder <value> can have the following values:
0 Aligned
1 1-byte-aligned
2 2-byte-aligned
4 4-byte-aligned
8 8-byte-aligned
Example
{attribute 'pack_mode' := '1'}
TYPE myStruct:
STRUCT
Enable: BOOL;
Counter: INT;
MaxSize: BOOL;
MaxSizeReached: BOOL;
END_STRUCT
END_TYPE
A variable of data type myStruct is instantiated aligned.
If the address of its component Enable is 0x0100, then the component Counter
will follow on address 0x0101, MaxSize on 0x0103 and MaxSizeReached on
0x0104.
With pack_mode=2, Counter would be found on 0x0102, MaxSize on 0x0104
and MaxSizeReached on 0x0106.
Attribute ProcessValue
Overview
The ProcessValue attribute marks a component of a structure. In the CFC
editor, you can execute the Use attributed member as input command (see
EcoStruxure Machine Expert, Menu Commands, Online Help) to connect this
structure to a scalar type input.
EIO0000002854.04 523
Variables Declaration
Syntax
{attribute 'ProcessValue'}
Insert Location
Insert the ProcessValue attribute in the line above the structure variable.
Example
TYPE QINT :
STRUCT
Status : STRING;
{attribute 'ProcessValue'}
Value1 : INT;
Value2 : INT;
END_STRUCT
END_TYPE
Attribute qualified_only
Overview
When the pragma {attribute 'qualified_only'} is assigned on top of a
global variable list, the variables of this list can only be accessed by using the
global variable name, for example gvl.g_var. This works even for variables of
enumeration type. It can be useful to avoid name mismatch with local variables.
Syntax
{attribute 'qualified_only'}
Example
Assume the following global variable list (GVL) is provided with attribute
'qualified_only':
{attribute 'qualified_only'}
VAR_GLOBAL
iVar:INT;
END_VAR
Within POU PLC_PRG, the global variable has to be called with the prefix GVL, as
shown in this example:
GVL.iVar:=5;
The following incomplete call of the variable will be detected as an error:
iVar:=5;
Attribute reflection
Overview
Attach the pragma {attribute 'reflection'} to POUs containing variables
that are tagged with the instance-path attribute, page 509 or the is-connected
attribute, page 510.
524 EIO0000002854.04
Variables Declaration
Syntax
{attribute 'reflection'}
Example
Refer to the attribute instance-path example, page 509 and to the attribute
is-connected example, page 511.
Attribute subsequent
Overview
The pragma {attribute 'subsequent'} forces variables to be allocated in a
row at one location in memory. If the list changes, the whole list will be allocated at
a new location. This pragma is used in programs and global variable lists (GVL).
Syntax
{attribute 'subsequent'}
NOTE: If one variable in the list is RETAIN, the whole list will be located in
retain memory.
NOTE: VAR_TEMP in a program with attribute subsequent will be detected
as a compiler error.
Attribute symbol
Overview
The pragma {attribute 'symbol'} defines which variables are to be handled
in the symbol configuration.
The following export operations are performed on the variables:
• Variables are exposed as symbols in the symbol configuration.
• Variables are exported to an XML file in the project directory.
• Variables are exported to a file not visible and available on the target system
for external access, for example, by an OPC server.
Variables provided with that attribute will be downloaded to the controller even if
they have not been configured or are not visible within the symbol configuration
editor.
NOTE: The symbol configuration has to be available as an object below the
respective application in the Tools Tree.
Syntax
{attribute 'symbol' := 'none' | 'read' | 'write' | 'readwrite'}
Access is only allowed on symbols coming from programs or global variable lists.
For accessing a symbol, specify the symbol name completely.
You can assign the pragma definition to particular variables or collectively to all
variables declared in a program.
• To be valid for a single variable, place the pragma in the line before the
variable declaration.
EIO0000002854.04 525
Variables Declaration
Example
With the following configuration, the variables A and B will be exported with read
and write access. Variable D will be exported with read access.
{attribute 'symbol' := 'readwrite'}
PROGRAM PLC_PRG
VAR
A : INT;
B : INT;
{attribute 'symbol' := 'none'}
C : INT;
{attribute 'symbol' := 'read'}
D : INT;
END_VAR
Attribute to_string
Overview
The to_string attribute determines the output type of the result of an
enumeration component conversion with the TO_STRING operator. If the
enumeration declaration contains the pragma, the name of the enumeration
component is displayed as string instead of the numeric value.
Syntax
{attribute 'to_string'}
Insert Location
Insert the to_string attribute in the first line above the declaration part of the
enumeration.
Example
Declaration of the enumeration color:
{attribute 'to_string'}
TYPE color :
(
red := 0,
blue := 1,
green := 2
);
END_TYPE
Conversion with TO_STRING:
526 EIO0000002854.04
Variables Declaration
PROGRAM PLC_PRG
VAR
i_color: color;
s_show_color: STRING;
END_VAR
i_color := 1;
s_show_color := TO_STRING(i_color);
In this case, s_show_color displays the value ‘blue’ instead of 1 as the
conversion result.
Syntax
{warning disable <compiler ID>}
Compiler ID: Every advisory and every error detected by the compiler has a
unique ID, which is displayed at the beginning of the description.
Example
VAR
{warning disable C0195}
test1 : UINT := -1;
{warning restore C0195}
test2 : UINT := -1;
END_VAR
In this example, an advisory will be detected for test2. But no advisory will be
detected for test1.
EIO0000002854.04 527
Variables Declaration
Examples
The smart coding functionality offers components of structure:
528 EIO0000002854.04
Data Types
Data Types
What’s in This Chapter
General Information..................................................................................... 529
Standard Data Types ................................................................................... 529
Extensions to IEC Standard ......................................................................... 535
User-Defined Data Types............................................................................. 539
General Information
Data Types
Overview
You can use standard data types, page 529, user-defined data types, page 539, or
instances of function blocks when programming in EcoStruxure Machine Expert.
Each identifier is assigned to a data type. This data type dictates how much
memory space will be reserved and what type of values it stores.
BOOL
BOOL type variables can have the values TRUE (1) and FALSE (0). 8 bits of
memory space are reserved.
For further information, refer to the chapter BOOL constants, page 628.
NOTE: You can use implicit checks to validate the conversion of variable
types (refer to the chapter POUs for Implicit Checks, page 164).
EIO0000002854.04 529
Data Types
Integer
The table lists the available integer data types. Each of the types covers a different
range of values. The following range limitations apply.
NOTE: Conversions from larger types to smaller types may result in loss of
information.
For further information, refer to the description of number constants, page 632.
NOTE: You can use implicit checks to validate the conversion of variable
types (refer to the chapter POUs for Implicit Checks, page 164).
530 EIO0000002854.04
Data Types
REAL / LREAL
The data types REAL and LREAL are floating-point types. They represent rational
numbers.
Characteristics of REAL and LREAL data types:
Example:
PROGRAM PLC_PRG
VAR
rMax: REAL := 3.402823E+38; // Largest number
rPosMin : REAL := 1.0E-44; // Smallest positive number
rNegMax: REAL := -1.0E-44; // Largest negative number
rMin: REAL := -3.402823E+38; // Smallest number
lrMax: LREAL := 1.7976931348623158E+308; // Largest
number
lrPosMin : LREAL := 4.94065645841247E-324; // Smallest
positve number
lNegMax: LREAL := -4.94065645841247E-324; // Largest
negative number
lrMin: LREAL := -1.7976931348623158E+308; // Smallest
number
END_VAR
NOTE: The support of data type LREAL depends on the target device. See in
the corresponding documentation whether the 64-bit type LREAL gets
converted to REAL during compilation (possibly with a loss of information) or
persists.
NOTE: If a REAL or LREAL is converted to SINT, USINT, INT, UINT, DINT,
UDINT, LINT, or ULINT and the value of the real number is out of the value
range of that integer, the result will be undefined and will depend on the target
system. Even an exception is possible in this case. In order to get target-
independant code, handle any range exceedance by the application. If the
REAL/LREAL number is within the integer value range, the conversion will
work on all systems in the same way.
When assigning i1 := r1; an error is detected. Therefore, the previous note
applies when using conversion operators, page 588 such as the following:
i1 := REAL_TO_INT(r1);
For further information, refer to REAL/LREAL constants (operands), page 633.
NOTE: You can use implicit checks to validate the conversion of variable
types (refer to the chapter POUs for Implicit Checks, page 164).
EIO0000002854.04 531
Data Types
STRING
A STRING data type variable can contain any string of characters. The size entry
in the declaration determines the memory space to be reserved for the variable. It
refers to the number of characters in the string and can be placed in parentheses
or square brackets. If no size specification is given, the default size of 80
characters will be used.
In general, the length of a string is not limited. But string functions can only
process strings with a length of 1...255 characters. If a variable is initialized with a
string too long for the variable data type, the string will be correspondingly cut from
right to left.
NOTE: The memory space needed for a variable of type STRING is 1 byte per
character + 1 additional byte. This means, the “STRING[80]” declaration
needs 81 bytes.
Example of a string declaration with 35 characters:
str:STRING(35):='This is a String';
For further information, refer to WSTRING and STRING Constants (Operands),
page 633.
NOTE: You can use implicit checks to validate the conversion of variable
types (refer to the chapter POUs for Implicit Checks, page 164).
WSTRING
The WSTRING data type differs from the STRING type (ASCII) by interpretation in
Unicode format, and needing two bytes for each character and two bytes extra
memory space (each only one in case of a STRING).
The library standard64.lib provides functions for WSTRING strings.
The number of characters for WSTRING depends on the contained characters. A
size of 10 for WSTRING means that the length of the WSTRING can take a
maximum of 10 WORDS. For some characters in Unicode, multiple WORDS are
required for coding a character so that the number of characters does not have to
correspond to the length of the WSTRING (10 in this case). The data type requires
one WORD of extra memory as it is terminated with a 0.
If a size is not defined, then 80 WORDS plus one for the terminating character 0
are allocated.
Examples:
wstr:WSTRING:="This is a WString";
wstr10 : WSTRING(10) := "1234567890";
For further information, refer to the following descriptions:
• STRING, page 532
• STRING constants, page 633 (operands)
532 EIO0000002854.04
Data Types
EIO0000002854.04 533
Data Types
ANY / ANY_<type>
When you implement a function, and one of the function inputs (VAR_INPUT) has
a generic IEC data type (ANY or ANY_<type>), then the data type of the call
parameter is not defined as unique. Variables of different data types can be
passed to this function. The value passed and its type can be requested within the
function via a predefined structure.
Generic IEC data types that allow the use of elementary data types for function
inputs:
Example:
FUNCTION ANYBIT_TO_BCD : DWORD
VAR_INPUT
value : ANY_BIT;
END_VAR
If the function ANYBIT_TO_BCD is called, then a variable of data type BYTE,
WORD, DWORD, or LWORD can be passed to the function as a parameter.
Predefined structure:
When compiling the code, an ANY data type is replaced internally with the
following structure:
TYPE AnyType :
STRUCT
// the type of the actual parameter
typeclass : __SYSTEM.TYPE_CLASS ;
// the pointer to the actual parameter
pvalue : POINTER TO BYTE;
// the size of the data, to which the pointer points
diSize : DINT;
END_STRUCT
END_TYPE
The actual call parameter assigns the structure elements at runtime.
Example:
This code example compares whether the two passed variables have the same
type and the same value.
FUNCTION Generic_Compare : BOOL
VAR_INPUT
any1 : ANY;
any2 : ANY;
END_VAR
VAR
icount: DINT;
END_VAR
Generic_Compare := FALSE;
IF any1.typeclass <> any2.typeclass THEN
RETURN;
END_IF
IF any1.diSize <> any2.diSize THEN
RETURN;
END_IF
534 EIO0000002854.04
Data Types
// Byte comparison
FOR icount := 0 TO any1.diSize-1 DO
IF any1.pvalue[iCount] <> any2.pvalue[iCount] THEN
RETURN;
END_IF
END_FOR
Generic_Compare := TRUE;
RETURN;
// END_FUNCTION
Also refer to the description of the __VARINFO operator, page 618.
UNION
Overview
As an extension to the IEC 61131-3 standard, you can declare unions in user-
defined types.
The components of a union have the same offset. Therefore, they occupy the
same storage location. Thus, assuming a union definition as shown in the
following example, an assignment to name.a also manipulates name.b.
Example
TYPE name: UNION
a : LREAL;
b : LINT;
END_UNION
END_TYPE
BIT
Overview
You can use the BIT data type only for particular variables within structures, page
549 or in a function block, page 166. The possible values are TRUE (1) and
FALSE (0).
A BIT element consumes 1 bit of memory space and allows you to address single
bits of a structure by name (for further information, refer to the paragraph Bit
Access in Structures, page 550). Bit elements which are declared one after
another will be combined in bytes. In contrast to BOOL types, page 529, where 8
bits are reserved in any case, the use of memory space can get optimized. On the
other hand, the access to bits takes definitely more time. For that reason, use the
BIT data type if you want to store several boolean pieces of information in a
compact format.
EIO0000002854.04 535
Data Types
References
Overview
This data type is available in extension to the IEC 61131-3 standard.
A reference stores the address of an object (a variable) that is located elsewhere
in memory; in this respect, the behavior is identical to a pointer.
In contrast to a pointer, a variable behaves like an object when the syntax is
concerned. Additionally, variables declared as REFERENCE provide the following
advantages compared to POINTERS:
• A reference does not have to be dereferenced explicitly (with ^) to access the
contents of the referenced object.
• When passing values to input parameters of functions/function blocks/
methods, the following applies: If an input is declared as REFERENCE TO
<data type>, a variable of the corresponding <data type> can be passed
(refInput := variable instead of ptrInput :=ADR(variable)).
• The compiler verifies that references of the same data type are assigned to
each other.
For further information, refer to the Assignment operator REF description, page
311.
You can also use an implicit pointer monitoring function as described in the
paragraph CheckPointer function, page 538.
Syntax
<identifier> : REFERENCE TO <data type>
Example Declaration
A : REFERENCE TO DUT;
B : DUT;
C : DUT;
A REF= B; // corresponds to A := ADR(B);
A := C; // corresponds to A^ := C;
NOTE: It is not possible to declare references like REFERENCE TO
REFERENCE or ARRAY OF REFERENCE or POINTER TO REFERENCE.
536 EIO0000002854.04
Data Types
Pointers
Overview
As an extension to the IEC 61131-3 standard, you can use pointers.
Pointers save addresses while an application program is running. A pointer can
point to a variable of any data type, page 529 or to a function block instance. The
possibility of using an implicit pointer monitoring function is described further
below in the paragraph CheckPointer function, page 538.
Example
VAR
pt:POINTER TO INT; (* of pointer pt *)
var_int1:INT := 5; (* declaration of variables var_int1 and
var_int2 *)
var_int2:INT;
END_VAR
pt := ADR(var_int1); (* address of var_int1 is assigned to
pointer pt *)
var_int2:= pt^; (* value 5 of var_int1 gets assigned to
var_int2 via dereferencing of pointer pt; *)
In online mode, you can jump from a pointer to the declaration location of the
referenced variable by executing the Go To Reference command (see
EcoStruxure Machine Expert, Menu Commands, Online Help).
Function Pointers
EcoStruxure Machine Expert also supports function pointers. These pointers can
be passed to external libraries, but it is not possible to call a function pointer within
an application in the programming system. The runtime function for registration of
EIO0000002854.04 537
Data Types
callback functions (system library function) expects the function pointer, and,
depending on the callback for which the registration was requested, the respective
function will be called implicitly by the runtime system (for example, at STOP). In
order to enable such a system call (runtime system), set the respective properties
(by default under View > Properties... > Build) for the function object.
You can use the ADR operator, page 586 on function names, program names,
function block names, and method names. Since functions can move after online
change, the result is not the address of the function, but the address of a pointer to
the function. This address is valid as long as the function exists on the target.
Executing the Online Change command can change the contents of addresses.
CAUTION
INVALID POINTER
Verify the validity of the pointers when using pointers on addresses and
executing the Online Change command.
Failure to follow these instructions can result in injury or equipment
damage.
Subtracting Pointers
The result of the difference between two pointers is a value of type DWORD.
CheckPointer Function
To monitor pointer access during runtime, you can use the implicit monitoring
function CheckPointer. You can adapt it, if required. To achieve this, add the
POUs for implicit checks object, page 164 to the application. Activate the check
box related to the category Pointer Checks.
NOTE: You have to implement the CheckPointer function during machine
commissioning to verify whether the passed pointer refers to a valid memory
address and whether the alignment of the referenced memory area fits to the
data type of the variable that the pointer points to.
CheckPointer monitors variables of type REFERENCE TO in a similar way.
NOTE: There is no implicit call of the check function for the THIS pointer.
538 EIO0000002854.04
Data Types
Template:
Declaration part:
// Implicitly generated code : DO NOT EDIT
FUNCTION CheckPointer : POINTER TO BYTE
VAR_INPUT
ptToTest : POINTER TO BYTE;
iSize : DINT;
iGran : DINT;
bWrite: BOOL;
END_VAR
When called, the following input parameters are provided to the function:
• ptToTest: Target address of the pointer
• iSize: Size of referenced variable; the data type of iSize has to be integer-
compatible and has to cover the maximum potential data size stored at the
pointer address.
• iGran: Granularity of the access that is the largest non-structured data type
used in the referenced variable; the data type of iGran has to be integer-
compatible
• bWrite: Type of access (TRUE= write access, FALSE= read access); the
data type of bWrite has to be BOOL.
EIO0000002854.04 539
Data Types
You can define them via creating DUT (Data Unit Type) objects in the POUs tree
or Devices tree or within the declaration part of a POU.
See the Best practices for the Naming of Identifiers, page 463 in order to make it
as unique as possible.
See the following user-defined data types:
• arrays, page 540
• structures, page 549
• enumerations, page 550
• subrange types, page 552
• references, page 536
• pointers, page 537
Arrays
Overview
An array is a collection of data elements of the same data type. One- and multi-
dimensional arrays of fixed or variable length are supported. You can define
arrays both in the declaration part of a POU and in the global variable lists. You
can also use implicit boundary checks, page 542.
The data type ARRAY with variable length can only be declared for VAR_IN_OUT
variables of function blocks, methods, and functions. Use the operators LOWER_
BOUND(<array name>,<dim>) and UPPER_BOUND(<array name>,<dim>)
to get the lower and upper limits of this array.
540 EIO0000002854.04
Data Types
i, sum2 : DINT;
END_VAR
sum2:= 0;
FOR i:= LOWER_BOUND(A,1) TO UPPER_BOUND(A, 1) DO // The
length of the respective array is determined.
sum2:= sum2 + A[i];
END_FOR;
SUM:= sum2;
Initializing Arrays
Example for complete initialization of an array
arr1 : ARRAY [1..5] OF INT := [1,2,3,4,5];
arr2 : ARRAY [1..2,3..4] OF INT := [1,3(7)]; (* short for
1,7,7,7 *)
arr3 : ARRAY [1..2,2..3,3..4] OF INT := [2(0),4(4),2,3];
(* short for 0,0,4,4,4,4,2,3 *)
Example of the initialization of an array of a structure
Structure definition
TYPE STRUCT1
STRUCT
p1:int;
p2:int;
p3:dword;
END_STRUCT
END_TYPE
Array initialization
ARRAY[1..3] OF STRUCT1:= [(p1:=1,p2:=10,p3:=4723),(p1:=2,p2:
=0,p3:=299),(p1:=14,p2:=5,p3:=112)];
Example of the partial initialization of an array
arr1 : ARRAY [1..10] OF INT := [1,2];
Elements where no value is pre-assigned are initialized with the default initial
value of the basic type. In the previous example, the elements arr1[3]...arr1
[10] are therefore initialized with 0.
EIO0000002854.04 541
Data Types
lrIn := 11.22)];
END_VAR
542 EIO0000002854.04
Data Types
In this example, the implicit call to the CheckBounds function preceding the
assignment affects that the value of the index is changed from 10 into the upper
limit 7. Therefore, the value TRUE is assigned to the element a[7] of the array.
This is how you can correct attempted access outside the array range via the
function CheckBounds.
Vector
Overview
Vector operations are supported natively only on 64-bit processors and offer a
performance advantage only on these processors. Consult the data sheet of your
controller for information on the processor.
Vector operations on the x86/64-bit platforms with SSE2 and ARM64 with NEON
are supported natively. On other platforms, vector operations are divided into
individual statements. For example, vector addition is performed by executing
multiple single addition operations.
The command set extensions of the processors are SIMD (Single Instruction,
Multiple Data) extensions. SIMD describes a computer architecture in which
multiple data sets of the same type are processed simultaneously with one
command call. In vector operations, for example, it is possible to add four pairs of
numbers at the same time.
Syntax
<variable name> : __VECTOR[ <vector size> ] OF <element
type> ( := <initialization> )? ;
<vector size> : 1 |2 | 3 | 4 | 5| 6 | 7| 8
<element type> : REAL | LREAL
// (...)? : Optional
A vector data type is an array of floating-point numbers with a maximum of 8
elements. The operators __vc<operator name> are available for this data type.
They allow you to implement vector operations without additional function calls.
vcA[0] := 1.1;
vcA[1] := 2.2;
vcA[2] := 3.3;
EIO0000002854.04 543
Data Types
For target systems with computer architecture that is generally suitable for vector
processing, it is not a good practice to use vectors of arbitrary size. An optimal
vector size is available for each processor depending on the type of data
processing. The processing time of vectors of this size is optimized. There is no
advantage in speed for vectors that are declared as a larger array. Vectors that are
declared as smaller arrays do not fully exploit the capabilities of the processor.
You can query the optimal size at runtime by using the following constants of data
type INT:
• Constants.vcOptimalREAL: For vectors with REAL elements.
• Constants.vcOptimalLREAL: For vectors with LREAL elements.
A return value 1 means that the accelerated vector processing is not available for
the target system.
Example:
PROGRAM PLC_PRG
VAR
iOVS_REAL : INT; // Optimal vector size for REAL
elements
iOVS_LREAL : INT; // Optimal vector size for LREAL
elements
END_VAR
iOVS_REAL := Constants.vcOptimalREAL;
iOVS_LREAL := Constants.vcOptimalLREAL;
Operator __VCADD
The operator calculates the sum of two vectors.
Syntax:
<vector variable> := <1st vector operand> __VCADD <2nd
vector operand>;
Example of an add operation:
FUNCTION_BLOCK FB_ADD
VAR
vcA : __VECTOR[3] OF REAL := __VCSET_REAL(3, 3, 3);
vcB : __VECTOR[3] OF REAL := __VCSET_REAL(1, 2, 3);
vcResult : __VECTOR[3] OF REAL;
END_VAR
Operator __VCSUB
The operator calculates the difference between two vectors.
Syntax:
<vector variable> := <vector minuend> __VCSUB <vector
subtrahend>;
Example of a subtract operation:
FUNCTION_BLOCK FB_SUB
VAR
vcA : __VECTOR[3] OF REAL := __VCSET_REAL(3, 3, 3);
vcB : __VECTOR[3] OF REAL := __VCSET_REAL(1, 2, 3);
vcResult0 : __VECTOR[3] OF REAL;
vcResult1 : __VECTOR[3] OF REAL;
END_VAR
544 EIO0000002854.04
Data Types
Operator __VCMUL
The operator calculates the product of two vectors or of a scalar (floating-point
number) and a vector.
Syntax:
<vector variable> := <1st vector operand> __VCMUL <2nd
vector operand> | <scalar operand> __VCMUL <vector operand>
| <vector operand> __VCMUL <scalar operand>;
Example of a multiplication operation:
FUNCTION_BLOCK FB_MUL
VAR
rScalar : REAL := 1.1;
vcA : __VECTOR[3] OF REAL;
vcB : __VECTOR[3] OF REAL;
vcResult0 : __VECTOR[3] OF REAL;
vcResult1 : __VECTOR[3] OF REAL;
vcResult2 : __VECTOR[3] OF REAL;
END_VAR
Operator __VCDIV
The operator calculates the quotient of two vectors or of a vector and a scalar.
Syntax:
<vector variable> := <vector dividend> __VCDIV <vector
divisor> | <vector dividend> __VCMUL <scalar divisor>;
Example of a division operation:
FUNCTION_BLOCK FB_DIV
VAR
iScalar : INT := 3;
rScalar : REAL := 1.5;
vcA : __VECTOR[3] OF REAL := __VCSET_REAL(3, 3, 3);
vcB : __VECTOR[3] OF REAL := __VCSET_REAL(1, 2, 3);
vcResult0 : __VECTOR[3] OF REAL;
vcResult1 : __VECTOR[3] OF REAL;
vcResult2 : __VECTOR[3] OF REAL;
END_VAR
Operator __VCDOT
The operator calculates the dot product (scalar product) of two vectors.
Syntax:
<scalar variable> := <1st vector operand> __VCDOT <2nd
vector operand>;
Example of a dot product:
FUNCTION_BLOCK FB_DOT
VAR
rResult : REAL;
vcA : __VECTOR[3] OF REAL := __VCSET_REAL(3, 3, 3);
EIO0000002854.04 545
Data Types
Operator __VCSQRT
The operator calculates the square root of each element in the vector.
Syntax:
<vector variable> := __VCSQRT <vector operand>;
Example of a square root:
FUNCTION_BLOCK FB_SQRT
VAR
vcA : __VECTOR[3] OF REAL := __VCSET_REAL(4, 9, 16);
vcResult0 : __VECTOR[3] OF REAL;
END_VAR
vcResult0 := __VCSQRT(vcA);
Operator __VCMAX
The operator calculates the maximum vector of two vectors. The maximum is
determined element by element.
Syntax:
<vector variable> := __VCMAX <1st vector operand>, <2nd
vector operand>;
Example of a maximum vector:
FUNCTION_BLOCK FB_MAX
VAR
vcA : __VECTOR[3] OF REAL := __VCSET_REAL(3, 3, 3);
vcB : __VECTOR[3] OF REAL := __VCSET_REAL(1, 2, 6);
vcResult0 : __VECTOR[3] OF REAL;
END_VAR
Operator __VCMIN
The operator calculates the minimum vector of two vectors. The minimum is
determined element by element.
Syntax:
<vector variable> := __VCMIN <1st vector operand>, <2nd
vector operand>;
Example of a minimum vector:
FUNCTION_BLOCK FB_MIN
VAR
vcA : __VECTOR[3] OF REAL := __VCSET_REAL(3, 3, 3);
vcB : __VECTOR[3] OF REAL := __VCSET_REAL(1, 2, 6);
vcResult0 : __VECTOR[3] OF REAL;
END_VAR
Operator __VCSET_REAL
The operator sets the elements of a vector in a statement. The elements are of
data type REAL.
546 EIO0000002854.04
Data Types
Syntax:
<vector variable> __VCSET_REAL( <first literal>, ( < next
literal> )+ ) ;
( ... )+ // number of elements have to match
Example:
FUNCTION_BLOCK FB_SET
VAR
vcA : __VECTOR[3] OF REAL := __VCSET_REAL(3, 3, 3);
vcB : __VECTOR[3] OF REAL := __VCSET_REAL(1, 2, 3);
END_VAR
Operator __VCSET_LREAL
The operator sets the elements of a vector in a statement. The elements are of
data type LREAL.
You can use the operator wherever variables are valid, such as in assignments,
implementations or as parameters in function calls.
Syntax:
<vector variable> __VCSET_LREAL( <first literal>, ( < next
literal> )+ ) ;
( ... )+ // number of elements have to match
Example:
FUNCTION_BLOCK FB_SET
VAR
vclA : __VECTOR[3] OF LREAL := __VCSET_LREAL(3, 3,
3);
vclB : __VECTOR[3] OF LREAL := __VCSET_LREAL(1, 2,
3);
END_VAR
Operator __VCLOAD_REAL
The operator interprets each arbitrary memory area as a vector. This is useful for
connecting vector variables to existing code.
The operator requires two parameters:
• The first parameter indicates the number of vector elements.
• The second parameter is a pointer to the REAL data.
Syntax:
<vector variable> __VCLOAD_REAL( <vector size>, ( < pointer
to data of type REAL> ) ;
<vector size> : 2 | 3 | 4 | 5| 6 | 7| 8
Example of interpretation as vector:
FUNCTION_BLOCK FB_LOAD
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
rData0 : REAL := 1.234;
rData1: REAL := 5.678;
rData2 : REAL := 9.123;
EIO0000002854.04 547
Data Types
Operator __VCLOAD_LREAL
The operator interprets each arbitrary memory area as a vector. This is useful for
connecting vector variables to existing code.
The operator requires two parameters:
• The first parameter indicates the number of vector elements.
• The second parameter is a pointer to the LREAL data.
Syntax:
<vector variable> __VCLOAD_LREAL( <vector size>, ( < pointer
to data of type LREAL> ) ;
<number of vector elements> : 1 | 2 | 3 | 4 | 5| 6 | 7| 8
Example of interpretation as vector:
FUNCTION_BLOCK FB_LOAD
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
lrData0 : LREAL := -1.7976931348623158E+308;
lrData1: LREAL := 1.6E+308;
lrData2 : LREAL := 1.7E+308;
lrData3 : LREAL := -1.6E+308;
plData: POINTER TO LREAL := ADR(lrData0);
Operator __VCSTORE
The operator saves/copies the contents of the vector to the specified memory
address. The number and the types of elements from the vector variables are
applied.
Syntax:
__VCSTORE( <pointer to data>, <vector variable> );
Example of storage:
FUNCTION_BLOCK FB_STORE
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
rData0 : REAL := 3;
rData1: REAL := 3;
rData2 : REAL := 3;
pData: POINTER TO REAL := ADR(rData0);
lrData0 : LREAL := 4;
lrData1: LREAL := 4;
lrData2 : LREAL := 4;
lrData3 : LREAL := 4;
plData: POINTER TO LREAL := ADR(lrData0);
548 EIO0000002854.04
Data Types
__VCSTORE(pData, vcA);
__VCSTORE(plData, vclA);
Structures
Overview
Create structures in a project as DUT (Data Type Unit) objects via the Add Object
dialog box.
They begin with the keywords TYPE and STRUCT and end with END_STRUCT and
END_TYPE.
Syntax
TYPE <structurename>:
STRUCT
<declaration of variables 1>
...
<declaration of variables n>
END_STRUCT
END_TYPE
<structurename> is a type that is recognized throughout the project and can be
used like a standard data type.
Nested structures are allowed. The only restriction is that variables may not be
assigned to addresses (the AT declaration is not allowed).
Example
Example for a structure definition named Polygonline:
TYPE Polygonline:
STRUCT
Start:ARRAY [1..2] OF INT;
Point1:ARRAY [1..2] OF INT;
Point2:ARRAY [1..2] OF INT;
Point3:ARRAY [1..2] OF INT;
Point4:ARRAY [1..2] OF INT;
End:ARRAY [1..2] OF INT;
END_STRUCT
END_TYPE
Initialization of Structures
Example:
Poly_1:polygonline := ( Start:=[3,3], Point1:=[5,2], Point2:
=[7,3], Point3:=[8,5], Point4:=[5,7], End:= [3,5]);
Initializations with variables are not possible. For an example of the initialization of
an array of a structure, refer to Arrays, page 540.
EIO0000002854.04 549
Data Types
Enumerations
Overview
An enumeration is a user-defined type that is made up of a number of comma-
delimited string constants. These constants are referred to as enumeration values.
Enumeration values are identifiers for global constants in the project.
Enumeration values are recognized globally in all areas of the project even if they
are declared within a POU.
An enumeration is created in a project as a DUT object via the Add Object dialog
box.
NOTE: Local enumeration declaration is only possible within TYPE.
550 EIO0000002854.04
Data Types
Initialization
If... Then ...
• If you have not defined a <default The variable is initialized with the value of the
first enumeration component. This applies
value> in the declaration of the
enumeration (see following example), and unless a component is initialized with the value
0 in the enumeration declaration. In this case,
• If you have neither defined an explicit the variable is also initialized with the value 0.
initialization value for the declaration of
variables of the type <enum
identifier>
EIO0000002854.04 551
Data Types
Subrange Types
Overview
A subrange type is a user-defined type, page 539 whose range of values is only a
subset of that of the basic data type. You can also use implicit range boundary
checks, page 553.
You can do the declaration in a DUT object but you can also declare a variable
directly with a subrange type.
Syntax
Syntax for the declaration as a DUT object:
552 EIO0000002854.04
Data Types
<ug> a constant compatible with the basic type, setting the lower boundary of the
range types
<og> a constant compatible with the basic type, setting the upper boundary of the
range types.
Example
TYPE
SubInt : INT (-4095..4095);
END_TYPE
WARNING
UNINTENDED EQUIPMENT OPERATION
Do not change the declaration part of an implicit check function.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Example
The assignment of a variable belonging to a signed subrange type entails an
implicit call to CheckRangeSigned. The default implementation of that function
trimming a value to the permissible range is provided as follows:
Declaration part:
// Implicitly generated code : DO NOT EDIT
FUNCTION CheckRangeSigned : DINT
EIO0000002854.04 553
Data Types
VAR_INPUT
value, lower, upper: DINT;
END_VAR
Implementation part:
// Implicitly generated code : Only an Implementation
suggestion
IF (value < lower) THEN
CheckRangeSigned := lower;
ELSIF(value > upper) THEN
CheckRangeSigned := upper;
ELSE
CheckRangeSigned := value;
END_IF
When called, the function gets the following input parameters:
• value: the value to be assigned to the range type
• lower: the lower boundary of the range
• upper: the upper boundary of the range
As long as the assigned value is within the valid range, it will be used as return
value of the function. Otherwise, in correspondence to the range violation, either
the upper or the lower boundary of the range will be returned.
The assignment i:=10*y will now be replaced implicitly by
i := CheckRangeSigned(10*y, -4095, 4095);
If y, for example, has the value 1000, the variable i will not be assigned to
10*1000=10000 (as provided by the original implementation), but to the upper
boundary of the range that is 4095.
The same applies to function CheckRangeUnsigned.
NOTE: If neither of the functions is available, no type checking of subrange
types occurs during runtime. In this case, you can assign any DINT/UDINT
value to a variable of subrange type DINT/UDINT. You can assign any LINT/
ULINT value to a variable of a subrange type LINT/ULINT.
554 EIO0000002854.04
Programming Guidelines
Programming Guidelines
What’s in This Chapter
Naming Conventions ................................................................................... 555
Prefixes ...................................................................................................... 556
SmartTag Functions .................................................................................... 561
Naming Conventions
General Information
Creating Designator Names
Choose a relevant, short, description in English for each designator: the basis
name. The basis name should be self-explanatory. Capitalize the first letter of
each word in the basis name. Write the rest in lower case letters (example:
FileSize). This basis name receives prefixes to indicate scope and properties.
Whenever possible, the designator should not contain more than 20 characters.
This value is a guideline. You can adjust the number upward or downward if
necessary.
If abbreviations of standard terms (TP, JK-FlipFlop, ...) are used, the name should
not contain more than 3 capital letters in sequence.
Case-Sensitivity
Consider case-sensitivity, especially for prefixes, to improve readability when
using designators in the IEC program.
NOTE: The compiler is not case-sensitive.
Valid Characters
Use only the following letters, numbers and special characters in designators:
0...9, A...Z, a...z,
In order to be able to display the prefixes clearly, an underline is used as the
separator. The syntax is explained in the respective prefix section.
Do not use underscores in the basis name.
Examples
Correct Designator Incorrect Designators
diState diSTATE
xInit x_Init
diCycleCounter diCyclecounter
lrRefVelocity lrRef_Velocity
c_lrMaxPosition clrMaxPosition
FC_PidController FC_PIDController
EIO0000002854.04 555
Programming Guidelines
Prefixes
Prefix Parts
Overview
Prefixes are used to assign names by function.
The following parts of prefixes are available:
namespace prefix, page 560 for POUs, data types, variables, [namespace].[identifier] TPL.G_dwErrorCode
and constants declared within a
library
Order of Prefixes
Overview
Designators contain the scope prefix and the type prefix. Use the property prefix
according to the property of the variables (for example, for constants). An
additional namespace prefix is used for libraries.
Obligatory Order
The following order is obligatory:
scope][property][_][type][identifier]
Scope prefixes and property prefixes are separated from type prefixes by an
underscore (_).
Example
Gc_dwErrorCode : DWORD;
diCycleCounter : DINT;
The additional namespace prefix is used for libraries:
[namespace].[scope][property][_][type][identifier]
Example
ExampleLibrary.Gc_dwErrorCode
556 EIO0000002854.04
Programming Guidelines
FB_MotionCorrection
Use the additional namespace prefix for libraries:
[namespace].[POU][_][identifier]
Namespace prefixes are separated from POU prefixes by a dot (.).
Example
ExampleLibrary.FC_SetError()
Scope Prefix
Overview
The scope prefix indicates the scope of variables and constants. It indicates
whether it is a local or global variable, or a constant.
Global variables are indicated by a capital G_ and a property prefix c is added to
global constants (followed by an underscore in each case).
NOTE: Additionally identify the global variables and constants of libraries with
the namespace of the library.
Example
VAR_GLOBAL CONSTANT
Gc_dwExample : DWORD := 16#0000001A;
END_VAR
Access to the global variable of a library with the namespace INF:
INF.G_dwExample := 16#0000001A;
EIO0000002854.04 557
Programming Guidelines
The IEC 61131-3 standard data type prefixes as well as the prefixes for the
extensions to the standard are listed in the table.
Examples
piCounter: POINTER TO INT;
aiCounters: ARRAY [1..22] OF INT;
paiRefCounter: POINTER TO ARRAY [1..22] OF INT;
apstTest : ARRAY[1..2] OF POINTER TO ST_MotionStructure;
rdiCounter : REFERENCE TO DINT;
ifMotion : IF_Motion;
558 EIO0000002854.04
Programming Guidelines
Property Prefix
Overview
The property prefix identifies the properties of variables and constants.
ati_ AT %IX x.y AT %IB z AT %IW k input variable that should write ati_x0_0MasterEncoderInitOK
on the IEC input area
atq_ AT %QX x.y AT %QB z AT %QW k output variable that should write atq_w18AxisNotDone
on the IEC input area
atm_ AT %MX x.y AT %MB z AT %MW k marker variable that should write atm_w19ModuleNotReady
on the IEC marker area
NOTE:
• Do not declare constants as RETAIN or PERSISTENT.
• Do not declare any RETAIN variables within POUs. This administers the
complete POU in the retain memory area.
POU Prefix
Overview
The following program organization units (POU) are defined in IEC 61131-3:
• function
• function block
• program
• data structure
• list type
• union
• interface
EIO0000002854.04 559
Programming Guidelines
EcoStruxure Machine Expert offers additional POUs for the creation and
management of test cases:
• test case
• test series
• test resources
The designator is composed of a POU prefix and as short a name as possible (for
example, FB_GetResult). Just like a variable, use uppercase for the first letter of
each word in the name. Write the rest in lower case letters. Form a composite
POU name from a verb and a noun.
The prefix is written with an underscore before the name and identifies the type of
POU based on the table:
Namespace Prefix
Overview
You can view the namespace of a library in the Library Manager. Use a short
acronym (PacDriveLib -> PDL) as namespace. Do not change the default
namespace of a library.
To reserve an unambiguous namespace for your own, self-developed libraries,
contact your Schneider Electric responsible.
Example
A function FC_DoSomething() is located within the library TestlibraryA
(namespace TLA) as well as in TestlibraryB (namespace TLB). The respective
function is accessed by prefixing the namespace.
If both libraries are located within a project, the following call-up results in an error
detected during compilation:
FC_DoSomething();
In this case, it is necessary to define clearly which POU is to be called up.
TLA.FC_DoSomething();
TLB.FC_DoSomething();
560 EIO0000002854.04
Programming Guidelines
SmartTag Functions
SmartTag Function
Overview
The SmartTag function provides support in writing program code by suggesting
commands suitable at the programming element. If the cursor is placed on a
programming element with SmartTag function, the light bulb icon is displayed.
Click the icon to display a list of commands available for this programming
element.
Available smart tags:
• The declare variable command (see EcoStruxure Machine Expert, Menu
Commands, Online Help) is available for undeclared variables in the
implementation part of the ST editor.
EIO0000002854.04 561
Operators
Operators
What’s in This Chapter
Arithmetic Operators.................................................................................... 562
Bitstring Operators ...................................................................................... 571
Bit-Shift Operators....................................................................................... 574
Selection Operators..................................................................................... 578
Comparison Operators ................................................................................ 582
Address Operators ...................................................................................... 586
Calling Operator .......................................................................................... 588
Type Conversion Operators ......................................................................... 588
Numeric Functions ...................................................................................... 602
IEC Extending Operators ............................................................................. 608
Initialization Operator................................................................................... 623
Multicore Operators ..................................................................................... 623
Overview
EcoStruxure Machine Expert supports all IEC operators. In contrast to the
standard functions, these operators are recognized implicitly throughout the
project.
Besides the IEC operators, the following operators are supported which are not
specified by the standard:
• ANDN
• ORN
• XORN
• SIZEOF (refer to arithmetic operators, page 562)
• ADR
• BITADR
• content operator (refer to address operators, page 586
• some scope operators, page 621
• __CURRENTTASK
• __COMPARE_AND_SWAP
• __XADD
• __TEST_AND_SET
Arithmetic Operators
Overview
The following operators, specified by the IEC1131-3 standard, are available:
• ADD
• MUL
• SUB
• DIV
• MOD
• MOVE
Additionally, there is the following standard-extending operator:
• SIZEOF
562 EIO0000002854.04
Operators
WARNING
UNINTENDED EQUIPMENT OPERATION
Always verify the operands and results used in mathematical operations to
avoid arithmetic overflow.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
ADD
Overview
IEC operator for the addition of variables
Allowed types
• __UXINT
• __XINT
• __XWORD
• BYTE
• DATE
• DATE_AND_TIME
• DINT
• DT
• DWORD
• INT
• LDATE
• LDATE_AND_TIME
• LDT
• LINT
• LREAL
• LTIME
• LTOD
• LWORD
• REAL
• SINT
• TIME
• TIME_OF_DAY
• TOD
• UDINT
• UINT
• ULINT
• USINT
• WORD
For time data types, the following combinations are possible:
• TIME+TIME=TIME
EIO0000002854.04 563
Operators
• TIME+LTIME=LTIME
• LTIME+LTIME=LTIME
For date and time data types, the following combinations are possible:
• TOD+TIME=TOD
• DT+TIME=DT
• TOD+LTIME=LTOD
• DT+LTIME=LDT
• LTOD+TIME=LTOD
• LDT+LTIME=LDT
• LTOD+LTIME=LTOD
• LDT+LTIME=LDT
In the FBD/LD editor, the ADD operator is an extensible box. This means, instead
of a series of concatenated ADD boxes, you can use 1 box with multiple inputs.
Use the command Insert Input for adding further inputs. The number is unlimited.
Example in IL
LD 7
ADD 2
ADD 4
ADD 7
ST iVar
Example in ST
var1 := 7+2+4+7;
Examples in FBD
564 EIO0000002854.04
Operators
MUL
Overview
IEC operator for the multiplication of variables
Allowed types
• BYTE
• WORD
• DWORD
• LWORD
• SINT
• USINT
• INT
• UINT
• DINT
• UDINT
• LINT
• ULINT
• REAL
• LREAL
• TIME
TIME variables can be multiplied with integer variables.
In the FBD/LD editor, the MUL operator is an extensible box. This means, instead
of a series of concatenated MUL boxes, you can use 1 box with multiple inputs.
Use the command Insert Input for adding further inputs. The number is unlimited.
Example in IL
LD 7
MUL 2 ,
4 ,
7
ST Var1
Example in ST
var1 := 7*2*4*7;
EIO0000002854.04 565
Operators
Examples in FBD
SUB
Overview
IEC operator for the subtraction of one variable from another one.
Allowed types:
• BYTE
• WORD
• DWORD
• LWORD
• SINT
• USINT
• INT
• UINT
• DINT
• UDINT
• LINT
• ULINT
• REAL
• LREAL
• TIME
• LTIME
• TIME_OF_DAY(TOD)
• LTIME_OF_DAY(LTOD)
• DATE
• LDATE
• DATE_AND_TIME(DT)
• LDATE_AND_TIME(LDT)
For time data types, the following combinations are possible:
566 EIO0000002854.04
Operators
• TIME–TIME=TIME
• LTIME–LTIME=LTIME
For date and time data types, the following combinations are possible:
• DATE–DATE=TIME
• LDATE–LDATE=LTIME
• TOD–TIME=TOD
• LTOD–TIME=LTOD
• TOD–TOD=TIME
• LTOD–LTOD=LTIME
• DT-TIME=DT
• LDT-LTIME=LDT
• DT-DT=TIME
• LDT–LDT=LTIME
Consider that negative TIME / LTIME values are undefined.
Example in IL
LD 7
SUB 2
ST Var1
Example in ST
var1 := 7-2;
Example in FBD
DIV
Overview
IEC operator for the division of one variable by another one:
Allowed types:
• BYTE
• WORD
• DWORD
• LWORD
• SINT
• USINT
• INT
• UINT
• DINT
• UDINT
EIO0000002854.04 567
Operators
• LINT
• ULINT
• REAL
• LREAL
• TIME
TIME variables can be divided by integer variables.
Example in IL
(Result in Var1 is 4.)
LD 8
DIV 2
ST Var1
Example in ST
var1 := 8/2;
Examples in FBD
WARNING
UNINTENDED EQUIPMENT OPERATION
Use the check functions described in this document, or write your own checks to
avoid division by zero in the programming code.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
NOTE: For more information about the implicit check functions, refer to the
chapter POUs for Implicit Checks, page 164.
Check Functions
You can use the following check functions to verify the value of the divisor in order
to avoid a division by 0 and adapt them, if necessary:
568 EIO0000002854.04
Operators
• CheckDivDInt
• CheckDivLint
• CheckDivReal
• CheckDivLReal
For information on inserting the function, refer to the description of the POUs for
implicit checks function, page 164.
The check functions are called automatically before each division found in the
application code.
See the following example for an implementation of the function CheckDivReal.
MOD
Overview
IEC operator for the modulo division of one variable by another one.
Allowed types:
• BYTE
• WORD
• DWORD
• LWORD
• SINT
• USINT
• INT
• UINT
• DINT
• UDINT
EIO0000002854.04 569
Operators
• LINT
• ULINT
The result of this function is the integer remainder of the division.
Different target systems may behave differently concerning a division by zero
error. It can lead to a controller HALT, or may go undetected.
WARNING
UNINTENDED EQUIPMENT OPERATION
Use the check functions described in this document, or write your own checks to
avoid division by zero in the programming code.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
NOTE: For more information about the implicit check functions, refer to the
chapter POUs for Implicit Checks, page 164.
Example in IL
Result in Var1 is 1.
LD 9
MOD 2
ST Var1
Example in ST
var1 := 9 MOD 2;
Examples in FBD
MOVE
Overview
IEC operator for the assignment of a variable to another variable of an appropriate
data type.
The MOVE operator is possible for all data types.
As MOVE is available as a box in the graphic editors FBD, LD, CFC, there the
(unlocking) EN/ENO functionality can also be applied on a variable assignment.
570 EIO0000002854.04
Operators
Example in IL
Result: var2 gets value of var1
LD var1
MOVE
ST var2
You get the same result with
LD var1
ST var2
Example in ST
ivar2 := MOVE(ivar1);
You get the same result with
ivar2 := ivar1;
SIZEOF
Overview
This arithmetic operator is not specified by the standard IEC 61131-3.
You can use it to determine the number of bytes required by the given variable x.
The SIZEOF operator returns an unsigned value. The type of the return value will
be adapted to the found size of variable x.
Return Value of SIZEOF(x) Data Type of the Constant Implicitly Used for
the Found Size
0 ≤ size of x < 256 USINT
256 ≤ size of x < 65,536 UINT
Example in ST
var1 := SIZEOF(arr1); (* d.h.: var1:=USINT#10; *)
Example in IL
Result is 10
arr1:ARRAY[0..4] OF INT;
Var1:INT;
LD arr1
SIZEOF
ST Var1
Bitstring Operators
Overview
The following bitstring operators are available, matching the IEC1131-3 standard:
EIO0000002854.04 571
Operators
AND
Overview
IEC bitstring operator for bitwise AND of bit operands.
If the input bits each are 1, then the resulting bit will be 1, otherwise 0.
Allowed types:
• BOOL
• BYTE
• WORD
• DWORD
• LWORD
Example in IL
Result in Var1 is 2#1000_0010.
Var1:BYTE;
LD 2#1001_0011
AND 2#1000_1010
ST var1
Example in ST
var1 := 2#1001_0011 AND 2#1000_1010
Example in FBD
OR
Overview
IEC bitstring operator for bitwise OR of bit operands.
If at least 1 of the input bits is 1, the resulting bit will be 1, otherwise 0.
572 EIO0000002854.04
Operators
Allowed types:
• BOOL
• BYTE
• WORD
• DWORD
• LWORD
Example in IL
Result in var1 is 2#1001_1011.
var1:BYTE;
LD 2#1001_0011
OR 2#1000_1010
ST Var1
Example in ST
Var1 := 2#1001_0011 OR 2#1000_1010
Example in FBD
XOR
Overview
IEC bitstring operator for bitwise XOR of bit operands.
If only 1 of the input bits is 1, then the resulting bit will be 1; if both or none are 1,
the resulting bit will be 0.
Allowed types:
• BOOL
• BYTE
• WORD
• DWORD
• LWORD
NOTE: XOR allows adding additional inputs. If more than 2 inputs are
available, then an XOR operation is performed on the first 2 inputs. The result,
in turn, will be XOR combined with input 3, and so on. This has the effect that
an odd number of inputs will lead to a resulting bit = 1.
Example in IL
Result is 2#0001_1001.
Var1:BYTE;
LD 2#1001_0011
XOR 2#1000_1010
ST var1
EIO0000002854.04 573
Operators
Example in ST
Var1 := 2#1001_0011 XOR 2#1000_1010
Example in FBD
NOT
Overview
IEC bitstring operator for bitwise NOT operation of a bit operand.
The resulting bit will be 1 if the corresponding input bit is 0 and vice versa.
Allowed types
• BOOL
• BYTE
• WORD
• DWORD
• LWORD
Example in IL
Result in Var1 is 2#0110_1100.
Var1:BYTE;
LD 2#1001_0011
NOT
ST var1
Example in ST
Var1 := NOT 2#1001_0011
Example in FBD
Bit-Shift Operators
SHL
Overview
IEC operator for bitwise left-shift of an operand.
574 EIO0000002854.04
Operators
Examples
See in the following example in hexadecimal notation the different results for erg_
byte and erg_word. The result depends on the data type of the input variable
(BYTE or WORD), although the values of the input variables in_byte and in_
word are the same.
Example in ST
PROGRAM shl_st
VAR
in_byte : BYTE:=16#45; (* 2#01000101 )
in_word : WORD:=16#0045; (* 2#0000000001000101 )
erg_byte : BYTE;
erg_word : WORD;
n: BYTE :=2;
END_VAR
erg_byte:=SHL(in_byte,n); (* Result is 16#14, 2#00010100 *)
erg_word:=SHL(in_word,n); (* Result is 16#0114,
2#0000000100010100 *)
Example in FBD
Example in IL
LD in_byte
SHL 2
ST erg_byte
SHR
Overview
IEC operator for bitwise right-shift of an operand.
erg:= SHR (in, n)
in: operand to be shifted to the right
n: number of bits, by which in gets shifted to the right
EIO0000002854.04 575
Operators
NOTE: If n exceeds the data type width, it depends on the target system how
BYTE, WORD, DWORD and LWORD operands will be filled. Some cause
filling with zeros (0), others with n MOD <register width>.
Examples
The following example in hexadecimal notation shows the results of the arithmetic
operation depending on the type of the input variable (BYTE or WORD).
Example in ST
PROGRAM shr_st
VAR
in_byte : BYTE:=16#45; (* 2#01000101 )
in_word : WORD:=16#0045; (* 2#0000000001000101 )
erg_byte : BYTE;
erg_word : WORD;
n: BYTE :=2;
END_VAR
erg_byte:=SHR(in_byte,n); (* Result is 16#11, 2#00010001 *)
erg_word:=SHR(in_word,n); (* Result is 16#0011,
2#0000000000010001 *)
Example in FBD
Example in IL
LD in_byte
SHR 2
ST erg_byte
ROL
Overview
IEC operator for bitwise rotation of an operand to the left.
erg:= ROL (in, n)
Allowed data types
• BYTE
• WORD
• DWORD
• LWORD
in will be shifted 1 bit position to the left n times while the bit that is furthest to the
left will be reinserted from the right
NOTE: The amount of bits which is considered for the arithmetic operation
depends on the data type of the input variable. If the input variable is a
constant, the smallest possible data type is considered. The data type of the
output variable has no effect at all on the arithmetic operation.
576 EIO0000002854.04
Operators
Examples
See in the following example in hexadecimal notation the different results for erg_
byte and erg_word. The result depends on the data type of the input variable
(BYTE or WORD), although the values of the input variables in_byte and in_
word are the same.
Example in ST
PROGRAM rol_st
VAR
in_byte : BYTE:=16#45;
in_word : WORD:=16#45;
erg_byte : BYTE;
erg_word : WORD;
n: BYTE :=2;
END_VAR
erg_byte:=ROL(in_byte,n); (* Result is 16#15 *)
erg_word:=ROL(in_word,n); (* Result is 16#0114 *)
Example in FBD
Example in IL
LD in_byte
ROL n
ST erg_byte
ROR
Overview
IEC operator for bitwise rotation of an operand to the right.
erg:= ROR (in, n)
Allowed data types
• BYTE
• WORD
• DWORD
• LWORD
in will be shifted 1 bit position to the right n times while the bit that is furthest to
the left will be reinserted from the left.
NOTE: The amount of bits which are taken into account for the arithmetic
operation depends on the data type of the input variable. If the input variable is
a constant, the smallest possible data type is taken into account. The data
type of the output variable has no effect at all on the arithmetic operation.
EIO0000002854.04 577
Operators
Examples
See in the following example in hexadecimal notation the different results for erg_
byte and erg_word. The result depends on the data type of the input variable
(BYTE or WORD), although the values of the input variables in_byte and in_
word are the same.
Example in ST
PROGRAM ror_st
VAR
in_byte : BYTE:=16#45;
in_word : WORD:=16#45;
erg_byte : BYTE;
erg_word : WORD;
n: BYTE :=2;
END_VAR
erg_byte:=ROR(in_byte,n); (* Result is 16#51 *)
erg_word:=ROR(in_word,n); (* Result is 16#4011 *)
Example in FBD
Example in IL
LD in_byte
ROR n
ST erg_byte
Selection Operators
Overview
Selection operations can also be performed with variables.
For purposes of clarity the examples provided in this document are limited to the
following which use constants as operators:
• SEL, page 578
• MAX, page 580
• MIN, page 580
• LIMIT, page 581
• MUX, page 581
SEL
Overview
IEC selection operator for binary selection.
G determines whether IN0 or IN1 is assigned to OUT.
578 EIO0000002854.04
Operators
Example in IL
LD TRUE
SEL 3,4 (* IN0 = 3, IN1 =4 *)
ST Var1 (* result is 4 *)
LD FALSE
SEL 3,4
ST Var1 (* result is 3 *)
Example in ST
Var1:=SEL(TRUE,3,4); (* result is 4 *)
Example in FBD
Note
NOTE: When G is TRUE, EcoStruxure Machine Expert does not compute a
textual expression that precedes IN0.
When G is FALSE, EcoStruxure Machine Expert does not compute a textual
expression that precedes IN1.
In graphical programming languages, where a Box, Jump, Return, Line
Branch, or Edge Detection is connected to IN0 or IN1, these statements will
always be computed, independently of the input G. This may have an impact
on the amount of executed code and thus on the performance. Verify your
code carefully to see whether the expressions connected to the inputs IN0
and IN1 should always be executed or only depending on the input G.
Example 1: MyFunc is directly connected to the input IN1. MyFunc is only
executed if bSelect at the input G is FALSE:
EIO0000002854.04 579
Operators
Example 2: MyFunc is connected via a link to the input IN1. MyFunc is always executed (regardless whether
bSelect at the input G is FALSE or TRUE):
MAX
Overview
IEC selection operator performing a maximum function.
The MAX operator returns the greater of the 2 values.
OUT := MAX(IN0, IN1)
IN0, IN1 and OUT can be any type of variable.
Example in IL
Result is 90
LD 90
MAX 30
MAX 40
MAX 77
ST Var1
Example in ST
Var1:=MAX(30,40); (* Result is 40 *)
Var1:=MAX(40,MAX(90,30)); (* Result is 90 *)
Example in FBD
MIN
Overview
IEC selection operator performing a minimum function.
The MIN operator returns the lesser of the 2 values.
OUT := MIN(IN0, IN1)
IN0, IN1 and OUT can be any type of variable.
Example in IL
Result is 30
580 EIO0000002854.04
Operators
LD 90
MIN 30
MIN 40
MIN 77
ST Var1
Example in ST
Var1:=MIN(90,30); (* Result is 30 *);
Var1:=MIN(MIN(90,30),40); (* Result is 30 *);
Example in FBD
LIMIT
Overview
IEC selection operator performing a limiting function.
OUT := LIMIT(Min, IN, Max) means:
OUT := MIN (MAX (IN, Min), Max)
Max is the upper and Min the lower limit for the result. Should the value IN exceed
the upper limit Max, LIMIT will return Max. Should IN fall below Min, the result
will be Min.
IN and OUT can be any type of variable.
Example in IL
Result is 80
LD 90
LIMIT 30 ,
80
ST Var1
Example in ST
Var1:=LIMIT(30,90,80); (* Result is 80 *);
MUX
Overview
IEC selection operator for multiplexing operation.
OUT := MUX(K, IN0,...,INn)) means:
OUT := INk
IN0, ...,INn and OUT can be any identical data type. Make sure that variables
of the identical data type are used at these positions, especially when using user-
defined data types. The compiler verifies the identity of the types and returns
EIO0000002854.04 581
Operators
Example in IL
Result is 30
LD 0
MUX 30 ,
40 ,
50 ,
60 ,
70 ,
80
ST Var1
Example in ST
Var1:=MUX(0,30,40,50,60,70,80); (* Result is 30 *);
NOTE: A textual expression occurring ahead of an input other than INk will
not be processed.
In graphical programming languages, where a Box, Jump, Return, Line
Branch, or Edge Detection is connected to IN0 or INn, these statements will
always be computed, independently of the input K. This may have an impact
on the amount of executed code and thus on the performance. Verify your
code carefully to see whether the expressions connected to the inputs IN0,
INn should always be executed or only depending on the input K.
For an example illustrating this issue, refer to the SEL operator, page 579.
Comparison Operators
Overview
The following operators matching the IEC1131-3 standard are available:
• GT, page 582
• LT, page 583
• LE, page 583
• GE, page 584
• EQ, page 585
• NE, page 585
GT
Overview
Comparison operator performing a Greater Than function.
The GT operator is a boolean operator which returns the value TRUE when the
value of the first operand is greater than that of the second.
The operands can be of any basic data type.
582 EIO0000002854.04
Operators
Example in IL
Result is FALSE
LD 20
GT 30
ST Var1
Example in ST
VAR1 := 20 > 30;
Example in FBD
LT
Overview
Comparison operator performing a Less Than function.
The LT operator is a boolean operator which returns the value TRUE when the
value of the first operand is less than that of the second.
The operands can be of any basic data type.
Example in IL
Result is TRUE
LD 20
LT 30
ST Var1
Example in ST
VAR1 := 20 < 30;
Example in FBD
LE
Overview
Comparison operator performing a Less Than Or Equal To function.
EIO0000002854.04 583
Operators
The LE operator is a boolean operator which returns the value TRUE when the
value of the first operand is less than or equal to that of the second.
The operands can be of any basic data type.
Example in IL
Result is TRUE
LD 20
LE 30
ST Var1
Example in ST
VAR1 := 20 <= 30;
Example in FBD
GE
Overview
Comparison operator performing a Greater Than Or Equal To function.
The GE operator is a boolean operator which returns the value TRUE when the
value of the first operand is greater than or equal to that of the second.
The operands can be of any basic data type.
Example in IL
Result is TRUE
LD 60
GE 40
ST Var1
Example in ST
VAR1 := 60 >= 40;
Example in FBD
584 EIO0000002854.04
Operators
EQ
Overview
Comparison operator performing an Equal To function.
The EQ operator is a boolean operator which returns the value TRUE when the
operands are equal.
The operands can be of any basic data type.
Example in IL
Result is TRUE
LD 40
EQ 40
ST Var1
Example in ST
VAR1 := 40 = 40;
Example in FBD
NE
Overview
Comparison operator performing a Not Equal To function.
The NE operator is a boolean operator which returns the value TRUE when the
operands are not equal.
The operands can be of any basic data type.
Example in IL
LD 40
NE 40
ST Var1
Example in ST
VAR1 := 40 <> 40;
EIO0000002854.04 585
Operators
Example in FBD
Address Operators
ADR
Overview
This address operator is not specified by the standard IEC 61131-3.
ADR returns the address, page 637 of its argument in a DWORD. This address
can be assigned to a pointer, page 537 within the project.
NOTE: EcoStruxure Machine Expert allows you to use the ADR operator with
function names, program names, function block names, and method names.
Refer to the chapter Pointers, page 537 and consider that function pointers can be
passed to external libraries. Nevertheless, there is no possibility to call a function
pointer within EcoStruxure Machine Expert. In order to enable a system call
(runtime system), set the respective object property (in the menu View >
Properties... > Build) for the function object.
Example in ST
dwVar:=ADR(bVAR);
Example in IL
LD bVar
ADR
ST dwVar
WARNING
UNINTENDED EQUIPMENT OPERATION
Assign the value of any POINTER TO type variable(s) prior to the first use of it
within a POU, and at every subsequent cycle.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
586 EIO0000002854.04
Operators
Content Operator
Overview
This address operator is not specified by the standard IEC 61131-3. You can
dereference a pointer by adding the content operator ^ (ASCII caret or circumflex
symbol) after the pointer identifier.
Example in ST
pt:POINTER TO INT;
var_int1:INT;
var_int2:INT;
pt := ADR(var_int1);
var_int2:=pt^;
CAUTION
INVALID POINTER
Verify the validity of the pointers when using pointers on addresses and
executing the Online Change command.
Failure to follow these instructions can result in injury or equipment
damage.
BITADR
Overview
This address operator is not specified by the standard IEC 61131-3.
BITADR returns the bit offset within the segment in a DWORD. The offset value
depends on whether the option Byte addressing in the target settings is activated
or not.
The highest nibble in that DWORD indicates the memory area:
Memory: 16#40000000
Input: 16#80000000
Output: 16#C0000000
Example in ST
VAR
xVar AT %IX2.3:BOOL;
dwBitoffset: DWORD;
END_VAR
dwBitoffset:=BITADR(xVar); (* Result if byte addressing=
TRUE: 16#80000013, if byte addressing=FALSE: 16#80000023 *)
EIO0000002854.04 587
Operators
Example in IL
LD xVar
BITADR
ST dwBitoffset
CAUTION
INVALID POINTER
Verify the validity of the pointers when using pointers on addresses and
executing the Online Change command.
Failure to follow these instructions can result in injury or equipment
damage.
Calling Operator
CAL
Overview
IEC operator for calling a function block or a program.
Use CAL in IL to call up a function block instance. Place the variables that will
serve as the input variables in parentheses right after the name of the function
block instance.
Example
Calling up the instance Inst of a function block where input variables Par1 and
Par2 are 0 and TRUE, respectively.
CAL INST(PAR1 := 0, PAR2 := TRUE)
Syntax
Typed conversion: <elem.type1>_TO_<elem.type2>
Overloaded conversion: TO_<elem.type2>
588 EIO0000002854.04
Operators
If the operand value for a type conversion operator is outside the value range of
the target data type, the result output depends on the controller processor type
and is therefore undefined. This is the case, for example, when a negative
operand value is converted from LREAL to the target data type UINT.
NOTICE
UNDEFINED OUTPUT
Verify that the values of the target data type are within the expected range after
type conversion.
Failure to follow these instructions can result in equipment damage.
When converting the data type to STRING or WSTRING, the typed value is left-
aligned as a character string and truncated if it exceeds the length of the target
string variable.
NOTICE
STRING MANIPULATION
Declare a return variable of sufficient size for the type conversion operators
<>_TO_STRING and <>_TO_WSTRING.
Failure to follow these instructions can result in equipment damage.
Overloaded Conversions
General Information
For general hints to be considered during type conversion, refer to the chapter
Type Conversion Functions, page 588.
NOTE: Conversions from larger data types to smaller types may result in loss
of information.
Overloaded conversions are not specified by the standard {(notrans) IEC 61131-
3}. To comply with the standard, use the operators of the syntax <type> _TO_
<another type> as described in this chapter.
The rules for typed conversions also apply to overloaded conversions.
EIO0000002854.04 589
Operators
Definition
In overloaded conversions, the operators convert values into other data types,
explicitly specifying only a target data type and no source data type (data type of
the operands).
Syntax
<variable name> := <TO operator> ( <operand> );
<operand> = <variable name> | <literal>
Examples in ST
VAR
iNumber_1 : INT;
rNumber_2 : REAL := 123.456;
iNumber_2 : INT;
xIsTrue : BOOL;
sOutputText : STRING;
sText : STRING := 'Hello World!';
wsText: WSTRING;
dateEvent : DATE := D#2019-9-3;
uiEvent : UINT;
uxiData : __UXINT;
END_VAR
Examples in ST with conversion results:
Example Result
iNumber_1 := TO_INT(4.22); 4
BOOL_TO Conversions
General Information
For general hints to be considered during type conversion, refer to the chapter
Type Conversion Functions, page 588.
Definition
IEC operator for conversions from type BOOL to any other type.
Syntax
BOOL_TO_<data type>
590 EIO0000002854.04
Operators
Conversion Results
The conversion results for number types and for string types depend on the state
of the operand:
Operand State Result for Number Types Result for String Types
TRUE 1 TRUE
FALSE 0 FALSE
NOTE: The operators that convert a value into a character string of type
STRING or WSTRING require an operand that matches the target data type.
Examples in ST
Examples in ST with conversion results:
Example Result
i:=BOOL_TO_INT(TRUE); 1
str:=BOOL_TO_STRING(TRUE); 'TRUE'
t:=BOOL_TO_TIME(TRUE); T#1ms
tof:=BOOL_TO_TOD(TRUE); TOD#00:00:00.001
dat:=BOOL_TO_DATE(FALSE); D#1970
dandt:=BOOL_TO_DT(TRUE); DT#1970-01-01-00:00:01
Examples in IL
Examples in IL with conversion results:
Example Result
LD TRUE 1
BOOL_TO_INT
ST i
LD TRUE 'TRUE'
BOOL_TO_STRI...
ST str
LD TRUE T#1ms
BOOL_TO_TIME
ST t
LD TRUE TOD#00:00:00.001
BOOL_TO_TOD
ST tof
LD FALSE D#1970-01-01
BOOL_TO_DATE
ST dandt
LD TRUE DT#1970-01-01-00:00:01
BOOL_TO_DT
ST dandt
Examples in FBD
Examples in FBD with conversion results:
EIO0000002854.04 591
Operators
Example Result
'TRUE'
T#1ms
TOD#00:00:00.001
D#1970-01-01
DT#1970-01-01-00:00:01
TO_BOOL Conversions
General Information
For general hints to be considered during type conversion, refer to the chapter
Type Conversion Functions, page 588.
Definition
IEC operator for conversions from another variable type to BOOL.
Syntax
<data type>_TO_BOOL
Conversion Results
The result is TRUE when the operand is not equal to 0. The result is FALSE when
the operand is equal to 0.
The result is TRUE for STRING type variables when the operand is TRUE.
Otherwise the result is FALSE.
Examples in ST
Examples in ST with conversion results:
592 EIO0000002854.04
Operators
Example Result
b := BYTE_TO_BOOL(2#11010101); TRUE
b := INT_TO_BOOL(0); FALSE
b := TIME_TO_BOOL(T#5ms); TRUE
b := STRING_TO_BOOL('TRUE'); TRUE
Examples in IL
Examples in IL with conversion results:
Example Result
LD 213 TRUE
BYTE_TO_BOOL
ST b
LD 0 FALSE
INT_TO_BOOL
ST b
LD T#5ms TRUE
TIME_TO_BOOL
ST b
LD 'TRUE' TRUE
STRING_TO_BOOL
ST b
Examples in FBD
Examples in FBD with conversion results:
Example Result
TRUE
FALSE
TRUE
TRUE
EIO0000002854.04 593
Operators
Definition
Conversion from an integral number type to another number type.
Syntax
<INT data type>_TO_<INT data type>
For information on the integer data type, refer to the chapter Standard Data Types,
page 530.
Conversion Results
If the number you are converting exceeds the range limit, the first bytes for the
number will be ignored.
Example in ST
si := INT_TO_SINT(4223); (* Result is 127 *)
If you save the integer 4223 (16#107f represented hexadecimally) as a SINT
variable, it will appear as 127 (16#7f represented hexadecimally).
Example in IL
LD 4223
INT_TO_SINT
ST si
Example in FBD
Definition
IEC operator for conversions from the variable type REAL or LREAL to a different
type.
The value will be rounded up or down to the nearest whole number and converted
into the new variable type.
Exceptions to this are the following variable types:
• STRING
• BOOL
• REAL
594 EIO0000002854.04
Operators
• LREAL
NOTE: The rounding logic that is applied depends on the target system or the
FPU (Floating Point unit) of the target system. A value of -1.5 can thus be
converted differently on different controllers.
Conversion Results
If a REAL or LREAL is converted to SINT, USINT, INT, UINT, DINT, UDINT, LINT
or ULINT and the value of the real number is out of the value range of that integer,
the result will be undefined, and may lead to a controller exception.
NOTE: Validate any range overflows by your application and verify that the
value of the REAL or LREAL is within the bounds of the target integer before
performing the conversion.
When converting to type STRING, consider that the total number of digits is
limited to six. If the (L)REAL number has more digits, then the sixth will be
rounded. If the length of the STRING is defined too short, it will be cut from the
right end.
Example in ST
Examples in ST with conversion results:
Example Result
i := REAL_TO_INT(1.5); 2
j := REAL_TO_INT(1.4); 1
i := REAL_TO_INT(-1.5); –2
j := REAL_TO_INT(-1.4); –1
Example in IL
LD 2.75
REAL_TO_INT
ST i
Example in FBD
TIME_TO/TIME_OF_DAY Conversions
General Information
For general hints to be considered during type conversion, refer to the chapter
Type Conversion Functions, page 588.
Definition
IEC operator for conversions from the variable type TIME or TIME_OF_DAY to a
different type.
EIO0000002854.04 595
Operators
Syntax
TIME_TO_<data type>
TOD_TO_<data type>
Conversion Results
The time will be stored internally in a DWORD in milliseconds (beginning with
12:00 A.M. for the TIME_OF_DAY variable). This value will then be converted.
In case of type STRING the result is a time constant.
NOTE: The operators that convert a value into a character string of type
STRING or WSTRING require an operand that matches the target data type.
Examples in ST
Examples in ST with conversion results:
Example Result
dw := TIME_TO_DWORD(T#5m); 300000
si := TOD_TO_SINT(TOD#00:00:00.012); 12
Examples in IL
Examples in IL with conversion results:
Example Result
LD T#12ms 'T#12ms'
TIME_TO_STRI...
ST str
LD T#300000ms 300000
TIME_TO_DWORD
ST dw
LD TOD#00:00:00.012 12
TIME_TO_SINT
ST si
Examples in FBD
596 EIO0000002854.04
Operators
DATE_TO/DT_TO Conversions
General Information
For general hints to be considered during type conversion, refer to the chapter
Type Conversion Functions, page 588.
Definition
IEC operator for conversions from the variable type DATE or DATE_AND_TIME to
a different type.
Syntax
DATE_TO_<data type>
DT_TO_<data type>
Conversion Results
The date will be stored internally in a DWORD in seconds since Jan. 1, 1970. This
value will then be converted.
For STRING type variables, the result is the date constant.
NOTE: The operators that convert a value into a character string of type
STRING or WSTRING require an operand that matches the target data type.
Examples in ST
Examples in ST with conversion results:
Example Result
b := DATE_TO_BOOL(D#1970-01-01); FALSE
i := DATE_TO_INT(D#1970-01-15); 29952
Examples in IL
Examples in IL with conversion results:
Example Result
LD D#1970-01-01 FALSE
DATE_TO_BOOL
ST b
LD D#1970-01-01 29952
DATE_TO_INT
ST i
LD D#1970-01-15-05:05: 129
DATE_TO_BYTE
ST byt
LD D#1998-02-13-14:20 'DT#1998-02-13-14:20'
DATE_TO_STRI...
ST str
EIO0000002854.04 597
Operators
Examples in FBD
STRING_TO Conversions
General Information
For general hints to be considered during type conversion, refer to the chapter
Type Conversion Functions, page 588.
Definition
IEC operator for conversions from the variable type STRING to a different type.
Syntax
STRING_TO_<data type>
Specifying Values
Specify the operand of type STRING matching the IEC61131-3 standard. The
value must correspond to a valid constant (literal), page 481 of the target type.
Convertible strings can contain:
• Number with type prefix (example: '16#FFFFFFFF')
• Number with grouping characters (example: '2#1111_1111')
NOTE: Use the underscore, as the international weight and measure
grouping character (thin space) is not permitted.
• Floating-point number, also in exponential notation (example: '9.876' or
'1.2E-34')
NOTE: Floating-point numbers are not convertible. The comma is treated
as a following character and therefore truncated.
• Time, time of day, and date specification with prefix and size (example:
'T#2h', 'DT#2019-9-9-12:30:30.9')
• Infinite values (example: '1.7E+400')
• Additional character after a number (example: '2m' or '3.14') are
truncated. Additional characters before a number are not permitted.
• Spaces before (example: ' 3.14')
The operand must represent a valid value of the target data type.
598 EIO0000002854.04
Operators
NOTE: If the data type of the operand does not match the target type, or if the
value exceeds the range of the target data type, then the result depends on
the processor type and is therefore undefined.
Conversions from larger types to smaller types may result in loss of
information.
CAUTION
LOSS OF DATA
When converting mismatched data types or when the value being converted is
larger than the target data type, be sure that the result is validated within your
application.
Failure to follow these instructions can result in injury or equipment
damage.
Example in IL
Example Conversion result
LD 'TRUE' TRUE
STRING_TO_BOOL
ST b
Examples in ST
Example Conversion result
b := STRING_TO_BOOL('TRUE'); TRUE
w := STRING_TO_WORD('abc34'); 0
w := STRING_TO_WORD('34abc'); 34
t := STRING_TO_TIME('T#127ms'); T#127ms
r := STRING_TO_REAL('1.234'); 1.234
bv := STRING_TO_BYTE('500'); 244
Example in FBD
Example Conversion result
TRUE
TRUNC
General Information
For general hints to be considered during type conversion, refer to the chapter
Type Conversion Functions, page 588.
EIO0000002854.04 599
Operators
Definition
IEC operator for conversions from REAL to DINT. The whole number portion of
the value will be used.
The result of these functions is not defined if the input value cannot be
represented with a DINT or INT. The behavior for such input values is platform-
dependent.
Examples in ST
Examples in ST with conversion results:
Example Result
diVar:=TRUNC(1.9); 1
diVar:=TRUNC(–1.4); –1
Example in IL
LD 1.9
TRUNC
ST diVar
TRUNC_INT
General Information
For general hints to be considered during type conversion, refer to the chapter
Type Conversion Functions, page 588.
Definition
IEC operator for conversions from REAL to INT. The whole number portion of the
value will be used.
The result of these functions is not defined if the input value cannot be
represented with an INT. The behavior for such input values is platform-
dependent.
Examples in ST
Examples in ST with conversion results:
Example Result
iVar:=TRUNC_INT(1.9); 1
iVar:=TRUNC_INT(-1.4); –1
Example in IL
LD 1.9
TRUNC_INT
ST iVar
600 EIO0000002854.04
Operators
ANY_..._TO Conversions
General Information
For general hints to be considered during type conversion, refer to the chapter
Type Conversion Functions, page 588.
Definition
Conversion from any data type, or more specifically from any numeric data type to
another data type. As with any type of conversion, the size of the operands must
be taken into account in order to have a successful conversion.
Syntax
ANY_NUM_TO_<numeric data type>
ANY_TO_<any data type>
Example
Conversion from a variable of data type REAL to INT:
re : REAL := 1.234;
i : INT := ANY_TO_INT(re)
TO_<xxx> Conversions
General Information
For general hints to be considered during type conversion, refer to the chapter
Type Conversion Functions, page 588.
This operator is not specified by the standard IEC 61131-3.
Definition
Conversion of variables from one type to another type. The input type must not be
specified explicitly (overloaded conversion).
Also refer to the description of type conversion functions, page 588.
Syntax
TO_<data type>
Example in ST
Conversion from a variable of data type REAL to INT:
VAR
iVar: INT;
bVar: BOOL;
strVar: STRING;
rVar: REAL;
END_VAR
iVar := TO_INT(4.22); (* Result: 4 *)
EIO0000002854.04 601
Operators
Numeric Functions
Overview
This chapter describes the available numeric IEC operators specified by the
standard IEC 61131-3.
ABS
Definition
Numeric IEC operator for returning the absolute value of a number.
In- and output can be of any numeric basic data type.
Example in IL
The result in i is 2.
LD –2
ABS
ST i
Example in ST
i:=ABS(–2);
Example in FBD
SQRT
Definition
Numeric IEC operator for returning the square root of a number.
The input variable can be of any numeric basic data type, the output variable has
to be type REAL or LREAL.
Example in IL
The result in q is 4.
LD 16
SQRT
ST q
602 EIO0000002854.04
Operators
Example in ST
q:=SQRT(16);
Example in FBD
LN
Definition
Numeric IEC operator for returning the natural logarithm of a number.
The input variable can be of any numeric basic data type, the output variable has
to be type REAL or LREAL.
Example in IL
The result in q is 3.80666.
LD 45
LN
ST q
Example in ST
q:=LN(45);
Example in FBD
LOG
Definition
Numeric IEC operator for returning the logarithm of a number in base 10.
The input variable can be of any numeric basic data type, the output variable has
to be type REAL or LREAL.
Example in IL
The result in q is 2.49762.
LD 314.5
LOG
ST q
EIO0000002854.04 603
Operators
Example in ST
q:=LOG(314.5);
Example in FBD
EXP
Definition
Numeric IEC operator for returning the exponential function.
The input variable can be of any numeric basic data type, the output variable has
to be type REAL or LREAL.
Example in IL
The result in q is 7.389056099.
LD 2
EXP
ST q
Example in ST
q:=EXP(2);
Example in FBD
SIN
Definition
Numeric IEC operator for returning the sine of an angle.
The input defining the angle in radians can be of any numeric basic data type, the
output variable has to be of type REAL or LREAL.
Example in IL
The result in q is 0.479426.
LD 0.5
SIN
ST q
604 EIO0000002854.04
Operators
Example in ST
q:=SIN(0.5);
Example in FBD
COS
Definition
Numeric IEC operator for returning the cosine of an angle.
The input defining the angle in arch minutes can be of any numeric basic data type
where the output variable has to be of type REAL or LREAL.
Example in IL
The result in q is 0.877583.
LD 0.5
COS
ST q
Example in ST
q:=COS(0.5);
Example in FBD
TAN
Definition
Numeric IEC operator for returning the tangent of a number. The value is
calculated in arch minutes.
The input variable can be of any numeric basic data type where the output
variable has to be type REAL or LREAL.
Example in IL
The result in q is 0.546302.
LD 0.5
TAN
ST q
EIO0000002854.04 605
Operators
Example in ST
q:=TAN(0.5);
Example in FBD
ASIN
Definition
Numeric IEC operator for returning the arc sine (inverse function of sine) of a
number. The value is calculated in arch minutes.
The input variable can be of any numeric basic data type where the output
variable has to be type REAL or LREAL.
Example in IL
The result in q is 0.523599.
LD 0.5
ASIN
ST q
Example in ST
q:=ASIN(0.5);
Example in FBD
ACOS
Definition
Numeric IEC operator for returning the arc cosine (inverse function of cosine) of a
number. The value is calculated in arch minutes.
The input variable can be of any numeric basic data type where the output
variable has to be type REAL or LREAL.
Example in IL
The result in q is 1.0472.
LD 0.5
ACOS
ST q
606 EIO0000002854.04
Operators
Example in ST
q:=ACOS(0.5);
Example in FBD
ATAN
Definition
Numeric IEC operator for returning the arc tangent (inverse function of tangent) of
a number. The value is calculated in arch minutes.
The input variable can be of any numeric basic data type where the output
variable has to be type REAL or LREAL.
Example in IL
The result in q is 0.463648.
LD 0.5
ATAN
ST q
Example in ST
q:=ATAN(0.5);
Example in FBD
EXPT
Definition
Numeric IEC operator for exponentiation of a variable with another variable:
OUT = IN1 to the IN2
The input variable can be of numeric basic data types (SINT, USINT, INT, UINT,
DINT, UDINT, LINT, ULINT, REAL, LREAL, BYTE, WORD, DWORD, and LWORD)
where the output variable has to be type REAL or LREAL.
The result of this function is not defined if the following applies:
• The base is negative.
• The base is zero and the exponent is ≤ 0.
The behavior for such input values is platform-dependent.
EIO0000002854.04 607
Operators
Example in IL
The result is 49.
LD 7
EXPT 2
ST Var1
Example in ST
var1:=EXPT(7,2);
Example in FBD
608 EIO0000002854.04
Operators
__DELETE
Definition
This operator is not specified by the IEC 61131-3 standard.
For compatibility information, refer to the EcoStruxure Machine Expert/CODESYS
compiler version mapping table in the Compatibility and Migration User Guide
(see EcoStruxure Machine Expert Compatibility and Migration, User Guide).
The __DELETE operator deallocates the memory for objects allocated before via
the __NEW operator, page 611.
__DELETE has no return value and its operand will be set to 0 after the operation.
Activate the option Use dynamic memory allocation in the Application build
options view (see EcoStruxure Machine Expert, Menu Commands, Online Help)
(View > Properties... > Application build options). Consult the Programming
Guide specific to your controller for whether the options are available on your
controller.
Syntax
__DELETE (<pointer>)
If pointer is a pointer to a function block, the dedicated method FB_Exit will be
called before the pointer is set to NULL.
NOTE: Use the exact data type of the derived function block and not that of
the base function block. Do not use a variable of type POINTER TO BaseFB.
This is necessary because if the base function block implements no FB_Exit
function, then at the later usage of __DELETE(pBaseFB), no FB_Exit is
called.
NOTE: Make sure that __DELETE is not called by two tasks simultaneously. It
is a good practice to use __DELETE in only one task. If this is not feasible, use
a semaphore (SysSemEnter) or a comparable method, to help avoid
concurrent calls of __DELETE.
You can use a semaphore (SysSemEnter) to help prevent two tasks from
deallocating memory at the same time. In this case, the extensive use of
__DELETE causes higher jitter.
EIO0000002854.04 609
Operators
Example
In the following example, the function block FBDynamic is allocated dynamically
via _NEW from the POU PLC_PRG. By doing so, FB_Init method will be called, in
which a type DUT is allocated. When __DELETE is called on, the function block
pointer from PLC_PRG, FB_Exit will be called, which in turn frees the allocated
internal type.
FUNCTION_BLOCK FBDynamic
VAR_INPUT
in1, in2 : INT;
END_VAR
VAR_OUTPUT
out : INT;
END_VAR
VAR
test1 : INT := 1234;
_inc : INT := 0;
_dut : POINTER TO DUT;
END_VAR
out := in1 + in2;
PLC_PRG(PRG)
VAR
pFB : POINTER TO FBDynamic;
bInit: BOOL := TRUE;
bDelete: BOOL;
loc : INT;
END_VAR
IF (bInit) THEN
pFB := __NEW(FBDynamic);
bInit := FALSE;
END_IF
IF (pFB <> 0) THEN
pFB^(in1 := 1, in2 := loc, out => loc);
pFB^.INC();
END_IF
IF (bDelete) THEN
__DELETE(pFB);
END_IF
__ISVALIDREF
Definition
This operator is not specified by the IEC 61131-3 standard.
610 EIO0000002854.04
Operators
__NEW
Definition
This operator is not specified by the IEC 61131-3 standard.
The operator __NEW allocates dynamic memory for function block instances, user-
defined data types or arrays of standard data types. The operator returns a
suitably typed pointer to the object. If the operator is not used within an
assignment, a message is displayed.
Activate the option Use dynamic memory allocation in the Application build
options view (see EcoStruxure Machine Expert, Menu Commands, Online Help)
(View > Properties... > Application build options) to use the __NEW operator.
Consult the Programming Guide specific to your controller for whether the options
are available on your controller.
If no memory could be allocated, by __NEW will return 0.
For deallocating, use __DELETE.
Syntax
<pointer name> := __NEW (<type>[,<size>]);
The operator creates a new object of the specified type <type> and returns a
pointer to that <type>. The initialization of the object is called after creation. If 0 is
returned, the operation has not been completed successfully.
NOTE: Use the exact data type of the derived function block and not that of
the base function block. Do not use a variable of type POINTER TO BaseFB.
This is necessary because if the base function block implements no FB_Exit
function, then at the later usage of __DELETE(pBaseFB), no FB_Exit is
called.
If <type> is scalar, the optional operand <size> has to be set additionally and
the operator creates an array of scalar types with the size length.
Example
pScalarType := __New(ScalarType, length);
NOTE: A function block or a user-defined data type created dynamically with
__NEW has a fixed memory area. The data layout cannot be modified by an
online change. Therefore, new variables cannot be added to or deleted from
the type, and types cannot be modified.
Therefore, only function blocks out of libraries (because they cannot change) and
function blocks with attribute enable_dynamic_creation are allowed for the
__NEW operator. If a function block changes with this flag so that copy code will be
necessary, a message is produced.
NOTE: The code for memory allocation needs to be non-re-entrant.
A semaphore (SysSemEnter) is used to avoid 2 tasks try to allocate memory at
the same time. Thus, extensive usage of __New may produce higher jitter.
Example with a scalar type:
{attribute 'enable_dynamic_creation'}
TYPE DUT :
STRUCT
a,b,c,d,e,f : INT;
EIO0000002854.04 611
Operators
END_STRUCT
END_TYPE
PROGRAM PLC_PRG
VAR
pDut : POINTER TO DUT;
bInit: BOOL := TRUE;
bDelete: BOOL;
END_VAR
IF (bInit) THEN
pDut := __NEW(DUT);
bInit := FALSE;
END_IF
IF (bDelete) THEN
__DELETE(pDut);
END_IF
Example with a function block:
{attribute 'enable_dynamic_creation'}
FUNCTION_BLOCK FBDynamic
VAR_INPUT
in1, in2 : INT;
END_VAR
VAR_OUTPUT
out : INT;
END_VAR
VAR
END_VAR
out := in1 + in2;
PROGRAM_PLC_PRG
VAR
pFB : POINTER TO FBDynamic;
loc : INT;
bInit: BOOL := TRUE;
bDelete: BOOL;
END_VAR
IF (bInit) THEN
pFB := __NEW(FBDynamic);
bInit := FALSE;
END_IF
IF (pFB <> 0) THEN
pFB^(in1 := 1, in2 := loc, out => loc);
END_IF
IF (bDelete) THEN
__DELETE(pFB);
END_IF
Example with an array:
PLC_PRG(PRG)
VAR
bInit: BOOL := TRUE;
bDelete: BOOL;
pArrayBytes : POINTER TO BYTE;
test: INT;
parr : POINTER TO BYTE;
END_VAR
IF (bInit) THEN
pArrayBytes := __NEW(BYTE, 25);
bInit := FALSE;
END_IF
IF (pArrayBytes <> 0) THEN
pArrayBytes[24] := 125;
test := pArrayBytes[24];
END_IF
IF (bDelete) THEN
__DELETE(pArrayBytes);
END_IF
612 EIO0000002854.04
Operators
__QUERYINTERFACE
Definition
This operator is not specified by the IEC 61131-3 standard.
At runtime, __QUERYINTERFACE is enabling a type conversion of an interface
reference to another. The operator returns a result with type BOOL. TRUE implies,
that the conversion is successfully executed.
Syntax
__QUERYINTERFACE(<ITF_Source>, < ITF_Dest>
The operator needs as the first operand an interface reference or a function block
instance of the intended type and as second operand an interface reference. After
execution of __QUERYINTERFACE, the ITF_Dest holds a reference to the
intended interface if the object referenced from ITF_Source implements the
interface. In this case, the conversion is successful and the result of the operator
returns TRUE. In all other cases, the operator returns FALSE.
A precondition for an explicit conversion is that not only the ITF_Source but also
ITF_Dest is an extension of the interface __System.IQueryInterface. This
interface is provided implicitly and needs no library.
Example
Example in ST:
INTERFACE ItfBase EXTENDS __System.IQueryInterface
METHOD mbase : BOOL
END_METHOD
INTERFACE ItfDerived1 EXTENDS ItfBase
METHOD mderived1 : BOOL
END_METHOD
INTERFACE ItfDerived2 EXTENDS ItfBase
METHOD mderived2 : BOOL
END_METHOD
FUNCTION_BLOCK FB1 IMPLEMENTS ItfDerived1
METHOD mbase : BOOL
mbase := TRUE;
END_METHOD
METHOD mderived1 : BOOL
mderived1 := TRUE;
END_METHOD
END_FUNCTION_BLOCK
FUNCTION_BLOCK FB2 IMPLEMENTS ItfDerived2
METHOD mbase : BOOL
mbase := FALSE;
END_METHOD
METHOD mderived2 : BOOL
mderived2 := TRUE;
END_METHOD
END_FUNCTION_BLOCK
PROGRAM POU
VAR
inst1 : FB1;
inst2 : FB2;
itfbase1 : ItfBase := inst1;
itfbase2 : ItfBase := inst2;
itfderived1 : ItfDerived1 := 0;
itfderived2 : ItfDerived2 := 0;
bTest1, bTest2, xResult1, xResult2: BOOL;
END_VAR
xResult1 := __QUERYINTERFACE(itfbase1, itfderived1); //
xResult = TRUE, itfderived1 <> 0
EIO0000002854.04 613
Operators
// references the
instance inst1
xResult2 := __QUERYINTERFACE(itfbase1, itfderived2); //
xResult = FALSE, itfderived2 = 0
xResult3 := __QUERYINTERFACE(itfbase2, itfderived1); //
xResult = FALSE, itfderived1 = 0
xResult4 := __QUERYINTERFACE(itfbase2, itfderived2); //
xResult = TRUE, itfderived2 <> 0
// references the
instance inst2
__QUERYPOINTER
Definition
This operator is not specified by the IEC 61131-3 standard.
At runtime, __QUERYPOINTER is assigning an interface reference to an untyped
pointer. The operator returns a result with type BOOL. TRUE implies, that the
conversion has been successfully executed.
Syntax
__QUERYPOINTER (<ITF_Source>, < Pointer_Dest>
For the first operand, the operator requires an interface reference or a function
block instance of the intended type and for the second operand an untyped
pointer. After execution of __QUERYPOINTER, the Pointer_Dest holds the address
of the reference to the intended interface. In this case, the conversion is
successful and the result of the operator returns TRUE. In all other cases, the
operator returns FALSE. Pointer_Dest is untyped and can be cast to any type. The
programmer has to ensure the actual type. For example, the interface could
provide a method returning a type code.
A precondition for an explicit conversion is that the ITF_Source is an extension of
the interface __System.IQueryInterface. This interface is provided implicitly and
needs no library.
Example
TYPE KindOfFB
(FB1 := 1, FB2 := 2, UNKOWN := -1);
END_TYPE
INTERFACE Itf EXTENDS __System.IQueryInterface
METHOD KindOf : KindOfFB
END_METHOD
FUNCTION_BLOCK F_BLOCK_1 IMPLEMENTS ITF
METHOD KindOf : KindOfFB
KindOf := KindOfFB.FB1;
END_METHOD
FUNCTION_BLOCK F_BLOCK_2 IMPLEMENTS ITF
METHOD KindOf : KindOfFB
KindOf := KindOfFB.FB2;
END_METHOD
FUNCTION CAST_TO_ANY_FB : BOOL
VAR_INPUT
itf_in : Itf;
END_VAR
VAR_OUTPUT
pfb_1: POINTER TO F_BLOCK_1 := 0;
pfb_2: POINTER TO F_BLOCK_2 := 0;
END_VAR
VAR
614 EIO0000002854.04
Operators
AND_THEN
Definition
This operator is not specified by the IEC 61131-3 standard. It is only allowed for
programming in structured text (ST).
The AND_THEN performs an AND-operation of operands of type BOOL and BIT
with short-circuiting mode. This has the following effect:
If all operands are TRUE, then the result of the operation is TRUE, otherwise it is
FALSE.
When one operand is FALSE, then the expressions at the other operands are not
evaluated (lazy evaluation). In this regard, the AND_THEN operator differs from the
AND operator as defined in the standard IEC-61131-3. AND always evaluates all
expressions, page 572.
In contrast to this, when using the standard IEC-operator AND, always all
operands are evaluated, page 572.
OR_ELSE
Definition
This operator is not specified by the IEC 61131-3 standard. It is only allowed for
programming in structured text (ST).
The OR_ELSE performs an OR-operation of operands of type BOOL and BIT with
short-circuiting mode. This has the following effect:
If at least one of the operands is TRUE, then the result of the operation is TRUE,
otherwise it is FALSE.
When one operand is TRUE, then the expressions at the other operands are not
evaluated (lazy evaluation). In this regard, the OR_ELSE operator differs from the
OR operator as defined in the standard IEC-61131-3. OR always evaluates all
expressions, page 572.
Example
VAR
bEver: BOOL;
bX1: BOOL;
dw: DWORD := 16#000000FF;
END_VAR
bEver := FALSE;
bX := dw.8 OR_ELSE dw.1 OR_ELSE dw.1 OR_ELSE (bEver :=
TRUE);
EIO0000002854.04 615
Operators
dw.8 is FALSE and dw.1 is TRUE, thus the result of the operation (bX) is TRUE.
However, the expression at the third input is not executed, bEver remains
FALSE. If you used the standard OR operation instead, page 572, bEver were set
to TRUE.
Syntax
__TRY
<statements_try>
__CATCH(exec)
<statements_catch>
__FINALLY
<statements_finally>
__ENDTRY
<statements_next>
Function
If an exception is detected while <statements_try> is executed (even in
functions called from there), then <statements_catch> is executed. In that
way, execution does not stop as it is the case when other exceptions are detected.
However, there is a log message in the runtime system with information about the
range offset and the type of exception that has been detected.
After executing <statements_catch>, <statements_finally> is
automatically executed (if programmed), and then <statements_next> is
executed.
The variable <exception> must be of type __SystemExceptionCode.
Example
If the statement in __TRY produces an exception, then program execution is not
stopped, and then the statements in __CATCH are executed. Therefore, the
function exc is executed. Then the statement in __ENDTRY is executed.
FUNCTION Tester : UDINT
VAR_INPUT
count : UDINT;
END_VAR
VAR_OUTPUT
strExceptionText : STRING;
END_VAR
VAR
exc : __SYSTEM.ExceptionCode;
END_VAR
__TRY
Tester := tryFun(count := count, testcase := g_testcase);
//This statement is tested. If it produces an exception,
then the statement in __CATCH is executed first, and then
the statement in __FINALLY.
616 EIO0000002854.04
Operators
__CATCH(exc)
HandleException(exc, strExceptionText => strExceptionText);
__FINALLY
GVL.g_count := GVL.g_count + 2;
__ENDTRY
Use the Stop execution on handled exceptions command (see EcoStruxure
Machine Expert, Menu Commands, Online Help) to stop execution at the error
location despite the programmed exception handling.
Type __System.Exception
TYPE ExceptionCode:
( RTSEXCPT_UNKNOWN :=
16#FFFFFFFF,
RTSEXCPT_NOEXCEPTION :=
16#00000000,
RTSEXCPT_WATCHDOG :=
16#00000010,
RTSEXCPT_HARDWAREWATCHDOG :=
16#00000011,
RTSEXCPT_IO_CONFIG_ERROR :=
16#00000012,
RTSEXCPT_PROGRAMCHECKSUM :=
16#00000013,
RTSEXCPT_FIELDBUS_ERROR :=
16#00000014,
RTSEXCPT_IOUPDATE_ERROR :=
16#00000015,
RTSEXCPT_CYCLE_TIME_EXCEED :=
16#00000016,
RTSEXCPT_ONLCHANGE_PROGRAM_EXCEEDED :=
16#00000017,
RTSEXCPT_UNRESOLVED_EXTREFS :=
16#00000018,
RTSEXCPT_DOWNLOAD_REJECTED :=
16#00000019,
RTSEXCPT_BOOTPROJECT_REJECTED_DUE_RETAIN_ERROR :=
16#0000001A,
RTSEXCPT_LOADBOOTPROJECT_FAILED :=
16#0000001B,
RTSEXCPT_OUT_OF_MEMORY :=
16#0000001C,
RTSEXCPT_RETAIN_MEMORY_ERROR :=
16#0000001D,
RTSEXCPT_BOOTPROJECT_CRASH :=
16#0000001E,
RTSEXCPT_BOOTPROJECTTARGETMISMATCH :=
16#00000021,
RTSEXCPT_SCHEDULEERROR :=
16#00000022,
RTSEXCPT_FILE_CHECKSUM_ERR :=
16#00000023,
RTSEXCPT_RETAIN_IDENTITY_MISMATCH :=
16#00000024,
RTSEXCPT_IEC_TASK_CONFIG_ERROR :=
16#00000025,
RTSEXCPT_APP_TARGET_MISMATCH :=
16#00000026,
RTSEXCPT_ILLEGAL_INSTRUCTION :=
16#00000050,
RTSEXCPT_ACCESS_VIOLATION :=
16#00000051,
RTSEXCPT_PRIV_INSTRUCTION :=
16#00000052,
RTSEXCPT_IN_PAGE_ERROR :=
16#00000053,
EIO0000002854.04 617
Operators
RTSEXCPT_STACK_OVERFLOW :=
16#00000054,
RTSEXCPT_INVALID_DISPOSITION :=
16#00000055,
RTSEXCPT_INVALID_HANDLE :=
16#00000056,
RTSEXCPT_GUARD_PAGE :=
16#00000057,
RTSEXCPT_DOUBLE_FAULT :=
16#00000058,
RTSEXCPT_INVALID_OPCODE :=
16#00000059,
RTSEXCPT_MISALIGNMENT :=
16#00000100,
RTSEXCPT_ARRAYBOUNDS :=
16#00000101,
RTSEXCPT_DIVIDEBYZERO :=
16#00000102,
RTSEXCPT_OVERFLOW :=
16#00000103,
RTSEXCPT_NONCONTINUABLE :=
16#00000104,
RTSEXCPT_PROCESSORLOAD_WATCHDOG :=
16#00000105,
RTSEXCPT_FPU_ERROR :=
16#00000150,
RTSEXCPT_FPU_DENORMAL_OPERAND :=
16#00000151,
RTSEXCPT_FPU_DIVIDEBYZERO :=
16#00000152,
RTSEXCPT_FPU_INEXACT_RESULT :=
16#00000153,
RTSEXCPT_FPU_INVALID_OPERATION :=
16#00000154,
RTSEXCPT_FPU_OVERFLOW :=
16#00000155,
RTSEXCPT_FPU_STACK_CHECK :=
16#00000156,
RTSEXCPT_FPU_UNDERFLOW :=
16#00000157,
RTSEXCPT_VENDOR_EXCEPTION_BASE :=
16#00002000
RTSEXCPT_USER_EXCEPTION_BASE :
=16#00010000 )
UDINT ; END_TYPE
__VARINFO
Definition
This operator is not specified by the IEC 61131-3 standard.
618 EIO0000002854.04
Operators
Function
The __VARINFO operator provides information about a variable of the project at
runtime. The information is stored as a data structure in a variable of data type
__SYSTEM.VAR_INFO.
Example
At runtime, the variable MyVarInfo contains the information about the variable
MyVar.
//Declaration
VAR
MyVarInfo: __SYSTEM.VAR_INFO
MyVAR: INT;
END_VAR
//Program code
MyVarInfo:= __VARINFO (MyVar);
Type SYSTEM.VAR_INFO
A variable with data type __SYSTEM.VAR_INFO contains the following elements:
EIO0000002854.04 619
Operators
‘__POSITION’
Definition
This operator is not specified by the IEC 61131-3 standard.
At runtime, the ‘__POSITION’ operator retrieves the position of a variable in the
declaration part or in the implementation part of a POU. The operator has to be
assigned variables of type STRING in the declaration part of in the implementation
part.
Result of ‘__POSITION’:
• Declaration part: 'Line <line number> (Decl)'
• Implementation part: 'Line <line number>, Column <column number>
(Impl)'
Example
PROGRAM PROG1
VAR
strPOS : STRING := __POSITION(); //Yields the line
number of this declaration
strlocalPOS : STRING;
END_VAR
strlocalPOS := __POSITION(); //Yields the line and
column number of this assignment
‘__POUNAME’
Definition
This operator is not specified by the IEC 61131-3 standard.
At runtime, the ‘__POUNAME’ operator retrieves the name of the POU that calls
the operator ‘__POUNAME’. The result is of type STRING.
The result of the operator ‘__POUNAME’ depends on the location where it is
implemented:
620 EIO0000002854.04
Operators
Get/Set accessor of a property The property name + Get/Set qualified with the
function block name
GVL GVL name
Structure Structure name
Data structure UNION Union name
Example
PROGRAM PROG1
VAR
strPOU : STRING := __POUNAME(); //Yields 'PROG1'
strlocalPOU : STRING;
END_VAR
Scope Operators
Definition
In extension to the IEC operators, there are several possibilities to disambiguate
the access to variables or modules if the variables or module name is used
multiple times within the scope of a project.
The following scope operators can be used:
• global scope operator
• global variable list name
• enumeration name
• library namespace
• global node operator
EIO0000002854.04 621
Operators
If a variable name declared in more than one global variable lists is referenced
without the global variable list name as a preceding operator, a message will be
generated.
Library Namespace
You can add the library namespace to a POU as a prefix separated by a dot to
make the access to the POU unique. By default, the namespace of a library is
identical to the library name.
Example: LIB_A.FB_A
Syntax
<library namespace>.<library POU>
Example
If a library which is included in a project contains the POU FB_A and there is also
a POU FB_A defined locally in the project, then you can assign the name LIB_A.
FB_A to the function block of the library in order to differentiate from the POU.
var1 := FB_A(in := 12); // Call of the project function
block FB_A
var2 := LIB_A.FB_A(in := 22); // Call of the library
function block FB_A
You can define another name for the namespace either in the Project
Information when creating a library project in the Project Information (by default
in the Project menu), or later in the Properties dialog box of an included library in
the Library Manager.
Enumeration Name
You can use the type name of an enumeration to disambiguate the access to an
enumeration constant. Therefore, it is possible to use the same constant in
different enumerations.
The enumeration name has to precede the constant name, separated by a dot (.).
Syntax
<enumeration name>.<constant name>
Example
The constant Blue is a component of enumeration Colors as well as of
enumeration Feelings.
color := Colors.Blue; // Access to enum value Blue in type
Colors
feeling := Feelings.Blue; // Access to enum value Blue in
type Feelings
622 EIO0000002854.04
Operators
Initialization Operator
INI Operator
Overview
NOTE: The INI operator is obsolete. The method FB_init replaces the INI
operator. For further information about the FB_init method, refer to the
chapter FB_init, FB_reinit Methods, page 486. However, the operator can still
be used for keeping compatibility with projects imported from earlier
EcoStruxure Machine Expert versions.
You can use the INI operator to initialize retain variables which are provided by a
function block instance used in the POU.
Assign the operator to a boolean variable.
Syntax
<bool-variable> := INI(<FB-instance, TRUE|FALSE)
If the second parameter of the operator is set to TRUE, all retain variables defined
in the function block FB will be initialized.
Example in ST
fbinst is the instance of function block fb, in which a retain variable retvar is
defined.
Declaration in POU
fbinst:fb;
b:bool;
Implementation part
b := INI(fbinst, TRUE);
ivar:=fbinst.retvar (* => retvar gets initialized *)
Multicore Operators
Overview
Multicore operators are not specified by the standard IEC 61131-3.
They are used for task synchronization, especially when working on multicore
platforms. The operators TEST_AND_SET and __COMPARE_AND_SWAP are
used for similar tasks.
EIO0000002854.04 623
Operators
__CURRENTTASK
Overview
This operator is not specified by the standard IEC 61131-3.
In runtime mode, the operator provides information about the IEC task that is
running.
This function is not available for all supported controllers. Consult the
Programming Guide specific to your controller for further information.
The __CURRENTTASK operator allows for access to a structure with two variables:
• TaskIndex: Zero-based index that identifies the task.
• pTaskInfo: Detailed information about the running task. It can be assigned to
a POINTER TO Task_Info2 from the library CmpIecTask.
The operator cannot be used in the declaration of a POU. This would result in a
detected compiler error. If the running task cannot be determined, then the
TaskIndex -1 and the pTaskInfo are zero.
Example
//Declaration
VAR
idx : INT;
pInfo : POINTER TO Task_Info2;
END_VAR
//Program code
idx := __CURRENTTASK.TaskIndex;
pInfo := __CURRENTTASK.pTaskInfo;
__COMPARE_AND_SWAP
Overview
This operator is not specified by the standard IEC 61131-3.
It can be used for implementing a semaphore, for example, to help ensure
exclusive access to a variable that is written by different tasks.
The following elements are assigned to __COMPARE_AND_SWAP:
• Pointer to a data type __XWORD variable
• Old value as input, can also be data type __XWORD variable
• New value as input, can also be data type __XWORD variable
Example: bMutex := __COMPARE_AND_SWAP(ADR(dwSynch), dwOld,
dwNew);
The referenced __XWORD variable is compared with the old value. If both are
equal, the new value is written. The result of the function is TRUE if the new value
is written.
NOTE: The data type __XWORD is replaced by DWORD on 32-bit systems
and by LWORD on 64-bit systems by the compiler.
This atomic operation cannot be interrupted by another task, even on multicore
platforms.
624 EIO0000002854.04
Operators
Example
The following example illustrates a typical use case: Implementing exclusive
access to a variable of type STRING which is addressed via the pstrOutput
pointer.
As the access to a variable of type STRING is not atomic, the contents may be
inconsistent if multiple tasks write to the same string at the same time.
Using the __COMPARE_AND_SWAP operator function allows you to write the same
STRING variable in different tasks.
FUNCTION ExclusiveStringWrite : BOOL
VAR_INPUT
strToWrite : STRING;
pstrOutput : POINTER TO STRING;
END_VAR
VAR_STAT
dwSynch : __XWORD;
END_VAR
VAR
bMutex: BOOL;
END_VAR
__XADD
Overview
This operator is not specified by the standard IEC 61131-3.
It can be used for implementing an atomic counter. Simple addition operations
executed on integer variables, for example iTest := iTest + 1;, are not
executed atomically. This implies the risk that another process may access the
variable between the read and write operation.
If the counter is incremented in multiple tasks, the result of the counter can be less
than the number of counting cycles.
Example: The initial value of the variable is 0. Two tasks execute the above code
one time each. After that, the variable can have the value 1. This may cause
issues if arrays are being processed in multiple tasks, but nevertheless each
processing cycle requires a unique index for the array.
When the __XADD operator is called, the following procedure applies:
1. __XADD retrieves a pointer to a type DINT variable as the first summand.
2. __XADD retrieves a type DINT value as the second summand.
3. __XADD returns the old value of the first summand and in the same step adds
the second summand to the first summand.
Function call example: diOld := __XADD(ADR(diVar), deAdd);
EIO0000002854.04 625
Operators
Example
The following example illustrates a typical use case: An array is to be populated
from two tasks in such a way that all positions in the array are used and no
position is overwritten.
Using the __XADD operator function allows multiple tasks to populate a Boolean
array.
FUNCTION WriteToNextArrayPosition : BOOL
VAR_EXTERNAL
g_diIndex : DINT; // Index and array are
globally defined and used by multiple tasks
g_boolArray : ARRAY [0..1000] OF BOOL;
END_VAR
VAR_INPUT
bToWrite : BOOL;
END_VAR
VAR
diIndex : DWORD;
END_VAR
TEST_AND_SET
Overview
TEST_AND_SET can be used for implementing a semaphore, for example, to help
ensure exclusive access to a variable that is written by different tasks.
NOTE: TEST_AND_SET is not supported by Modicon M262 Logic/Motion
Controllers. Further, it is not specified by the standard IEC 61131-3.
The following procedure is applied to TEST_AND_SET:
1. A variable of type DWORD is assigned as input. Write access to this variable
must be possible.
2. The variable is set to 1.
3. The previous value is returned as the result.
This operation cannot be interrupted by another task; this also applies to multicore
platforms.
Example: The call in the program is dwOldValue := TEST_AND_SET(dw);. The
variables dwOldValue and dw must be of data type DWORD.
Example
The following example illustrates a typical use case: Implementing exclusive
access to a variable of type STRING which is addressed via the pstrOutput
pointer.
As the access to a variable of type STRING is not atomic, the contents may be
inconsistent if multiple tasks write to the same string at the same time.
Using the TEST_AND_SET operator function allows you to write the same STRING
variable in different tasks.
FUNCTION ExclusiveStringWrite : BOOL
626 EIO0000002854.04
Operators
VAR_INPUT
strToWrite : STRING;
pstrOutput : POINTER TO STRING;
END_VAR
VAR_STAT
dwSynch : DWORD;
END_VAR
VAR
dwOldValue: DWORD;
END_VAR
EIO0000002854.04 627
Operands
Operands
What’s in This Chapter
Constants ................................................................................................... 628
Variables .................................................................................................... 635
Addresses .................................................................................................. 637
Functions.................................................................................................... 639
Constants
BOOL Constants
Overview
BOOL constants are the logical values TRUE and FALSE.
Refer to the description of the data type BOOL, page 529.
TIME/LTIME Constants
Overview
TIME constants are used to operate the standard timer modules. The time
constant TIME is of size 32 bit, resolution in milliseconds as specified by the IEC
61131-3 standard. Additionally, LTIME is supported as an extension to the
standard as time base for high-resolution timers. LTIME is of size 64 bit and
provides a resolution in nanoseconds.
The library standard64.lib provides functions for WSTRING strings.
Example Description
TIME1 := T#14ms; –
TIME1 := t#12h34m15s; –
628 EIO0000002854.04
Operands
Example Description
DATE Constants
Overview
Use these constants to enter dates.
Syntax
d#<date declaration>
Instead of d# you can also use the following:
• D#
• date#
• DATE#
Enter the date declaration in format <date keyword>#<year>-<month>-
<day>.
DATE values are internally handled as DWORD values, containing the time span
in seconds since 01.01.1970, 00:00 clock, with an upper limit of DATE#2106-2-7.
Examples
DATE#1996-05-06
d#1972-03-29
For further information, refer to the description of the Date and Time Data Types,
page 533.
LDATE Constants
Overview
Use the LDATE constant to specify a date.
EIO0000002854.04 629
Operands
Syntax
ld#<date declaration>
Instead of ld# you can also use the following:
• LD#
• ldate#
• LDATE#
Enter the date declaration in format <date keyword>#<year>-<month>-
<day>.
LDATE values are internally handled as LWORD values, containing the time span
in seconds since 01.01.1970, 00:00 clock, with an upper limit of DATE#2554-7-21.
Examples
LDATE#2018-8-8
LD#1996-05-06
For further information, refer to the description of the Date and Time Data Types,
page 533.
DATE_AND_TIME Constants
Overview
DATE constants and TIME constants can also be combined to form so-called
DATE_AND_TIME constants.
Syntax
dt#<date and time declaration>
Instead of dt# you can use the following:
• DT#
• date_and_time#
• DATE_AND_TIME#
Enter the date and time declaration in format <year-month-day-hour:minute:
second>.
You can enter seconds as real numbers. This allows you to specify fractions of a
second.
DATE_AND_TIME values are internally handled as DWORD values, containing
the time span in seconds since 01.01.1970, 00:00 clock until February 7, 2106
06:28:15.
Examples
DATE_AND_TIME#1996-05-06-15:36:30
dt#1972-03-29-00:00:00
For further information, refer to the description of the Date and Time Data Types,
page 533.
LDATE_AND_TIME Constants
Overview
Use the LDATE_AND_TIME (LDT) constant to specify a 64-bit date and time.
630 EIO0000002854.04
Operands
Syntax
ldt#<date and time declaration>
Instead of ldt# you can use the following:
• LDT#
• ldate_and_time#
• LDATE_AND_TIME#
Enter the date and time declaration in format <year-month-day-hour:minute:
second>.
You can enter seconds as real numbers. This allows you to specify fractions of a
second.
LDATE_AND_TIME values are internally handled as LWORD values, containing
the time span in seconds since 01.01.1970, 00:00 clock until July 21, 2554
23:59:59.99999999.
Examples
LDATE_AND_TIME#1996-05-06-15:36:30
ldt#1972-03-29-00:00:00
LDT#2018-08-08-13:33:20.5
For further information, refer to the description of the Date and Time Data Types,
page 533.
TIME_OF_DAY Constants
Overview
Use this type of constant to store times of the day.
Syntax
tod#<time declaration>
Instead of tod# you can also use the following:
• TOD#
• time_of_day#
• TIME_OF_DAY#
Enter the time declaration in format <hour:minute:second>.
You can enter seconds as real numbers. This allows you to specify fractions of a
second.
TIME_OF_DAY values are internally handled as DWORD values, containing the
time span in milliseconds since 00:00 clock.
Examples
TIME_OF_DAY#15:36:30.123
tod#00:00:00
For further information, refer to the description of the Date and Time Data Types,
page 533.
EIO0000002854.04 631
Operands
LTIME_OF_DAY Constants
Overview
Use this type of constant to store times of the day in 64 bit format.
Syntax
ltod#<time declaration>
Instead of ltod# you can also use the following:
• LTOD#
• ltime_of_day#
• LTIME_OF_DAY#
Enter the time declaration in format <hour:minute:second>.
You can enter seconds as real numbers. This allows you to specify fractions of a
second.
LTIME_OF_DAY values are internally handled as LWORD values, containing the
time span in nanoseconds since 00:00 clock.
Examples
LTIME_OF_DAY#15:36:30.123456789
ltod#00:00:00
For further information, refer to the description of the Date and Time Data Types,
page 533.
Number Constants
Overview
Number values can appear as binary numbers, octal numbers, decimal numbers,
and hexadecimal numbers. Integer values that are not decimal numbers are
represented by the base followed by the number sign (#) in front of the integer
constant. The values for the numbers 10...15 in hexadecimal numbers are
represented by the letters A...F.
You can include the underscore character within the number.
Examples
14 (decimal number)
632 EIO0000002854.04
Operands
• UDINT
• REAL
• LREAL
Implicit conversions from larger to smaller variable types are not permitted.
Therefore, a DINT variable cannot simply be used as an INT variable. Use the
type conversion functions, page 588.
REAL/LREAL Constants
Overview
REAL and LREAL constants can be given as decimal fractions and represented
exponentially. Use the decimal point as decimal separator according to the
International System of Units (SI).
Examples
REAL/LREAL Constant Description
For limits of the REAL and LREAL data types, refer to the description of the
Standard Data Types, page 531.
String Constants
Overview
A string constant is an arbitrary sequence of characters. STRING, page 532
constants are preceded and followed by single quotation marks. WSTRING, page
532 constants are preceded and followed by double quotation marks. The
characters are coded according to the character set specified in ISO/IEC 8859-1.
You may also enter blank spaces and special characters (special characters for
different languages, like accents or umlauts).
In strings, the combination of the dollar sign ($) followed by 2 hexadecimal
numbers is interpreted as a hexadecimal code according to the coding in ISO/IEC
8859-1. The code corresponds to ASCII code. In addition, note the special cases
presented in the table.
Hexadecimal Code
Combinations of characters starting with a dollar sign which are interpreted as
hexadecimal code:
EIO0000002854.04 633
Operands
'$41' A
'$9A' ©
'$40' @
Examples
Constant declaration of a STRING:
VAR CONSTANT
constA : STRING := 'Hello world';
constB : STRING := 'Hello world $21'; // Hello world!
END_VAR
Examples of WSTRING declarations:
wstr:WSTRING:="This is a WString";
wstr10 : WSTRING(10) := "1234567890";
Syntax
<Type>#<Literal>
<Type> is the desired data type. Possible entries are:
• BOOL
634 EIO0000002854.04
Operands
• SINT
• USINT
• BYTE
• INT
• UINT
• WORD
• DINT
• UDINT
• DWORD
• REAL
• LREAL
Write the type in uppercase letters.
<Literal> specifies the constant. The data entered has to fit within the data type
specified in <Type>.
Example
var1:=DINT#34;
If the constant cannot be converted to the target type without data loss, a
message will be generated.
You can use typed literals wherever normal constants can be used.
Variables
Variables
Overview
You can declare variables either locally in the declaration part of a POU or in a
global variable list (GVL) or in a persistent variables list or in the I/O mapping of
devices.
Refer to the chapter Variables Declaration, page 461 for information on the
declaration of a variable, including the rules concerning the variable identifier and
multiple use.
It depends on the data type, page 529 where a variable can be used.
You can access available variables through the Input Assistant.
Syntax Access to
EIO0000002854.04 635
Operands
Syntax
<variablename>.<bitindex>
Example
a : INT;
b : BOOL;
...
a.2 := b;
The third bit of the variable a will be set to the value of the variable b, therefore
variable a will equal 3.
If the index is greater than the bit width of the variable, the following message will
be generated:
'Index '<n>' outside the valid range for variable '<var>'!'
Bit addressing is possible with variables of the following data types:
• SINT
• INT
• DINT
• USINT
• UINT
• UDINT
• BYTE
• WORD
• DWORD
If the data type does not allow bit accessing, the following message will be
generated:
'Invalid data type '<type>' for direct indexing'.
Do not assign bit access to a VAR_IN_OUT variable.
636 EIO0000002854.04
Operands
enable:int:=2;
END_VAR
2. Bit access on an integer variable
Declaration in POU:
VAR
xxx:int;
END_VAR
Bit access:
xxx.enable := true; (* -> the third bit in variable xxx will
be set TRUE *)
Addresses
Direct Addresses
Overview
A direct address specified in EcoStruxure Machine Expert contains the following
information:
• Information on the memory location.
• Memory format (size)
• Offset of the memory location. The offset is specified by an integer number,
which in case of a bit address is followed by a dot and a number for the
position of the bit.
Syntax
%<memory area prefix><size prefix><number|.number|.number....>
EIO0000002854.04 637
Operands
M memory location
X single bit
B byte (8 bits)
Examples
Example address Description
NOTE: The memory size for input, output, and memory data (declarations with
AT %I, %Q and %M) is predefined by the target device and can be overwritten in
the properties of an application object (see EcoStruxure Machine Expert,
Menu Commands, Online Help) for PacDrive controllers (PacDrive LMC Eco,
PacDrive LMC Pro/Pro2).
Mode Example
The range for the second element of the bit address that is the number following
the dot, is as follows:
• byte addressing mode: 0...7
• word addressing mode: 0...15
Also for the handling of bit addresses, you can configure the devices differently.
They are then interpreted correspondingly by the EcoStruxure Machine Expert
compiler.
Example: In a byte-addressing device, the bit address %IX2.5 addresses byte 2
(IB2). In a word-addressing device, however, it addresses word 2, which refers to
a different location within the memory.
638 EIO0000002854.04
Operands
Functions
Functions
Overview
In ST, a function call can be used as an operand.
Example
Result := Fct(7) + 3;
For a general description of functions and their declarations, refer to the Function
description in the Program Organization Unit (POU) section of this Programming
Guide, page 153.
TIME() Function
This function returns the time (based on milliseconds) which has been passed
since the system was started.
The data type is TIME.
Example in IL
TIME
ST systime (* Result for example: T#35m11s342ms *)
Example in ST
systime:=TIME();
EIO0000002854.04 639
EcoStruxure Machine Expert Templates
What’s in This Part
General Information about Templates ............................................................ 641
Managing Device Templates ......................................................................... 648
Managing Function Templates....................................................................... 657
640 EIO0000002854.04
General Information about Templates
Step Action
1 Create your functionality within an EcoStruxure Machine Expert project and test it with
the corresponding hardware or in the simulation.
3 Open another EcoStruxure Machine Expert project and select the template from the
template library in order to make the functionality available to this project.
General Notes
When using EcoStruxure Machine Expert templates, note the following:
• Templates are not controller-specific and can therefore be made available for
any controller. Verify that the controller to which you add the template is
capable of executing the functionality contained in the template.
• After the template has been installed, you can freely adapt the created
objects to your individual requirements.
• It is possible to install one template several times on the same controller
device. In order to avoid naming conflicts when creating the objects, they are
renamed automatically during installation. For further information, refer to the
Naming of Objects section of the Adding Devices from Template chapter,
page 650.
EIO0000002854.04 641
General Information about Templates
Supported Fieldbusses
EcoStruxure Machine Expert templates can include field devices that are linked to
the following fieldbusses:
• CANopen
• Modbus serial line (Modbus IOScanner)
• Modbus TCP IO Scanner
• SoftMotion General Drive Pool
• CANmotion
• Ethernet IP Scanner
• Sercos3
Template Libraries
Template libraries contain the definition of several device or function templates.
Write Protection
The standard template libraries included in the EcoStruxure Machine Expert
scope of delivery are write-protected, which means that they cannot be deleted or
renamed.
NOTE: You cannot change write-protected libraries (uninstalling individual
templates or changing names), but you can completely uninstall them.
642 EIO0000002854.04
General Information about Templates
Template Administration
For administration of the available device and function templates in EcoStruxure
Machine Expert, select Tools > Template Repository in the EcoStruxure
Machine Expert Logic Builder.
The Template Repository dialog box opens:
From the Location list, select the type of templates to be displayed in the
Installed Templates box:
• <All locations> is selected by default: all available device and function
templates are displayed
• Legacy displays the device and function templates of EcoStruxure Machine
Expert V3.1 (if installed)
• User: displays only those device and function templates that you have
created or installed
• System: displays the standard device and function templates delivered by
EcoStruxure Machine Expert
The path to the directory where the template libraries are stored is displayed
below the Location field.
The Installed Templates box lists the installed templates in 2 groups: Device
Templates and Function Templates. Each template library can either contain
device templates or function templates.
EIO0000002854.04 643
General Information about Templates
Step Action
2 Browse to the folder where the template library file you want to install is saved.
3 Select the library file you want to install and click OK.
Result: The selected template library is installed and is indicated in the Template
Repository dialog box, including the device or function templates it contains.
Step Action
1 In the Installed Templates list of the Template Repository dialog box, select the
template library you want to remove.
Step Action
1 In the Installed Templates list of the Template Repository dialog box, select the
template library you want to rename.
3 Enter the new name in the box and press Enter or leave the box.
Step Action
1 To create a new template library, select the option User or <All locations> from the
Location list.
2 To create a new template library for device templates, select the Device Templates
node in the Installed Templates list and click the Create Library button.
Result: A new template library with a default name is added at the bottom of the Device
Templates section of the Installed Templates list.
To create a new template library for function templates, select the Function Templates
node in the Installed Templates list and click the Create Library button.
Result: A new template library with a default name is added at the bottom of the
Function Templates section of the Installed Templates list.
3 Rename the new template library as stated above and fill it with device or function
templates by using for example the copy and paste operations described below.
644 EIO0000002854.04
General Information about Templates
Step Action
1 Select the template library you want to export in the Installed Templates list.
4 Transfer the template library file to the other PC and install it by using the Template
Repository.
EIO0000002854.04 645
General Information about Templates
The Properties dialog box for the selected library or template library is displayed.
Element Description
Template Name / Library Name box Indicates the name of the library or template library these properties apply to. To
change the name, click this box and adapt the name according to your
requirements.
Help ID box For Schneider Electric templates or template libraries, contains the reference to
the respective description in the online help.
If there is an online help document available for your templates, you can enter a
full reference to its location in the online help or a keyword corresponding to an
index in the online help.
Show Help button Opens the online help document specified in the Help ID box or the index of the
online help searching for the keyword specified in the Help ID box.
Info section –
Language list Contains the languages that are available for the graphical user interface of
EcoStruxure Machine Expert. If you select a language, the content of the
language-dependent elements Comment, Description, and Picture is displayed
in the selected language.
Import From File button Displays a standard Open dialog box. It allows you to browse for an XML file that
contains the localized content of the language-dependent elements Comment,
Description, and Picture. The structure of this XML file must follow the structure
indicated in the example, page 647.
Comment box Allows you to enter a short text (for example to provide an overview of the contents
and purpose of the selected library or template library). This text is indicated as a
tooltip when you select template libraries in EcoStruxure Machine Expert.
646 EIO0000002854.04
General Information about Templates
Element Description
Description box Allows you to enter a long text (for example to provide a detailed description of the
contents and purpose of the selected library or template library.
... button You can also click the ... button to browse for the graphic file.
The check box Read-Only is only available for template libraries to indicate
whether the selected template library is in read-only status. It is not possible to
change the status of the template library here.
EIO0000002854.04 647
Managing Device Templates
648 EIO0000002854.04
Managing Device Templates
Step Action
2 At the bottom of the Devices & Modules view, activate the option Device Template.
Result: The templates of field devices available in EcoStruxure Machine Expert are displayed in the Devices & Modules
view.
3 Select an entry in the Devices & Modules view, drag it to the Devices tree, and drop it at a suitable subnode of a controller.
4 In the Add Device From Template dialog box, set the Device Name as well as the Device Address if the fieldbus requires
numerical addresses. In case the device templates includes control logic, select the program (POU) in which the control
logic is inserted.
Result: The device is created and parameterized according to the selected device template including the optional
visualization screens and control logic.
Step Action
2 Right-click field device manager, and execute the command Add Device From Template from the contextual menu.
EIO0000002854.04 649
Managing Device Templates
Step Action
3 In the Add Device From Template dialog box, select the Device Template to be used, and set the Device Name as well as
the Device Address if the fieldbus requires numerical addresses. In case the device templates includes control logic, select
the program (POU) in which the control logic is inserted.
Result: The device is created and parameterized according to the selected device template including the optional
visualization screens and control logic.
NOTE: The undo / redo function is not available for the process of creating
field devices.
Naming of Objects
In order to avoid naming conflicts if the same device template is used as a basis
for creating different field devices, the following naming conventions are applied to
the field devices and the associated objects (FB, visualization, and variables):
Case 1:
contains the name of the original field this part of the object is replaced by the name of the
device, new field device that is created.
Example:
The device template for the field device For a new device Axis1 being created with this device
ATV1 contains a variable Var_ATV1_ template, the new variable is correspondingly named
Input. Var_Axis1_Input.
Case 2:
does not contain the name of the original the name of the new device plus an underscore are
device, inserted in the original name to form a unique new
name.
Example:
The device template for the field device For a new device Axis1 being created with this device
ATV1 contains a variable Var_Input1. template, the new variable is correspondingly named
Axis1_Var_Input1.
650 EIO0000002854.04
Managing Device Templates
EIO0000002854.04 651
Managing Device Templates
Supported Visualizations
EcoStruxure Machine Expert supports both types of visualizations:
• Plain visualizations
• Modular visualizations using frames
Visualizations using frames have a better flexibility and modularity.
Plain Visualizations
Visualizations without frames are based on a single visualization object, created
for the I/O device.
EcoStruxure Machine Expert references the data of the I/O device within the
properties of the visual elements. When you create a new device based on this
device template, EcoStruxure Machine Expert directly replaces the variables in
the properties of the visual elements.
652 EIO0000002854.04
Managing Device Templates
EIO0000002854.04 653
Managing Device Templates
InOTB_Conv20 Input block Converting data coming from the OTB into
the format required by the control block
Step Action
1 Right-click the field device you want to save as device template in the Devices tree.
2 Select the command Save As Device Template from the contextual menu.
Result: EcoStruxure Machine Expert automatically builds the application. After the built
process has been successfully completed, the Save as Device Template dialog box will
be displayed.
3 Define the new device template in the Save as Device Template dialog box as stated
below.
4 Click OK to close the Save as Device Template dialog box and to create your new
device template.
654 EIO0000002854.04
Managing Device Templates
1 indicates the type of the field device on which the device template is based
2 indicates the fieldbus type of the field device
3 the name of the device template that will be created (initially the name of the
original field device)
4 select the template library the device template will be added to
5 select function blocks and visualizations that should be saved with the device
template
6 Properties button to add further information to the device template
EIO0000002854.04 655
Managing Device Templates
Step Action
1 In the Save as Device Template dialog box, click the ... button right to the Template
Library text box.
2 The Select Template Library dialog box displays all template libraries that have been
installed for the current project or have been created. Write-protected template libraries
are not displayed.
To add the new device template to 1 of these template libraries, select the suitable entry
and click OK.
Step Action
1 In the Save as Device Template dialog box, click the ... button to the right of the
Function Blocks text box.
The Select Function Block dialog box displays all function block instances contained
by the control logic of the field device, page 652.
2 Select the check box of an individual function block to select it for the device template.
Or select the check box of a root node to select all elements below this node.
3 Click the OK button.
Step Action
1 In the Save as Device Template dialog box, click the ... button to the right of the
Visualizations text box.
The Select Visualizations dialog box displays those visualizations that are linked with
the field device or with one of the selected function blocks.
2 Select the check box of an individual visualization to select it for the device template.
Or select the check box of a root node to select all elements below this node.
3 Click the OK button.
656 EIO0000002854.04
Managing Function Templates
EIO0000002854.04 657
Managing Function Templates
The Add Function From Template dialog box provides the following elements to
configure your function:
Element Description
Function Name text box Enter a name that is used for the new folder of this application and for the naming
of the elements it contains.
Function Template Click the ... button and select a function template from the Select Function
Template dialog box.
Device Name Contains the name of the future field device. You cannot change this name.
658 EIO0000002854.04
Managing Function Templates
Element Description
Device Type Indicates the type of the field device. You cannot edit this cell.
Fieldbus Type Indicates the fieldbus type of the field device. You cannot edit this cell.
Master Contains the fieldbus master to which the field device is connected. If there are
several masters, you can select the master of your choice from the list.
Address Initially empty. For field devices on fieldbusses that require numerical addresses
(Modbus serial line and CANopen), click the ... button right to the field and assign
the address of your choice.
I/O Mapping table Lists the I/O variables that are part of the function template. It allows you to map
them to the I/O channels of existing devices and modules.
Name Contains the name of the I/O variable that has to be mapped on an I/O channel.
Data Type Indicates the data type of the I/O channel to which the I/O variable was originally
mapped.
Mapping Click the ... button to open the Select I/O Mapping dialog box. It allows you to
select an I/O channel on which you can map the selected variable.
After the variable has been mapped to an I/O channel, this Mapping field contains
the input or output address of the I/O channel on which the variable is mapped.
Parameters table Lists the template parameters included in the function template.
Object Indicates the name of the GVL or program in which the variable is defined. You
cannot edit this field.
Name Contains the name of the variable. You cannot edit this cell.
Data Type Indicates the data type of the variable. You cannot edit this cell.
Default Indicates the default value of the variable. This is the initial value of the variable
when the template was created. You cannot edit this cell.
New Value Edit this cell if you want to assign a new value to the variable. If you leave this cell
empty, the Default value is used for this variable.
Result: EcoStruxure Machine Expert verifies whether the settings are correct and
inserts the new application function as separate node below the Application node
or displays an error detection message.
EIO0000002854.04 659
Managing Function Templates
The Select I/O Mapping dialog box contains the following columns:
Column Description
Channel Contains the tree structure. Each device is represented by the device
name and the device icon. Each I/O channel is represented by the channel
name.
Address Contains the input / output address that corresponds to the I/O channel.
Mapping Contains the I/O variable that is currently mapped on the I/O channel.
Objects Created
The function template creates the following objects in your project:
Object Description
Root folder A new folder is created under the Application node in the Devices tree that is
named as defined in the Function Name text box.
Field devices The field devices that are included in the function template are created using
names that apply to the naming rules and are connected to the fieldbus master.
The I/O mapping is automatically adjusted, if necessary.
Objects The objects that are included in the function template are created below the root
available as folder in the respective navigator (Devices tree, Applications tree, Tools tree)
subnodes of the using names that apply to the naming rules. The properties of the objects are
automatically adjusted.
660 EIO0000002854.04
Managing Function Templates
Object Description
Global variable The global variable lists that are included in the function template are created
lists below the root folder using names that apply to the naming rules.
External Global variables whose global variable lists do not belong to the function
variables template are restored in their original global variable list as follows:
• If a global variable list with the original name does not already exist below
the application, it is created automatically.
• If a global variable with the original name does not already exist in this
global variable list, it is created automatically.
If the type of global variable is not correct, EcoStruxure Machine Expert issues
an error detection message.
Persistent Persistent variables are restored in the respective variable list of the application
variables as follows:
• If a persistent variable list does not already exist below the application, it is
created automatically with its original name.
• If a variable with the original name does not already exist in the persistent
variable list, it is created automatically.
If the type of persistent variable is not correct, EcoStruxure Machine Expert
issues a message.
External objects Objects that are not included in the function template but are referenced by the
function template (such as function blocks and DUTs) are handled as follows:
• If the object does not exist, it is created
• If the object already exists and has not been modified, it remains
unchanged
• If the object already exists and modifications are detected, an error is
reported in the Messages view. To display further information on the
detected modifications, click the entry in the Messages view.
Any objects that are created with the instantiation of the function template are
listed in the Messages pane.
Naming of Objects
In order to avoid naming conflicts, if you instantiate the same function template
several times on the same controller device, the following naming conventions are
applied to the application functions and the associated objects:
Case 1:
contains the name of the application function, this part of the object is replaced by the name of
the new application function that is created.
Example:
The template original application function Axis For a new application function Axis1 being
contains a program Axis_Init. created with this template, the new program is
correspondingly named Axis1_Init.
Case 2:
does not contain the name of the application the name of the new application function plus
function, an underscore are inserted in the original name
to form a unique new name.
Example:
The original application function Axis contains a For a new application function Axis1 being
program InitProg. created with this function template, the new
program is correspondingly named Axis1_
InitProg.
EIO0000002854.04 661
Managing Function Templates
NOTE: Use rather short names for your application functions so that they are
completely displayed.
Template Parameters
A template parameter is a variable with an adjustable initial value.
662 EIO0000002854.04
Managing Function Templates
Step Action
2 Select the My Template node, and click the green plus button.
Result: A new node with the default name LIB1 is inserted below the MyTemplate node.
3 Select the LIB1 node and click the green plus button.
EIO0000002854.04 663
Managing Function Templates
Step Action
4 In the Function Template tab of the Create New Template dialog box, enter a Name for your function template.
Drag the elements you want to include in the function template from the Applications tree to the Elements box of the
Function Template tab. The elements listed in this box is inserted in your function template.
NOTE: The elements must belong to the same application.
5 The Parameters tab of the Create New Template dialog box displays those variables that are included in the elements you
selected in the Function Template tab.
664 EIO0000002854.04
Managing Function Templates
Step Action
From the list of variables, select those you want to declare as template parameters by selecting the check box of the
variable or of a node.
6 The Properties tab of the Create New Template dialog box allows you to add further information to the function template.
You can insert a link to the online help of this function template. The dialog box allows you to add further textual information
that can be localized, and you can add a graphic illustrating this function template. For a description of these parameters,
refer to the chapter Adding Further Information for Templates or Template Libraries, page 645.
Step Action
1 Right-click a subfolder of an application node in the Applications tree or a functional model node in the Functional tree.
2 Execute the command Save As Function Template from the contextual menu.
EIO0000002854.04 665
Managing Function Templates
Step Action
Result: EcoStruxure Machine Expert automatically builds the application. After the built process has been successfully
completed, the Save As Function Template dialog box is displayed.
4 Click OK to close the Save as Function Template dialog box and to create your new function template.
Result: EcoStruxure Machine Expert verifies that the function template can be created and displays a message that the
function template has been created successfully or indicates the errors detected.
Step Action
1 In the Save as Function Template dialog box, click the ... button next to the Template Library text box.
2 The Select Template Library dialog box displays the template libraries that have been installed for the open project or have
been created. Write-protected libraries are not displayed.
To add your new function template to one of these template libraries, select the suitable entry and click OK.
666 EIO0000002854.04
Managing Function Templates
Step Action
1 In the Save as Function Template dialog box, click the ... button to the right of the Parameters text box.
2 Select the check box of an individual variable to select it as template parameter for the function template.
Or select the check box of a root node to select all elements below this node.
3 Click the OK button.
Result: The selected variables are displayed in the Parameters text box of the Save as Function Template dialog box.
They are displayed in the Parameters table of the Add Function From Template dialog box where you can assign New
Values for these parameters.
Step Action
1 In the Save as Function Template dialog box, click the ... button right to the Template Name text box.
Result: The name of this function template is inserted in the Template Name text box and the name of the template library
where it is stored in is inserted in the Template Library text box.
4 Click OK to close the Save as Function Template dialog box and to replace the selected function template with the new
application function.
EIO0000002854.04 667
Troubleshooting and FAQ
What’s in This Part
Generic - Troubleshooting and FAQ............................................................... 669
Accessing Controllers - Troubleshooting and FAQ .......................................... 674
668 EIO0000002854.04
Generic - Troubleshooting and FAQ
Troubleshooting
Log File
Overview
EcoStruxure Machine Expert automatically creates a log file. It provides
information that is useful for debugging purposes. The size of the file is not
restricted and there is no automatic removal or overwriting procedure.
The file is deleted only when EcoStruxure Machine Expert is uninstalled.
NOTE: Delete the file manually in suitable time intervals so that it does not use
a large amount of disk space on your PC. The file is found in the temporary
folder of Windows, defined by the variable %TEMP%.
Procedure
Step Action
1 Double-click the node of your analog CANopen device in the Devices tree.
2 In the CANopen Remote Device tab of the editor, enable the option Enable Expert Settings.
Result: Additional tabs are displayed and the Service Data Object tab is populated with information.
EIO0000002854.04 669
Generic - Troubleshooting and FAQ
Step Action
3 Open the Service Data Object tab and click the New... button.
Result: The Select item from object directory dialog box is displayed.
4 From the list of objects, select object 6423, enter 1 as Value, and click OK.
Result: Analog input transmission on the CANopen bus is activated. You can now configure parameters of the analog
values as described in the hardware manual of your device.
first start after On first start after EcoStruxure Machine Expert has been installed, the
EcoStruxure Machine software will generate its working environment on the PC. This is done
Expert installation only one time but has significant impact on the duration of the first
startup.
first start after reboot After rebooting the PC, the startup time of EcoStruxure Machine
Expert can be longer than usual because Microsoft Windows
consumes some time in the background to launch services that are
needed to run EcoStruxure Machine Expert. This can have impact on
the startup duration and cannot be avoided.
subsequent starts Users experience better performance of the startup when the system
has been started previously on the PC.
670 EIO0000002854.04
Generic - Troubleshooting and FAQ
Step Action
3 In the Load Menu dialog box, navigate to the folder ...\Program Files\Schneider Electric
\EcoStruxure Machine Expert\Vx.x\LogicBuilder\Settings, select the file Standard.opt.
menu, and click Open.
Result: The Customize dialog box now shows the standard EcoStruxure Machine
Expert settings.
4 To load these standard settings to the EcoStruxure Machine Expert graphical user
interface, click OK.
Step Action
3 In the Load Menu dialog box, navigate to the folder ...\Program Files\Schneider Electric
\SoMachine Software\Vx.x\LogicBuilder\Settings\OriginalCoDeSys, select the file
Standard.opt.menu, and click Open.
Result: The Customize dialog box now shows the CODESYS settings.
4 To load these CODESYS settings to the EcoStruxure Machine Expert graphical user
interface, click OK.
NOTE: The menus and shortcuts of the EcoStruxure Machine Expert software
differ, depending on the window or editor that is currently open.
EIO0000002854.04 671
Generic - Troubleshooting and FAQ
Expanding Menus
EcoStruxure Machine Expert main menus and contextual menus can be displayed
in a collapsed or full view. In the collapsed mode seldom used or disabled
commands are hidden. After clicking the arrow menu item at the bottom of a
menu, the corresponding menu expands, showing all its menu items.
For always showing the menus in the full viewing mode, activate the option
Always show full menus in the Tools > Options > Features dialog box.
672 EIO0000002854.04
Generic - Troubleshooting and FAQ
Step Action
2 Verify that your cable is correctly connected between the controller and the Modbus
Serial slave.
3 Reset your controller.
the parameter
uiNumberOfCommunicatingSlaves is decreased
and xAllSlavesOK is set to FALSE.
After the communication to the slave has been re-established, a rising edge on the
xReset entry of the slave is required:
• To reset xError.
• To update the values of uiNumberOfCommunicatingSlaves.
• To update the values of xAllSlavesOK.
Solution
Restart the target controller.
EIO0000002854.04 673
Accessing Controllers - Troubleshooting and FAQ
Example
This example shows the steps to access an M262 with IP address 192.168.1.33
from a PC with IP address 192.168.1.10 residing in subnet 255.255.255.0.
Step Action
1 Connect the controller directly to the PC running EcoStruxure Machine Expert or to the network of the PC using an Ethernet
cable.
2 In EcoStruxure Machine Expert, open the Communication Settings view of the device editor, page 78.
3 To adapt the communication settings of the controller, right-click the controller in the Communication Settings list, and
execute the command Edit communication settings... from the contextual menu.
4 In the Edit communication settings dialog box, enter a free IP address available in your network.
674 EIO0000002854.04
Accessing Controllers - Troubleshooting and FAQ
Carefully manage the IP addresses because each device on the network requires
a unique address. Having multiple devices with the same IP address can cause
unintended operation of your network and associated equipment.
WARNING
UNINTENDED EQUIPMENT OPERATION
• Verify that all devices have unique addresses.
• Obtain your IP address from your system administrator.
• Confirm that the device’s IP address is unique before placing the system into
service.
• Do not assign the same IP address to any other equipment on the network.
• Update the IP address after cloning any application that includes Ethernet
communications to a unique address.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
NOTE: Some controllers support a parameter that helps to prevent them from
being remotely accessed (RemoteCommunicationAccess parameter of the
LMC •0•C controllers.
1 PC
2 hop controller
3 target controller
4 USB
5 Ethernet
Address Information
In the example, USB uses a different protocol. It is therefore normally not possible
to use the IP address to address the target controller. Instead, the routing
information is used that describes the way to connect to the target controller over
1 or more hops.
EIO0000002854.04 675
Accessing Controllers - Troubleshooting and FAQ
This routing information is displayed as a tooltip of an entry of the controller list (in
the following example [Address] 0000.2001):
NOTE: Since this address only describes the way the controller is connected,
it can change upon each modification of the local PCs or the network adapter
settings of the hop controller. For example, upon activating or deactivating
network adapters or upon starting/stopping services that use network
adapters. The address to a specific target can differ from different sending
PCs.
Nodename
Since the Nodename of the controller is a stable identifier in the system, it is used
to identify the target.
If IP Address is selected as Connection Mode, it is tried to get the information
from the Nodename itself. Some controllers (such as LMC •0•C) create the
Nodename automatically including the IP address. You can also configure the
Nodename by yourself (as described in the FAQ Why is the Controller not Listed
in the Communication Settings View?, page 679) to enable the system to find a
controller by its IP address. If the IP address is missing in the nodename, it is tried
to get the IP address from a controller. But not all devices or their current firmware
version support the service. In this case, use the Connection Mode Nodename
to connect or set a device name that includes the IP address in brackets. For
example MyDevice (192.168.1.30).
676 EIO0000002854.04
Accessing Controllers - Troubleshooting and FAQ
Step Action
1 In EcoStruxure Machine Expert, open the Communication Settings view of the device
editor, page 78.
2 To adapt the communication settings of the controller, right-click the controller in the
Communication Settings list, and execute the command Edit communication
settings... from the contextual menu.
3 Adapt the Subnet mask configured for the controller exactly to the subnet mask of your
EcoStruxure Machine Expert PC.
Example:
Step Action
1 In the Windows notification area, verify whether the Gateway Management Console icon
2 Right-click the Gateway Management Console icon, and execute the command Start
Gateway from the contextual menu.
3 In the Windows notification area, verify whether the Gateway Management Console icon
EIO0000002854.04 677
Accessing Controllers - Troubleshooting and FAQ
Step Action
1 Open the Tools > Options > Device editor dialog box (see EcoStruxure Machine
Expert, Menu Commands, Online Help).
2 Select the Communication page > Controller selection mode setting and confirm by
clicking OK.
678 EIO0000002854.04
Accessing Controllers - Troubleshooting and FAQ
WARNING
UNINTENDED EQUIPMENT OPERATION
• Verify that all devices have unique Nodenames before placing the system
into service.
• Update the Nodename after cloning any application that includes Ethernet
communications to a unique Nodename.
Failure to follow these instructions can result in death, serious injury, or
equipment damage.
Step Action
2 Right-click the device with a duplicate Nodename in the list and execute the commands
Set active path and Change device name from the contextual menu.
3 In the Change device name dialog box, enter a unique Nodename in the New text box.
4 Click OK to confirm and to close the Change device name dialog box.
5 In the Communication Settings view, click the Scan network button to refresh the list
of devices.
Result: The second device with the same Nodename of the device you just have
changed will now be displayed in the list.
EIO0000002854.04 679
Accessing Controllers - Troubleshooting and FAQ
Step Action
Right-click the Gateway Tray Application icon in the Windows task bar .
680 EIO0000002854.04
Appendices
What’s in This Part
Network Communication............................................................................... 682
Python Script Language................................................................................ 687
Controller Feature Sets for Migration ............................................................. 750
EIO0000002854.04 681
Network Communication
Network Communication
What’s in This Chapter
Network Topology........................................................................................ 682
Addressing and Routing............................................................................... 682
Structure of Addresses ................................................................................ 684
Network Topology
Overview
The EcoStruxure Machine Expert control network is a system programmed to
configure itself (address assignment) to support transparent communication
media and to route packets between different networks. The routing mechanism
lets any node in the network, that is, even nodes with low resources, reroute
packets. So, large routing tables, complex calculations, or requests during runtime
are avoided.
The control network is configured hierarchically, that is, each node has one parent
node and an arbitrary number of children. A node without a parent is referred to as
top-level node. Cycles are not permitted, that is, a control network has a tree
structure.
Parent-child relationships arise from the specification of network segments. A
network segment corresponds, for example, to a local Ethernet or a serial point-to-
point connection. It distinguishes between the main network (mainnet) and the
subnetworks (subnet). Each node has, at most, one main network, wherein it
expects its parent. For each node, an arbitrary number of subnets can be
configured. The node acts as parent for all of them.
If a network segment had been defined simultaneously as subnet of several
nodes, the network would have several parents. However, the resulting
configuration will be invalid, as each network segment is allowed to have one
parent only.
682 EIO0000002854.04
Network Communication
In the example, the addresses of the child nodes are given in hexadecimal
representation. The first 4 digits represent the address of the particular parent
within the main net. For example, 0x007A=122 for PLC1. The next byte (displayed
in blue) is reserved for the subnet index and this is followed by the local address,
for example, C=12 for node ID 12.
Due to the structuring of the address, the routing algorithm can be kept relatively
lean. For example, no routing tables are necessary. Information is required locally:
on the own address and on the address of the parent node.
Thereon, a node may properly handle data packets.
• If the target address equals the address of the current node, it is determined
as receiver.
• If the target address starts with the address of the current node, the packet is
intended for a child or descendant of the node and has to be forwarded.
• Else, the receiver is not a descendant of the current node. The packet has to
be forwarded to the own parent.
Relative Addressing
Relative addressing is a special feature. Relative addresses, page 685 do not
contain the node number of the receiver node, but directly describe the path from
the sender to the receiver. The principle is similar to a relative path in the file
system: The address consists of the number of steps the packet has to move up,
that is, to the next respective parent, and the subsequent path down to the target
node.
The advantage of relative addressing is that 2 nodes within the same subtree are
able to continue the communication when the entire subtree is moved to another
position within the overall control network. While the absolute node addresses will
change due to such a relocation, the relative addresses are still valid.
Determination of Addresses
A node attempts to determine its own address as that coming from its parent or
whether itself is a top-level node. For this purpose, a node will send an address
determination via a broadcast message to its main network during boot-up. As
long as this message is not responded to, the node considers itself to be a top-
EIO0000002854.04 683
Network Communication
level node, although it will continue to try to detect a parent node. A parent node
will respond by an address notification. Thereon, the node will complete its own
address and pass it to the subnets.
Address determination can be executed at bootup or on request of the
programming PC.
Structure of Addresses
Overview
Below is a detailed description on the structure of the following address types:
• Network Addresses, page 684
• Node Addresses, page 685
• Absolute and Relative Addresses, page 685
• Broadcast Addresses, page 686
Network Addresses
Network addresses represent a mapping of addresses of a network type (for
example, IP addresses) to logical addresses within a control network. This
mapping is handled by the respective block driver. Within an Ethernet with class C
IP addresses, the first 3 bytes of the IP address are the same for all network
devices. Therefore, the last 8 bits of the IP address suffice as a network address
since they allow unambiguous mapping between the 2 addresses at the block
driver.
A node has separate network addresses for each network connection. Different
network connections may have the same network address since this address has
to be unique only locally for each network connection.
Terminology: In general, the network address of a node without a statement of the
network connection refers to the network address in the main network.
The length of a network address is specified in bits and can be chosen by the
block driver as required. Within a network segment, the same length must be used
for all nodes.
A network address is represented as an array of bytes with the following coding:
• Length of the network address: n bits
• Required bytes: b = (n + 7) DIV 8
• The (n MOD 8) lowest-order bits of the first byte and all remaining (n DIV 8)
bytes are used for the network address.
684 EIO0000002854.04
Network Communication
Node Addresses
The node address indicates the absolute address of a node within a control
network, and therefore, is unique within the whole tree. The address consists of up
to 15 address components, each consisting of 2 bytes. The lower a node is
located within the network hierarchy, the longer its address.
The node address consists of the partial addresses of all predecessors of the
node and the node itself. Each partial address consists of one or several address
components. The length is therefore always a multiple of 2. The partial address of
a node is formed from the network address of the node in its main network and the
subnet index of the main network in the parent node. The bits required for the
subnet index are determined by the router of the parent node. Filler bits are
inserted between the subnet index and the network address in order to ensure
that the length of the partial address is a multiple of 2 bytes.
Special cases:
• Node has no main network: There is no subnet index nor a network address
in the main network. In this case, the address is set to 0x0000.
• Node with main network but without parent: In this case, a subnet index with
0-bit length is assumed. The partial address corresponds to the network
address, supplemented by filler bits if required.
Example - node address
EIO0000002854.04 685
Network Communication
On arrival at the common parent, the relative path (an array of address
components) is then followed downwards in the normal way.
Formal: The node address of the receiver is formed by removing the last address
offset components from the node address of the sender and appending the
relative path to the remaining address.
Example
Within the example, a letter will represent an address component, whereas a point
will separate the particular nodes. Since a node is allowed to have multiple
address components, it is allowed to have multiple letters within the example.
Node A: a.bc.d.ef.g
Node B: a.bc.i.j.kl.m
• Address of the lowest common parent: a.bc
• Relative address from A to B: -4/i.j.kl.m (The number -4 results from the 4
components d, e, f, and g. Therefore the packet has to be raised).
The relative address has to be adjusted with each pass through an intermediate
node. It is sufficient to adjust the address offset. This is always done by the parent
node: If a node receives a packet from one of its subnets, the address offset is
increased by the length of the address component of this subnet.
• If the new address offset is < 0, the packet must be forwarded to the parent
node.
• If the address offset 1 ≥ 0, the packet must be forwarded to the child node of
the local address of which is located at the position described by the address
offset within the relative address. First, the address offset must be increased
by the length of the local address of the child node to ensure that the node
sees a correct address.
A special situation arises when the error described above occurs while
determining the common parent. In this case, the address offset at the “real”
common parent is negative, but the magnitude is greater than the length of the
partial address of the subnet the packet originates from. The node must detect this
case, calculate the local address of the next child node based on the address of
the previous node and the length difference, and adapt the address offset such
that the next node will see a correct relative address. Also, the address
components themselves remain unchanged and only the address offset will be
modified.
Broadcast Addresses
There are 2 types of broadcasts - global and local ones. A global broadcast is sent
to all nodes within a control network. The empty node address (length 0) is
reserved for this purpose.
Local broadcasts are sent to all devices of a network segment. For this purpose,
all bits of the network address are set to 1. This is possible both in relative and in
absolute addresses.
A block driver must be able to handle both broadcast addresses, that is, empty
network addresses and network addresses with all bits set to 1, must be
interpreted and sent as broadcast.
686 EIO0000002854.04
Python Script Language
General Information
Introduction
Python Scripting in EcoStruxure Machine Expert
EcoStruxure Machine Expert includes a Python interpreter which can be used as a
powerful tool to automate the development environment.
You can execute Python script files via the menu command Tools > Scripting >
Execute Script File... in the main menu of the EcoStruxure Machine Expert Logic
Builder.
The documentation for Python scripting in EcoStruxure Machine Expert consists
of several parts:
The chapter Accessing the Python Interpreter in EcoStruxure Machine Expert,
page 689 describes how you can open the Python interpreter of EcoStruxure
Machine Expert and how you can execute script files with it and how you can
otherwise interact with it. The chapters Using the Logic Builder Shell, page 691,
Using the Logic Builder Scripting Immediate View, page 697, and Keyboard
Commands in the Logic Builder Shell and the Scripting Immediate View, page 699
provide more details on individual parts.
The sections Schneider Electric Script Engine Examples, page 713 and
CODESYS Script Engine Examples, page 726 provide various examples for how
to automate EcoStruxure Machine Expert with Python scripts. These examples
are given to provide a common thread that shows the capabilities of the
EcoStruxure Machine Expert-specific API (Application Programming Interface)
available to Python scripts.
The chapters Explore EcoStruxure Machine Expert Python API (with dir() and
inspectapi), page 700, Best Practices, page 704, and EcoStruxure Machine
Expert Scripting - Python API, page 707 provide general hints on how to get
started with Python scripting and how to explore the API provided.
The sections Schneider Electric - Script Engine Class Library and Script Engine
Plugin API Reference provided in the Programming with EcoStruxure Machine
Expert part of the EcoStruxure Machine Expert online help provide the reference
of the EcoStruxure Machine Expert-specific API available to Python scripts. You
can use these members in the same manner as described in the aforementioned
examples.
EIO0000002854.04 687
Python Script Language
Coding Conventions
In order to harmonize and facilitate the work of different programmers on the same
programming project, it makes sense to agree on a common programming style.
EcoStruxure Machine Expert adheres to the Style Guide for Python Code. The
scripts and examples delivered with EcoStruxure Machine Expert adhere to these
conventions. For improved readability of code, it is a best practice that your own
code adheres to the same conventions.
For further information, refer to the Style Guide for Python Code at http://www.
python.org/dev/peps/pep-0008/.
Useful Links
For further information, refer to the following websites:
• Official Python webpage providing a tutorial and language references at
http://docs.python.org/.
• Official Python blog at http://blog.python.org/.
• Beginner’s Guide to Python at http://wiki.python.org/moin/BeginnersGuide.
• Official CODESYS forum providing examples and helpful information at http://
forum.codesys.com/.
• IronPython interpreter at http://ironpython.codeplex.com/.
• Free Galileo Openbook (only available in German) at http://openbook.
galileocomputing.de/python/.
688 EIO0000002854.04
Python Script Language
Logic Builder user interface Interactive (REPL) Interactive Python shell with a Menu command View >
command-line interface, Scripting > Scripting
embedded in the user interface Immediate in the Logic Builder
of EcoStruxure Machine Expert. (also refer to the chapter Using
the Logic Builder Scripting
Immediate View, page 698).
Python file (*.py) Select a script file to be Menu command Tools >
executed from within the user Scripting > Execute Script
interface of EcoStruxure File... command in the Logic
Machine Expert. Builder (also refer to the chapter
Using the Logic Builder Scripting
Immediate View, page 697.
Python file (*.py) Executes a Python script from Open LogicBuilderShell.exe with
the Windows command-line, a script file as a command-line
from a batch file, or similar argument (refer to the chapter
ways. Using the Logic Builder Shell,
page 691).
EIO0000002854.04 689
Python Script Language
690 EIO0000002854.04
Python Script Language
EIO0000002854.04 691
Python Script Language
Commands
At the input prompt (>>>), type your Python statements and press Enter to
execute them.
The following sequence of commands provides an example on how to open a
project, search a device node and print the name:
IronPython 2.7.4 (2.7.4.40) on .NET 4.0.30319.18444 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> projectName = "C:\\temp\\MyProject.project"
>>> proj = projects.open(projectName)
>>> sercosNode = proj.find("SERCOSIII", True)[0]
>>> print(sercosNode.get_name(False))
SERCOSIII
>>>
Usage:
LogicBuilderShell.exe [options] [file.py|- [arguments]]
The [options] are defined in the list of command-line arguments below.
[arguments] is a placeholder for arguments that are passed to the script file.
Command-line arguments of the Logic Builder Shell:
--nologo Skips the display of the informational text of the Logic Builder LogicBuilderShell.exe --nologo
during startup.
Use Case 1
When executing scripts in Continuous Integration (CI) systems - for example, to
Checkout an EcoStruxure Machine Expert project from Subversion (SVN),
compile the project and save as library - you need the script output printed to a
console. With the LogicBuilderShell.exe as real console application, you can
redirect the output or call it in a CI system (for example, Jenkins) where the output
is fetched and added to a build log.
Example:
LogicBuilderShell.exe MyScript.py > output.txt
692 EIO0000002854.04
Python Script Language
Use Case 2
LogicBuilderShell.exe allows you to use the built-in command-line debugging
feature called pdb module.
Example:
LogicBuilderShell.exe -m pdb MyScript.py
Use Case 3
Test your Python scripts in no UI mode to verify that it is working. In console mode,
you can enter input via the console. Keep in mind that reading input from the
console is only possible in the LogicBuilderShell.exe. In the Scripting Immediate
view, that is available in the Logic Builder user interface, no console input is
possible. This has the effect that the statement readline() is ignored.
Example:
import sys
print("Please enter a text: ")
text = sys.stdin.readline()
print("Your entered text: " + text)
Use Case 4
Explore the Python and EcoStruxure Machine Expert API and documentation.
• Use the built-in help() feature to access the Python help via the IronPython
shell. To achieve this, make sure that an Internet connection is available.
Example:
help() # start the built-in help module
topics # list all available topics
##### here you'll get the list of available topics #####
LIST # dumps the help to work with lists.
##### here you'll get the help working with lists #####
quit # leaf build-in help feature
• Use the built-in dir() feature to print available api functions.
Example:
dir() # prints the list of defined variables and functions in current script
scope
##### here you'll get the list of defined variables or functions in current script
scope #####
import sys
dir(sys) # prints the available functions defined in sys module
##### here you'll get the list of defined variables or functions in sys module
#####
• Use the inspectapi module to explore the EcoStruxure Machine Expert
Python API. Due do technical restrictions, the built-in dir() feature of
Python cannot print the API help for the EcoStruxure Machine Expert Python
API. To achieve this, use the inspectapi.
Example:
inspectapi.dir(projects) # prints the available API functions of "projects" which
provides access e.g. to open a Machine Expert project
##### here you'll get the Machine Expert API provided via "projects" variable
#####
Use Case 5
Use -i switch as argument passed to the LogicBuilderShell.exe in combination
with a specified script to get the shell prompt at the end of the script run. This can
help to inspect interactively after running a script, for example, to see the content
of variables.
EIO0000002854.04 693
Python Script Language
694 EIO0000002854.04
Python Script Language
Selection of pdb debugger commands (refer to the Python help on the Internet for
more details):
b(reak) With a line number argument, set a break at this position in the file.
With a function argument, set a break at the first executable statement within that function. The line
number may be prefixed with a file name and a colon to specify a breakpoint in another file
(probably one that has not been loaded yet). The file is searched on sys.path. Each breakpoint is
assigned a number to which the other breakpoint commands refer.
If a second argument is present, it is an expression which must evaluate to TRUE before the
breakpoint is honored.
Without argument, list all breaks. For each breakpoint listed, the number of times that the
breakpoint has been hit, the ignore count, and the associated condition, if any, are included.
Without arguments, list 11 lines around the current line or continue the previous listing.
With two arguments, list the given range; if the second argument is less than the first, it is
interpreted as a count.
n(ext) Continue execution until the next line in the current function is reached or it returns. (The difference
between next and step is that step stops inside a called function while next executes called
functions at (nearly) full speed, only stopping at the next line in the current function.)
s(tep) Execute the current line, stop at the first possible occasion (either in a function that is called or on
the next line in the current function).
u(ntil) Continue execution until the line with the line number greater than the current one is reached or
when returning from the current frame.
EIO0000002854.04 695
Python Script Language
In each line in the following listing starting with (pdb), a debugger command is
executed, such as list (l) or help or next (n) or quit (q). In between you
can see the statement or its output which was executed.
LogicBuilderShell.exe -m pdb MachineExpertPythonDemonstration.py
Machine Expert Logic Builder Shell version 1.53.16.0
Copyright (C) Schneider Electric Automation GmbH 2014-2015
Demonstration how to use Python pdb module to debug Machine Expert Python scripts
> C:\temp\MachineExpertpythondemonstration.py(5)<module>()
-> if projects.primary:
(Pdb) help
Documented commands (type help <topic>):
========================================
EOF bt cont enable jump pp run unt
a c continue exit l q s until
alias cl d h list quit step up
args clear debug help n r tbreak w
b commands disable ignore next restart u whatis
break condition down j p return unalias where
Miscellaneous help topics:
==========================
exec pdb
Undocumented commands:
======================
retval rv
(Pdb) l
1
2 print("Demonstration how to use Python pdb module to debug Machine Expert
Python scripts")
3
4 # close open project
5 -> if projects.primary:
6 print("Close project")
7 projects.primary.close()
8
9 print("Open project")
10 projects.open("c:\\Temp\\MyProject.project")
11
(Pdb) n
> C:\temp\MachineExpertpythondemonstration.py(9)<module>()
-> print("Open project")
(Pdb) n
Open project
> C:\temp\MachineExpertpythondemonstration.py(10)<module>()
-> projects.open("c:\\Temp\\MyProject.project")
(Pdb) l
5 if projects.primary:
6 print("Close project")
7 projects.primary.close()
8
9 print("Open project")
10 -> projects.open("c:\\Temp\\MyProject.project")
11
12 sercosDevice = projects.primary.find("SERCOSIII", True)[0]
13
14 sercosDeviceName = sercosDevice.get_name(False)
15
(Pdb) n
IOError: IOError(...oject'.")
> C:\temp\MachineExpertpythondemonstration.py(10)<module>()
-> projects.open("c:\\Temp\\MyProject.project")
(Pdb) q
Machine Expert Logic Builder Shell terminated.
696 EIO0000002854.04
Python Script Language
EIO0000002854.04 697
Python Script Language
The Scripting Immediate view allows you to enter Python statements and to
execute them (using the REPL).
To run a Python script file, click the ... button or enter the script name into the
prompt textbox and click the Go! button.
Click the Reset button to reset the Scripting Immediate view and to clear the
current scope.
698 EIO0000002854.04
Python Script Language
Element Description
Example
Enter and execute the following statement in the Scripting Immediate view.
projectName = "C:\\temp\\MyProject.project"
Proceed as follows:
Step Action
When you assign a different value to the variable projectName, the changed
content is displayed.
EIO0000002854.04 699
Python Script Language
700 EIO0000002854.04
Python Script Language
• If the object is a module object, the list contains the names of the attributes of
the module.
• If the object is a type or class object, the list contains the names of its
attributes, and recursively of the attributes of its bases.
• Otherwise, the list contains the names of the attributes of the object, the
names of the attributes of its class, and recursively of the attributes of the
base classes.
Example (in LogicBuilderShell.exe):
>>> import struct
>>> dir() # show the names in the module namespace
['__builtins__', '__doc__', '__name__', 'struct']
>>> dir(struct) # show the names in the struct module
['Struct', '__builtins__', '__doc__', '__file__', '__name__
',
'__package__', '_clearcache', 'calcsize', 'error', 'pack',
’pack_into',
'unpack', 'unpack_from']
>>> class Shape(object):
def __dir__(self):
return ['area', 'perimeter', 'location']
>>> s = Shape()
>>> dir(s)
['area', 'perimeter', 'location']
inspectapi Functions
Since the dir() function does not list all EcoStruxure Machine Expert Python API
elements, additional functions are provided to display them for Python script
developers.
inspectapi is a Python module loaded automatically while starting the
LogicBuilderShell.exe or the Scripting Immediate view. As a result, a variable/
module inspectapi is available in the current scope. This variable is also listed
by executing the dir() function.
The inspectapi variable/module provides the following functions:
inspectapi.dir_
properties
Examples:
# To see the API of the inspect api itself
inspectapi.dir(inspectapi)
Output:
Members of type 'InspectAPI'
Methods:
dir (obj, verbose = False)
dir_events (obj, verbose = False)
dir_fields (obj, verbose = False)
dir_methods (obj, verbose = False)
dir_properties (obj, verbose = False)
# To see the API of projects variable
inspectapi.dir(projects)
EIO0000002854.04 701
Python Script Language
Output:
Members of type 'ScriptProjects'
Properties:
[get] all
[get] primary
Methods:
convert (stPath, stOutputPath, converter, bPrimary)
convert (stPath, stOutputPath, converterGuid, bPrimary)
create (stPath, bPrimary)
get_all ()
get_by_path (stPath)
get_primary ()
open (stPath, stPassword, bPrimary)
open (stPath, encryption_password, session_user, session_
password, bPrimary)
open_archive (stArchiveFile, stProjectPath, bOverwrite,
stPassword)
open_archive (stArchiveFile, stProjectPath, bOverwrite,
encryption_password, session_user, session_password)
# open a project
proj = projects.open("c:\\temp\\MyScript.py ”)
# To see API of primary project
inspectapi.dir(projects.primary)
Output (truncated):
Members of type 'ScriptProject'
Properties:
[set] active_application
[get] dirty
[get] handle
[get] has_library_manager
[get] has_project_info
[get] is_root
[get] library
[get] path
[get] primary
[get] project
[get] svn
[get] user_management
Methods:
add (stName, id, stModuleId)
add (stName, iType, stId, stVersion, stModuleId)
check_all_pool_objects ()
clean_all ()
close ()
compare_to (projectFile)
compare_to (projectFile, ignoreWhiteSpace, ignoreComments,
ignoreProperties)
...
logout ()
save ()
save_archive (stArchiveFile)
save_archive (stPath, additional_categories)
save_archive (stPath, comment, additional_categories)
save_archive (stPath, additional_files, additional_
categories)
....
save_as (stPath, stPassword)
save_as_compiled_library (destination_name)
set_active_application (value)
update ()
# search objects by name (e.g. a device with name SERCOSIII)
objs = projects.primary.find("SERCOSIII", True)
# extract object at index 0 from returned list (if found).
theObj = obj[0]
# see the available API of the found object SERCOSIII
inspectapi.dir(theObj)
702 EIO0000002854.04
Python Script Language
Output (truncated):
Members of type 'ScriptObject'
Properties:
[get] connectors
[get] device_parameters
[get] embedded_object_types
[get] guid
[get] handle
[get] has_textual_declaration
[get] has_textual_implementation
[get] index
[get] is_application
[get] is_device
[get] is_explicit_connector
[get] is_folder
[get] is_libman
[get] is_project_info
[get] is_root
[get] is_task
[get] parent
[get] project
[get] svn
[get] type
Methods:
add (stName, id, stModuleId)
add (stName, iType, stId, stVersion, stModuleId)
allowed_interfaces_at (index)
can_convert (targetDeviceId, targetModuleId = null)
can_convert (targetType, targetId, targetVersion,
targetModuleId = null)
convert (targetDeviceId, targetModuleId = null)
convert (targetType, targetId, targetVersion,
targetModuleId = null)
create_folder (stFolderName)
disable ()
enable ()
export_native (destination, includeChildren, profileName,
reporter)
export_xml (reporter, stPath, bRecursive)
export_xml (reporter, stPath, bRecursive,
bExportFolderStructure)
export_xml (reporter, stPath, bRecursive,
bExportFolderStructure, bPlainText)
export_xml (stPath, bRecursive, bExportFolderStructure,
bPlainText)
find (namePath)
find (stName, recursive)
get_address ()
get_all_parameters ()
...
move (newParent, nNewIndex)
plug (stName, id, stModuleId)
plug (stName, iType, stId, stVersion, stModuleId)
reboot_plc ()
remove ()
rename (stNewName)
reset_diagnosis_messages ()
set_communication_address (address)
set_gateway_and_address (stGateway, stAddress)
set_gateway_and_address (gateway, stAddress)
set_parameter (parameter, value)
set_parameter_iec_address (identifier, connectorId,
iecAddress)
set_parameter_io_variable_mapping (identifier,
connectorId, variable, createVariable = False)
set_parameter_io_variable_mapping (identifier,
connectorId, subElementIndex, variable, createVariable =
False)
EIO0000002854.04 703
Python Script Language
set_simulation_mode (bSimulation)
unplug ()
update (id, stModuleId)
update (iType, stId, stVersion, stModuleId)
Executing Scripts
Overview
You can execute script files (filename.py), containing a sequence of script
commands, from the EcoStruxure Machine Expert user interface.
For further information on running scripts form the EcoStruxure Machine Expert
user interface, refer to the chapter Script-Related Commands (see EcoStruxure
Machine Expert, Menu Commands, Online Help).
Batch Files
Frequently used commands
Command Description
> Writes the output to a file. If the file already exists, it will be
overwritten.
>> Appends the output to a file. If the file does not already exist, it
will be created.
Application example:
@echo off
REM Go to the directory where EcoStruxure Machine Expert is
installed
cd "<Replace this with the path to the LogicBuilderShell.
exe, for example, C:\Program Files\Schneider Electric
\EcoStruxure Machine Expert\V2.0>"
REM Run LogicBuilderShell.exe with no graphical user
interface and the full path to the script
LogicBuilderShell.exe "<Replace this with the full file path
where the script is stored, for example, D:\MyScripts
\TestScript.py>"
pause
Best Practices
Indentation (Tabs and Spaces)
Blocks in Python are created by indentation of codes of block (unlike, for example,
END_IF statements in structured text, or curly brackets {" "} in the C
programming language).
Examples:
704 EIO0000002854.04
Python Script Language
Note that when mixing tabs and spaces for indentation: In Python, tab characters
are internally replaced by 8 spaces. Since numerous editors by default use 4
spaces, this can lead to code errors that are difficult to find. Source code blocks
appear to have the same size of the indent but actually the indentation is different.
Therefore, care should be taken when using copy and paste commands.
To help to avoid this, configure your editor in such a way that it automatically
replaces tab characters by spaces.
Case Sensitivity
Python is a case-sensitive language (in contrast to, for example, structured text).
Therefore, MyVar and MYVAR refer to two different variables.
Colons (:)
Loop declarations and conditions end with a colon.
Example:
if len(messages) == 0:
print("--- Build successful ---")
EIO0000002854.04 705
Python Script Language
For further information, refer to the chapter Schneider Electric Script Engine
Examples in this document, page 713 or to the chapter Explore EcoStruxure
Machine Expert Python API (with dir() and inspectapi), page 700 to explore
the API directly.
706 EIO0000002854.04
Python Script Language
EIO0000002854.04 707
Python Script Language
708 EIO0000002854.04
Python Script Language
EIO0000002854.04 709
Python Script Language
Examples
Example of using a global API function to open a project:
projects.open("MyProject.project")
Example to find and rename a project tree object (after a project was loaded):
myObject = projects.primary.find("SERCOSIII")[0]
myObject.rename("New_SERCOSIII_Name")
The figure shows the project tree object in the user interface and the traversed
project tree printed by a script:
Devices
Untitled1
LMC_PacDrive (PacDrive LMC 300/400/402/600/...
Device Addressing
Message logger
PLC Logic
Application
Library Manager
SR_Main (PRG)
Task Configuration
TASK_SR_Main
SR_Main
Sercos_Master (Sercos Master)
DQG_DigitalOut (Digital Outputs)
DIG_DigitalIn (Digital Inputs)
TPG_TPIn (Touch Probe Inputs)
AI_0 (Analog Input)
AI_1 (Analog Input)
AQ_0 (Analog Output)
AQ_1 (Analog Output)
POUs
Untitled1
Project Information
Project Information
Project Settings
710 EIO0000002854.04
Python Script Language
"Name" Yes This text is displayed as a tooltip for the icon in the
toolbar.
Example:
"Name": "Pause"
"Desc" No This element is not used in EcoStruxure Machine
Expert.
"Icon" Yes This element contains the name of the image file (in .ico
format) if the image file is located in the same folder
(Script Commands) as the config.json file.
EIO0000002854.04 711
Python Script Language
Example:
"Icon": "pause.ico"
"Path" Yes This element contains the name of the Python script file
in .py format if the script file is located in the same folder
(Script Commands) as the config.json file.
Example:
"Path": "stop.py"
Example:
712 EIO0000002854.04
Python Script Language
Library library
Controller Settings
The controller settings consist of the following elements
Element Description
EIO0000002854.04 713
Python Script Language
Device Parameters
Overview
To change a parameter, the parameter ID and the ParameterSet are required.
In order to find the required device and list the respective parameters, use the find
method that finds objects by a given name or path in the project.
# Example-Device Lexium62
moduleName = 'DRV_Lexium62'
cnt = 1
for c in connectors:
print("Connector " +str(cnt) +" for "+moduleName +":
")
714 EIO0000002854.04
Python Script Language
params = c.host_parameters
count = params.Count
print("Number of available Parameters for this
connector: ", count)
if count > 0:
for p in params:
print(p.visible_name + " - ID: %s " %
p.id + " - Value: %s" % p.value)
cnt = cnt+1
print
(-
"------------------------------------------------------------------"
Compiler Version
Overview
With the compiler version extension, you can display the mapped compiler
versions and you can set a new compiler version by executing the script.
EIO0000002854.04 715
Python Script Language
# Save project
projects.primary.save()
Visualization Profile
Overview
With the visualization profile extension, you can display the visualization profiles
and you can set the active visualization profile of the project.
# Save project
projects.primary.save()
Update Project
Overview
With the update project extension, you can update your project. This is the same
function as provided by the Project Update dialog box that is displayed when you
716 EIO0000002854.04
Python Script Language
open the project in the graphical user interface of EcoStruxure Machine Expert
and click OK.
Update Libraries
Overview
With the update libraries extension, you can update the libraries of the project
automatically. This is the same function as provided by the Libraries > Automatic
version mapping (all libraries) command in the graphical user interface of
EcoStruxure Machine Expert.
EIO0000002854.04 717
Python Script Language
# Clean application
app.clean()
print("; ".join(texts))
Communication Settings
Overview
This example shows how to load or set the IP address of a controller of your
choice by executing the script.
def main():
if not projects.primary:
718 EIO0000002854.04
Python Script Language
main()
Start ETEST
Overview
In software programming, the module ETEST is used to verify the correct
functionality of individual methods or algorithms of a program. ETEST is a white-
box testing method, meaning that the source code to be verified is known when
designing test cases and determining the expected results.
The procedure typically consists of 3 steps:
• initializing the initial state
• executing the operation that is to be tested
• comparing the actual results with the expected results
The ETEST script driver performs the following tasks:
• displaying test elements
• searching particular tests
• executing particular tests
Refer to the following example.
EIO0000002854.04 719
Python Script Language
if test_elements == None:
print ("No test series 'TS_MySeries' found")
else:
# Print all testelements
for test_element in test_elements:
print ("Found test element in Series TS_MySeries: "
+ test_element.Name)
onlineapp.logout()
projects.primary.close()
720 EIO0000002854.04
Python Script Language
def perform_application_login(project):
app = project.active_application
onlineapp = online.create_online_application(app)
onlineapp.login(OnlineChangeOption.Try, True)
def main():
if not projects.primary:
system.ui.error("No active project.")
return
perform_application_login(projects.primary)
main()
Convert Device
Overview
Converting devices within the project can become a complex procedure. This API
simplifies the conversion process and helps to avoid errors.
EIO0000002854.04 721
Python Script Language
def main():
# Set the project as primary project
proj = projects.primary
controller = proj.find('LMC_PacDrive', True)[0]
drives = controller.find('DRV_Lexium62', True)
if len(drives) == 0:
print("Expected drive object not found")
return
drive = drives[0]
if not projects.primary:
print("No project open.")
else:
main()
def main():
722 EIO0000002854.04
Python Script Language
if not projects.primary:
print("No project open.")
else:
main()
def main():
proj = projects.primary
controller = proj.find('LMC_PacDrive', True)[0]
drive = proj.find('DRV_Lexium62', True)[0]
if not projects.primary:
print("No project open.")
else:
main()
Comparing Projects
Overview
There are several use cases where it is useful to have a script automatically
comparing the contents of two projects. The Python project comparison function
allows you to compare two projects. As a result it provides the information if the
projects are different.
def main():
EIO0000002854.04 723
Python Script Language
proj = projects.primary
if len(content) != 0:
with open(filename, 'wb') as f:
f.writelines(content)
else:
print("Projects are equal.")
if not projects.primary:
print("No project open.")
else:
main()
libmgr = app.get_library_manager()
print("# Checking all libraries:")
for lib in libmgr.get_libraries():
724 EIO0000002854.04
Python Script Language
if not libmgr.is_current_mapping_valid():
for lib in libmgr.get_invalid_library_mappings():
print("Library reference cannot be satisfied for: "
+ lib)
print("Trying to auto-map libraries to valid versions")
libmgr.make_auto_mapping()
else:
print("All mappings valid")
Accessing POUs
Overview
The following examples show how to print and manipulate the code of a POU.
They are only available for textual programming languages.
proj = projects.primary
pou = proj.find('SR_Main', True)[0]
EIO0000002854.04 725
Python Script Language
proj = projects.primary
pou = proj.find('SR_Main', True)[0]
Project
Overview
Since the examples for this namespace are relatively short and self-explanatory,
their meaning is not explained in detail. Complete examples are provided, where
appropriate.
New Project
This method creates a new project.
It consists of 2 parameters:
• a string specifying the location where the project will be stored
• a boolean parameter: If TRUE, the project will be the new primary project.
This parameter is optional, the default value is TRUE.
The method returns the IProject instance (refer to the specification in the
document Automation Platform SDK) which can be used for further steps.
import os
try:
# Clean up any open project
if projects.primary:
projects.primary.close()
726 EIO0000002854.04
Python Script Language
Load Project
This method loads a project. Any open projects will not be closed.
The first parameter specifies the path of the project that will be loaded.
import os
try:
# Clean up any open project
if projects.primary:
projects.primary.close()
Save Project
This method saves the project at its physical location.
# Save project
projects.primary.save()
Save Archive
This method saves the project as an archive. The additional categories which are
selected by default are included, but no extra files.
The first parameter specifies the path where the archive will be saved.
import os
EIO0000002854.04 727
Python Script Language
projects.primary.save_archive(os.path.join(archive_path,
archive_name))
Close Project
This method closes the project. If there are unsaved changes in this project, these
changes will be discarded.
# Clean up any open project:
if projects.primary:
projects.primary.close()
Find Objects
This method finds objects matching the given name.
It consists of 2 parameters:
• The first parameter is the name of the object that is searched.
• The second parameter specifies whether a recursive search is performed.
This parameter is optional, the default value is FALSE. This method returns a
collection of objects.
# Search for
result_list = projects.primary.find('MyController', True)
Native Import
This method imports the specified files in the native XML format in the top level of
this project.
import os
728 EIO0000002854.04
Python Script Language
try:
# Clean up any open project
if projects.primary:
projects.primary.close()
files = os.listdir(object_path)
project_reference.save()
PLCOpenXML Import
This method imports the contents of the specified PLCopenXML file into the top
level of the project.
import os
try:
# Clean up any open project
if projects.primary:
projects.primary.close()
EIO0000002854.04 729
Python Script Language
Native Export
This method exports the given objects in native format into a string, or a file at the
given path. The non-exportable objects are detected as an error, but the export
continues.
import sys,io,os
def collect_objects(project_reference):
# List that stores all POU nodes
project_objects = []
for i in project_objects:
print("Found: ", i.type, i.guid, i.get_name())
return project_objects
730 EIO0000002854.04
Python Script Language
try:
# Clean up any open project
if projects.primary:
projects.primary.close()
export_objects(collected_objects, project_reference)
except Exception as exception:
print("Error: " + str(exception))
if not system.trace:
print("Please turn on the 'Script Tracing' function
to get detailed information about the script execution.")
PLCOpenXML Export
This method exports the given objects in PLCopenXML format into a string, or a
file at the given path. The non-exportable objects are detected as an error, but the
export continues.
import os
EIO0000002854.04 731
Python Script Language
try:
# Get the project reference of the currently opened
project
project_reference = projects.primary
if device != None:
filename = os.path.join(object_path, device[0].get_
name() + ".xml")
Online Application
Overview
NOTE: Some of the online application commands can temporarily change the
active application.
This interface is exported to Python, and thus complies to Python naming
standards.
Prepared Values
This example shows how to write prepared values.
try:
# Trying to create online application
online_application = online.create_online_application()
print("app:" + str(online_application.application_state)
+ "op:" + online_application.operation_state.ToString("f"))
732 EIO0000002854.04
Python Script Language
assert len(online_application.get_prepared_expressions
()) == 0, "Still some prepared values remain."
assert len(online_application.get_forced_expressions())
== 0, "Still some prepared values remain."
Logout Application
This method logs out the application. If the application is not logged in, nothing
happens.
# Get the project reference
project_reference = projects.primary
EIO0000002854.04 733
Python Script Language
online_application = online.create_online_application
(active_application)
Start Application
This method starts the application.
# Get the project reference
project_reference = projects.primary
Stop Application
This method stops the application.
# Get the project reference
project_reference = projects.primary
Objects
Find
This method finds objects matching the given name.
It consists of 2 parameters:
• The first parameter is the name of the object that is searched.
734 EIO0000002854.04
Python Script Language
Remove
This method removes the object.
# Finds the MyController object in the project
results = projects.primary.find("MyController", True)
Rename
This method renames the object to the new name.
# Finds the MyController object in the project
results = projects.primary.find("MyController", True)
Import/Export
Refer to the description of imports/exports for projects, page 729. The only
difference is that the object is called for import / export, instead of the project.
Devices
Overview
This chapter describes methods for manipulating device objects.
Add
This method adds the specified device.
It consists of 3 parameters:
• A string specifying the name of the device.
• DeviceID specifying the ID of the device. For the DeviceID value, refer to the
device description of the device you want to add.
• A string specifying the module ID.
# We want to add a TM5C12D6T6L Module to the TM5_Manager
# Search for the TM5_Manager. The new Module will be
inserted below this object.
parent_device = projects.primary.find('TM5_Manager', True)
[0]
if not(parent_device == None):
EIO0000002854.04 735
Python Script Language
parent_device.add("Module_TM5C12D6T6L", DeviceID(51063,
"101a 0363", "3.1.2.2"))
Disable
This method marks this device as disabled during download.
# Finds the MyController object in the project
device = projects.primary.find("MyController", True)[0]
if not(device == None):
device.disable()
Enable
This method marks this device as enabled during download.
# Finds the MyController object in the project
device = projects.primary.find("MyController", True)[0]
if not(device == None):
device.enable()
Get Address
This method gets the address of the device. It returns a string.
# Finds the MyController object in the project
device = projects.primary.find("MyController", True)[0]
if not(device == None):
print("Address: " + device.get_address())
if not(device == None):
print(str(device.get_device_identification()))
Get Gateway
This method returns the GUID of the gateway.
# Finds the MyController object in the project
device = projects.primary.find("MyController", True)[0]
if not(device == None):
print("Gateway: " + str(device.get_gateway()))
Insert
This method inserts the specified device at the specified index.
It consists of 4 parameters:
• A string specifying the name of the device.
• Int32 specifying the index where to insert the device.
• DeviceID specifying the ID of the device. For the DeviceID value, refer to the
device description of the device you want to add.
736 EIO0000002854.04
Python Script Language
if not(parent_device == None):
# We need the amount of children to add the new device
at the end
child_count = len(parent_device.get_children())
if not(device == None):
device.set_gateway_and_address(gateway, address)
if not(device == None):
device.set_simulation_mode (True)
Update
This method updates the specified device.
# This is a more generic approach to find and update a
device by its device description
import os
return newest_version
EIO0000002854.04 737
Python Script Language
if not(device == None):
device_identification = device.get_device_identification
()
738 EIO0000002854.04
Python Script Language
Choose
This method allows you to choose between one of several listed items.
# Set the necessary fields
option_list = ["TM241C24R", "TM262M25MESS8T"]
Error Detection
This method indicates an error detection message. It inhibits any further actions
until the message has been acknowledged.
system.ui.error("Error")
Info
This method indicates an information message. It inhibits any further actions until
the message has been acknowledged.
# Set the necessary fields
dialog_message = "Project update has been completed
successfully"
EIO0000002854.04 739
Python Script Language
selected_file = system.ui.open_file_dialog(dialog_title,
dialog_filename, initial_directory, file_filter)
Query String
This method queries the input or edit of a text string.
# Set the necessary fields
dialog_message = "Please enter a filename for your project:"
dialog_prefilled_text = "c:\Python\QueryStringExample.
project"
Warning
This method indicates an advisory message. It inhibits any further actions until the
message has been acknowledged.
# Set the necessary fields
dialog_message = "Project update failed. Please check the
log for detailed errors."
740 EIO0000002854.04
Python Script Language
Reading Values
Overview
The script opens an application in EcoStruxure Machine Expert and logs in to the
device. If the controller is not in RUNNING state, it will be set to RUNNING. Then
the variable iVar1 is read and displayed in the Messages view or command line.
At the end, the application is closed.
try:
# Clean up any open project
if projects.primary:
projects.primary.close()
# Login to device
onlineapp.login(OnlineChangeOption.Try, True)
# Wait 1 second
system.delay(1000)
EIO0000002854.04 741
Python Script Language
# Login to application
online_application.login(OnlineChangeOption.Try, True)
# Wait 2 seconds
system.delay(2000)
for i in range(len(watch_expressions)):
recipe_output_file.write(watch_expressions[i])
recipe_output_file.write(" = ")
recipe_output_file.write(watch_values[i])
recipe_output_file.write("\n")
# Close files
recipe_output_file.close()
# Send Email
# Import respective libraries
import smtplib
from email.mime.text import MIMEText
#open output file
recipe_output_file = open("C:\Python\Objects\Output.txt",
"r")
mail = MIMEText(recipe_output_file.read())
recipe_output_file.close()
742 EIO0000002854.04
Python Script Language
# Send email
smtp = smtplib.SMTP("Name of the SMTP Server")
smtp.sendmail(sender, [to], mail.as_string())
smtp.quit()
EIO0000002854.04 743
Python Script Language
744 EIO0000002854.04
Python Script Language
CreateDut.py
# encoding:utf-8
from __future__ import print_function
STRUCT_CONTENT = """\
a : BOOL;
b : BIT;
c : BIT;
"""
UNION_WHOLE = """\
TYPE MyUnion :
UNION
Zahl : INT;
Prozent : MyAlias;
Bits : MyStruct;
END_UNION
END_TYPE
"""
proj = projects.primary
folder = proj.find('DataTypes', recursive = True)[0]
# Create a struct DUT and insert the list of variables just
into the right
# place in line two, row 0 (line numbering starts with line
0)
struktur = folder.create_dut('MyStruct') # DutType.Structure
is the default
struktur.textual_declaration.insert(2, 0, STRUCT_CONTENT)
# Alias types get their "content" via the base type, which
will just end up
# as one line in the declaration part:
# TYPE MyAlias : INT (0..100); END_TYPE
bereich = folder.create_dut('MyAlias', DutType.Alias, "INT
(0..100)")
# Instead of injecting the variables into the existing
declaration,
# one can also just replace the complete declaration part,
including the
# boilerplate code.
union = folder.create_dut('MyUnion', DutType.Union)
union.textual_declaration.replace(UNION_WHOLE)
System_UI_Test.py
# encoding:utf-8
from __future__ import print_function
EIO0000002854.04 745
Python Script Language
res = system.ui.browse_directory_dialog("Choose a
directory", path="C:\\")
print("The user did choose: '%s'" % res)
746 EIO0000002854.04
Python Script Language
ProjectInfoExample.py
# encoding:utf-8
from __future__ import print_function
proj = projects.load("D:\Some.library")
info = proj.get_project_info()
proj.save()
EIO0000002854.04 747
Python Script Language
Sample Script
import tempfile
if projects.primary:
projects.primary.close()
tempdir = tempfile.mkdtemp()
URL = "svn://localhost/testrepo/trunk/SvnTestLibrary/"
repo = librarymanager.repositories[0]
librarymanager.install_library(proj.path, repo, True)
proj.close()
748 EIO0000002854.04
Python Script Language
online.set_default_credentials("my_user", "my_password")
EIO0000002854.04 749
Controller Feature Sets for Migration
TWDLCAA10DRF 6 4 No 3 1 0 1 No
TWDLCDA10DRF 6 4 No 3 1 0 1 No
TWDLCAA16DRF 9 7 No 3 1 0 1+1 No
TWDLCDA16DRF 9 7 No 3 1 0 1+1 No
TWDLCAA24DRF 14 10 No 3 1 0 1+1 No
TWDLCDA24DRF 14 10 No 3 1 0 1+1 No
TWDLCAA40DRF 24 16 No 4 2 2 1+1 No
TWDLCDA40DRF 24 16 No 4 2 2 1+1 No
TWDLCAE40DRF 24 16 No 4 2 2 1+1 Yes
TWDLCDE40DRF 24 16 No 4 2 2 1+1 Yes
TWDLMDA20DTK 12 8 Yes 2 2 2 1+1 No
TWDLMDA20DUK 12 8 Yes 2 2 2 1+1 No
TWDLMDA20DRT 12 8 Yes 2 2 2 1+1 No
TWDLMDA40DTK 24 16 Yes 2 2 2 1+1 No
TWDLMDA40DUK 24 16 Yes 2 2 2 1+1 No
Dig In = number of digital inputs
M221 Controllers
Controller Dig In Dig Out Ana In MOD FC HSC PWM Serial ETH CART
TM221C16R 9 7 2 TM2/ 4 2 0 1 No 1
TM3
TM221C16T 9 7 2 TM2/ 4 2 2 1 No 1
TM3
TM221C24R 14 10 2 TM2/ 4 2 0 1 No 1
TM3
TM221C24T 14 10 2 TM2/ 4 2 2 1 No 1
TM3
TM221C40R 24 16 2 TM2/ 4 2 0 1 No 2
TM3
750 EIO0000002854.04
Controller Feature Sets for Migration
Controller Dig In Dig Out Ana In MOD FC HSC PWM Serial ETH CART
TM221C40T 24 16 2 TM2/ 4 2 2 1 No 2
TM3
TM221CE16R 9 7 2 TM2/ 4 2 0 1 Yes 1
TM3
TM221CE16T 9 7 2 TM2/ 4 2 2 1 Yes 1
TM3
TM221CE24R 14 10 2 TM2/ 4 2 0 1 Yes 1
TM3
TM221CE24T 14 10 2 TM2/ 4 2 2 1 Yes 1
TM3
TM221CE40R 24 16 2 TM2/ 4 2 0 1 Yes 2
TM3
TM221CE40T 24 16 2 TM2/ 4 2 2 1 Yes 2
TM3
TM221M16R/G 8 8 2 TM2/ 4 2 0 2 No 0
TM3
TM221M16T/G 8 8 2 TM2/ 4 2 2 2 No 0
TM3
TM221M32TK 16 16 2 TM2/ 4 2 2 2 No 0
TM3
TM221ME16R/G 8 8 2 TM2/ 4 2 0 1 Yes 0
TM3
TM221ME16T/G 8 8 2 TM2/ 4 2 2 1 Yes 0
TM3
TM221ME32TK 16 16 2 TM2/ 4 2 2 1 Yes 0
TM3
Dig In = number of digital inputs
TM241C24R 14 10 0 TM2/ 8 2 4 2 No 1
TM3
TM241C24T/U 14 10 0 TM2/ 8 2 4 2 No 1
TM3
TM241C40R 24 16 0 TM2/ 8 2 4 2 No 2
TM3
TM241C40T/U 24 16 0 TM2/ 8 2 4 2 No 2
TM3
TM241CE24R 14 10 0 TM2/ 8 2 4 2 Yes 1
TM3
TM241CE24T/U 14 10 0 TM2/ 8 2 4 2 Yes 1
TM3
TM241CE40R 24 16 0 TM2/ 8 2 4 2 Yes 2
TM3
EIO0000002854.04 751
Controller Feature Sets for Migration
Controller Dig In Dig Out Ana In MOD FC HSC PWM Serial ETH CART
752 EIO0000002854.04
Glossary
C
CFC:
(continuous function chart) A graphical programming language (an extension of
the IEC 61131-3 standard) based on the function block diagram language that
works like a flowchart. However, no networks are used and free positioning of
graphic elements is possible, which allows feedback loops. For each block, the
inputs are on the left and the outputs on the right. You can link the block outputs to
the inputs of other blocks to create complex expressions.
D
DTM:
(device type manager) Classified into 2 categories:
• Device DTMs connect to the field device configuration components.
• CommDTMs connect to the software communication components.
The DTM provides a unified structure for accessing device parameters and
configuring, operating, and diagnosing the devices. DTMs can range from a
simple graphical user interface for setting device parameters to a highly
sophisticated application capable of performing complex real-time calculations for
diagnosis and maintenance purposes.
DUT:
(data unit type) Along with the standard data types the user can define own data
type structures, enumerationen types, and references as data type units in a DUT
editor.
E
element:
The short name of the ARRAY element.
F
FBD:
(function block diagram) One of 5 languages for logic or control supported by the
standard IEC 61131-3 for control systems. Function block diagram is a graphically
oriented programming language. It works with a list of networks, where each
network contains a graphical structure of boxes and connection lines, which
represents either a logical or arithmetic expression, the call of a function block, a
jump, or a return instruction.
G
GRAFCET:
The functioning of a sequential operation in a structured and graphic form.
This is an analytical method that divides any sequential control system into a
series of steps, with which actions, transitions, and conditions are associated.
GVL:
(global variable list) Manages global variables within an EcoStruxure Machine
Expert project.
EIO0000002854.04 753
I
IL:
(instruction list) A program written in the language that is composed of a series of
text-based instructions executed sequentially by the controller. Each instruction
includes a line number, an instruction code, and an operand (refer to IEC 61131-
3).
L
LD:
(ladder diagram) A graphical representation of the instructions of a controller
program with symbols for contacts, coils, and blocks in a series of rungs executed
sequentially by a controller (refer to IEC 61131-3).
M
MAC address:
(media access control address) A unique 48-bit number associated with a specific
piece of hardware. The MAC address is programmed into each network card or
device when it is manufactured.
O
OPC UA:
OPC Unified Architecture: OPC UA is an interoperability standard for the secured
and reliable exchange of data in the industrial automation space. It is a platform
independent communication protocol using the server/client model. The
connection between client and server is commonly based on the reliable transport
layer protocol (TCP, Transmission Control Protocol).
For more information about the OPC especially OPC UA refer to the official
webpage of the OPC Foundation at https://opcfoundation.org.
P
POU:
(program organization unit) A variable declaration in source code and a
corresponding instruction set. POUs facilitate the modular re-use of software
programs, functions, and function blocks. Once declared, POUs are available to
one another.
Python interpreter:
A program that directly executes instructions that have been entered.
R
REPL:
(read-eval-print-loop) A simple, interactive computer programming environment. It
takes single user inputs, evaluates them, and returns the result.
RTS:
(request to send) A data transmission signal and CTS signal that acknowledges
the RTS from the destination node.
754 EIO0000002854.04
S
Sercos:
(serial real-time communications system) A digital control bus that interconnects,
motion controls, drives, I/Os, sensors, and actuators for numerically controlled
machines and systems. It is a standardized and open controller-to-intelligent
digital device interface, designed for high-speed serial communication of
standardized closed-loop real-time data.
SFC:
(sequential function chart) A language that is composed of steps with associated
actions, transitions with associated logic condition, and directed links between
steps and transitions. (The SFC standard is defined in IEC 848. It is IEC 61131-3
compliant.)
shell:
A shell is a (console) program that allows the user to interact with a program with
a textual based interface.
T
TLS:
(transport layer security) A protocol for encrypted data transfer. Successor of
SSL.
U
UDP:
(user datagram protocol) A connectionless mode protocol (defined by IETF RFC
768) in which messages are delivered in a datagram (data telegram) to a
destination computer on an IP network. The UDP protocol is typically bundled
with the Internet protocol. UDP/IP messages do not expect a response, and are
therefore ideal for applications in which dropped packets do not require
retransmission (such as streaming video and networks that demand real-time
performance).
UTC:
(universal time coordinated) The primary time standard by which the world
regulates clocks and time.
EIO0000002854.04 755
Index cam data structure ........................................... 445
cam data structures
generate data .................................................. 445
generation ....................................................... 444
A cam diagram
ABS add ................................................................. 444
IEC operator .................................................... 602 cam motion editor
access protection ................................................ 135 generating cam data structures ......................... 444
Acknowledge diagnosis command.......................33 parameterizing cam diagrams ........................... 444
Acknowledge Diagnosis for Subtrees cam segment ...................................................... 444
command............................................................33 CANopen analog inputs ....................................... 669
ACOS CANopen devices .................................................55
IEC operator .................................................... 606 CASE
ADD instruction........................................................ 313
IEC operator .................................................... 563 Catalog view ........................................................40
adding controllers..................................................54 certificates
adding controllers by drag and drop ........................52 expired............................................................ 213
adding devices and modules by drag and drop ........53 CFC execution order ........................................... 274
adding devices from device template by drag and command
drop....................................................................53 Convert Device.................................................60
adding expansion devices by drag and drop ............52 Convert SoMachine Basic Project .......................61
addressing.......................................................... 682 Convert Twido Project ........................................61
ADR communication manager configuration....................55
operator .......................................................... 586 communication settings .........................................81
alarm class editor ................................................ 413 __COMPARE_AND_SWAP
Alarm Configuration object ................................ 412 operator .......................................................... 624
alarm group editor ............................................... 416 configuration diagnostic .........................................57
analog inputs constants............................................................ 481
CANopen ........................................................ 669 Content
Analyzation library ............................................... 301 operator .......................................................... 587
analyzing expressions ......................................... 301 CONTINUE
AND instruction........................................................ 316
IEC operator .................................................... 572 controller - HMI variable exchange........................ 441
ANY ................................................................... 534 conversions
ANY_<type> ....................................................... 534 overloaded ...................................................... 589
ANY_NUM_TO Convert Device command ....................................60
IEC operator .................................................... 601 convert SoMachine Basic project............................61
ANY_TO convert Twido project.............................................61
IEC operator .................................................... 601 core dump .......................................................... 218
array .................................................................. 557 COS
array declaration ................................................. 320 IEC operator .................................................... 605
ASIN __CURRENTTASK
IEC operator .................................................... 606 operator .......................................................... 624
ATAN
IEC operator .................................................... 607
automatic I/O mapping......................................... 126 D
axis allocation data types........................................................... 529
cam motion editor .....................................446, 448 DATE ................................................................. 533
date and time data types ...................................... 533
DATE_AND_TIME............................................... 533
B DATE_TO
BIT ..................................................................... 535 IEC operator .................................................... 597
BITADR declaring
operator .......................................................... 587 arrays ............................................................. 320
BOOL................................................................. 529 __DELETE
BOOL_TO operator .......................................................... 609
IEC operator .................................................... 590 device templates ................................................. 648
boot application................................................... 204 device user management
Boot Application .................................................. 200 access protection ............................................. 135
build-time performance ........................................ 672 device user rights
disabling.......................................................... 142
resetting .......................................................... 142
C device user rights management............................ 142
devices
CAL adding...............................................................57
IEC operator .................................................... 588 diagnostic messages for devices ............................33
calculate value automatically dialog box
cam motion editor ............................................ 446 Select Function Block .................................... 133
cam data dir(…)
EIO0000002854.04 757
Python function................................................ 700 G
disabling encryption............................................. 146
discontinuous courses of the positions .................. 447 GE
DIV IEC operator .................................................... 584
IEC operator .................................................... 567 Generated IEC source code tab of the cam
double Nodenames ............................................. 679 motion editor ..................................................... 446
download.....................................................200, 203 global node operator............................................ 622
boot application ............................................... 204 global variables - VAR_GLOBAL ............................ 477
Boot Application............................................... 200 GT
DT...................................................................... 533 IEC operator .................................................... 582
DT_TO
IEC operator .................................................... 597
DTM.....................................................................33 H
health information
fieldbus .............................................................57
E HMI - controller variable exchange........................ 441
EcoStruxure Machine Expert Twin..................... 123 HMI connection indications .................................. 443
Edit communication settings dialog box...............81
Emulation Settings ............................................ 123
encryption I
disabling.......................................................... 146 IEC code
END_IF generating from cam data ................................. 445
instruction........................................................ 313 IEC objects
END_VAR ............................................................ 475 fieldbus Diagnostic/O mapping............................57
END_WHILE IEC Objects view ................................................ 109
instruction........................................................ 315 IEC source code
EQ generating ....................................................... 455
IEC operator .................................................... 585 IEC source code of the cam diagram .................... 446
executing Python scripts ...................................... 457 IF
execution order instruction........................................................ 313
CFC ................................................................ 274 importing alarms ................................................. 418
EXIT increasing build-time performance ........................ 672
instruction........................................................ 316 indications
EXP HMI connection................................................ 443
IEC operator .................................................... 604 INI
expansion devices.................................................55 IEC operator .................................................... 623
expansions ...........................................................54 input and output variables - VAR_IN_OUT ............. 476
expired certificates .............................................. 213 input data structure
exporting alarms ................................................. 418 FB_MultiCam................................................... 445
EXPT MC_Cam_ID ................................................... 445
IEC operator .................................................... 607 input variables - VAR_INPUT ................................ 475
external variables - VAR_EXTERNAL ..................... 478 inspectapi.dir
Python function................................................ 700
installation
F third-party Sercos devices ..................................50
FAQ instance variables - VAR_INST............................. 478
login to controller not successful........................ 677 instructions
FB_Exit .............................................................. 483 ST editor.......................................................... 310
FB_init INT..................................................................... 530
IEC operator .................................................... 623 INT_TO
FB_Init ............................................................... 483 IEC operator .................................................... 593
FB_MultiCam ...................................................... 445 integer ................................................................ 530
FB_Reinit ........................................................... 483 IronPython .......................................................... 687
FdtConnections node ..........................................33 __ISVALIDREF
FFB Finder ......................................................... 358 operator .......................................................... 610
field device configuration........................................55
fieldbus health information .....................................57
fieldbusses supported by templates ...................... 642 J
firewall settings ................................................... 135 JMP
first login to controller........................................... 138 instruction........................................................ 316
FOR
instruction........................................................ 314
Function and Function Block Finder ...................... 358 L
function templates ............................................... 657
Functional Model node ........................................37 lambda
Functional tree ....................................................37 law of motion ................................................... 451
law of motion....................................................... 451
LE
758 EIO0000002854.04
IEC operator .................................................... 583 NOT
LIMIT IEC operator .................................................... 574
IEC operator .................................................... 581 NVL
literals configuration example ...................................... 339
typed............................................................... 481 considerations ................................................. 333
LN controllers supporting NVL................................ 333
IEC operator .................................................... 603 network variables list ........................................ 331
local variables - END_VAR .................................... 475 rules ............................................................... 337
local variables - VAR ............................................ 475 NVL communication suspended ........................... 673
LOG
IEC operator .................................................... 603
login ............................................................200, 203 O
login to controller................................................. 138
login to controller not successful ........................... 677 online mode
Logoff current device user command................. 139 cam motion editor ............................................ 446
logoff procedure .................................................. 139 OR
LREAL ............................................................... 531 IEC operator .................................................... 572
LREAL_TO output variables - VAR_OUTPUT............................ 475
IEC operator .................................................... 594 overloaded conversions ....................................... 589
LT
IEC operator .................................................... 583
LTIME ................................................................ 533 P
parameterizing cam diagrams .............................. 444
persistent variables ............................................. 480
M "__POOL." operator........................................... 622
managing tags ......................................................40 pragmas
MAX region ............................................................. 495
IEC operator .................................................... 580 PROGRAM......................................................... 151
MC_Cam_ID....................................................... 445 programming environments for Python.................. 687
memory usage by recipes .................................... 382 project archives................................................... 225
menus ................................................................ 671 protecting applications ......................................... 141
MIN publishing variables ............................................. 437
IEC operator .................................................... 580 publishing variables (HMI).................................... 438
MOD Python................................................................ 687
IEC operator .................................................... 569 Python script execution........................................ 457
Modbus IOScanner on a Serial Line...................... 672
Modbus Serial IOScanner
error detected .................................................. 672 Q
Modbus SL devices ...............................................55 __QUERYINTERFACE
Modbus slave disconnected ................................. 672 operator .......................................................... 613
motion design object editor .................................. 327 __QUERYPOINTER
Motion Design Object... command...................... 327 operator .......................................................... 614
Motion Editor
displaying several Motion Editor views ............. 445
Motion Editor tab ............................................... 448 R
MOVE
IEC operator .................................................... 570 REAL ................................................................. 531
MUL REAL_TO
IEC operator .................................................... 565 IEC operator .................................................... 594
MUX recipes
IEC operator .................................................... 581 memory usage................................................. 382
refreshing variables ............................................. 441
region pragmas ................................................... 495
N remanent variables.............................................. 479
REPEAT
NE instruction........................................................ 315
IEC operator .................................................... 585 retain variables.................................................... 479
Network Device Identification RETURN
accessing new controllers................................. 674 instruction........................................................ 312
connecting via IP address and address ROL
information..................................................... 675 IEC operator .................................................... 576
FAQs .............................................................. 677 ROR
in Communication Settings tab.........................78 IEC operator .................................................... 577
network variables list (receiver) ............................ 335 routing ................................................................ 682
__NEW run ..................................................................... 213
operator .......................................................... 611
NodeName...........................................................84
Nodenames
double............................................................. 679
EIO0000002854.04 759
S U
Script Engine ...................................................... 687 UNION ............................................................... 535
Script Hook Manager ......................................... 457 updating devices ...................................................59
scripting for managing user rights ......................... 748 Use DTM Connection checkbox............................33
searching within catalogs .......................................40
SEL
IEC operator .................................................... 578 V
Select Function Block dialog box ....................... 133
selecting variables............................................... 438 VAR .................................................................... 475
Sercos VAR_EXTERNAL .................................................. 478
installation of third-party devices .........................50 VAR_GLOBAL ...................................................... 477
SHL VAR_IN_OUT ...................................................... 476
IEC operator .................................................... 574 VAR_IN_OUT CONSTANT ..................................... 476
shortcuts............................................................. 671 VAR_INPUT ........................................................ 475
SHR VAR_INST .......................................................... 478
IEC operator .................................................... 575 VAR_OUTPUT ...................................................... 475
SIN VAR_STAT .......................................................... 478
IEC operator .................................................... 604 VAR_TEMP .......................................................... 477
SIZEOF variable definition ................................................ 434
IEC operator .................................................... 571 variable exchange
smart coding ....................................................... 527 communication speed ...................................... 441
SmartTag functions.............................................. 561 variable types...................................................... 434
SQRT variables............................................................. 475
IEC operator .................................................... 602 persistent ........................................................ 186
ST editor publishing........................................................ 437
instructions ...................................................... 310 publishing Vijeo-Designer ................................. 438
startup performance ............................................ 670 remanent......................................................... 186
static variables - VAR_STAT ................................. 478 Vijeo-Designer
stop.................................................................... 213 publishing variables.......................................... 438
STRING ............................................................. 532 visualizations ...................................................... 651
STRING_TO
IEC operator .................................................... 598
SUB W
IEC operator .................................................... 566 WHILE
symbol configuration............................................ 431 instruction........................................................ 315
WSTRING .......................................................... 532
T
tagging catalog items.............................................40 X
TAN __XADD
IEC operator .................................................... 605 operator .......................................................... 625
tasks XOR
adding............................................................. 199 IEC operator .................................................... 573
template libraries................................................. 648
templates............................................................ 641
temporary variables - VAR_TEMP .......................... 477
TEST_AND_SET
operator .......................................................... 626
TIME .................................................................. 533
time data types.................................................... 533
TIME_OF_DAY ................................................... 533
IEC operator .................................................... 595
TIME_TO
IEC operator .................................................... 595
TO_BOOL
IEC operator .................................................... 592
TOD ................................................................... 533
transfer variable - VAR_IN_OUT CONSTANT........... 476
transition............................................................. 164
Troubleshooting .................................................. 669
TRUNC
IEC operator .................................................... 599
TRUNC_INT
IEC operator .................................................... 600
typed literals ....................................................... 481
760 EIO0000002854.04
Schneider Electric
35 rue Joseph Monier
92500 Rueil Malmaison
France
+ 33 (0) 1 41 29 70 00
www.se.com