Documente Academic
Documente Profesional
Documente Cultură
Training fr Umsteiger
Training fr Umsteiger
Overview of contents
03.05.2012
03.05.2012
Special methods:
FB_Init, FB_Exit, FB_Reinit
TwinCAT 3 | Training | Object-orientated
programming in IEC
03.05.2012
03.05.2012
03.05.2012
2nd Edition
IEC 61131-3
3rd Edition
IEC 61131-3
C++
Java
C#
Multilingual capability
OOP/procedural mixed
Classes
~ (FB)
Methods
~ (Actions)
Interfaces
Polymorphism
+/-
Reference semantics
+ (Interfaces)
Constructor/Destructor
Properties
Visibility
~ (Variables)
~ (Variablen)
- (in TC3)
03.05.2012
Overview of contents
03.05.2012
History
1st edition 1993
2nd edition 2003: bugfixes and small extensions
3rd edition 2011
working at 3rd starts 2008
1st draft in july 2009
release 2010
10.12.2012
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.
10.12.2012
10
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
Unicode format
10.12.2012
11
Enum Type
Explixitly specify the datatype of an enumeration.
Default type is INT.
10.12.2012
12
UNION
All variables have the same memory offset.
All variables occupy the same memory location.
Size of the memory is defined by the major variable.
10.12.2012
13
10.12.2012
14
10.12.2012
15
10.12.2012
16
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)}
10.12.2012
17
Pragma Instructions
Messages
{text 'Hello World!'}
{info 'Information!'}
{warning 'Warning!'}
{error 'Error!'}
10.12.2012
18
Pragma Instructions
10.12.2012
19
References
A reference is an alias for an object.
Instead of pointers.
Typesafe.
No dereferencing.
10.12.2012
20
EXTENDS
INTERFACE
IMPLEMENTS
THIS
SUPER
10.12.2012
21
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.
10.12.2012
22
PROPERTY
Gives access to internal states or values.
Provides methods how to get and/or set the value.
10.12.2012
23
10.12.2012
24
10.12.2012
25
old_inst.fb_exit(bInCopyCode := TRUE);
10.12.2012
26
THIS
Every function block provides the pointer THIS.
THIS points to the current function block.
10.12.2012
27
EXTENDS
Structure includes all variables from the extended base.
10.12.2012
28
EXTENDS
Function block includes all variables from the extended base.
10.12.2012
29
EXTENDS
function block includes all methods from the extended base.
10.12.2012
30
SUPER
Every function block provides the pointer SUPER.
SUPER points to the basic function block.
10.12.2012
31
INTERFACE
No body (implementation).
No declaration of internal variables.
10.12.2012
32
IMPLEMENTS
A function block implements
the interface.
10.12.2012
33
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.
10.12.2012
34
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.
10.12.2012
35
10.12.2012
36
Dynamic Memory
__NEW
__DELETE
10.12.2012
37
ANY_TYPE
ANY_NUM_TO_<NUMERIC>
ANY_TO_<TYPE>
10.12.2012
38
Overview of contents
03.05.2012
39
03.05.2012
40
03.05.2012
41
03.05.2012
42
03.05.2012
43
03.05.2012
44
03.05.2012
45
Sample04: Cylinder
Example: Cylinder
Task:
Cylinders should all look the same
Identical behaviour
Special form: cylinder with diagnosis
03.05.2012
46
FB_Cylinder
+bAtLeftPos : bool
+bAtRightPos : bool
TimerReach
TimerStart
iState : int
+M_StateMachine() : bool
FB_CylinderDiag
+tTimeOut
WatchDogTimer
+M_StateMachine() : bool
+M_Diag() : bool
TwinCAT 3 | Training | Object-orientated
programming in IEC
03.05.2012
47
03.05.2012
48
03.05.2012
49
Implementation
of the interface
method
03.05.2012
50
03.05.2012
51
Overwriting the
interface
method
03.05.2012
52
03.05.2012
53
Training fr Umsteiger
Thank you very much
for your attention!
Training fr Umsteiger
Overview of contents
eXtended Automation
(XA) overview
Architecture (XAA)
Engineering (XAE)
Runtime (XAR)
Connectivity
TwinCAT 2 Migration
Functions
TwinCAT 3 | Overview
23.05.2012
Engineering (XAE)
Runtime (XAR)
TwinCAT 3 | Overview
23.05.2012
TcCOM
Safety
C++
Module
TcCOM
TcCOM
TcCOM
eXtended
Automation
Runtime (XAR)
PLC
TcCOM
TwinCAT 3
eXtended
Automation (XA)
eXtended
Automation
Engineering (XAE)
TwinCAT 3
Integrated
Visual Studio
2010 Shell
Visual Studio
2010
TwinCAT 3 | Overview
23.05.2012
eXtended Automation
Runtime (XAR)
TwinCAT 3 | Overview
23.05.2012
Architecture (XAA)
PC System
Windows 32/64 bit
TwinCAT 3 Engineering Environment based on Visual Studio
System Manager
- Configuration
Programming
- IEC 61131-3
- objectoriented extensions
- C/C++
eXtended
Automation Engineering (XAE)
TcCOM
TcCOM
CPLC
Module
C++
PLC
Module
TcCOM
Simulink
PLC
Module
NC
PLC
TcCOM
TcCOM
CNC
PLC
Safety
PLC
TcCOM
TcCOM
PLC
PLC
TcCOM
Real-time Kernel
PLC
PLC
eXtended
Automation Runtime (XAR)
Fieldbus
TwinCAT 3 | Overview
23.05.2012
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 | Overview
23.05.2012
eXtended Automation
Engineering (XAE)
TwinCAT 3 | Overview
23.05.2012
eXtended Automation
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:
NEU object-orientated extension)
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
Embedded in Microsoft Visual Studio 2010
TwinCAT 3 | Overview
23.05.2012
10
eXtended Automation
Engineering (XAE) - variants
TwinCAT 3 Standard
Based on the Microsoft
Visual Studio Shell
Integrated System
Manager
Integrated IEC-61131-3
3rd edition programming
(OOP)
Integrated Safety PLC
TwinCAT 3 Integrated
Integration in an existing
Microsoft 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 thirdparty software tools
TwinCAT 3 | Overview
23.05.2012
11
Engineering (XAE)
TwinCAT 3 Standard
System Manager
Configuration
I/O
PLC
MC
NC
CNC
Safety
others
Configuration,
parameterisation and
diagnosis
Debugging of the PLC
code
Programming
IEC 61131
Objectoriented
extensions
IEC Compiler
TwinCAT 3 Runtime
TwinCAT 3 | Overview
23.05.2012
12
Engineering (XAE)
TwinCAT 3 Integrated
Matlab/
Simulink
Third-party
programming
tool
Programming
Non
real-time
Real-time
Real-time
Workshop
C#.NET
IEC 61131
Objectoriented
extensions
IEC Compiler
C/C++
C/C++
Microsoft C Compiler
TwinCAT 3 Runtime
TwinCAT 3 | Overview
23.05.2012
13
Engineering (XAE)
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
Ultimate
Professional
23.05.2012
14
Engineering (XAE)
Parallel programming of IEC 61131 and C++
C++ Code
IEC Code
TwinCAT 3 | Overview
23.05.2012
15
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 | Overview
23.05.2012
16
Engineering (XAE)
Integrated System Manager | Directory tree
System configuration
PLC configuration
Safety PLC configuration
C++ module configuration
I/O configuration
TwinCAT 3 | Overview
23.05.2012
17
Engineering (XAE)
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
Virtual
process
images
Physical
process
images
Inputs
Inputs
Outputs
Fieldbus 1
Outputs
Inputs
Outputs
Inputs
Fieldbus 2
TwinCAT 3 | Overview
Outputs
Fieldbus 3
23.05.2012
18
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 | Overview
23.05.2012
19
Engineering (XAE)
TwinCAT 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 | Overview
23.05.2012
20
Engineering (XAE)
TwinCAT 3 PLC | Development environment
Common tree structure for hardware and software
Common output of diagnosis and error messages (PLC, C++, system etc.)
TwinCAT 3 | Overview
23.05.2012
21
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 | Overview
23.05.2012
22
Engineering (XAE)
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
TwinCAT 3 | Overview
23.05.2012
23
+
PLC
SP
Pos Ctrl
Velo Preset
Limit
+
+
Scale & Limit
Pos Meas.
Drives
Layer
Fieldbus
Layer
Soft Motion
Layer
Soft SPS
Layer
Engineering (XAE)
TwinCAT 3 Motion Control | Abstraction level
TwinCAT 3 | Overview
23.05.2012
24
Engineering (XAE)
TwinCAT 3 Motion Control | From PTP to Robot Control
Covered functionality
NC PTP
NC I
CNC
Robotics
Point-to-Pointmovement
Interpolated motion
with 3 axes and
5 additional axes
Complete CNC
functionality
Interpolated motion
for robotic control
interpolated
movement for
up to 32 axes
per channel
various
transformations
gearing
camming
superposition
flying saw
programming
according to DIN 66025
technological features
straightforward
utilisation through
function blocks from
the PLC
TwinCAT 3 | Overview
23.05.2012
25
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 | Overview
23.05.2012
26
Engineering (XAE)
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
No t
Motion
ye t
a va
File I/O ilable!
TwinCAT 3 | Overview
23.05.2012
27
Engineering (XAE)
C/C++ programming languages | Integration
TwinCAT 3 | Overview
23.05.2012
28
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 | Overview
23.05.2012
29
Engineering (XAE)
Matlab/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
Download and execution in the TwinCAT 3 runtime (XAR)
TwinCAT 3 | Overview
23.05.2012
30
Engineering (XAE)
Matlab/Simulink | Integration
TwinCAT 3 | Overview
23.05.2012
31
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 | Overview
23.05.2012
32
Engineering (XAE)
C#/.NET programming
HMI/
Windows processes
PLC module
C++ module
Real-time Code
TwinCAT 3 | Overview
23.05.2012
33
Engineering (XAE)
Runtime (XAR)
TwinCAT 3 | Overview
23.05.2012
34
eXtended Automation
Runtime (XAR)
TwinCAT 3 | Overview
23.05.2012
35
eXtended Automation
Runtime (XAR) | Modular runtime systems
Debugging
PLC
C++
Module
Task
TcCOM
Task
TcCOM
TcCOM
Call
PLC
Simulink
Module
PLC
CNC
Task
Task
PLC
NC
Call
PLC
PLC
C++
Module
TcCOM
Task
TcCOM
Task
Call
PLC
C
Module
TcCOM
PLC
TcCOM
Task
TcCOM
TcCOM
TC Configuration
TcCOM
TwinCAT Real-time
Kernel
PLC
Simulink
Module
PLC
Safety
TwinCAT 3 Runtime
Fieldbus
TwinCAT 3 | Overview
23.05.2012
36
eXtended Automation
Runtime (XAR) | TwinCAT modules
Must
Description (methods, functions, names
etc.)
StateMachine (Init, PreOp, Op)
TcCom Interface
TwinCAT Module
Module Description
State Machine
ITComObject Interface
Can
Interfaces
Parameter
Interfaces
Pointers
Interfaces
Parameter
Data Areas
Contexts
Data Areas
Categories
ADS Port
TwinCAT 3 | Overview
Data Area
Pointers
23.05.2012
37
eXtended Automation
TwinCAT 3 Multi-core support
TwinCAT 3 | Overview
23.05.2012
38
Runtime (XAR)
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
Multi-core CPU
Core 0
Core 1
Core 2
Core 3
Core ...
Windows
Apps
PLC Control
User HMI
PLC Runtime 0
PLC Runtime 1
NC Runtime 1
Windows
Drivers
ADS
ADS
ADS
Task 0 Task 1
ADS
ADS
L2 Shared Cache
System Memory
TwinCAT 3 | Overview
23.05.2012
39
Runtime (XAR)
TwinCAT 3 Multi-core support | Assignment
Activation of the cores
TwinCAT 3 | Overview
23.05.2012
40
Overview of contents
Motivation why
TwinCAT 3
eXtended Automation
(XA) - overview
Architecture (XAA)
Engineering (XAE)
Runtime (XAR)
Connectivity
TwinCAT 2 Migration
Functions
TwinCAT 3 | Overview
23.05.2012
41
eXtended Automation
Connectivity
TwinCAT 3 | Overview
23.05.2012
42
eXtended Automation
Connectivity | ADS to Communication
(PLC) PC 1
(PLC) PC 2
TwinCAT
TwinCAT
TwinCAT
TwinCAT
Automation
Protocols
Industry
Protocols
IT
Protocols
Web
Server Ils
TwinCAT
Automation
Device
Specification
(ADS)
OPC UA,
Modbus
TCP, Modbus
RTU
3964R/RK512
IEC 61850,
IEC 61400-25,
IEC 60870-510x,
BACnet, FIAS,
Creston
WLAN,
Bluetooth,
TCP, UDP,
RAS,
FTP, VPN,
SNMP, SNTP,
SMS, SMTP
XML, AJAX,
ASP,
DPWS/WSD
Automation
Device
Specification
(ADS)
Acyclic
TwinCAT ADS
Router
Cyclic
EtherCAT Automation
Protocol (EAP),
Network variables
TwinCAT 3 | Overview
23.05.2012
43
Overview of contents
Motivation why
TwinCAT 3
eXtended Automation
(XA) - overview
Architecture (XAA)
Engineering (XAE)
Runtime (XAR)
Connectivity
TwinCAT 2 Migration
Functions
TwinCAT 3 | Overview
23.05.2012
44
eXtended Automation
TwinCAT 2 Migration | Opening old projects
The opening of projects created with TwinCAT 2 results in:
TwinCAT 3 | Overview
23.05.2012
45
Overview of contents
Motivation why
TwinCAT 3
eXtended Automation
(XA) - overview
Architecture (XAA)
Engineering (XAE)
Runtime (XAR)
Connectivity
TwinCAT 2 Migration
Functions
TwinCAT 3 | Overview
23.05.2012
46
eXtended Automation
TwinCAT Functions
The previously familiar TwinCAT supplements also exist in TwinCAT 3
The designation changes to TwinCAT Functions: TFxxxx
TwinCAT 3 | Overview
23.05.2012
47
Overview
Training fr Umsteiger
Thank you very much for your
attention!
12.04.2013
Engineering (XAE)
Runtime (XAR)
TwinCAT 3 | Overview
23.05.2012
TcCOM
Safety
C++
modules
TcCOM
TcCOM
TcCOM
eXtended
Automation
Runtime (XAR)
PLC
TcCOM
TwinCAT 3
eXtended
Automation (XA)
eXtended
Automation
Engineering (XAE)
TwinCAT 3
Integrated
Visual Studio
2010 Shell
Visual Studio
2010
23.05.2012
TwinCAT 3
Integrated
Visual Studio
2010 Shell
Visual Studio
2010
eXtended
Automation
Runtime (XAR)
TwinCAT 3 | Overview
23.05.2012
eXtended
Automation
Runtime (XAR)
TcCOM
Safety
C++
modules
TcCOM
TcCOM
TcCOM
PLC
TcCOM
EtherCAT
TwinCAT 3 | Overview
23.05.2012
TwinCAT 3
Standard / Integrated
TwinCAT Transport Layer - ADS
TwinCAT 3 Runtime
Real-time Kernel
Simulink
PLC
modules
C++
PLC
modules
PLC
PLC
IO
CNC
PLC
TwinCAT 3 | Overview
23.05.2012
TwinCAT 3
Standard / Integrated
Real-time Kernel
CNC
PLC
Simulink
PLC
modules
C++
PLC
modules
PLC
PLC
IO
TwinCAT 3 Runtime
Config Mode:
to enable communication (programming)
XAE status
PC
taskbar
TwinCAT 3 | Overview
23.05.2012
PC taskbar
Real-time load in %
TwinCAT 3 | Overview
23.05.2012
Establishment of a connection
Practical part
Establishment of a
connection
TwinCAT 3 | Overview
23.05.2012
Establishment of a connection
Requirement: TC3 is successfully installed on the programming computer and the
target computer
Hardware with PC (XAE)
Target system CX with BK1120 Bus Station
12.04.2013
10
Hardware
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
12.04.2013
11
12.04.2013
12
12.04.2013
13
12.04.2013
14
Establishment of a connection
To search, first select Local Target System
12.04.2013
15
Establishment of a connection
searches
for TC
controllers
IPC/ CX
Connection
to both
devices
(enter PC
target
system)
12.04.2013
16
Establishment of a connection
Logon information: user name and password for computer.
Training CX 1020
CX training:
Administrator
1
12.04.2013
17
Establishment of a connection
Connection
valid
12.04.2013
18
Establishment of a connection
12.04.2013
19
PC taskbar
12.04.2013
20
12.04.2013
21
Hardware test
Scanning
Freerun Mode
TwinCAT 3 | Overview
22
23.05.2012
Scan Hardware
Check Config
Mode, activate
Config Mode if
necessary
Scan
12.04.2013
23
Scan Hardware
Scan Hardware
12.04.2013
24
Freerun
In Freerun Mode,
I/O can be tested
without PLC program
12.04.2013
25
PLC Program
Practical part
TwinCAT 3 | Overview
26
23.05.2012
12.04.2013
27
12.04.2013
28
12.04.2013
29
12.04.2013
30
Linking
Link
12.04.2013
31
Linking
Link
12.04.2013
32
Linking
Further links
12.04.2013
33
Activate
Activating the
configuration
Wait for Run Mode
12.04.2013
34
Activate
If TwinCAT XAR is not
registered, a 7-day
licence can be created
12.04.2013
35
Login
Logon to PLC project
Login
Start
PLC
PLC
Online
PLC RUN
12.04.2013
36
Online
Monitoring
Global variables online
Write
Value
s
12.04.2013
38
12.04.2013
39
12.04.2013
40
12.04.2013
41
12.04.2013
42
12.04.2013
43
12.04.2013
44
12.04.2013
45
12.04.2013
46
Autostart
Practical part
TwinCAT 3 | Overview
47
23.05.2012
Autostart
Boot project
Enable autostart
Creating a boot project
12.04.2013
48
Autostart
TwinCAT autostart
12.04.2013
49
Autostart
User name and
password for the
control computer
12.04.2013
50
Handling
Training fr Umsteiger
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
TwinCAT 3 Standard
TwinCAT 3 Integrated
Integrated TwinCAT
System Manager
Integrated IEC-61131-3
3rd edition programming
(OOP)
Integrierte Safety PLC
23.05.2012
TwinCAT 3 | Handling
23.05.2012
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
TwinCAT 3 | Handling
23.05.2012
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
System configuration
The tree entry system contains
Licence
Real time
Tasks
Routing
TcCom Objects
TwinCAT 3 | Handling
23.05.2012
Alternative:
7-day test licence
Sales-related procedure
1. Ordering of the desired TwinCAT 3 package
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
TwinCAT 3 | Handling
23.05.2012
Licence | Diagram
Procedure for generating and integrating a chargeable licence file:
TwinCAT 3 | Handling
23.05.2012
10
23.05.2012
11
23.05.2012
12
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:
TwinCAT 3 | Handling
23.05.2012
13
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.
TwinCAT 3 | Handling
23.05.2012
14
TwinCAT 3 | Handling
23.05.2012
15
Task Management
Central management of the task(s) for
this solution
23.05.2012
16
TcCom Objects
Linking of binaries
Matlab/Simulink
C++ modules in TwinCAT standard environments
TwinCAT 3 | Handling
23.05.2012
17
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
18
TwinCAT 3 | Handling
23.05.2012
19
TwinCAT 3 | Handling
23.05.2012
20
TwinCAT 3 | Handling
23.05.2012
21
LD
Contact networks at all inputs
Coils at all outputs
Several blocks in a network
IL
Now table-orientated
TwinCAT 3 | Handling
23.05.2012
22
TwinCAT 3 | Handling
23.05.2012
23
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
24
TwinCAT 3 | Handling
23.05.2012
25
TwinCAT 3 | Handling
23.05.2012
26
Screwless
connection
technology
Symmetrical
unlatching for
vertical removal
TwinCAT 3 | Handling
23.05.2012
27
Leading PE contact
TwinCAT 3 | Handling
23.05.2012
28
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
29
0.1
BOOL
Variable name
AT
;
INT
This results in the following declaration possibilities for the example variable
AnalogValuePot1:
or
TwinCAT 3 | Handling
23.05.2012
30
TwinCAT 3 | Handling
23.05.2012
31
Analog_Value AT %IB2:INT;
1. No special
characters
2. No spaces
3. Permitted for
separation
b
c
TwinCAT 3 | Handling
4. No umlauts
23.05.2012
32
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
33
TwinCAT 3 | Handling
23.05.2012
34
23.05.2012
35
TwinCAT 3 | Handling
23.05.2012
36
TwinCAT 3 | Handling
23.05.2012
37
TwinCAT 3 | Handling
23.05.2012
38
TwinCAT 3 | Handling
23.05.2012
39
TwinCAT 3 | Handling
23.05.2012
40
TwinCAT 3 | Handling
23.05.2012
41
TwinCAT 3 | Handling
23.05.2012
42
23.05.2012
43
The blinker is to be realised by means of an AND condition and two seriesconnected timer blocks of the type TON, to which an instance name will also be
assigned in the next step
TwinCAT 3 | Handling
23.05.2012
44
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.
TwinCAT 3 | Handling
23.05.2012
45
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.
TwinCAT 3 | Handling
23.05.2012
46
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.
TwinCAT 3 | Handling
23.05.2012
47
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:
TwinCAT 3 | Handling
23.05.2012
48
TwinCAT 3 | Handling
23.05.2012
49
TwinCAT 3 | Handling
23.05.2012
50
The FB_Blinker is now called again by creating a box in the first network
In this case, however, the button is used that appears as soon as the inner ???
are selected:
TwinCAT 3 | Handling
23.05.2012
51
After insertion, an instance name is selected as before and added to the variables
area VAR in the POU MAIN
TwinCAT 3 | Handling
23.05.2012
52
Subsequently, the variable Taster1 can be created via the variable declaration in
the global variables at address %IX0.1:
TwinCAT 3 | Handling
23.05.2012
53
TwinCAT 3 | Handling
23.05.2012
54
The variables from this instance can now be connected to the hardware
TwinCAT 3 | Handling
23.05.2012
55
TwinCAT 3 | Handling
23.05.2012
56
2
The feedback signal can be recognised by the
green TwinCAT icon in the TwinCAT XAE and
the taskbar.
TwinCAT 3 | Handling
23.05.2012
57
TwinCAT 3 | Handling
23.05.2012
58
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
59
Power ON
Windows start
Windows login
Starting of TwinCAT
XAR
TwinCAT 3 | Handling
23.05.2012
60
2
1
TwinCAT 3 | Handling
23.05.2012
61
3
Context Menu
3
TwinCAT 3 | Handling
23.05.2012
62
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
63
TwinCAT 3 | Handling
23.05.2012
64
23.05.2012
65
Select from
the list or
search
TwinCAT 3 | Handling
23.05.2012
66
TwinCAT 3 | Handling
23.05.2012
67
Select from
the list and
OK
TwinCAT 3 | Handling
23.05.2012
68
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
69
23.05.2012
70
Declaration
Instance formation
Declaration
Call and
assignment
TwinCAT 3 | Handling
23.05.2012
71
Declaration
Instance formation
Declaration
Call and
assignment
TwinCAT 3 | Handling
23.05.2012
72
Declaration
Instance formation
Declaration
Call and
assignment
TwinCAT 3 | Handling
23.05.2012
73
Declaration
Instance formation
Declaration
Call and
assignment
TwinCAT 3 | Handling
23.05.2012
74
Explanation
1.In a structure,
structure the individual elements
of the structure are located one behind
the other in memory. The overall
memory requirement is thus
determined from the sum of the sizes
of the individual elements.
2.In a union the memory requirement is
determined from the largest element. In
the example shown above, therefore,
from the String variable.
TwinCAT 3 | Handling
23.05.2012
75
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
76
TwinCAT 3 | Handling
23.05.2012
77
1
4
TwinCAT 3 | Handling
23.05.2012
78
TwinCAT 3 | Handling
23.05.2012
79
TwinCAT 3 | Handling
10.12.2012
80
TwinCAT 3 | Handling
10.12.2012
81
PLC-Program
z.B.: 1 ms
2 ms
3 ms
4 ms
NC-Cycle
2
5 ms
NC-Cycle
t
t
PCL-Cycle
TwinCAT 3 | Handling
10.12.2012
82
1 ms
50s
Too low base period has a high copy expenses and thus may result in a higher
processor utilization as required for the application!
TwinCAT 3 | Handling
10.12.2012
83
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
84
TwinCAT 3 | Handling
10.12.2012
85
TwinCAT 3 | Handling
10.12.2012
86
Overview of contents
Version differences
TwinCAT 3 | Handling
23.05.2012
87
10.12.2012
88
Handling
Training fr Umsteiger
Thank you very much
for your attention!
Training fr Umsteiger
Identifier
Indentifier serves to assign individual names to variables, data types,
functions, etc.
The identifier starts with a letter or underscore
followed by numbers, letters and underscore
No distinction is made between upper and lower case
The following are not permitted
special characters (!, , , $, etc.)
spaces
consecutive underscores
umlauts
12.04.2013
Keywords
Keywords are identifiers specified by IEC61131-3. They are thus fixed
components of the syntax and therefore may not be used for other
purposes.
Examples
Standard operators AND, OR, NOT
Standard types BOOL, INT, REAL...
Types TYPE, STRUCT
Block types FUNCTION, FUNCTION_BLOCK, PROGRAM
12.04.2013
12.04.2013
Lower
Upper
BOOL
FALSE
TRUE
Size
Prefix
x
b
BYTE
8 BIT
by
Bitstring
WORD
16 BIT
Bitstring
DWORD
32 BIT
dw
Bitstring
12.04.2013
Detail slides
Overflows
Example: EL3102
Example: KL2531
TwinCAT Training: Programmer
12.04.2013
Lower
Upper
Size
Prefix
TIME_OF_DAY
TOD#0:0:0
TOD#23:59:
59
32 Bit
tod
DATE
D#1970:01:01
D#2106 ???
32 Bit
date
DATE_AND_TIME
DT#1970:01:01:00:00:00
DT#2106
???
32 Bit
dt
TIME
T#0s
T#49d17h2m 32BIT
47s295ms
tim
Detail slides
DT example - reading the system time
DT example - working with standard operators
12.04.2013
Lower
Upper
Size
Prefix
REAL
4 Byte
LREAL
8 Byte
lr
12.04.2013
Description
Example
Size
Prefix
STRING
String in ASCII
code. Standard
length 80
characters.
Maximum length
255. Strings are
zero-terminated
1234ABCDE
80 +1
ABCDE$R$L
ABCDE$0D$0A
Assignment
Result SIZEOF
Result LEN
sVar : STRING;
sVar:=ABC;
81
sVar1 :STRING(1);
sVar := X;
sVar: STRING(255);
sVar:=ABC;
256
12.04.2013
ASCII Code
$0D
CR
$R
$r
CR
$L
$l
Line Feed
$N
$n
New Line
$T
$t
Tab
Detail slides
Example: FIND
Example: string functions LEN, REPLACE
String conversion with Union
12.04.2013
10
Description
Example
Description
Pre
fix
WSTRING
String in Unicode
format
Level 0,Block
0x0400-0x4FFF
Cyrillic
ws
Training, seminar
Level 0
Block 0x00000x007F
Basic Latin
12.04.2013
11
Examples
BOOL
TRUE
2#1
16#1
FALSE
2#0
16#0
WORD,
DWORD
2#1010111111111110
16#AFFE
45054
INT
2#1000000000000001
16#8001
-32768
TIME
t#1h
t#60m
t#3600000ms
t#0.5d
t#12h
t#43200000ms
day
hours
min
sec
ms
ms
REAL
t#30m18s90ms
t#0.505025h
0.3333
3.333e-1
t#1818090ms
12.04.2013
12
Identifier
Data type
Initial value
bStellerUntenLinks:BOOL:=TRUE;
12.04.2013
13
AT
%I
Data type;
%Q*
12.04.2013
14
AT
%I
%Q
%M
Byte
Bit
Type
Byte
Detail slides
Detail - Replace %MB by UNION
TwinCAT Training: Programmer
12.04.2013
15
IX10.6
IX10.5
IX10.4
IX10.3
IX10.2
IX10.1
IX10.0
IB10
IB1
IB0
IW0
IX22.6
IX22.5
IB23
IX22.4
IX22.3
IB22
IX22.2
IX22.1
IB21
IW22
IB20
IW20
ID20
IX22.0
12.04.2013
16
END_VAR
VAR_OUTPUT ..
END_VAR
12.04.2013
17
Implementation
TwinCAT Training: Programmer
12.04.2013
18
Project machine
PROGRAM A
PROGRAM B
VAR
VAR
locVar AT%MB2:WORD;
END_VAR
END_VAR
LD %MB2
12.04.2013
19
Example
name:
Gvl1
LD Var1
LD Gvl1.Var1
12.04.2013
20
12.04.2013
21
Global
END_VAR
VAR CONSTANT
pi:REAL:=3.141592654;
Also locally
possible
END_VAR
TwinCAT Training: Programmer
12.04.2013
22
Parent type
Name
Data type
New value
Derivation
Name
Data type
Initial value
Area
Inherit
ance
Initial value
Area
12.04.2013
23
Syntax:
TYPE
<Bezeichner>:<Zuweisungsausdruck>;
END_TYPE
Type
Declaration
12.04.2013
24
12.04.2013
25
12.04.2013
26
12.04.2013
27
12.04.2013
28
12.04.2013
29
Use
Online
12.04.2013
30
Use
Declaration
Online
12.04.2013
31
12.04.2013
32
12.04.2013
33
1-dimensional
2-dimensional
3-dimensional
12.04.2013
34
i:= 9
Feld_1[i+2] := 120;
Feld_1[9];
Feld_2[1,2];
120
12.04.2013
35
CheckBounds := L;
Limited
value
CheckBounds := U;
ELSE
OK case
CheckBounds := I;
END_IF
12.04.2013
36
12.04.2013
37
12.04.2013
38
Checkbounds is compiled-in
in XAR
10
Do not write,
it is called
automatically
(not visible in
the code)
10
9
Can be checked with call build:
TwinCAT Training: Programmer
12.04.2013
39
12.04.2013
40
LREAL;
LREAL;
LREAL;
LREAL;
LREAL;
LREAL;
LREAL;
LREAL;
LREAL;
LREAL;
LREAL;
BOOL; (*Pumpe ?*)
12.04.2013
41
TRUE,
Position:=
Positions[55].XPos ,
Velocity:=
Positions[55].FeedrateX
Acceleration:=
Positions[55].AccelerationX,
Deceleration:=
Positions[55].DeccelerationX,
Jerk:=
Positions[55].JerkX,
Direction:=
.........,
Axis:=
.............,
);
TwinCAT Training: Programmer
12.04.2013
42
Block types
In IEC61131-3 there are three types of block covered by the generic
term POU (PROGRAM ORGANISATION UNIT):
Program
Function Block
Function
12.04.2013
43
12.04.2013
44
12.04.2013
45
1,2,3........ VAR_INPUT
Outputs:
precisely 1!, but structure variable possible. The name of
the output is at the same time the name of the function.
Transfer by reference
1,2,3........ VAR_IN_OUT ,
Monitoring: In the online mode of the PLC control only ??? are visible
for the local variables, since this data area is used by all functions in the
cycle and monitoring (debug) takes place only at the cycle limits.
Remedy: program development with breakpoints
Use: algorithms where the result is available after a run. Scaling,
comparison, etc.
12.04.2013
46
Symbol
Binding strength
(expression)
Strongest binding
Function name (parameter list)
EXPT
NOT
*
Same binding strength,
processing from left to right
/
(10/2*5 = 25 )
MOD
+
Same binding strength
<,>,<=,>=
=
<>
AND
XOR
Weakest binding
OR
TwinCAT Training: Programmer
12.04.2013
47
Example
Assignment:=
PosWert := 10;
RETURN
RETURN;
IF
CASE
FOR
WHILE
REPEAT
EXIT
Empty instruction
12.04.2013
48
ST: IF instruction
Is needed to branch in a program, depending on conditions. With the
IF instructions its not possible to jump back in the PLC cycle.
GOTO is also not available
Keywords:
IF
THEN
ELSIF
ELSE
END_IF
12.04.2013
49
ST: IF instruction
IF Condition THEN
Instruction block;
END_IF
No
Condition
Yes
Instruction block
12.04.2013
50
ST: IF instruction
IF a>b THEN
Instruction block A;
ELSE
Instruction block B;
END_IF
Condition
No
Yes
Instruction block A
Instruction block B
12.04.2013
51
ST: IF instruction
IF Condition1 THEN
Instruction block A;
ELSE
IF Condition2 THEN
Instruction block B;
Condition 1
ELSE
No
Yes
IF Condition3 THEN
Condition 2
Instruction block C;
ELSE
Yes
Instruction block D;
END_IF
END_IF
END_IF
Instruction
Instruction
block A
block B
No
Condition 3
No
Yes
Instruction
block C
Instruction
block D
12.04.2013
52
ST: IF instruction
IF Condition1 THEN
Instruction block A;
ELSIF Condition2 THEN
Instruction block B;
ELSIF Condition3 THEN
Instruction block C;
ELSE
Instruction block D;
END_IF
Condition 1
No
Yes
Condition 2
No
Yes
Condition 3
No
Yes
Instruction
block A
Instruction
block B
Instruction
block C
Instruction
block D
12.04.2013
53
ST: IF instruction
What can the BOOLEAN EXPRESSION be?
Conditions:
BOOLEAN variable
Comparison
Function calls
Querying of FB instances
NO FB call!
IF bVar THEN
.
IF a>b THEN
.
IF LEFT(STR:= strVar, SIZE:=7) =
'TwinCAT' THEN
.
IF Ton1.Q THEN
.
IF Ton1(IN:=bVar, PT:=T#1s ) THEN
12.04.2013
54
ST CASE Instruction
CASE Selection criterion OF
1:
Selection criterion = 2
or 4 or 6
Instruction 1
2, 4, 6: Instruction 2
7..10: Instruction 3
Selection
criterion = 1
Selection criterion = 7
or 8 or 9 or 10?
No
Yes
..
No
ELSE
Yes
Default
instructions
No
Yes
END_CASE;
Two identical values
may not be available
for selection in the list.
Instruction 1
Instruction 2
Instruction 3
Default
instructions
12.04.2013
55
CASE State OF
0:
Q0:=TRUE;
IF Transition THEN state := 1; END_IF
1:
Q1:=TRUE;
IF Transition THEN state := 2; END_IF
2:
Step-further condition
(Transition)
Q2:=TRUE;
IF Transition THEN state := 3; END_IF
3:
Q3:=TRUE;
IF Transition THEN state := 0; END_IF
END_CASE
12.04.2013
56
Instructions;(*State=0*)
IF THEN
Instructions
if state = 0
1:
Instructions;(*State=1*)
Instructions
if state = 1
2:
Instructions;(*State=2*)
Instructions
if state = 2
3:
Instructions;(*State=3*)
Instructions
if state = 3
END_CASE
12.04.2013
57
Enum-Typ:
TYPE Schritte :
(INIT:=0, START, AUTOMATIK, ENDE);
END_TYPE
CASE State OF
INIT:
Instructions;(*State=0*)
START:
Instructions;(*State=1*)
AUTOMATIK:
Instructions;(*State=2*)
ENDE:
Instructions;(*State=3*)
END_CASE
12.04.2013
58
CASE State OF
INIT:
Q0:=TRUE;
IF Transition THEN state := START; END_IF
START:
Step-further condition
(Transition)
Q1:=TRUE;
IF Transition THEN state := AUTOMATIK; END_IF
Q3:=TRUE;
IF Transition THEN state := INIT; END_IF
END_CASE
TwinCAT Training: Programmer
12.04.2013
59
VAR CONSTANT
Step1 : INT:=
0;
Step1:
Instructions;(*State=0*)
Step2 : INT:=
1;
Step2:
Instructions;(*State=1*)
Step3 : INT:=
2;
Step3..Step4:
Step4 : INT:=
3;
END_CASE
END_VAR
VAR
State:INT;
END_VAR
12.04.2013
60
1
e.g.: 1ms
2
2ms
3
3ms
Begin of a new
time slice
4
4ms
1
5ms
12.04.2013
61
Expression
Processing
n cycle fix
FOR
SINT/INT/DINT
Instructions
Yes
follow condition
WHILE
BOOL
Instructions
No
follow condition
REPEAT
BOOL
Condition
follows
instructions
No
12.04.2013
62
Start i:=StartValue
Yes
i
>EndValue
No
Instruction block
i: = i + step size
Feld[i]:=i*2;(*Anweisung*)
END_FOR
Cycle n
TwinCAT Training: Programmer
12.04.2013
63
Cycle n
Yes
Boolean
expression
No
Instruction block
i: = i + step size
Cycle n
TwinCAT Training: Programmer
12.04.2013
64
Instruction block
i:= i + step size
i:=0;
REPEAT
Feld[i]:=i*2;(*Anweisung*)
i:=i+1;
UNTIL i>100
No
Boolean
expression
Yes
END_REPEAT
Cycle n
TwinCAT Training: Programmer
12.04.2013
65
ST: FB calls in ST
VAR
TON1:TON;
END_VAR
TON1 (IN:= NOT TON1.Q , PT:=T#1s );
Q0:= TON1.Q;
12.04.2013
66
12.04.2013
67
ST: FC calls in ST
Result:=Scale (x:=Eingang, xug:=0.0, xog:=32767.0, yug:=0.0,yog:=100.0);
(* Gleichwertig:*)
Result:=Scale (Eingang, 0.0, 32767.0, 0.0, 100.0);
(* Gleichwertig:*)
Result:=Scale (
xog:=
x:=
Eingang,
xug:=
0.0,
32767.0,
yug:=
0.0,
yog:=
100.0
);
In case of functions, all inputs must be occupied
TwinCAT Training: Programmer
12.04.2013
68
ST: FC calls in ST
Result := Scale (x:=Eingang, xug:=0.0, xog:=32767.0, yug:=0.0,yog:=100.0);
Result
CALL
Input parameters
(* Gleichwertig:*)
Result:=Scale
(
x:=
Eingang,
xug:=
0.0,
xog:=
32767.0,
yug:=
0.0,
yog:=
100.0
);
12.04.2013
69
Special methods:
FB_Init, FB_Exit, FB_Reinit
TwinCAT 3 | Training | Object-orientated
programming in IEC
70
03.05.2012
12.04.2013
71
Special methods:
FB_Init, FB_Exit, FB_Reinit
TwinCAT Training: Programmer
12.04.2013
72
12.04.2013
73
12.04.2013
74
12.04.2013
75
03.05.2012
12.04.2013
76
Example task
Example: a clock generator FB is to be created
that should be able to do the following:
generate a flashing cycle
generate a PWM signal (e.g. heating)
Parameter
fixed flashing time for flashing cycle
clock output for flashing signal
MaxCycles defines number of PLC cycles 100% duty cycle for PWM
generator
DCPercent; duty cycle in %
Enable: BOOL, enable for PWM signal
Vendor, name of the manufacturer as a string
12.04.2013
77
Standard procedure
All parameters are transferred with VAR_INPUT VAR_OUTPUT
The sub-functions are programmed in the FB and run through with the complete FB
to flashing
cycle
to PWM
generator
to flashing
cycle
to PWM
generator
12.04.2013
78
Standard procedure
This block is to be extended later
clock ratio of the flashing cycle is to be modified
the PWM generator is given a target profile generator (e.g. temperature profile)
Co
py
ex and
ten
d
12.04.2013
79
Alternative
With the new options
Methods
Features
Inheritance
Overwrite
12.04.2013
80
Example
A clock generator FB is to be created
Methods:
m_ClockGenerator generates the flashing cycle
M_Pwm generates a PWM signal (e.g. heating)
Features
p_CycleTime specifies flashing time for flashing cycle
p_MaxCycles defines number of PLC cycles 100% duty cycle
for PWM generator
p_Vendor
queries a string
12.04.2013
81
Example
FB_ClockGenerator
m_ClockGenerator()
m_Pwm()
p_Vendor
p_CycleTime
12.04.2013
82
12.04.2013
83
Example
FB_ClockGenerator
m_ClockGenerator()
m_PwmProfile()
p_Vendor
p_CycleTime
FB_ClockGeneratorEX
m_ClockGenerator() overwrite
m_PwmProfile() (new)
p_Vendor (overwrite)
12.04.2013
84
Extension
Block
see training examples
12.04.2013
85
The function blocks and functions are made available by integrating the
Standard.LIB. This is automatically integrated into the PLC project when
the project is created.
Standard blocks
Function Blocks
Timer
Functions
String Functions
Counter
Memory
Trigger
12.04.2013
86
FBD /CFC
ST
Comments
BOOL
AND
WORD
AND
DWORD
AND
12.04.2013
87
ST
Comments
Arithmetic Operators
Overloading possible,
beware of overflow with
integers.
- * /
Determines integral
remainder of a division
(in this case 4)
12.04.2013
88
Comments
FBD /CFC
ST
StrVarMode := SEL(Mode1, , Mode1Selected );
Example:
If Mode1 = TRUE, StrVarmode
contains Mode1Selected,
otherwise an empty string
12.04.2013
89
FBD /CFC
Selection with
integer variable,
inputs can be
overloaded
ST:
Online:
12.04.2013
90
Appendix: Conversions
Operator
ST
Comments
Time values are resolved
in ms rt1:REAL
iT1:INT
bVar1:BOOL
Rounding up takes place:
0.4 output goes FALSE
>=0.5 output goes TRUE
12.04.2013
91
Appendix: Conversions
FBD /CFC
ST
Comments
Result 20000.0
Implicit conversion also
possible
Conversion to INT with
rounding up/down
Conversion to INT without
rounding up/down
Beware of overflows
(Result is negative)
12.04.2013
92
CLK
R_TRIG
Q
CLK
F_TRIG
Q
ST
CLK
BOOL
Trigger input
BOOL
12.04.2013
93
SET1
SR
RESET1
Q1
SET1
RS
ST
RESET1
Q1
SET1
BOOL
Set
RESET1 BOOL
Reset
Q1
Output
BOOL
12.04.2013
94
IN
Q
ET
ST
IN
PT
TIME
BOOL Output
ET
TIME
12.04.2013
95
IN
PT
ST
IN
PT
TIME
BOOL Output
ET
TIME
ET
12.04.2013
96
IN
Q
ST
IN
PT
TIME
BOOL Output
ET
TIME
ET
12.04.2013
97
CU
BOOL
RESET BOOL
Counter reset
PV
UINT
Preset Value
BOOL
CV
WORD
12.04.2013
98
CD
BOOL
LOAD
BOOL
PV
UINT
Preset Value
BOOL
CV
UINT
12.04.2013
99
LOAD
CD
CU
RESET
CV
ST
CV=PV
QD
QU
CU
BOOL
CV
UINT
CD
BOOL
RESET
BOOL
Reset
LOAD
BOOL
PV
UINT
Preset Value
QU
BOOL
QD
BOOL
12.04.2013
100
ResultOnline
ST
STR1
STRING
First string
STR2
STRING
12.04.2013
101
ResultOnline
ST
STR1
STRING
STR2
STRING
String to be found
12.04.2013
102
Detail : Overflows
Beware of overflows with numerical operations
0000h
INT 0
FFFFh
INT -1
8000h
7FFFh
INT -32768
INT 32767
PLC memory
INT value
TwinCAT Training: Programmer
12.04.2013
103
Value
Decimal
32767
16383
0
-16383
-32768
Hexadecimal
0x7FFF
0x3FFF
0x0000
0xC001
0x8000
Status word from (EL3102-0000-0016) with older models only SW.0 - SW.7 1 byte
Bit
SW.15
SW.14
Name
TxPDO
Toggle
Bit
Name
SW.13
SW.12
SW.11
SW.10
SW.9
SW.8
SW.7
SW.6
SW.5
SW.4
SW.3
SW.2
SW.1
SW.0
ERROR
Limit 2
Overrange
Underrange
Limit 1
With older
models
12.04.2013
104
Velocity
Bit
15
14
Cont. VZ
13
12
11
10
Velocity value
Controlbyte (Ctrl)
Bit
Name
CB.7
CB.6
RegAccess Reset
CB.5
CB.4
CB.3
CB.2
CB.1
CB.0
AutoStop
AutoStart
Reduced
Current
Start
PLC-Stop
Enable
CW.13
CW.12
Reduced
Current
(drive)
CW.4
enLatch
FallEdge
CW.11
CW.10
CW.9
CW.8
Reduced
Current
SetPos
disMixed
Decay
GetEncoder
Position
CW.3
enLatch
RiseEdge
CW.2
enLatch
Input2
CW.1
enLatch
Input1
CW.0
Bit
Name
CW.15
CW.14
CW.7
CW.6
CW.5
GetPosition ToggleLatch GetLatch
Error
Data
Data
enLatchC
Position
Bit
15
14
13
12
11
10
Statusbyte (Status)
Bit
Name
SB.7
SB.6
RegAccess Error
SB.5
SB.4
SB.3
Warning
Idle
LoadAngle
SB.2
SB.1
SB.0
Ready
SW.7
SW.6
SW.5
SW.4
SW.3
SW.2
SW.1
SW.0
Encoder
Disabled
LatchData
Toggled
LatchData
InByte2,3
LatchValid
Target
Reached
SetPos
Ready
Input E2
Input E1
Bit
Name
SW.15
SW.10
OpenLoad
Br A
SW.9
Under
Voltage
SW.8
Over
Temperature
SW.14
NoControl
Config Error
Power
SW.13
SW.12
SW.11
OverCurrent OverCurrent OpenLoad
Br B
Br A
Br B
Summary
Description
Typ
INT
BYTE
WORD
UINT
BYTE
WORD
12.04.2013
106
12.04.2013
107
12.04.2013
108
Pos 1
Pos
10
Pos
11
10
12.04.2013
109
Pos 1
Pos 5
sVal
sResult
.1
-5
-5
12345
12345
12.04.2013
110
A
B
C
D
E
$R
$N
TwinCAT Training: Programmer
12.04.2013
111
Possible
Better, since user
does not have to
manage addresses
12.04.2013
112
System
Query the set PLC cycle time
Task no.
12.04.2013
113
Training fr Umsteiger
SFC
Sequential Function Chart, SFC
Step
Action
Transition
Jump
Jump to Target Step
TwinCAT Training: Programmer
12.04.2013
SFC
12.04.2013
SFC
Branch
Alternative
Brach
12.04.2013
SFC
Branch
Alternative
Brach
Both transition are active
12.04.2013
SFC
Branch
simultaneos
Brach
One transition to enter
simultaneos execution
One transition to leave
12.04.2013
SFC
Branch
simultaneos, special case
Brach
12.04.2013
SFC
Actions
Brach
direct assign of a bool variable with
an action (here qualifier N)
12.04.2013
SFC
Actions
direct assign of a bool variable with an action (here Qualifier S0 R0)
12.04.2013
SFC
Jump
Target Step
12.04.2013
10
Connectivity
12.04.2013
ADS (General)
Definition
NEU
ADS General
Definition: ADS = Automation Device Specification
modular ADS devices
e.g. PLC (each runtime system), NC, etc.
message exchange by ADS via the message router
12.04.2013
Router
unambiguously
identifiable by:
AdsAmsServerNetID
12.04.2013
12.04.2013
851
852
853
801
811
821
831
NC
500
(501)
IP Address
172.16.17.108
IO server
TwinCAT device
IO Mapper
Beckhoff Training: TwinCAT ADS
12.04.2013
12.04.2013
12.04.2013
Client-server relationship
1.) Confirmed services
2.) Unconfirmed services
ADS Client
ADS Server
Request
(Anforderung)
Indication
(Aufforderung)
Confirmation
(Besttigung)
Response
(Antwort)
12.04.2013
PLC I
Uses ADS FB
Request
Indication
(FB call)
Confirmation
Response
12.04.2013
10
%M
Memory range
%I
Input range
%Q
Output range
By name
PLC variable
Global
Example: .Tempsetpoint
Example: MAIN.TON1.ET
12.04.2013
11
Asynchronous:
Notification:
12.04.2013
12
12.04.2013
13
IDXGRP
IDXOFFS
%MB
0x4020
MB address
Example
IDXGRP 0x4020
IDXOFFS 100
%MX
%IB
0x4021
0xF020
MB address * 8 +
bit address
IDXGRP 0x4021
IB address
IDXGRP 0xF020
IDXOFFS 81
IDXOFFS 0
%IX
%QB
0xF021
0xF030
IB address * 8 +
bit address
IDXGRP 0xF021
QB address
IDXGRP 0xF030
IDXOFFS 41
ISXOFF 100
%QX
0XF031
QB address * 8 +
bit address
IDXGRP 0xF011
IDXOFFS 167
12.04.2013
14
Action
IDXGRP
IDXOFFS
Example
Create
Handle
0xF003
Read / Write
by
handle
0xF005
Handle
Delete
Handle
0xF006
WRITE: VarName
Read: Handle
12.04.2013
15
PLC examples
12.04.2013
16
Access by address
Example: PLC 1 sends to PLC2 2; access by address
PLC 1
12.04.2013
17
Access by address
Variable access
PLC 1
PORT PLC2
NETID local
12.04.2013
18
Access by address
Notes
12.04.2013
19
PLC 1
12.04.2013
20
NetiD local
PORT PLC2
Create Handle
12.04.2013
21
12.04.2013
22
12.04.2013
23
12.04.2013
24
INDEXGROUP
0x4020
INDEXGROUP
0x4021
INDEXGROUP 0x4021
INDEXOFFSET 10*8 +1 = 81
INDEXGROUP 0x4020
INDEXOFFSET 12
12.04.2013
25
PLC
C# Application
VAR_GLOBAL
END_VAR
12.04.2013
26
12.04.2013
27
Result
12.04.2013
28
%MB ACCES
lblMW12.Text = TcClient.ReadAny
(0x4020,
12,
typeof(short)).ToString();
Result
12.04.2013
29
TcClient.Dispose();
Enables the resources
12.04.2013
30
12.04.2013
31
Basic procedure:
Insert TcClient
Insert Namespace
Instance object variable for TcClient
Create handle variables
Request handle on PLC variable(s)
Write & read by handle
Delete handle(s)
Release resources (dispose)
12.04.2013
32
PLC
C# Application
VAR_GLOBAL
BIT0 :BOOL;
BIT1 :BOOL;
BIT2 :BOOL;
BIT3 :BOOL;
iVar0 :INT;
diVar0 :DINT;
END_VAR
12.04.2013
33
hBit0 = TcClient.CreateVariableHandle(".BIT0");
Request handle
Name of the PLC variable. Do
not forget the dot with global
variables
(. BIT0)
12.04.2013
34
Type of variable
Handle on the variable
TcClient.WriteAny(hiVar0, (short)tbariVar0.Value);
Value to the PLC
PLC INT is in C# Short
Handle
Beckhoff Training: TwinCAT ADS
12.04.2013
35
TcClient.Dispose();
Release resources
Details: Open the templates (PLC/C#) distributed in the course and follow
the instructions
Beckhoff Training: TwinCAT ADS
12.04.2013
36
12.04.2013
37
General procedure:
Register notification on each variable (handle)
Create event handler
Evaluate received data in the Notification Event
Delete notifications
Release resources
12.04.2013
38
PLC
VAR_GLOBAL
AxisName:STRING(19);
Ready:
Error:
actVelocity:
actPosition: LREAL;
setVelocity:
setPosition: LREAL;
Lagdistance: LREAL;
END_VAR
C# Application
BOOL;
BOOL;
LREAL;
LREAL;
12.04.2013
39
Instance TcClient
TcClient.AdsNotificationEx += new
AdsNotificationExEventHandler(TcClient_AdsNotificationEx);
Event
Name of the event function
12.04.2013
40
12.04.2013
41
Update method
Filter time
User object or zero
Data type of the read
variable
12.04.2013
42
12.04.2013
43
12.04.2013
44
PLC
VAR_GLOBAL
VisuPositions: ARRAY [0..19]
OF LREAL;
C# Application
double[] PlcArray;
END_VAR
12.04.2013
45
46
12.04.2013
47
12.04.2013
48
C# Application
double[] PlcArray;
END_VAR
12.04.2013
49
12.04.2013
50
12.04.2013
51
TcClient.DeleteDeviceNotification(hnPlcArray);
Delete notifications
Details: Open the templates (PLC/C#) distributed in the course and follow
the instructions
12.04.2013
52
12.04.2013
53
12.04.2013
54
C# Application
ListView
12.04.2013
55
12.04.2013
56
12.04.2013
57
Function to
read/write
Indexgroup +
Axid
Indexoffset
Acces Read
only
58
BinRead.ReadInt32()
Example for 32-bit INT
12.04.2013
59
AdsBinRead.ReadInt32()
Example for 32-bit INT
Details: Open the templates (PLC/C#) distributed in the course and follow
the instructions
12.04.2013
60
12.04.2013
61
12.04.2013
62
C# Application
private struct Axisstruct
{
AxisName:STRING(19);
Ready: BOOL;
Error: BOOL;
actVelocity: LREAL;
actPosition: LREAL;
setVelocity: LREAL;
setPosition: LREAL;
Lagdistance:LREAL;
END_STRUCT
END_TYPE
}
VAR_GLOBAL
Axistate1 :strAxisstate ;
END_VAR
12.04.2013
63
12.04.2013
64
AdsBinaryReader to
evaluate Stream
e.DataStream.Position = 0;
AdsBinaryReader AdsBinReader = new AdsBinaryReader(e.DataStream);
Axistruct1.AxisName = AdsBinReader.ReadPlcString(20);
Axistruct1.Ready = AdsBinReader.ReadBoolean();
Read Data from stream.
Position increments
automaticly
12.04.2013
65
TcClient.DeleteDeviceNotification(hnAxisstruct1);
Delete Notification only one handle per struct
TcClient.Dispose();
Release resources
Details: Open the templates (PLC/C#) distributed in the course and follow
the instructions
12.04.2013
66
12.04.2013
67
EtherCAT Training
Contents
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
30.01.2012
Hardware
Principles
Topology
Benefits and efficiency
Exercise: Driver Installation ->System Manager
EtherCAT Data Exchange
Protocol
Performance
The Feildbus EtherCAT
Configuration In System Manager
Exercise:
Parameterization and commissioning of the
System Manager
Sync Units
Exercise: Hot Connect
Diagnose
Exercise: Cable Redundancy
XFC eXtreme Fast Control Technology
Exercise: Distributed Clocks Timing
Exercise: Distributed Clocks
with input channels
Exercise: Oversampling
EtherCAT Training
Hardware
EtherCAT Fieldbus Master
IPC / Control Panel
Intel-Chipset based network card
with a TwinCAT real-time
Ethernet driver:
FC9001/9002/9004/9011
Supported network adapters in the
Information System
(Online:http://infosys.beckhoff.com/
content/1033/tcsystemmanager/refe
rence/ethercat/html/ethercat_supne
tworkcontroller.htm?id=10257)
Embedded PC / Control Panel
CX90xx
CX10xx
CX50xx
30.01.2012
EtherCAT Training
Hardware
Overview of standard components EL (IP20)
Bus Coupler
/ EK1101
EK1100
EtherCAT Training
Hardware
Overview of standard components KL (IP20)
Bus Coupler
BK1120
EtherCAT Training
Hardware
Overview of standard components EP (IP67)
EP1111 EtherCAT Box
EP1122 EtherCAT 2-port junction
EtherCAT Training
Hardware
More EtherCAT components
EK1501
EK1521
EK1122
EK1110
30.01.2012
EK 1132
EL6692
EtherCAT Training
Principle
EtherCAT Ultra high-speed for Automation
30.01.2012
EtherCAT Training
Principle
Highlights
Ethernet up to the terminal - complete continuity
the Ethernet interface process, scaled from 1 bit to 64 Kbytes
the first true Ethernet solution for the field level
exact timing and synchronization
There were far different problems to make the classic
Ethernet real-time capability:
Collision detection (CSMA / CD) override
Special switches to create as frames temporally accurate deliver
Problem
Also be sent to small amount of data must be a complete
Ethernet frame
Lower-level bus system will lead to additional delay (eg K-bus)
30.01.2012
EtherCAT Training
EtherCAT
The Ethernet down to the terminal!
Direct address of the EtherCAT Slave Controller (ESC) to process
data in the EtherCAT frame
Through the ESC command header distinguishes between
process data and other commands
Ringbussystem mit softwareseitigem Abschluss
From an Ethernet point of view: EtherCAT bus is an Ethernet device
Process data for example are the PLC is no longer welcome in, but
interpreted by the EtherCAT Slave Controller (ESC) taken
directly from the message.
The EtherCAT frame is only a few ns delayed while passing through
the EtherCAT slave
The last device in the bus segment sends the frame back to
the EtherCAT master
30.01.2012
EtherCAT Training
10
EtherCAT
ESC
The handling of the EtherCAT communication in an
EtherCAT slave is tasked by an EtherCAT Slave Controller (ESC)
Each EtherCAT slave has such an ESC to cyclic and
acyclic process data exchanged by the master to the slave via
the EtherCAT field bus
This ESC can handle simple functions such as direct digital inputs
and outputs, but it can also be connected via serial /
parallel interface to another processor in the EtherCAT slave for
the more complex tasks such as Motion Control.
30.01.2012
EtherCAT Training
11
EtherCAT
Overview of EtherCAT Slaves
30.01.2012
EtherCAT Training
12
EtherCAT
typical embedding of the ESC
Of the RJ45 connector, the electrical signals through the transformer
to the PHY (physical interface) led.
The ESC then extracts from the encoded signal,
the Ethernet payload and forwards them to the ESC to
the processing.
Minimum delay (as in a continuous process),
the EtherCAT telegram then passed through PHYtransformer bushing to the next EtherCAT slave.
The ESC is configured in slave-start automatically with
configuration data from an EEPROM. If another CPU exists in the
slave, it can communicate with it via interfaces.
30.01.2012
EtherCAT Training
13
Topology
EtherCAT Ultra high-speed for Automation
30.01.2012
EtherCAT Training
14
Topology
EtherCAT Training
15
Topology : Line
any number of nodes "in series"
IPC
..
..
DVI
Up to 65,535
participants
Cable: standard CAT 5 cable,
consistently without the
"crossover"
30.01.2012
EtherCAT Training
16
Topology : Chain
IPC
..
..
DVI
Up to 65,535
participants
Cable: standard CAT 5 cable,
consistently without the
"crossover"
30.01.2012
EtherCAT Training
17
IPC
..
..
DVI
Up to 65,535
participants
Cable: standard CAT 5 cable,
consistently without the
"crossover"
30.01.2012
EtherCAT Training
18
Topology : Mixed!
flexible tree structures - can be extended
IPC
..
..
DVI
Up to 65,535
participants
Cable: standard CAT 5 cable,
consistently without the
"crossover"
30.01.2012
EtherCAT Training
19
30.01.2012
EtherCAT Training
20
30.01.2012
EtherCAT Training
21
Seamless integration of
existing Fieldbus Devices
Process image update
time over EtherCAT (1500
bytes of I / O data): 150s
Before:
Process image update
time via PCI (500 bytes of I /
O data): 400s
30.01.2012
EtherCAT Training
22
EoE
Switchport
IPC
..
..
DVI
e.g. Connection
of a Label
Printer / Scanner
30.01.2012
EtherCAT Training
23
IPC
..
..
DVI
30.01.2012
24
Excersise
30.01.2012
EtherCAT Training
25
30.01.2012
EtherCAT Training
26
Excersise
Real-time Ethernet driver
The installation of real-time Ethernet driver can be made via the
TwinCAT System Manager.
To use the cable redundancy, the driver must be installed on two
network cards
30.01.2012
EtherCAT Training
27
30.01.2012
EtherCAT Training
28
30.01.2012
EtherCAT Training
29
30.01.2012
EtherCAT Training
30
Publisher/
Subscriber
EL6601
FC1100
Max. synchro
nous data
size
480 Byte,
any
1024 Byte,
1024 Byte,
Max. extent of
asynchronous
data
beliebig
AoE support
Yes
Yes
Yes
Yes
support DC
Yes
reference
- recommended to
synchronize EtherC
AT systemsTwinCAT
2.11 required
- Use of
Ethernet ports in
both
systems as realtime device recom
mended for
synchronous data
transfer
- Relocation
30.01.2012
bidirectional
EtherCAT Training
of RT devices in
a terminalEtherCAT recom
mended for
synchronous dat
a transfer
CX50x0B110
31
30.01.2012
EtherCAT Training
32
Protocol
EtherCAT Ultra high-speed for Automation
30.01.2012
EtherCAT Training
33
Protocol
optimized protocol directly in the Ethernet frame
fully implemented in hardware
for routing and socket interface: UDP datagram
Processing while passing
Distributed clock for precise synchronization
Time stamp data type for resolution in the nanosecond range
Oversampling data types for high resolution measurements
30.01.2012
EtherCAT Training
34
30.01.2012
EtherCAT Training
35
48 Bit
48 Bit
16 Bit
16 Bit
Destination
Source
EtherType
Header
Ethernet H.
IP Header
32 Bit
CRC
1..n EtherCAT
Telegram
64 Bit
UDP H.
Header
CRC
Length
0
30.01.2012
EtherCAT Training
1 Bit
4 Bit
Res.
11
Type
12
15
36
Protocol in detail
full integration of TCP / IP
all available Internet technologies: HTTP, FTP,
without limitation for real-time characteristics of the bus
system!
EtherCAT Device
Standard
TCP/IP
Stack
Real Time
Application
Ethernet
Application
TCP
UDP
Acyclic
Data
IP
Mailbox
Process Data
30.01.2012
EtherCAT Training
Ethernet PHY
37
Performance
EtherCAT Ultra high-speed for Automation
30.01.2012
EtherCAT Training
38
Performance
256 Digital-I/Os in 12 s
1.000 Digital-I/Os in 30 s
200 Analog-I/Os (16 Bit) in 50 s, corresponds 20-kHz-SamplingRate
100 servo axes in 100 s
12.000 Digital-I/Os in 350 s
The EtherCAT bus system is so fast that can be made between two
(PLC) control cyclesor internal processing of EtherCAT
EtherCAT is not limited to 100 MBaud
The bus system is no longer the bottleneck of control!
30.01.2012
EtherCAT Training
39
Performance
principle Ethernet on the Fly
Wagen
27
30.01.2012
EtherCAT Training
40
30.01.2012
EtherCAT Training
vom
vom Master
Master
zum Master
41
30.01.2012
EtherCAT Training
42
node 1
node 1
Data n
PLC Data
node 2
node 2
NC Data
node 3
node 4
node 3
Mapping
node 4
30.01.2012
EtherCAT Training
43
Feldbus Scanner/
DPRAM Master
node 1
node 1
node 2
node 2
Process
Data
node 3
node 4
node 3
Mapping
node 4
30.01.2012
EtherCAT Training
44
The EtherCAT
fieldbus mapping shifts in the slave
IPC
..
..
DVI
232
Telegram structure
Ethernet HDR
30.01.2012
HDR 1
PLC Data
HDR 2
NC Data
HDR n
Data n
CRC
Data n
PLC Data
NC Data
SubTelegramm 1
SubTelegramm 2
SubTelegramm n
45
PC RAM
Control task
30.01.2012
EtherCAT Training
CPU
memcopy
PC RAM
Control task
PCI
bus
DMA
46
Tmpd
Bus Cycle
TI/O
TI/O
Bus Cycle
TI/O
TI/O
Bus Cycle
TI/O
TI/O
Bus Cycle
TI/O
TI/O
TI/O
Bus Cycle
TI/O
TI/O
Bus Cycle
TI/O
TI/O
Bus Cycle
TI/O
TI/O
worst case
Reaction Time
Input
(best case)
Output
Tmpd: Master Processing Delay
TI/O: Local I/O Update Time
(local Extension Bus + Firmware)
30.01.2012
EtherCAT Training
47
I PLC Task O I PLC Task O I PLC Task O I PLC Task O I PLC Task
No master controller board more
Tmpd
Bus Cycle
TI/O
TI/O
Bus Cycle
TI/O
TI/O
Bus Cycle
TI/O
TI/O
Bus Cycle
TI/O
TI/O
TI/O
Bus Cycle
TI/O
TI/O
Bus Cycle
TI/O
TI/O
Bus Cycle
TI/O
TI/O
30.01.2012
EtherCAT Training
48
I PLC Task O I PLC Task O I PLC Task O I PLC Task O I PLC Task
DMA (NIC)
EtherCAT Cycle
30.01.2012
EtherCAT Training
49
I PLC Task O I PLC Task O I PLC Task O I PLC Task O I PLC Task
worst case
Reaction Time
Input
(Worst case)
best case
Input
(best case)
Output
30.01.2012
EtherCAT Training
50
30.01.2012
EtherCAT Training
51
30.01.2012
EtherCAT Training
52
EtherCAT Training
53
30.01.2012
EtherCAT Training
54
Configuration in System
Manager of EtherCAT frames
Example of an EtherCAT communication with
20 slaves and a 100us task
30.01.2012
EtherCAT Training
55
30.01.2012
EtherCAT Training
56
30.01.2012
EtherCAT Training
57
EtherCAT Training
58
Runtime behaviour
of the Diagnosis
30.01.2012
EtherCAT Training
59
30.01.2012
EtherCAT Training
60
30.01.2012
EtherCAT Training
61
30.01.2012
EtherCAT Training
62
Excersise
30.01.2012
EtherCAT Training
63
30.01.2012
EtherCAT Training
64
30.01.2012
EtherCAT Training
65
30.01.2012
EtherCAT Training
66
30.01.2012
EtherCAT Training
67
Update of
the EtherCAT Configuration Description
Since terminals is constantly evolving, the EtherCAT configuration
descriptions of the terminals (XML Device Description) is updated regularly
To take advantage of new terminals, modules, or FW-functions must be
provided according to current configuration descriptions
If these do not exist, the recognition of a new terminal will attempt to
load the description of the terminal :
This may range from not enough to ensure the proper operation of
the terminal - useful>update the XML device description
30.01.2012
EtherCAT Training
68
Update of
the EtherCAT Configuration Description
The current XML device description are available on the Beckhoff website
for download and is updated regularly :
http://www.beckhoff.com/english/download/elconfg.htm?id=71003277100532
The files of the extracted zip file can be manually copied to
".. \ TwinCAT \ Io \ EtherCAT"and the files will be replaced there
If necessary. existing cache files that were created when
you upload the device description from
the terminal should be deleted (eg: ".. \ TwinCAT \ Io \ EtherCAT \OnlineDes
criptionCache00000002.xml")
The update of the device description can be conveniently carried out via
the TwinCAT System Manager (from TwinCAT Build 2.11.1545) (ESIupdater)
The old files are automatically backed up (zipped file) and delete any
existing cache files
Same dialogue / function without the TwinCAT System
Manager EsiUpdateDlg.exeunder ".. \ TwinCAT \ Io
30.01.2012
EtherCAT Training
69
Update of
the EtherCAT Configuration Description
30.01.2012
EtherCAT Training
70
Sync Units
EtherCAT Ultra high-speed for Automation
30.01.2012
EtherCAT Training
71
30.01.2012
EtherCAT Training
72
Sync Units
What For?
Sync units are used in particular for applications in which
individual parts are either machine or error
conditions can be switched off without the other machine parts are
to be influenced by.
For dynamic activation and deactivation of modules and
their connection to any position in the field bus (Hot Connect)
these modules are in separate units Sync.
Communication terminals such as fieldbus master-slave modules,
or modules, eg PROFIBUS, CAN should be in separate Sync Units
30.01.2012
EtherCAT Training
73
Sync Units
parameterization in System Manager
SPSTask
Task
SPS
NCTask
Task
NC
SPSTask
Task
SPS
User
User
defined
defined
SyncUnit
Unit
Sync
30.01.2012
EtherCAT Training
74
Sync Units
EtherCAT Commands
EtherCAT Training
75
Excersise
Hot Connect
EtherCAT Ultra high-speed for Automation
30.01.2012
EtherCAT Training
76
Excersise
Hot Connect Funktionsprinzip
Many applications require a change in I / O configuration during
operation :
Machining centres with changing, sensor-equipped tool systems
Presses, in which individual printing units can be switched off
etc.
EtherCAT protocol structure allows this
The hot component Connect features / modules in the
EtherCAT network can in operation on or be
decoupled and may be attached to another, anywhere and on again
30.01.2012
EtherCAT Training
77
Excersise
Hot Connect with EK1101
The EK1101 EtherCAT Coupler has three hexadecimal ID
switches can be assigned to those of a group of
EtherCAT components of an ID.
This group can then be located at any point in the EtherCAT
network.
30.01.2012
EtherCAT Training
78
Excersise
Hot Connect - im System Manager
EtherCAT Training
79
Excersise
Hot Connect - SyncUnit assignment
Change the display in a directory tree
For each group Hot
Connect automatically sync its
own unit is inserted:
30.01.2012
EtherCAT Training
80
Diagnosis
EtherCAT Ultra high-speed for Automation
30.01.2012
EtherCAT Training
81
Diagnosis
30.01.2012
EtherCAT Training
82
Diagnosis :
EtherCAT State Machine
EtherCAT Training
Diagnose
Inputs -> Master -> FrmXState
FrmXState: Variable of type Word (UINT)
shows the status of
the frame X. For each EtherCATcommand a bit
is reserved:
Bit:
0 (0x0001) 1. EtherCAT command not sent (NOP
requested)
1 (0x0002) 2. EtherCAT command not sent (NOP
requested)
2 (0x0004) 3. EtherCAT command not sent (NOP
requested)...
14 (0x4000) 15. EtherCAT command not sent
(NOP requested)
15 (0x8000)complete frame not sent
EtherCAT Training
85
Diagnose
Inputs -> Master -> FrmXWcState
FrmXWcState shows b
it by bit
at the respective Ether
CAT commands that
have received an
invalid WcState.
30.01.2012
EtherCAT Training
86
Diagnose
FrmXWcState - Evaluation
From terminal 1
(EK1100) is now terminal 3
(EL2004) located.
The variable Frm0WcState reports
the diagnostic value 0x001116
bzw. 0001 00012.
The
binary is now evaluating the failu
re of the first and
5 Commands, each
characterized by bit 0 and bit 4.
Bit 0 = no output data is written
Bit 4 = Read not
successful broadcast
30.01.2012
EtherCAT Training
87
Diagnose
FrmXWcState Evaluation
An EtherCAT frame can consist of one or more commands.
These commands can be assigned different SyncUnits.
Each of these commands has an expected value of working counter.
The Master knows the number of slaves per SyncUnit that are
addressed to the respective command and calculates the
expected Working Counter.
The slaves Increment this value
If the master receives an incorrect working counter, then this
points to communication problems, to one or more slaves.
30.01.2012
EtherCAT Training
88
Diagnose
FrmXWcState Evaluation
Outputs can be switched on invalid WcState continue from the PLC to
ensure a safe state of the system.
Terminals, which are separated by the EtherCAT switch, the output after
the SyncManager watchdog (watchdog SM) from.
Input values "freeze" to view the last current value when
the WcState is invalid.
That is, although an input terminal of the affected SyncUnit is still
in surgery can be viewed old values when the WcState is invalid.
The WcState of EtherCAT slaves should be "always" be evaluated!
30.01.2012
EtherCAT Training
89
Explanation : FrmXWcState
WORD (UINT)
30.01.2012
EtherCAT Training
90
EtherCAT Training
91
30.01.2012
EtherCAT Training
92
30.01.2012
EtherCAT Training
93
EtherCAT Training
94
EtherCAT Training
95
30.01.2012
EtherCAT Training
96
30.01.2012
EtherCAT Training
97
Excersise
Cable Redundancy
EtherCAT Ultra high-speed for Automation
30.01.2012
EtherCAT Training
98
Excersise
Cable Redundancy
Cable redundancy to compensate for a disconnection between
two bus segments
To cover the entire bus system is a ring topology used
The ring topology starts by default via a second network port of the
control in both directions
In the event of redundancy - the ring is interrupted at one point are not achievable by the components supplied by the
second EtherCAT master with process data
30.01.2012
EtherCAT Training
99
Excersise
Cable redundancy - Setup
30.01.2012
EtherCAT Training
100
Excersise
Cable Redundancy - Diagnostic
Diagnosis of the system
over the system variables and slave count SlaveCount2
Evaluation of the system variable DevState
The variable count shows slave in normal operation the value 0, the
variable SlaveCount2all achievable EtherCAT slaves
In the case of
redundancy SlaveCount/SlaveCount2 shows the still accessible
slaves
In addition, over DevState and a corresponding bit values can be
diagnosed:
- 0x0001: Link Error am primren Port
- 0x0004: Link Error am Redundanzport
- 0x0008: Missing one frame
30.01.2012
EtherCAT Training
101
Praxiseinschub
Kabelredundanz Diagnose Topology View
Unterbrechung am
Redundanzport
Unterbrechungen,
Kommunikationsausfall zu
einem Klemmenblock
Klemme im 2.
Klemmenblock im
laufenden Betrieb
entfernt, dadurch
Spannungsunterbrechun
g zu nachfolgenden
Klemmen und
Kommunikationsausfall
dorthin
30.01.2012
EtherCAT Training
102
Excersise
Cable redundancy - Notes
30.01.2012
EtherCAT Training
103
30.01.2012
EtherCAT Training
104
Distributed Clocks
Time-Stamp
Oversampling
EtherCAT Training
105
Distributed Clocks
Consider a regular, discrete control loop :
Actual value (input components)
Forwarding to control (communication components)
Calculate reaction (control component)
Result of setpoint output (output component)
Process (controlled system)
Crucial to the control process is both a very short
response time, as well as a deterministic, ie be exactly calculable :
actual value
Setpoint output
The temporal accuracy is therefore expected in the I / O
component and not in communication or computation unit!
30.01.2012
EtherCAT Training
106
30.01.2012
EtherCAT Training
107
Distributed Clocks
Time synchronization system
Time accuracy: 1ns
Aligned clocks have a high degree of tolerance to faultrelated delays
Since communication uses a logical ring structure, the "master
clock" run-time offset to the individual "slave clocks" to
determine accurately and easily and vice versa
which are based on the distributed clocks tracked
Distributed clocks can also provide information to the local time of
data collection :
e.g. timestamp at terminals
30.01.2012
EtherCAT Training
108
Distributed Clocks
Reference Clock / Slave Clocks
In the EtherCAT strand exists a selected EtherCAT slave, which is
the reference clock /"master
clock" (M), to synchronize the slave clocks / "daughter Clock" (S) of
the other participants and the control.
This reference clock is the System Master.
30.01.2012
EtherCAT Training
109
Distributed Clocks
Determination of the master-slave offset
The Reference Clock (M) is the first slave
in line with EtherCAT distributed clock
functionality to the EtherCAT master IPC, but can also be
selected freely
Since each slave on the round trip a short delay - both in the
local (S) itself and by the intermediate transmission line - causes the
running times (At) between the reference
clock and the respective slave clock in the synchronization of
the slave Clocks to be considered.
30.01.2012
EtherCAT Training
110
Distributed Clocks
Measuring the offset times
Measuring the offset time starts in the start phase of the slave by
a broadcast read datagram (FRG)
Each slave is made to save the time of receipt of the telegram (with
respect to its local clock) on both the outward and also on the way
back .
This saved time points are then read by the master and charged
accordingly.
These cycles are measured for all EtherCAT slaves instead
of multiple times and repeated the process time.
This enables the EtherCAT master to create a very accurate
predictor of the topology, based on the frame delays between
the EtherCAT slave.
30.01.2012
EtherCAT Training
111
Time-Stamp
Process data are usually in your
"real" format (bit digital values, word for analogue values).
The temporal evaluation of the process data can now
be made now from the communication cycle (PLC cycle time) can
be derived.
Resolution and accuracy limits!
Timestamp data types include, in addition
payload
also an associated
time stamp
Input value: When something has happened?
Baseline: When should a reaction?
30.01.2012
EtherCAT Training
112
Oversampling
Process data are normally transmitted once per
communication cycle accurate.
Temporal resolution depends on the cycle time!
A higher resolution only by reducing the cycle time.
Practical, physical limit to the control component
Oversampling data-types now allow multiple sampling of a process
data within a communication cycle.
The oversampling factor is the number of sampling between two
communication cycles
The triggering of the scanning takes the I / O component by its local
clock (DC)
30.01.2012
EtherCAT Training
113
Excersise
30.01.2012
EtherCAT Training
114
Excersise
Distributed Clocks - Timing behavior
Mittwoch, 20. August 2008
Sync1 Timing-Diagramm
0
1000
2000
Datenaustausch
Master <-> Slave
Verzgerung, z.B.
bedingt durch einen
Jitter des PCs, der den
Sync1 Impuls (SyncImpuls der triggernden
Task) verschiebt
3000
Zykluszeit [s]
App
App
Shift Zeit
EC Master
112.4s
Reserve
FRAME
User Shift
500s
EC Master
112.4s
FRAME
Sync1
FRAME
App
Sync1
Sync1
Sync1
Shift Zeit
EC Master
112.4s
Verzgerung
Reserve
Reservezeit:
10% Zykluszeit
Reservezeit:
10s
Telegrammlaufzeit
10%
Zykluszeit
10 s Telegrammlaufzeit
50s Sicherheitsoffset
50 s Sicherheitsoffset
30.01.2012
EtherCAT Training
Datenaustausch
Master <->Slave:
Slave-Prozessdaten
sind noch nicht
bereit!
Erwarteter Zeitpunkt
des Datenaustausch:
Master <->Slave
Innerhalb der
Reserve-Zeit
Tritt dieser
Effekt
innerhalb von
5ms zwei Mal in
direkter Folge
auf, so spricht
man von einem
SyncLost
115
Distributed Clocks
Example Time Stamp / oversampling terminals
The distributed clock unit in the ESC has usually about 2
interrupts, which can be triggered timed: SYNC0 and SYNC1
If the local Distributed Clocks time with a userdefined default match time, triggers the ESC an interrupt and the
associated operations: SYNC0
Allowed time for example Beckhoff terminals Timestamp: The time
is about an event, for example, saved the arrival of a
(digital) signal and transmits the control
The ESC
can also automatically download new default values, which in this
case a cyclic sequence of actions for the ESC sequence (SYNC1) eg use Beckhoff terminals oversampling
30.01.2012
EtherCAT Training
116
Distributed Clocks
Capture - Latch 0/1
If an ESC configured, it can save the occurrence of an external
event, the current local time, so they put a capture
unit without delay in a buffer. These external events can be :
30.01.2012
EtherCAT Training
117
Excersise
30.01.2012
EtherCAT Training
118
Excersise
Distributed Clocks with Input Channels
In the figure, the master PC runs with his PLC to an
EtherCAT master an EtherCAT configuration with 3channel digital input terminal EL1202-0100 with Distributed Clocks
support.
30.01.2012
EtherCAT Training
119
Excersise
Reading the values from the terminals
The PLC controlled and thus the EtherCAT fieldbus operated with
1 ms cycle time
every 1 ms, the input terminals polled EL1202-0100 after their input
values.
The EL1202-0100 is now the local Distributed clock for
sampling of both input channels is used: with each
SYNC interrupt the ESC reads directly adjacent to the input value (0
or1).
The terminal puts its values into the incident shortly after EtherCAT
frame
By using the distributed clock signal, the sampling of the
inputs is highly stable in the continuous equal distance with a
deviation of <100 ns.
All EL1202 EtherCAT-0100 in the entire network by
default read their inputs at the same time, a global, independent
of their location.
30.01.2012
EtherCAT Training
120
Excersise
Distributed Clocks with Output Channels
Logic for output channels similar to that at input channels
The primary difference is
that the local slave clock sync has now to be most conveniently
by the passage of an EtherCAT frame, instead of at the input
channels before the frame.
Calculation of the global shift time for input and output slaves thus
takes place separately.
The standard established global shift time for the group
of output units is greater than the input modules.
Both lie in the meaningful range of 0 to
100% of EtherCAT cycle time.
30.01.2012
EtherCAT Training
121
Excersise
30.01.2012
EtherCAT Training
122
Excersise
Oversampling Digital Output EL2262
The EL2262 digital output
terminal connects the
binary output signals of the control
process level with electrical isolation.
The outputs are adjustable with
an integer multiple (oversampling factor:
n) of the controlled bus
cycle (n micro cycles per bus cycle).
The terminal would receive for
each micro-cycle, a set of
process data sequentially output.
The time base of the terminal can be
synchronized precisely with other
EtherCAT distributed
clock by participants.
30.01.2012
EtherCAT Training
123
Excersise
parameterization EL2262
The EL2262 is in the TwinCAT System Manager on an
oversampling = 200 set.
In the ESC generated in the terminal SYNC0 the interrupt with the nfold higher frequency.
At each SYNC0 signal is a new bit from the current record for each
channel read and output to the power stage.
By generating the SYNC0 pulse from the local synchronized clock in
the distributed clock composite is ensured that the output of the
output values in high temporal constant equal intervals with the
period of SYNC1 pulse (triggered PLC task) is.
30.01.2012
EtherCAT Training
124
Excersise
Oversampling factor set
Using the
tab "DC" ADJUSTING le
aves the oversampling
rate.
About "Advanced Setting
s" you can go into
the menu for
the Distributed Clocks
30.01.2012
EtherCAT Training
125
Excersise
Adavenced Settings DC
In the advanced settings of
the EL2262 to the distributed
clock, the
time of SYNC1Interrupts can
be changed.
By entering a "User defined shift
time" may be a
few microseconds of
the timecompared
with the global sync setting mov
ed forward or back.
30.01.2012
EtherCAT Training
126
Excersise
Variablendeklaration im PLC Control
For data transfer to the EL2262 is example for each channel an
array of size 25 bytes are required (200 bits / 8 = 25 bytes)
30.01.2012
EtherCAT Training
127
Excersise
Link in the System Manager
30.01.2012
EtherCAT Training
128