Version 1.7 Date: 2015-01-13 Application Note ET9300 (EtherCAT Slave Stack Code)
8 Application Note ET9300 2 Terms, Definition, Abbreviation Base Datatypes -- CoE Datatypes defined in ETG.1000.6 Entry – in conclusion with o
Application Note ET9300 9 3 Getting Started This is a step by step instruction how to start the EtherCAT slave development with the Slave Stac
10 Application Note ET9300 5. Create an ESI file according to the settings in step 4. 6. Make the ESI file available in the ESI cache of the
Application Note ET9300 11 4 Code Structure The EtherCAT slave stack as seen in Figure 1 consists of three parts: - PDI/Hardware abstraction
12 Application Note ET9300 5 Hardware Access The Slave Stack Code is executable on multiple platforms and controller architectures. This chap
Application Note ET9300 13 slave project. In general the hardware access implementation needs to support the following features: - ESC read/wr
14 Application Note ET9300 Table 2: Recommended Hardware Configurations Platform EL9800_HW PIC24 PIC18 MCI_HW FC1100_HW CONTROLLER_16BIT CONTRO
Application Note ET9300 15 Platform EL9800_HW PIC24 PIC18 MCI_HW FC1100_HW CONTROLLER_16BIT CONTROLLER_32BIT ESC_16BIT_ACCESS ESC_32BIT_ACCESS
16 Application Note ET9300 5.1 Interrupt Handler The following functions are provided by the generic Slave Stack Code (defined in ecatappl.h)
Application Note ET9300 17 5.2.1 Generic Prototype: UINT16 HW_Init(void) Parameter void Return 0 if initialization was successful > 0 if e
II Application Note ET9300 LEGAL NOTICETrademarks Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered tra
18 Application Note ET9300 Prototype: void HW_SetALEventMask(UINT16 intMask) Parameter “intMask” Interrupt mask (enabled interrupt shall be o
Application Note ET9300 19 Prototype: TSYNCMAN * HW_GetSyncMan(UINT8 channel) Parameter “channel” SyncManager channel Return Pointer to the S
20 Application Note ET9300 5.2.2 Read Access Prototype: void HW_EscRead(MEM_ADDR *pData, UINT16 Address, UINT16 Len ) Parameter “pData” Pointe
Application Note ET9300 21 Prototype: void HW_EscReadDWordIsr(UINT32 DWordValue, UINT16 Address) Parameter “DWordValue” Local 32Bit variable wh
22 Application Note ET9300 Prototype: void HW_EscReadByte(UINT8 ByteValue, UINT16 Address) Parameter “ByteValue” Local 8Bit variable where the
Application Note ET9300 23 5.2.3 Write Access Prototype: void HW_EscWrite(MEM_ADDR *pData, UINT16 Address, UINT16 Len ) Parameter “pData” Poin
24 Application Note ET9300 Prototype: void HW_EscWriteDWordIsr(UINT32 DWordValue, UINT16 Address) Parameter “DWordValue” Local 32Bit variable w
Application Note ET9300 25 Prototype: void HW_EscWriteByteIsr(UINT8 ByteValue, UINT16 Address) Parameter “ByteValue” Local 8Bit variable which
26 Application Note ET9300 6 Application This chapter includes an overview over the default (sample) applications, the application interface a
Application Note ET9300 27 Prototype: void ECAT_StateChange(UINT8 alStatus, UINT16 alStatusCode) Parameter alStatus Requested Al Status alStat
Application Note ET9300 1 DOCUMENT HISTORY Version Comment 1.0 Start document 1.1 Chapter 4 “Hardware access”. Define descriptions; prototypes
28 Application Note ET9300 Prototype: UINT16 (* pAPPL_EEPROM_Write)(UINT32 wordaddr) Parameter Wordaddr start word address within the EEPROM
Application Note ET9300 29 Prototype: UINT16 APPL_StopMailboxHandler(void) Parameter Void Return See generic ESM return code description Descri
30 Application Note ET9300 Prototype: UINT16 APPL_GenerateMapping (UINT16 *pInputSize, UINT16 *pOutputSize) Parameter Pointer to two 16bit vari
Application Note ET9300 31 Name pEEPROM Type UINT8 * Description Pointer to the EEPROM buffer, it is only required if EEPROM emulation is enabl
32 Application Note ET9300 - 32Bit Output Counter (0x7010) If the Output Counter is 0 the Input Counter is incremented with every application
Application Note ET9300 33 /************************************************************************** * Object 0x7010: outp
34 Application Note ET9300 #ifdef _SAMPLE_APPLICATION_ = {2/*the object has now two entries*/, {0x70100120,0x70100220/* Reference to object 0x
Application Note ET9300 35 SyncManager). NOTE: if one of the values mismatch with the information in the ESI file the slave will abort the stat
36 Application Note ET9300 <Index>#x1601</Index> <Name>RxPDO</Name> <Entry> <Index>#x7010</Ind
Application Note ET9300 37 <Sm DefaultSize="8" StartAddress="#x1800" ControlByte="#x64" Enable="1"&
2 Application Note ET9300 CONTENTS 1 References 7 2 Terms, Definition, Abbreviation 8 2.1 Abbreviation 8 3 Getting Started 9 3.1 SSC T
38 Application Note ET9300 </SubItem> </DataType> c. Update the object 0x7010. <Object> <Index>#x7010</Index>
Application Note ET9300 39 </Flags> </SubItem> <SubItem> <SubIdx>2</SubIdx> <Name>SubIndex
40 Application Note ET9300 <Info> <DefaultData>20000060</DefaultData> </Info> </SubItem>
Application Note ET9300 41 7 Objects Objects are slave application data (e.g. variables) which can be accessed by the EtherCAT master via CoE
42 Application Note ET9300 _REC_OBJ_DEF RecObj; 7.3 Entry descriptions A single entry description is defined in TSDOINFOENTRYDESC. All entry d
Application Note ET9300 43 Example: Object name (Object Code ARRAY) UCHAR ArrObjName[] = "Array Obj"; Example: Object name (Object
44 Application Note ET9300 Member Data type Description Write Pointer to Write Function. The prototype is listed below. This function will be
Application Note ET9300 45 Index Range Description 0xA000 – 0xAFFF Diagnosis Area 0xB000 – 0xBFFF Service Transfer Area 0xC000 – 0xEFFF Reserve
46 Application Note ET9300 {DEFTYPE_OCTETSTRING, 8*SIZEOF(sEnum0801_Value00), ACCESS_READ | OBJACCESS_NOPDOMAPPING}, {DEFTYPE_OCTETSTRING
Application Note ET9300 47 8 Mailbox 8.1 FoE (File Transfer over EtherCAT) FoE can be used to download and upload a file to an EtherCAT devic
Application Note ET9300 3 9.1 Supported Sync Modes 55 9.1.1 FreeRun 57 9.1.2 SyncManager 57 9.1.3 SyncManager/Sync0 58 9.1.4 SyncManag
48 Application Note ET9300 EOE_SendFrameReq()SendFragment()MBX_MailboxSendReq()Pending frame?YesFull Mbx buffer?YesFrame complete?NoStore datag
Application Note ET9300 49 EOE_ServiceInd()Init RequestYesYesNoNoCopy frame fragment to local bufferThis function is called from the generic ma
50 Application Note ET9300 3.) Write binary to the PIC controller of the Evaluation Kit (see Application Note EL9800 [3] ). 4.) Change EoE fl
Application Note ET9300 51 Figure 8: Network card settings 3.) Save settings a. Configure device b. Open TwinCAT c. Scan Network d. Selec
52 Application Note ET9300 Figure 10: EoE EtherCAT Slave Settings 4.) Set network at least to PRE-OP (mailbox communication needed) 5.) Open
Application Note ET9300 53 Figure 12: EoE Example 2 (Schema) Steps 1 to 3 are equal to EoE Example 1 (chapter 8.2.2.1). 4.) Enable IP Routing
54 Application Note ET9300 Figure 14: Enable IP Routing WinCE 5.) Restart the PC 6.) Add Route on the external PC a. Command: route ADD 192
Application Note ET9300 55 9 Synchronization The Slave Stack Code supports different modes of synchronisation which are based on three physica
56 Application Note ET9300 Table 7: Supported Sync Modes Sync Type AL_EVENT_ENABLED DC_SUPPORTED Sync0/1 Activation (Reg. 0x981) Sync0 Cycle ti
Application Note ET9300 57 9.1.1 FreeRun In this mode there is no slave application synchronisation (see Figure 16: Free Run). The function “P
4 Application Note ET9300 13.4.3 ObjectCode 88 13.4.4 SI (Subindex) 89 13.4.5 DataType 89 13.4.6 Default/Min/Max 90 13.4.7 M/O/C, B/S
58 Application Note ET9300 9.1.3 SyncManager/Sync0 This mode is recommended for most applications when the Sync0-event is used for synchroniza
Application Note ET9300 59 9.1.5 Sync0 In this mode the slave application is started on Sync0 (see Figure 20: Sync0 Synchronization). To reduc
60 Application Note ET9300 Cycles). The relation between Sync0 and the bus cycle is configured by the ESI element:CycleTimeSync0@Factor. Possib
Application Note ET9300 61 10 CiA402 drive profile Since version 4.30 the Slave Stack Code contains a sample implementation of the CiA402 driv
62 Application Note ET9300 Index Object name Variable in source code Comment/Description 0x6040 Controlword objControlWord object for the outpu
Application Note ET9300 63 Figure 23: CiA402 state transitions and option codes
64 Application Note ET9300 Table 9: State machine The transition number in Table 8 referring to the transition number in Figure 23.[1] 10.3 O
Application Note ET9300 65 Figure 24: Axis configuration NOTE: This sample doesn’t provide a target value overflow control! 10.4 TwinCAT set
66 Application Note ET9300 Figure 25: Set device variable without PLC link 10.4.1 Automatic network setup The TwinCAT System Manger provide
Application Note ET9300 67 Figure 27: Scan for new EtherCAT devices with TwinCAT 3 After the network scan is complete a message box appears wi
Application Note ET9300 5 FIGURES Figure 1: EtherCAT Slave Stack Code ...
68 Application Note ET9300 Figure 29: TwinCAT 3 CiA402 axis setup Add a new EtherCAT device and append the CiA402 description (Figure 30). Fi
Application Note ET9300 69 object index Type variable name device NC axis 0x6064 input Actual position “Enc_In” -> “nInData1” For the Stausw
70 Application Note ET9300 Figure 32: Encoder scaling The velocity output scaling is calculated with the following formula: velo.scaling = (2^
Application Note ET9300 71 11 TestApplication The test application is a specific slave stack which provides most of the specified EtherCAT sla
72 Application Note ET9300 Attribute Value Object Code ARRAY Max SubIndex 16 (7if build for EL9800) Table 14: Test Control Object Entries Su
Application Note ET9300 73 11.3 Mailbox Tests (0x2010 – 0x201F) Table 17: Test Object 0x2010 (Mailbox Group 1) 11.4 CoE Tests (0x2020 – 0x20
74 Application Note ET9300 11.6 Generic Objects The objects described in this chapter are used to test the correct SDO handling by the slave a
Application Note ET9300 75 SI8 UINT8 RO Default value:0x88 Bit types are based on unsigned short) SI9 BIT2 WO Default value:0x1 SI10 BIT2 RW D
76 Application Note ET9300 SI1 – 254 OCTET_STRING RW The first WORD of SI1 contains the Bitlength of each entry. The value can also be updated
Application Note ET9300 77 12 Tool The Slave Stack Code Tool allows creating new slave files depending on user specific requirements and setti
6 Application Note ET9300 TABLES Table 1: Hardware Related Settings ...
78 Application Note ET9300 12.2 Main User Interface Elements 12.2.1 Tool Bar 12.2.1.1 File The file menu (Figure 35: Configurator File Menu)
Application Note ET9300 79 [Project Update] Check for new Slave Stack Code version and update the current project. For further information see
80 Application Note ET9300 Figure 40: Tool Options - Generic o [Open last project on startup] The last slave project is reloaded on the nex
Application Note ET9300 81 o [Add comment if obsolete code was skipped] Specify if a source code comment shall be added when code was deleted
82 Application Note ET9300 [About] Show information about the SSC Tool. [Contact] Create a new email to [email protected] with your stan
Application Note ET9300 83 [Add File(s)] Add one or more files to the project. These files will not evaluated and just copied to the output fo
84 Application Note ET9300 Figure 47: Configurator Create Files [Cancel] Close dialog without creating new files [Close] Close dialog when new
Application Note ET9300 85 [offline] Load SSC files from a local SSC zip archive. Both options require an external archive tool (7-Zip, WinRAR®
86 Application Note ET9300 Importing a Configuration can either be done via the new project dialog (Figure 50: New Project | Import Configurati
Application Note ET9300 87 13 OD Tool The SSC OD Tool converts an application definition file to slave application files for the Beckhoff Slav
Application Note ET9300 7 1 References [1] ETG.6010 Implementation Guideline for the CiA402 Drive Profile (www.ethercat.org/ETG6010) [2] ETG
88 Application Note ET9300 The slave application data is organized in objects (see chapter 7). Only objects in the manufacturer specific range
Application Note ET9300 89 13.4.4 SI (Subindex) The Subindex can be either a decimal or hexadecimal value from 1 to 255. In case of an entry r
90 Application Note ET9300 Index Name Base Data Type Bit Size 0x000A OCTET_STRING ARRAY [0..n] OF BYTE 8*(n+1) 0x000B UNICODE_STRING ARRAY [0.
Application Note ET9300 91 Example Table 24 shows an Enum definition example. Table 24: Enum definition Table 25 shows an example for an entry
92 Application Note ET9300 14 EEPROM Handling To identify an EtherCAT slave and to provide parameter (e.g. process data, supported mailbox pro
Application Note ET9300 93 Figure 56: EEPROM Programmer | File Slaves menu (Figure 57: EEPROM Programmer | Slaves): [Scan]: Scans for connecte
94 Application Note ET9300 15 Bootloader The SSC is prepared to be used as the base code for a Bootloader implementation. The basic bootloader
Application Note ET9300 95 Appendix Support and Service Beckhoff and their partners around the world offer comprehensive support and service, m
Comments to this Manuals