Training für Umsteiger
Training für Umsteiger
Overview of contents
Object orientation with
IEC 61131-3 3
rdedition
Extension Details
Example applications for
OOP
03.05.2012 TwinCAT 3 | Training | Object-orientated
Requirements of the OO in automation technology
Integration into one PLC development environment (with online functions, online change etc.)
Mixing of procedural and object-orientated code (existing projects must be capable of being integrated simply and without expenditure)
Extension of the familiar IEC languages instead of an extra language for OOP OOP universal in all IEC languages (not only ST)
Standardisation of the language by the IEC ¾ New third edition of the IEC61131-3
Advanced IEC features | Keywords
Six new keywords:
METHOD : action on FB with own variables PROPERTY: POE pair for Set/Get of attribute
THIS : in Methode/Property for the current FB instance SUPER : in Method for access to the basic class instance EXTENDS : inheritance between FBs
INTERFACE : defines abstract object type (FB without implementation) IMPLEMENTS in the FB: instances can be called via the named interface
Call syntax for methods:
Objekt.Methodname(…)
Special methods:
FB_Init, FB_Exit, FB_Reinit
03.05.2012 TwinCAT 3 | Training | Object-orientated
Advanced IEC features | Application
Object-orientated extensions of IEC 61131-3, 3
rdedition:
the concept of the functional blocks has been extended by ¾ Classes
¾ Interfaces ¾ Methods ¾ Inheritance ¾ Attributes
¾ Keywords such as THIS, SUPER
Use of the extensions
¾ Possible in all IEC languages
Advanced IEC Features | SUPER and THIS
03.05.2012 TwinCAT 3 | Training | Object-orientated
Overview of the language properties
Language properties 2nd Edition
IEC 61131-3 3rd Edition IEC 61131-3 C++ Java C# Multilingual capability + + - - -OOP/procedural mixed - + + - -Classes ~ (FB) + + + + Methods ~ (Actions) + + + + Interfaces - + - + +
Partially abstract classes - - + + +
Polymorphism - + +/- + +
Reference semantics - + (Interfaces) - + +
Constructor/Destructor - + + + +
Properties - + - - +
Overview of contents
Object orientation with
IEC 61131-3 3
rdedition
Extension Details
Example applications for
OOP
03.05.2012 TwinCAT 3 | Training | Object-orientated
History
1st edition 1993
2nd edition 2003: bugfixes and small extensions 3rd edition 2011
working at 3rd starts 2008 1st draft in july 2009
Typography
3rd edition = 2nd edition + extensions single line comment
nanoseconds
enum type with named values pointers allowed
references
object oriented extension namespaces
call a program from other programs
mixed data types in expressions and implicit conversions. …
New datatypes
LINT, ULINT, LWORD 64 bit length.
LTIME, LDATE, LDATE_AND_TIME, LTIME_OF_DAY tTime:= LTIME#12s34ms2us44ns
DT:= CONCAT_DATE_TOD(DATE, TOD);
DATE:= CONCAT_DATE(YEAR, MONTH, DAY); UNION
several datatypes in a single memory space WSTRING
Enum Type
IEC61131-3 3rd Edition
Explixitly specify the datatype of an enumeration. Default type is INT.
UNION
All variables have the same memory offset.
All variables occupy the same memory location.
VAR_TEMP - Temporary Variables
IEC61131-3 3rd Edition
Temporary variables get initialized each call of the POU. Usable in programs and function blocks.
In methods and functions every declared variable is temporary!
VAR_STAT - Static Variables
Static variables get initialized only at the first call of the POU. Static variables get stored and don‘t lose their value.
Usable in methods and functions.
Expression for variable initialization
initialize variables with ST expressions
Pragma Instructions
{defined identifier} {undefined identifier} {IF expr} {ELSIF expr} {ELSE} {END_IF} {IF defined(variable:iInput)} {IF defined(pou:CheckBounds)} {IF defined(type:ST_DataType)} {IF hasattribute(variable:iInput, ‚DoSomething‘)} {IF hastype(variable:iInput, UINT)}
Pragma Instructions
Messages
{text 'Hello World!'} {info 'Information!'} {warning 'Warning!'} {error 'Error!'}
References
A reference is an alias for an object. Instead of pointers.
Typesafe.
No dereferencing.
Object Oriented Extensions
METHOD PROPERTY
FB_Init, FB_Exit, FB_Reinit
EXTENDS INTERFACE IMPLEMENTS
THIS SUPER
METHOD
Methods are describing a sequence of instructions. Like a function that depends to a function block. Extends the existing ACTION functionality.
VAR_INPUT, VAR_IN_OUT and VAR_OUTPUT Access to variables of the belonging function block.
PROPERTY
Gives access to internal states or values.
FB_init, FB_reinit, FB_exit
FB_init
Contains explicit initialization code for the function block. Gets called before starting the PLC. (SAFEOP => OP) Implicit initializations have already been done.
User defined inputs: fbVal: FB_Val(iVal:= 3); FB_reinit
Contains explicit reintinialization code for the function block. Gets called when the instance gets copied. (online change) FB_exit
Contains explicit deinitialization of ressources.
Gets called before a download, a reset or online change.
Execution order while online change.
IEC61131-3 3rd Edition Exit old instance.
old_inst.fb_exit(bInCopyCode := TRUE); Initialize new instance.
new_inst.fb_init(bInitRetains := FALSE, bInCopyCode := TRUE); Copy instance.
copy_fub(&old_inst, &new_inst);
THIS
Every function block provides the pointer THIS. THIS points to the current function block.
EXTENDS
Structure includes all variables from the extended base.
EXTENDS
EXTENDS
function block includes all methods from the extended base.
SUPER
Every function block provides the pointer SUPER. SUPER points to the basic function block.
Usable for overwriting existing methods from the base. Change the behaviour of a existing function block.
INTERFACE
IEC61131-3 3rd Edition
POU which defines/describes. methods and properties.
Just declaration, no implementation. Only input, output and inout variables.
No body (implementation).
No declaration of internal variables.
IMPLEMENTS
A function block implements the interface.
Provides the implementation of the declaration.
Interface Usage
Declare an instance of the function block, implementing the interface.
Declare an variable of the interface.
Store a reference to the function block in the interface.
Interface Benefits
Use different implementations depending on the situation.
If use mem instance is active, FB_MathMem would be used. Otherwise the FB_MathErase would be used.
Attention while using interfaces!
Function blocks are „value types“. Copied by value/memory. Interfaces are „reference types“. Copdied by reference/address.
Î Interfaces are pointers!
Extended Structured Text - ExST
TwinCAT 3 specific extensions.
Dynamic Memory __NEW
__DELETE
Adressing, Pointers and References __ISVALIDREF
__QUERYPOINTER __QUERYINTERFACE
Not yet implemented
Extensible Function – PARAMS
ANDN, ORN, XORN
ANY_TYPE
ANY_NUM_TO_<NUMERIC> ANY_TO_<TYPE>
Overview of contents
Object orientation with
IEC 61131-3 3
rdedition
Extension Details
Example applications for
OOP
Example applications for OOP
Sample01: Classic inheritance
EXTENDS : Inheritance between FBs
METHOD : Action on FB with own variables
Sample02: Inheritance with abstract upper class (late Binding) EXTENDS : Inheritance between FBs
METHOD : Action on FB with own variables
INTERFACE : defines abstract object type (FB without implementation) IMPLEMENTS in the FB: Instances can be called via the named interface SUPER : in Method for access to the basic class instance
Sample03: Access via Property by means of Get/Set PROPERTY: POE pair for Set/Get of attribute Sample04: Cylinder
EXTENDS, METHOD, INTERFACE , SUPER Sample05: Crossroads
Sample06: Overshadowing with THIS and SUPER
03.05.2012 TwinCAT 3 | Training | Object-orientated
Sample01: Classic inheritance
¾ EXTENDS : Inheritance between FBs
By setting the keyword EXTENDS, the respective function block gets all the properties (variables, actions, methods, etc.) of the basic function block as an extension to its own!
Sample01: Classic inheritance
¾ METHOD : Action on FB with own variables
Methods strongly resemble the familiar functions (FUN), i.e. all data are only present temporarily!
Permitted variable classes: VAR, VAR_INPUT, VAR_OUTPUT Not permitted: VAR_IN_OUT, VAR_TEMP
03.05.2012 TwinCAT 3 | Training | Object-orientated
Sample02: Inheritance with abstract upper class
¾ INTERFACE : defines abstract object type (FB without implementation) Used on function blocks for the management/organisation of methods
An INTERFACE describes a collection of method prototypes, i.e. methods that are only declared but not implemented. All methods of the interface are implemented by the FB (IMPLEMENTS).
The instance of an INTERFACE is filled in with code by assigning the FB that implements this INTERFACE at runtime (dynamically)
Sample02: Inheritance with abstract upper class
Characterisation of the interface with the respective FB instance that implements this interface.
03.05.2012 TwinCAT 3 | Training | Object-orientated
Sample03: Access via Property by means of Get/Set
¾ A PROPERTY can use the private variables of the block module in a program block (PRG) or function block (FB) by means of SET and GET
The SET and GET methods are added automatically by appending a PROPERTY. A
Sample04: Cylinder
03.05.2012 TwinCAT 3 | Training | Object-orientated
programming in IEC 46
Example: Cylinder
Task:
• Cylinders should all look the same
• Identical behaviour
Sample04 : PLC | OOA cylinder
+M_StateMachine() : bool ICylinder +M_StateMachine() : bool +bAtLeftPos : bool +bAtRightPos : bool ‐TimerReach ‐TimerStart ‐iState : int FB_Cylinder +M_StateMachine() : bool +M_Diag() : bool +tTimeOut ‐WatchDogTimer FB_CylinderDiagSample04 : PLC | Cylinder | Interface
Definition of an abstract upper class (INTERFACE): ICylinder
Associated METHOD is only created, associated data are only defined on implementation!
03.05.2012 TwinCAT 3 | Training | Object-orientated
Sample04 : PLC | Cylinder | Function block
Definition of a (basic) function block that implements the interface ICylinder. All functions required for a (basic) cylinder are defined here.
Sample04 : PLC | Cylinder | Method
METHOD for controlling all cylinders:
03.05.2012 TwinCAT 3 | Training | Object-orientated
programming in IEC 50
Implementation of the interface
Sample04 : PLC | Cylinder | Inheritance
Creation of a further FB, which extends the basic type (EXTENDS):
Sample04 : PLC | Cylinder | Further methods
Extension of the inherited METHOD by special types for diagnosis:
03.05.2012 TwinCAT 3 | Training | Object-orientated
programming in IEC 52
Overwriting the interface
Sample04 : PLC | Cylinder | Call via interface
Training für Umsteiger
Object-orientated programming in IEC
Thank you very much
for your attention!
Training für Umsteiger
eXtended Automation
(XA) overview
Architecture (XAA)
Engineering (XAE)
Runtime (XAR)
Connectivity
TwinCAT 2 Migration
Functions
23.05.2012 TwinCAT 3 | Overview 3 Architecture (XAA)
Engineering (XAE)
Runtime (XAR)
Architecture (XAA)
23.05.2012 TwinCAT 3 | Overview 5 TwinCAT 3 eXtended Automation (XA) eXtended Automation Runtime (XAR) eXtended Automation Engineering (XAE)Modular runtime system
TcCOM PLC Safety TcCOM NC TcCOM C++ Module TcCOM … TcCOM
TwinCAT 3 development environment based on Visual Studio® 2010
TwinCAT 3 Standard Visual Studio® 2010 Shell TwinCAT 3 Integrated Visual Studio® 2010 eXtended Architecture (XAA)
Architecture (XAA): subdivision into
engineering/runtime
eXtended Automation
Engineering (XAE)
Visual Studio
®2010 for
real-time programming in
IEC 61131-3 and C/C++
Visual Studio
®2010 for
the configuration of the
complete system
eXtended Automation
Runtime (XAR)
Execution of the created
modules in real-time
Support for multi-core
CPUs
23.05.2012
TwinCAT 3 | Overview 7
eXtended
Automation Engineering (XAE)
TwinCAT 3 Engineering Environment based on Visual Studio®
TwinCAT Transport Layer - ADS
TwinCAT 3 Runtime Real-time Kernel TcCOM PLC PLC SafetyPLC TcCOM PLC NC TcCOM PLC C Module TcCOM PLC CNC TcCOM PLC C++ Module TcCOM TcCOM PLC PLC
TwinCAT Automation Device Driver - ADD
PC System Fieldbus System Manager - Configuration Programming -IEC 61131-3 -objectoriented extensions - C/C++ PLC TcCOM Simulink® Module Windows 32/64 bit eXtended
Architecture (XAA)
Engineering (XAE)
TwinCAT 3 Standard TwinCAT 3 Integrated System Manager PLC Motion Control C/C++ programming Matlab®/Simulink® Integration C#/ .NET programming
Runtime (XAR)
Engineering (XAE)
23.05.2012
Engineering (XAE)
eXtended Automation Engineering (XAE)
TwinCAT 3
¾ One programming environment ¾ One project folder
¾ One debugging environment for IEC and C/C++ - code Integration of the familiar TwinCAT System Manager
Programming in IEC 61131-3 3rd Edition (NEU: object-orientated extension)NEU
Real-time programming in C/C++
¾ Integration and sequence of the C/C++ - program in the IEC environment or ¾ execution as independent real-time code
Link to Matlab®/Simulink®
TwinCAT 2 PLC projects can be converted into a TwinCAT 3 PLC project The ‘old’ TwinCAT System Manager file (*.tsm file) can be converted
Engineering (XAE) - variants
TwinCAT 3 Standard
Based on the Microsoft
Visual Studio
®Shell
Integrated System
Manager
Integrated IEC-61131-3
3
rdedition programming
(OOP)
Integrated Safety PLC
TwinCAT 3 Integrated
Integration in an existingMicrosoft Visual Studio® 2010 Integrated System Manager Integrated IEC-61131-3 3rd
edition programming (OOP) Integrated Safety PLC
C/C++ programming Matlab®/Simulink®
C# and .NET programming for non-real-time applications
Optional: implementation of third-party software tools
23.05.2012
TwinCAT 3 Standard
For (standard) PLC
programmers and users
of existing, compiled
modules (e.g. C/C++,
Matlab
®/Simulink
®)
Configuration,
parameterisation and
diagnosis
Debugging of the PLC
code
TwinCAT 3 Engineering Environment
System Manager Configuration – I/O – PLC – MC – NC – CNC – Safety – others Programming IEC 61131 Object-oriented extensions IEC Compiler TwinCAT 3 Runtime
TwinCAT 3 Integrated
For PLC and C/C++
programmer
Configuration,
parameterisation
and diagnosis
Module development
(C/C++ or
Matlab
®/Simulink
®)
Debugging (PLC,
C/C++,
Matlab
®/Simulink
®)
23.05.2012 TwinCAT 3 | Overview 13TwinCAT 3 Engineering Environment based on Visual Studio®
System Manager Configuration – I/O – PLC – C/C++ – MC – NC – CNC – Safety – others Programming IEC 61131 Object-oriented extensions IEC Compiler TwinCAT 3 Runtime
TwinCAT Transport Layer – ADS Non real-time C#.NET Real-time C/C++ Matlab®/ Simulink Real-time Workshop Microsoft C Compiler Third-party programming tool C/C++
TwinCAT 3 Integrated – integrated working area
Workbench integration - integrated working area
TwinCAT 3 framework = Microsoft Visual Studio® 2010
Use of the commonest development environment Supported by Microsoft
Extendable via plug-ins (e.g. third party modules) Usable with many common source-safe databases
Use of C/C++ source code for the programming of automation devices
Use of .NET languages for non-real-time applications (e.g. visualisations)
Improved help system on the basis of Microsoft Visual Studio®
2010 Help (Microsoft Help system)
Ultimate
Professional
Parallel programming of IEC 61131 and C++
C++ Code IEC Code
23.05.2012
Architecture (XAA)
Engineering (XAE)
TwinCAT 3 Standard TwinCAT 3 Integrated System Manager PLC Motion Control C/C++ programming Matlab®/Simulink® Integration C#/ .NET programming
Runtime (XAR)
Integrated System Manager | Directory tree
23.05.2012
TwinCAT 3 | Overview 17
System configuration
Motion control configuration
PLC configuration
Safety PLC configuration C++ module configuration
Integrated System Manager | Mapping
Mapping of the process image
Open for all common fieldbuses
Support for all PC hardware interfaces Simple diagnosis of the fieldbus data
Correlation between logical and physical fieldbus ¾A change of the bus system does not entail a change of the PLC code!
TwinCAT process images
Physical process Virtual process images Inputs Outputs
Architecture (XAA)
Engineering (XAE)
TwinCAT 3 Standard TwinCAT 3 Integrated System Manager PLC Motion Control C/C++ programming Matlab®/Simulink® Integration C#/ .NET programming
Runtime (XAR)
23.05.2012 TwinCAT 3 | Overview 19TwinCAT 3 PLC
Multiple numbers of PLC projects:
Number of possible tasks: 256 (compare here to TwinCAT 2: 4x4)
Number of possible PLC projects limited only by the memory capacity of the automation device (instead of 4 runtime systems in TwinCAT 2)
Programming
Standard IEC 61131-3 languages (IL, ST, FBD, LD, SFC) +CFC Use of the object-orientated extensions of IEC 61131-3, 3rd edition
Call and data exchange of code developed in C/C++ and Matlab®/Simulink® Large number of import and export interfaces
No direct addressing (necessary)
Commissioning/maintenance
Source code upload/download Online Change
Complete debugging (breakpoints, monitoring, sequence control etc.) of IEC and C/C++ code
TwinCAT 3 PLC | Development environment
Common tree structure for hardware and software
23.05.2012
TwinCAT 3 | Overview 21
Architecture (XAA)
Engineering (XAE)
TwinCAT 3 Standard TwinCAT 3 Integrated System Manager PLC Motion Control C/C++ programming Matlab®/Simulink® Integration C#/ .NET programming
Runtime (XAR)
TwinCAT 3 Motion Control
Scalable solutions (from stepper motor to servo) ¾ Higher flexibility in use and exchange of technology ¾ Shortened development time Æfaster delivery
¾ Fast commissioning, diagnosis and maintenance Abstraction level - identical access:
¾ PLC/SCADA/HMI always access the same objects, irrespective of the type of axis or fieldbus employed.
Conversion of mechanical to electronic systems: ¾ Electronic cam plate
¾ Electronic gearing ¾ Electronic coupling ¾ Electronic cam shaft ¾ ‘Flying saw’
23.05.2012
TwinCAT 3 Motion Control | Abstraction level
Soft SPS Lay e r + + + -Soft Mo tion Lay e r Fie ldbus Lay e r Drives Lay e r Velo Preset Pos Ctrl Pos Meas. PLC SP LimitTwinCAT 3 Motion Control | From PTP to Robot Control
Covered functionality 23.05.2012 TwinCAT 3 | Overview 25 NC PTP NC I CNC Robotics Point-to-Point- movement – gearing – camming – superposition – flying saw Interpolated motion with 3 axes and 5 additional axes – programming according to DIN 66025 – technological features – straightforward utilisation through function blocks from the PLC Complete CNC functionality – interpolated movement for up to 32 axes per channel – various transformations Interpolated motion for robotic control– support for a wide rande of kinematic systems
– optional torque pre-control
Architecture (XAA)
Engineering (XAE)
TwinCAT 3 Standard TwinCAT 3 Integrated System Manager PLC Motion Control C/C++ programming Matlab®/Simulink® Integration C#/ .NET programming
Runtime (XAR)
C/C++ programming languages
Reusability of already existing C/C++ code Common use of C/C++ and PLC code
Real-time applications available for all platforms (CE, 7)
Opening up of a completely new world for automation technology Renowned and well-known programming language
Standardised (C: ISO/IEC 9899 TC3, C++: IEC 14882)
The creation of Automation Device Drivers (ADD) enables you to implement your own drivers (e.g. for your own fieldbus system or the like)
Beckhoff SDK supports (similar to PLC libraries) ADS Motion File I/O 23.05.2012 TwinCAT 3 | Overview 27 Not ye t available!
Architecture (XAA)
Engineering (XAE)
TwinCAT 3 Standard TwinCAT 3 Integrated System Manager PLC Motion Control C/C++ programming Matlab®/Simulink® Integration C#/ .NET programming
Runtime (XAR)
23.05.2012 TwinCAT 3 | Overview 29Matlab
®/Simulink
® Well-known from science and measurement technology Large variability of toolboxes (e.g. fuzzy etc.)
Generation, simulation and optimisation of controller structures
Debug interface between Simulink® and TwinCAT
Code generation
Design: Simulink®
Automatic generation of C code by the Simulink® real-time workshop
Compilation with the Visual Studio® C compiler
Parameterisation in the TwinCAT System Manager
Matlab
®/Simulink
®| Integration
23.05.2012
Architektur (XAA)
Engineering (XAE)
TwinCAT 3 Standard TwinCAT 3 Integrated System Manager PLC Motion Control C/C++ programming Matlab®/Simulink® Integration C#/ .NET programming
Runtime (XAR)
C#/.NET programming
23.05.2012 TwinCAT 3 | Overview 33 PLC module C++ module Real-time Code HMI/ Windows processes Architecture (XAA)
Engineering (XAE)
Runtime (XAR)
Modular runtime system
TwinCAT modules
Runtime (XAR)
23.05.2012
Runtime (XAR) | Modular runtime systems
Dynamic environment for the execution and management of TwinCAT 3
modules
¾ Standard PLC code ¾ NC code
¾ C++ code ¾ …
Management of the modules with the TwinCAT Object Manager
Firmly defined interface (e.g. TwinCAT Component Object Model - TcCOM)
Fieldbus
TwinCAT Transport Layer - ADS
TwinCAT Object Manager
TwinCAT Re al-time Ke rne l TcCOM PLC TcCOM PLC C++ Module TcCOM PLC CNC TcCOM PLC Safety TcCOM PLC Simulink® Module TcCOM PLC PLC TcCOM PLC NC TcCOM C++ Module
TwinCAT Automation Device Driver - ADD
TcCOM PLC C Module TcCOM PLC Simulink® Module TC Configuration Debugging Task Task Task Task Task Task Task Call Call Call TwinCAT 3 Runtime
Runtime (XAR) | TwinCAT modules
Must
Description (methods, functions, names etc.)
StateMachine (Init, PreOp, Op) TcCom Interface Can Interfaces Parameter Data Areas … 23.05.2012 TwinCAT 3 | Overview 37 TwinCAT Module Interfaces Module Description Parameter State Machine ITComObject Interface
Data Areas Contexts Categories ADS Port Interfaces Pointers Data Area Pointers
TwinCAT 3 – Multi-core support
Support for multi-core systems
Assignment of the individual projects to different cores
¾ PLC, NC, HMI etc. each assigned to their own core
Scalable basic time for each core
Scalable CPU limit adjustable for each core 23.05.2012 TwinCAT 3 | Overview 39 Core 0 ADS Multi-core CPU Windows Apps PLC Control Windows Drivers ADS User HMI Core 1 ADS Core 2 PLC Runtime 0 Task 0 Task 1 ADS PLC Runtime 1 Core 3 ADS NC Runtime 1 Core ...
ADS Router Engine
System Memory
ADS Router Message Queues L2 Shared Cache
TwinCAT 3 – Multi-core support | Assignment
Activation of the cores Definition of the CPU limits
Definition of the basic time
Motivation – why
TwinCAT 3
eXtended Automation
(XA) - overview
Architecture (XAA)
Engineering (XAE)
Runtime (XAR)
Connectivity
TwinCAT 2 Migration
Functions
23.05.2012 TwinCAT 3 | Overview 41Connectivity | ADS to Communication
23.05.2012 TwinCAT 3 | Overview 43 TwinCAT TwinCAT TwinCAT(PLC) PC 2
TwinCAT Automation Device Specification (ADS) Automation Protocols OPC UA, Modbus TCP, Modbus RTU 3964R/RK512 Industry Protocols IEC 61850, IEC 61400-25, IEC 60870-5- 10x, BACnet, FIAS, Creston IT Protocols WLAN, Bluetooth, TCP, UDP, RAS, FTP, VPN, SNMP, SNTP, SMS, SMTP Web Server Ils XML, AJAX, ASP, DPWS/WSD TwinCAT Automation Device Specification (ADS)(PLC) PC 1
TwinCAT ADS Router
Acyclic TCP, UDP, Serial, Fieldbus TwinCAT ADS Router Cyclic EtherCAT Automation Protocol (EAP), Network variables
Motivation – why
TwinCAT 3
eXtended Automation
(XA) - overview
Architecture (XAA)
Engineering (XAE)
Runtime (XAR)
Connectivity
TwinCAT 2 Migration
Functions
TwinCAT 2 Migration | Opening ‘old’ projects
The opening of projects created with TwinCAT 2 results in:
1.) Conversion of ‘old’ projects to the TwinCAT 3 format ¾ Process can not be undone!
¾ TwinCAT 3 projects can not be saved in the TwinCAT 2 project format!
Conversion of existing TwinCAT 2 projects to the TwinCAT 3 format means:
Extension of the project by new features
Increased reusability of the existing code in new project parts Use of the same tools for all projects
Conversion of PLC Control and System Manager files
23.05.2012
Motivation – why
TwinCAT 3
eXtended Automation
(XA) - overview
Architecture (XAA)
Engineering (XAE)
Runtime (XAR)
Connectivity
TwinCAT 2 Migration
Functions
TwinCAT Functions
¾ The previously familiar TwinCAT supplements also exist in TwinCAT 3 The designation changes to TwinCAT Functions: TFxxxx
23.05.2012
TwinCAT 3 | Overview 47
TwinCAT 2 supplement licences cannot be used in TwinCAT 3!
New (if necessary trial) licences
Training für Umsteiger
Overview
Thank you very much for your
attention!
Architecture (XAA)
Engineering (XAE)
Runtime (XAR)
Architecture (XAA)
23.05.2012 TwinCAT 3 eXtended Automation (XA) eXtended Automation Runtime (XAR) eXtended Automation Engineering (XAE)Modular runtime system
TcCOM PLC Safety TcCOM NC TcCOM C++ modules TcCOM … TcCOM
TwinCAT 3 development environment based on Visual Studio® 2010
TwinCAT 3 Standard Visual Studio® 2010 Shell TwinCAT 3 Integrated Visual Studio® 2010 eXtended Architecture (XAA)
Architecture (XAA) - notebook example (XAE) CX
eXtended Automation
Engineering (XAE)
TwinCAT 3 development environment Visual Studio® 2010 TwinCAT 3 Standard Visual Studio® 2010 Shell TwinCAT 3 Integrated Visual Studio® 2010 eXtended Automation Runtime (XAR)
Architecture (XAA) - notebook example (XAE) CX
23.05.2012 TwinCAT 3 | Overview eXtended Automation Runtime (XAR)Modular runtime system
TcCOM PLC Safety TcCOM NC TcCOM C++ modules TcCOM … TcCOM
Ethernet interface used as programming interface
Architecture (XAA) - notebook example (XAE) CX
TwinCAT 3 development environment on notebook
TwinCAT 3
Standard / Integrated
TwinCAT 3 runtime on CX /IPC
TwinCAT Transport Layer - ADS
TwinCAT 3 Runtime Real-time Kernel PLC CNC C++PLC modules PLC PLC PLC Simulink® modules IO T w in CAT T ranspo rt La ye r -A D S
Architecture (XAA) - notebook example (XAE) CX
23.05.2012 TwinCAT 3 | Overview
TwinCAT 3 runtime on CX /IPC
TwinCAT Transport Layer - ADS
TwinCAT 3 Runtime Real-time Kernel PLC CNC C++PLC modules PLC PLC PLC Simulink® modules IO TwinCAT 3 development environment PC TwinCAT 3 Standard / Integrated TwinCAT Tra n sp ort L a y e r -A DS Config Mode:
to enable communication (programming) scanning of hardware / IO test in Freerun
Run Mode : PLC NC IO etc. operate in real-time PC
taskbar XAE status
Architecture (XAA) - notebook example (XAE) CX
PC taskbar
TwinCAT XAE displays TwinCAT state on the target system
TwinCAT on the target computer (CX / IPC)
The target computer
must be in the RUN
state in order to logon to the PLC
Practical part
Establishment of a
connection
23.05.2012
Requirement: TC3 is successfully installed on the programming computer and the target computer
Hardware with PC (XAE)
12.04.2013 11 Example hardware
PC with TwinCAT3 XAE, CX with EtherCAT
adaptor
TwinCAT3 XAE / XAR on the same computer (local) BK1120 Bus Coupler 2* KL1XX2 2-CHANNEL DIG IN 2* KL2XX4 4-CHANNEL DIG OUT 1* KL2531 Stepper Terminal
Taskbar TwinCAT VS2010 symbol
Starting the VS2010 / 2010 shell
New Project XAE Project
To search, first select Local Target System
searches for TC controllers IPC/ CX Connection to both devices (enter PC target system)
Logon information: user name and password for computer. Training CX 1020 12.04.2013 17 CX training: Administrator 1
Connection valid
PC taskbar
TwinCAT XAE displays TwinCAT state on the target system
TwinCAT on the target computer (CX / IPC)
12.04.2013 21
TwinCAT XAE displays TwinCAT
state on the target system The target system must
be in Config Mode for scanning and freerun test of the hardware
The target computer
must be in the RUN state
in order to logon to the PLC later
The TwinCAT system on the XAE computer must be in the Config Mode for logging on.
Run Mode is also possible if the XAE computer simultaneously represents a control computer (XAR)
Practical part
Hardware test
Scanning
Scan Hardware
Check Config Mode, activate Config Mode if necessary Scan 12.04.2013 23Scan Hardware
12.04.2013 25
Freerun
In Freerun Mode, I/O can be tested without PLC program
Practical part
Create PLC program
Generate global variables
12.04.2013 27
Add PLC project
Global Variable List
PLC project from template
Generate global variable list
12.04.2013 29
Global Variable List
Global Variable List
12.04.2013 31
Linking
Linking
12.04.2013 33
Linking
Activate
Activating the configuration
12.04.2013 35
Activate
If TwinCAT XAR is not registered, a 7-day licence can be created
Login
Logon to PLC project PLC RUN Start PLC PLC Online LoginXAE offline + PLC not in Run Mode XAE online + PLC not in Run Mode XAE offline + PLC in Run Mode
XAE online + PLC in Run Mode
Monitoring
Global variables online
Write Value
12.04.2013 39
Extending the program
Logout Create FB
Extending the program
12.04.2013 41
Extending the program
Edit FB
Toolbox: VIEW->TOOLBOX
Extending the program
Edit FB
Adapt connection with “Set output connection”
12.04.2013 43
Extending the program
Edit FB
Adapt connection with “Set output connection”
Extending the program
Call block in Main (ST) with input assistant and Auto Declare
12.04.2013 45
Extending the program
Call block in Main (ST) with input assistant and Auto Declare
Extending the program
Call block in Main (ST) with input assistant and Auto Declare Configure input and
Practical part
Settings for automatic start of
the XAR
Activate boot project
Enable boot project start
Set TwinCAT autostart for
RUN
23.05.2012
Autostart
Boot project
Enable autostart
12.04.2013 49
Autostart
Autostart
User name and password for the control computer
Training für Umsteiger
Handling
Overview of contents
Version differences
Visual Studio® 2010
Visual Studio® 2010 Shell
Integration of the TwinCAT System Manager
System PLC
Slide-in 1: EtherCAT Bus Terminals Slide-in 2: Variable Declaration
Practice slide-in 1: The first project Automatic start of the controller Establishing a remote connection Own data types
Working with several tasks Backup on the target system Encrypt the project
Version differences | Overview
23.05.2012
TwinCAT 3 | Handling 3
TwinCAT 3
Standard
Standard
Based on the Microsoft
Visual Studio
®Shell
Integrated TwinCAT
System Manager
Integrated IEC-61131-3
3
rdedition programming
(OOP)
Integrierte Safety PLC
TwinCAT 3
Integrated
Integrated
Integration in an existing Microsoft Visual Studio® 2010
Integrated System Manager
Integrated IEC-61131-3 3rd edition programming (OOP)
Integrierte Safety PLC C/C++ programming Matlab®/Simulink®
C# and .NET programming for non-real-time applications
Optional: Implementation of third-party software tools
Overview of contents
Version differences
Visual Studio® 2010
Visual Studio® 2010 Shell
Integration of the TwinCAT System Manager
System PLC
Slide-in 1: EtherCAT Bus Terminals Slide-in 2: Variable Declaration
Practice slide-in 1: The first project Automatic start of the controller Establishing a remote connection Own data types
Working with several tasks Backup on the target system Encrypt the project
23.05.2012
Integration of the TwinCAT System Manager
Complete integration of the TwinCAT System Manager into the Microsoft Visual Studio tree.
The complete collection of project data (PLC, NC, hardware configuration) is summarised in one ‘solution’
(Projectname.sln).
Each individual project in the solution has its own process image.
Simulation of I/Os and axes.
Overview of contents
Version differences
Visual Studio® 2010
Visual Studio® 2010 Shell
Integration of the TwinCAT System Manager
System
PLC
Slide-in 1: EtherCAT Bus Terminals Slide-in 2: Variable Declaration
Practice slide-in 1: The first project Automatic start of the controller Establishing a remote connection Own data types
Working with several tasks Backup on the target system Encrypt the project
23.05.2012
System configuration
The tree entry system contains Licence
Real time Tasks Routing
Licence | General overview
Licensing in TwinCAT 3 is divided into two steps:
¾ Sales-related procedure
¾ Technical integration in TwinCAT XAE
Sales
Sales--related procedurerelated procedure
1. Ordering of the desired TwinCAT 3 package
Technical integration in TwinCAT XAE
Technical integration in TwinCAT XAE
2. All licences necessary for the project are listed automatically in TwinCAT XAE. This
list can also be extended manually. A licence file (Licence Request File) is generated from it.
3. The licence file is sent by email to the Beckhoff Activation Server
4. The activation server creates a valid licence file (Licence Response File), which is
imported into TwinCAT XAE
23.05.2012
TwinCAT 3 | Handling 9
Alternative: Alternative:
Licence | Diagram
Licence | Generation of the chargeable licence
In the Licence section below System in the configuration tree, the project-related licences can be viewed on the ‘Order Information’ tab or further licences can be selected for ordering on the ‘Manage Licences’ tab.
The corresponding file is generated by actuating the ‘Generate Licence Request File…’ button
The generated file can then be sent by email:
23.05.2012
TwinCAT 3 | Handling 11
The Beckhoff Licence ID is transmitted on
confirmation of the order and must be entered here.
Licence | Importing the chargeable licence
The Licence Response File is received via the same email address that was used to send the Licence Request File
This file can be read in the same section where the Request File was also generated
After linking the licence file, it is automatically copied to ‘%TwinCATDIR% \Target\License’
Licence | 7-day test licence
In TwinCAT 3 there is a possibility to generate a 7-day test licence including the required TwinCAT Functions - completely without limitations!
There are two different ways to use a test licence:
a)
a)On the local systemOn the local system
i. The ‘Order Information’ tab displays all licences necessary for the project for
which a 7-day test licence is generated
ii. If a test licence has not yet been generated, but the project is to be activated,
then a message appears upon activation that licences are missing and will now be generated. It is necessary to input a code for this:
23.05.2012
Licence | 7-day test licence | Remote system
b)
b) On a remote systemOn a remote system
i. An ADS connection must exist in order to copy the licence to the device
ii. Two tabs are displayed in the Licence section: ‘Order Information (Runtime)’
and ‘Order Information (Engineering)’. The necessary 7-day test licence can be activated and confirmed on the ‘Runtime’ tab.
Real Time Settings
Assignment of the task(s) to a core
Definition of the base time for each core
Setting of the CPU limit of the core
23.05.2012
Task Management
Central management of the task(s) for this solution
Reference of the PlcTask from the PLC to Task Management
TcCom Objects
Linking of binaries Matlab/Simulink
C++ modules in TwinCAT standard environments …
23.05.2012
Overview of contents
Version differences
Visual Studio® 2010
Visual Studio® 2010 Shell
Integration of the TwinCAT System Manager
System
PLC
Slide-in 1: EtherCAT Bus Terminals Slide-in 2: Variable Declaration
Practice slide-in 1: The first project Automatic start of the controller Establishing a remote connection Own data types
Working with several tasks Backup on the target system Encrypt the project
PLC programming | Overview
Several PLC projects can be managed in a solution
¾ Number of possible tasks: 65,000 (compare TwinCAT 2: 4x4)
¾ Number of possible PLC projects: limited only by the memory capacity of the automation device (compare TwinCAT 2: 4 RTS)
Programming:
¾ Standard IEC 61131-3 languages (IL, ST, FBD, LD, SFC) +CFC
¾ Use of the object-orientated extensions of IEC 61131-3, 3rd edition
¾ Call and data exchange of code developed in C/C++ and Matlab®/Simulink®
¾ Large number of import and export interfaces ¾ No direct addressing (necessary)
Commissioning/maintenance ¾ Source code upload/download ¾ Online Change
¾ Complete debugging (breakpoints, monitoring, sequence control etc.) of IEC and C/C++ code
23.05.2012
PLC programming | Editor | Declaration of variables
Choice between ‘normal’ declaration view and tabular view All changes are consistent in both views
PLC programming | Editor | Structured Text (ST)
Improved usability:
¾ Automatic completion (auto-complete)
¾ Marking of keywords associated with one another
¾ Collapsing of programming structures
23.05.2012
PLC programming | Editor | LD/FBD/IL
Just one editor for all 3 programming languages!
¾
¾ Switching between the Switching
languages without translating ¾ Online switching possible ¾ Settings e.g. for
symbol comments affect all views ¾ Mixed networks
LD
¾ Contact networks at all inputs ¾ Coils at all outputs
¾ Several blocks in a network IL
PLC programming | Libraries
Namespaces and default namespaces Internal and external objects in one library Installation of the libraries necessary!
Identification via name, company and version
Several versions of a library possible per installation
Use of several versions of a library possible within a project
23.05.2012
Overview of contents
Version differences
Visual Studio® 2010
Visual Studio® 2010 Shell
Integration of the TwinCAT System Manager
System PLC
Slide-in 1: EtherCAT Bus Terminals
Slide-in 2: Variable Declaration Practice slide-in 1: The first project Automatic start of the controller Establishing a remote connection Own data types
Working with several tasks Backup on the target system Encrypt the project
Slide-in 1: EtherCAT Bus Terminals
23.05.2012
EtherCAT Coupler as link
The EtherCAT Coupler (e.g. EK1100) represents the link between the fieldbus master and the EtherCAT I/O system.
A fieldbus master can manage up to 65535 EtherCAT slaves
The EtherCAT terminals in detail
Power contacts for automatic bridging of the power potentials 23.05.2012 TwinCAT 3 | Handling 27 Symmetrical unlatching for vertical removal Screwless connection technology
Terminal block design: Terminal block design:
12 x 100 x 68 mm (W x H x D) 12 x 100 x 68 mm (W x H x D)
Further features of the EtherCAT terminals
4-wire connection technology
Leading PE contact Tongue and groove
connection
Terminal type based on the label
Digital inputs: EL1xxx
Digital outputs: EL2xxx
Analog inputs: EL3xxx
Analog outputs: EL4xxx
Communication: EL6xxx
Drive: EL7xxx
System: EL9xxx
Overview of contents
Version differences
Visual Studio® 2010
Visual Studio® 2010 Shell
Integration of the TwinCAT System Manager
System PLC
Slide-in 1: EtherCAT Bus Terminals
Slide-in 2: Variable Declaration
Practice slide-in 1: The first project Automatic start of the controller Establishing a remote connection Own data types
Working with several tasks Backup on the target system Encrypt the project
23.05.2012
Slide-in 2: Variable Declaration
In order to be able to link variables from the PLC to hardware inputs or outputs, these must be specially declared
¾ The variable AnalogValuePot1 is to record a potentiometer
control value via an analog input terminal. General addressing regulation:
This results in the following declaration possibilities for the example variable
AnalogValuePot1: or Variable name AT % I Q X B 0.1 2 : BOOL INT ; *
Fixed addressing vs. automatic addressing
In comparison with fixed addressing,
a placeholder for an address to be assigned by the System Manager is inserted in
automatic addressing by adding a ‘*’:
23.05.2012
Declaration regulation for naming
a b c
Lamp AT %QX0.0 : BOOL; Switch AT %IX0.0 : BOOL;
Analog_Value AT %IB2:INT; Temperature AT %IB100 :INT;
Zähler AT %IB3 : UINT; PWM_Output AT %QB10 :INT; Naming restrictions 1. No special characters 2. No spaces 3. Permitted for separation 4. No umlauts
Overview of contents
Version differences
Visual Studio® 2010
Visual Studio® 2010 Shell
Integration of the TwinCAT System Manager
System PLC
Slide-in 1: EtherCAT Bus Terminals Slide-in 2: Variable Declaration
Practice slide-in 1: The first project
Automatic start of the controller Establishing a remote connection Own data types
Working with several tasks Backup on the target system Encrypt the project
23.05.2012
Practice slide-in 1: The first project
Starting the TwinCAT 3 engineering (XAE) - fast start via the TwinCAT Icon
Creating a new project
Generating a new project Selection of the template
TwinCAT Project
TwinCAT Project creates a new solution with System Manager tree
Enter name and specify storage location for the solution
23.05.2012
Project folder explorer
The project folder explorer manages the complete solution and contains the name that was selected when creating the project.
If there is only one project, then this has the solution name.
If there are several projects the name can simply be changed with a ‘right click’.
Further projects can be added by ‘right-clicking’ on the project folder.
Existing projects always end with *.tsp
Installation: devices compatible with real-time Ethernet
For the use of real-time
Ethernet devices as fieldbus masters, such as
9 EtherCAT
9 Realtime Ethernet
it is necessary to install an appropriate protocol for an INTEL chipset-based Ethernet controller: TwinCATÆShow Realtime Ethernet Compatible Devices 23.05.2012 TwinCAT 3 | Handling 37
Step 1: Generating a hardware configuration
You can automatically search for devices by right-clicking on Devices in the I/O menu option.
Depending on the fieldbus masters in use, these will be displayed for selection in the subsequent window.
When the selection is confirmed
with , a search will be performed for slaves connected to the selected master if is selected in the dialog box. 2 3 1 2 3 1
Testing the created configuration
The Free Run mode can be activated in order to perform an I/O check.
23.05.2012
Step 2: Creating a PLC configuration
By right-clicking on PLC, either a new TwinCAT 3 project
or an existing TwinCAT 3 (*.plcproj) or TwinCAT 2 (*.pro file) can be added
The standard PLC project or an empty PLC project can be used as the template for the new
PLC project in detail
Below the PLC Configuration a PLC project is created with the name entered previously.
On creating the project the first POU: MAIN is also created.
The PLC project is subdivided into code and instance
At the same time as the PLC project, a PLC task was created as a reference to the created task in the system task area.
23.05.2012
Step 3: IEC example ‘Blinker’
A function block FB_Blinker is now added to the already created POU MAIN.
By right-clicking on POUs a further block can now be created as a function block in ‘FUP/FBD’.
1
FB_Blinker | Add box
Depending on the selected language, the ‘Toolbox’ contains elements for inserting into the block:
The first box is pulled here into the first network by drag & drop.
23.05.2012
TwinCAT 3 | Handling 43
A total of 3 boxes are required, which are inserted one after the other
FB_Blinker | Structure of the FB
The blinker is to be realised by means of an AND condition and two
series-connected timer blocks of the type TON, to which an instance name will also be assigned in the next step
FB_Blinker | Instancing
Typing the implementation name for a timer opens the selection help:
If the instance name is now issued by selecting the ‘???’ above the box, the declaration help for creating the instance opens:
If you confirm the entries here, then the instance is created in the selected object ‘FB_Blinker’ in the local variable class ‘VAR’.
The second box is instanced in exactly the same way.
23.05.2012
FB_Blinker | Instancing
The first box in the chain becomes the AND gate which, inserted as a function, requires no instance formation:
The first input of the AND gate should be connected to the external variable ‘bStart’. As soon as this is entered in place of ‘???’, the declaration help opens again.
VAR_INPUT is selected here as the memory location (Scope) The type of variable (type) is
recognised automatically on the basis of the block.
FB_Blinker | Instancing
The second input of the AND gate is connected to the output Q of the second timing element T2 and negated by right-clicking on the input in front of the box:
The runtime is specified via the PT inputs of timing elements T1 and T2, which are declared as input variables of the FB_Blinker
On creating the ‘tZeit’ variables, the declaration help opens again, via which the variables are created in the VAR_INPUT area.
23.05.2012
FB_Blinker | Instancing
The generated pulse is output from the FB_Blinker via the variable ‘bBlinkimpuls’ by declaration as VAR_OUTPUT.
The value is tapped by means of adding an ‘Insert Assignment’ by right-clicking in front of the ‘IN’ input of T2: