Agenda
Introduction
EtherCAT State Machine (ESM)
Mailbox
Process Data
Synchronisation
CiA402 Sample Implementation (CiA402)
Conformance Test Tool (CTT)
•Introduction
•ESM
•Mailbox
•Process Data
•Synchronisation
•CiA402
•CTT
Features
Structure
Prinzipal Components
SSC Introduction
SSC Features
Handling of the EtherCAT State Machine (ESM)
Distributed Clocks (DC)
Mailbox handling
Protocol handling for:
CoE (CAN Application Protocol over EtherCAT)
FoE (File Access over EtherCAT)
EoE (Ethernet over EtherCAT)
SoE (Servo Drive Profile over EtherCAT)
AoE (ADS over EtherCAT)
CIA402 Drive Profile (Sample Implementation)
SSC Structure
ESC address space (DPRAM)0x1000Register0x0000
Process dataMailbox
User Application
Generic EtherCAT stack
EtherCAT Slave Controller (extract)
Process Data Interface / IRQ
EtherCAT State
Machine
Process data
Mailbox
Application (e.g. CiA402 Drive Profile)
PDI/ Hardware Access
Application function set
Hardware function set
SSC Structure | File Stack
DL
AL
ESC
Process data interface (PDI) and hardware specific files (XXXXhw.*)
Code
confi
gura
tion (
ecat_
def.h
)
State machine (ecatslv.*) Process data (ecatappl.*)
User application (el9800appl.*, cia402appl.*, ….) VoE
Mailbox (mailbox.*)
Emer
genc
y (em
cy.*)
AoE
(eca
taoe.*
)
CoE
(eca
tcoe.*
)
FoE
(eca
tfoe.*
)
EoE
(eca
teoe.*
)
SoE
(eca
tsoe.*
)
sdos
erv.*
aoea
ppl.*
objde
f.*
foeap
pl.*
eoea
ppl.*
coea
ppl.*
IRQPDI
SSC Principal Components
Initialization
Hardware HW_INIT() [XXXhw.*]
Stack initialization MainInit() [ecatappl.*]
Mainloop MainLoop() [ecatappl.*]
Process data handling (in Freerun mode)
EtherCAT State Machine handling AL_ControlInd() [ecatslv.*]
Mailbox handling
(CiA402 State Machine CiA402_StateMachine() [cia402appl.*])
Interrupt handling [ecatappl.c]
Process data interface
Distributed Clocks
•Introduction
•ESM
•Mailbox
•Process Data
•Synchronisation
•CiA402
•CTT
EtherCAT State Machine Structure
State Transition ProcedureState RequestTransition FunctionsState Response
03.03.2012 8
EtherCAT State Machine (ESM)
ESM | Schema
(IP)
(OP)
(PI)
(PS) (SP)
(OS)(SO)
(SI)
(OI)
(IB) (BI)
Init
Pre-Operational
Safe-Operational
Bootstrap*
Operational
*optional
State Transition Procedure
Conditional: Master sends required configuration data
Master writes requested state to register 0x120 (AL Control)
Slave checks if written setup is valid and exectues transition specific operations
Slave writes result of the state transition to register 0x130 (AL Status)
If error occurs while state transition register 0x134 (AL Status Code)
shall be written
[1]
[2]
State Request
Master send state request [1]
Resulting ESC register values [2]
Bit 0 triggered by 0x120
AL_ControlInd() | Overview
SM OK?
Check SM settings
IP
PS
SO
OS/OP/OI
SP/SI
PI
Start Mailbox handler
Stop Output handler
Start Input handler
Stop Input handler
Start Output handler
Stop Mailbox handler
yes
no
no
no
no
no
yes
yes
yes
yes
yes
yes
Write register 0x130/0x134
no
successful
failed
failed
failed
successful
successful
no(IP)
(OP)
(PI)
(PS) (SP)
(OS)(SO)
(SI)
(OI)
Init
Pre-OP
Safe-OP
Operational
Start / Stop Mailbox Handler
Start Mailbox Handler MBX_StartMailboxHandler()
State transition: Init to PreOP (IP)
Check mailbox SyncManager (SM0 and SM1) settings
Enable mailbox SyncManager HW_EnableSyncManChannel()
Stop Mailbox Handler MBX_StopMailboxHandler()
State transition: PreOP to Init (PI)
Disable mailbox SyncManager HW_DisableSyncManChannel()
Free mailbox Queue buffer
Global indication variable: bMbxRunning
UserInterface: APPL_StartMailboxHandler()
APPL_StopMailboxHandler()
PreOP
InitIP PI
OP
SafeOP
Start Input Process Data handler
Calculate process data size APPL_GenerateMapping()
Start Input Handler StartInputHandler()
State transition: PreOP to SafeOP (PS)
Check process data SyncManger settings (SM2 and SM3)
Check distributed clocks settings (if enabled)
Setup process data watchdog (if enabled)
Enable output and input process data SyncManger
Set AL Event Mask (register 0x204:0x207)
Set global variable: bEcatInputUpdateRunning
User interface: APPL_StartInputHandler()
PreOP
Init
OP
SafeOPPS
Stop Input Process Data Handler
Stop Input Handler StopInputHandler()
State transitions:
OP to Init (OI)
OP to PreOP (OP)
SafeOP to PreOP (SP)
SafeOP to Init (SI)
Disable output process data SyncManger
Reset AL Event Mask (register 0x204:0x207)
Clear global variable: bEcatInputUpdateRunning
User interface: APPL_StopInputHandler()
PreOP
Init
OP
SafeOPSP
OI
OP
SI
Start / Stop Output Process Data Handler
Start Output Handler StartOutputHandler()
State transition: SafeOP to OP (SO)
Set global variable: bEcatOutputUpdateRunning
User interface: APPL_StartOutputHandler()
Stop Output Handler StopOutputHandler()
State transition:
OP to SafeOP (OS)
OP to PreOP (OP)
OP to Init (OI)
Clear global variable: bEcatOutputUpdateRunning
User interface: APPL_StopOutputHandler()
PreOP
Init
OP
SafeOP
OI
OP
SOOS
[3]
TwinCAT logger window
State Response
Master send read command for AL Status register (0x130) [3]
AL Status Code shall be set
•Introduction
•ESM
•Mailbox
•Process Data
•Synchronisation
•CiA402
•CTT
Mailbox Communication
Supported Protocols
Mailbox SyncManager Configuration
Mailbox handling within the SSCExample CoE
Mailbox | Supported Protocols
CoE (CAN Application Protocol over EtherCAT) COE_SUPPORTED
FoE (File Access over EtherCAT) FOE_SUPPORTED
EoE (Ethernet over EtherCAT) EOE_SUPPORTED
SoE (Servo Drive Profile over EtherCAT) SOE_SUPPORTED
AoE (ADS over EtherCAT) AOE_SUPPORTED
Example: ESI Mailbox Entry
Mailbox | ESI SyncManager Entry
SyncManager settings and information are located in ESC register 0x0800+y*8
y = number of SM
SyncManager mailbox settings
Size definition of SyncManager buffer
StartAddress in physical memory
ControlByte written on startup to register
ES
C A
L S
tatu
s re
gist
er
SyncManager 0 config datagram
Mailbox | SM Configuration
Mailbox Sync Manager are written during state change (Init to PreOP)
Mailbox | SM Configuration
Mailbox Sync Manager are written during state change (Init to PreOP)
SyncManager 0 config datagram
Master send request
Write to Out mailbox (SM0)
SDO Info of object 0x1008
Write last byte of SM buffer to set write complete bit(0x220.8)
CoE protocolMailbox header
CoE | SDO Info Request (1)
8Length
0x0000
Address0
Priority3
Type3
Counter0
Number8
Type0x03
OpCode0
FragLeft0x1008Obj Index
SyncManger 0 Buffer
CoE | SDO Info Request (2)
Poll SM0 Event bit (AL Event register 0x220.8) ECAT_Main()
SM0 Event bit is set
Copy mailbox content to local buffer MBX_CheckAndCopyMailbox()
Request can be handled
Check received mailbox header MailboxServiceInd()
Mailbox protocol type 3 (CoE)
[ecatslv.*]
[mailbox.*]
[mailbox.*]
DPRAM
0x220.8
RegisterPDSM0 SM1
Mailbox
PDI abstraction layer
Get CoE service type
Get Object description
polling
SM0 Buffer
80x0000
03 Type3
8 Type0x03 OpCode
00x1008 Obj Index
0
CoE | SDO Info Request (3)
Get type of CoE Service COE_ServiceInd()
CoE service type 8: „SDO Info“
Get SDO Info Service SDOS_SdoInfoInd()
SDO Info service OpCode 0x03: „Get Object Description“
Get object description from object dictionary OBJ_GetDesc() [objdef.*]
[ecatcoe.*]
[sdoserv.*]
DPRAM
0x220.8
RegisterPDSM1
Mailbox
PDI abstraction layer
Get CoE service type
Get Object description
polling
SM0 Buffer
80x0000
03 Type3
8 Type0x03 OpCode
00x1008 Obj Index
0
SM0
CoE | SDO Info Response (1)
Create reponse Adapt existing data MBX_MailboxSendReq()
Write response to In mailbox (SM1) [mailbox.*]
SM1 Buffer
80x0000
033
80x03 OpCode
00x1008
0
Device Name0x070x000x09
Info _NameObj CodeMax SubindexData type
DPRAM
0x220.8
RegisterPDSM1SM0
Mailbox
PDI abstraction layer
Get CoE service type
Get Object description
0x04
Length23
CoE | SDO Info Response (2)
Master sends empty datagram INPUT mailbox (SM1)Complete mailbox size
Returning datagram contains slave response SM1 Buffer
230x0000
03
Priority
3
8 Type0x04 OpCode
00x1008 Obj Index
0
Device Name0x070x000x09
Info _NameObj CodeMax SubindexData type
Type
Length
Counter
Address
Number
Frag Left
•Introduction
•ESM
•Mailbox
•Process Data
•Synchronisation
•CiA402
•CTT
Process Data Communication
Process data SyncManger configuration
FMMU configuration
Process data SyncManger content
Process data handling
SM Control Register (ET1100 Datasheet)
Process data SyncManger configuration mostly the same as mailbox SyncManager Initialization during state transition PreOP SafeOPSyncManger is set to buffered operation mode
Process Data | SM Configuration
TwinCAT Init Command window
0x1C00 0x1C051st Buffer
Sync Manager 3
0x1C06 0x1C0B2nd Buffer
0x1C0C 0x1C123rd Buffer
Process Data | TxPDO SM
0x1A00 0x1A02
FMMU Initialisation Datagram
ESI Entry just determines the number of used FMMUs
FMMU setup is calculated by the configurator / master
FMMU 1 setup example:Log address (Input process data image)Physical address
SM3 bufferDirection (input)
Process Data | FMMU Configuration
ESI FMMU Entry
Process Data | Example Datagram
cmd index Log addr Length Interrupt Data
1st Datagram12 0x00 0x01000000 6 0x0000 0x140000000000
TwinCAT Process Data Configuration
Process Data Datagram (LRW)
Process Data | Handling | SM Synchronous (1)
EtherCAT datagram command is 12 (Logical Read / Write)
Data is copied from FMMU0 to SM2 bufferWrite SM2 buffer set SM2 event bit 0x220.10
trigger PDI interrupt
SyncManger2 buffer (process data) is copied to local buffer in PDI ISR
ETG Technical Committee Meeting
cmd index Log addr Length Interrupt Data
1st Datagram12 0x00 0x01000000 6 0x0000 0x140000000000
DPRAM
0x220.10
Register
Mbx SM SM2 SM3
Mailbox
PDI abstraction layer
Application
Slave PD stack
FMMU 0 FMMU 1
PDO_OutputMapping() [ecatappl.*]
0x000x14
SM2 BufferIRQ
Process Data | Handling | SM Synchronous (2)
Map process data to objects APPL_OutputMapping() [XXXappl.*]
ETG Technical Committee Meeting
IRQ
DPRAM
0x220.10
Register
Mbx SM SM2 SM3
Mailbox
PDI abstraction layer
Application
Slave PD stack
FMMU 0 FMMU 1
Local Buffer
8bit Digital Outputs (0x7010) Align Byte SM1 Buffer
PDO (0x1601) Entries
8 bit Digital OutputLED 2 LED 3 LED 4 LED 5 LED 6 LED 7 LED 8LED 1
0x000x14
Process Data | Handling | SM Synchronous (3)
Execute slave application with updated outputs
Calls user defined applicationCalculate new inputs
ETG Technical Committee Meeting
DPRAM
0x220.10
Register
Mbx SM SM2 SM3
Mailbox
PDI abstraction layer
Application
Slave PD stack
FMMU 0 FMMU 1
ECAT_Application()[ecatappl.*]
EL9800_Application() orCiA402_Application()
e.g.:
Process Data | Handling | SM Synchronous (4)
Map object values to continuous local buffer
Write new input data to SM3 buffer
FMMU 1 writes data from SM3 buffer to EtherCAT datagramm which addresse 0x01000000
ETG Technical Committee Meeting
PDO_InputMapping()[ecatappl.c*]
DPRAM
0x220.10
Register
Mbx SM SM3SM2
Mailbox
PDI abstraction layer
Application
Slave PD stack
FMMU 0 FMMU 1
cmd index Log addr Length Interrupt Data
1st Datagram12 0x00 0x01000000 6 0x0000 0x1200000000000x00000000AE00
16 bit Analog Input
0xAE0x000x000x00
0x00
0x00
PDO Entries
SM3 Buffer
0x6020.110x1A00 0x1A02
APPL_InputMapping()[XXXappl.c*]
Process Data | Datagram Content
cmd index Log addr Length Interrupt Data
1st Datagram12 0x00 0x01000000 6 0x0000 0x00000000AE00
Datagram (Master to Slave): Output Process Data
Datagram (Slave to Master): Input Process Data
EtherCAT Slave
•Introduction
•ESM
•Mailbox
•Process Data
•Synchronisation
•CiA402
•CTT
Application Synchronisation
Supported Synchronous Mode
DC Synchronous Implementation
DC Synchronous | Implementation
SM2 Event
Copy Outputs from SM2 buffer to local memory PDO_OutputMapping()
Sync0 Event
Execute slave application ECAT_Application()
Copy Inputs from local memory to SM3 buffer PDO_InputMapping()
FrameSM2 Event Sync0Event
FrameSM2 Event Sync0Event
EtherCAT Bus Cycle
Sync0 Cycle
•Introduction
•ESM
•Mailbox
•Process Data
•Synchronisation
•CiA402
•CTT
CiA402 Sample Implementation
Structure
Supported Drive Modes
Object Dictionary
EtherCAT Slave Controller
CiA402 Sample Implementation
ESM Process data CoE Mailbox Protocol
Generic EtherCAT stack
CiA402 Application CiA402
Stack
CiA402 state
machine
CiA402 objects
User specific Application
CiA402 drive
structure
Axis specific
Cyclic synchronous position mode (Csp)
Master Slave
Control word (0x6040)Target position (0x607A)
Status word (0x6041)Actual position (0x6064)
Vel
ocity
cont
rol
Torq
ueco
ntro
l
Mas
ter
Appl
icat
ion
DR
IVE
EtherCAT
Pos
ition
cont
rol
Cyclic synchronous velocity mode (Csv)
Master Slave
Control word (0x6040)Target velocity(0x60FF)
Status word (0x6041)Actual position (0x6064)
Velo
city
cont
rol
Torq
ueco
ntro
l
Mas
ter
Appl
icat
ion
DR
IVE
EtherCATPo
sitio
nco
ntro
l
Status word (0x6041)Actual position (0x6064)Actual velocity (0x606C)
Mode of Operation display (0x6061)
Control word (0x6040)Target velocity(0x60FF)Target position (0x607A)
Mode of Operation (0x6060)
Csv / Csp
Master Slave
Vel
ocity
cont
rol
Torq
ueco
ntro
l
Mas
ter
Appl
icat
ion
DR
IVE
EtherCAT
Posi
tion
cont
rol*
Posi
tion
cont
rol*
*Position control can be either located on master or slave side
CiA402 Sample Implementation | Object Dict.
Object dictionary and device description based on the MDP
(Modular Device Profile)
RxPDO (Outputs) 0x1600 - 0x1602
Configuration Area0x1000 – 0x1FFF
Device Parameter0xF000 – 0xFFF
0x1610 - 0x1612
TxPDO (Inputs) 0x1A00 - 0x1A02 0x1A10 - 0x1A12
CiA402 objects* 0x6000 - 0x67FF
* not all objects defined in CiA402 Drive Profile are implemented in this sample application
0x6800 - 0x6FFF
Base Device 1st Axes 2nd Axes
PDO indexincrement 0x10
Object increment 0x800
CiA402 Files / References
Files:
Object dirctionary, Drive structure, Defines cia402appl.h
Drive Functions cia402appl.c
References:
ETG.6010 CiA402 Implementation Guideline
(ethercat.org → download → “EtherCAT Specification”)
•Introduction
•ESM
•Mailbox
•Process Data
•Synchronisation
•CiA402
•CTT
Conformance Test Tool
Layout
Test Files
Test Information
Layout | Home ScreenImproved layout:
(1) Tabbed layout for selected slaves and slave information
(2) Main window shows actual information. Here: overview information of a slave
(3) ESI Cache Browserlists all ESI descriptions loaded by tool
gives information about ESI elements
(4) Project Explorer shows scanned devices and loaded test files
(5) Logger Window shows information during test
(1)
(3)(2)
(4) (5)
CTT Features | Information Test description:
integrated into test cases- Purpose- Pre Condition- Action- Post Condition- References
Output:messages in Logger window:- warningsare highly recommended to fix
- errors have to be fixed
- messages / successinformation
Verbose mode:additional information for test result interpretation
CTT Features | Test Files / Test ID
(1)
(1) CTT lists test files with file ID, file version and name
(2) if single test case is selected the tool shows the Test ID composed of:- TestFile ID
2 Byte- TestGroup ID
2Byte- TestCase ID
2 ByteAdditionally listed:- TestFile Version
12 Byte (4B.4B.4B)- TestCase Name
(2)
TestFile ID TestCase IDTestGroup ID TestFile Version (format: x.x.x)
TestF
ileTe
stGro
upTe
st Ca
se