Download Print this page
Infineon XMC4800 Getting Started

Infineon XMC4800 Getting Started

Ethercat app ssc slave example
Hide thumbs Also See for XMC4800:

Advertisement

Quick Links

XMC4800
EtherCAT APP SSC
Slave Example
Getting Started V3.0

Advertisement

loading

Summary of Contents for Infineon XMC4800

  • Page 1 XMC4800 EtherCAT APP SSC Slave Example Getting Started V3.0...
  • Page 2 Defining the interface of EtherCAT slave node Generating Slave Stack Code and ESI file Implementation of the application How to test – using TwinCAT2 as host How to test – using TwinCAT3 as host Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 3 Defining the interface of EtherCAT slave node Generating Slave Stack Code and ESI file Implementation of the application How to test – using TwinCAT2 as host How to test – using TwinCAT3 as host Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 4 In this example we will demonstrate how easy it is to setup a proper EtherCAT communication by using the EtherCAT APP. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 5 XMC4800 Relax EtherCAT Kit RJ45 Ethernet Cable Windows Laptop installed - DAVE v4 (Version4.1.4 or higher) - TwinCAT2 or TwinCAT3 Master PLC - Slave Stack Code Tool Version 5.12 Micro USB Cable (Debugger connector) Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 6 ATTENTION: According our experience TwinCAT is best compatible with Intel™ ethernet chipset. For details on compatibility with your hardware, additional driver and general installation support please get into contact with your local BECKHOFF support. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 7 Requirements - free downloads DAVE (v4.1.4 or higher) Link: Download DAVE (Version 4) EtherCAT Slave Stack Code Tool Version 5.12 ETG membership obligatory Link: Slave Stack Code Tool Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 8 Defining the interface of EtherCAT slave node Generating Slave Stack Code and ESI file Implementation of the application How to test – using TwinCAT2 as host How to test – using TwinCAT3 as host Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 9 Setup – Hardware Micro USB cable Ethernet Cable Debugger connected to connected to IN-port X101 debug connector Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 10 Setup – Import example project into DAVE Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 11 These configuration files are included in the project already. The following slides show in detail how to define your EtherCAT slave node interface and to generate the slave stack code. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 12 Defining the interface of EtherCAT slave node Generating Slave Stack Code and ESI file Implementation of the application How to test – using TwinCAT2 as host How to test – using TwinCAT3 as host Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 13 XMC4800. The generated EtherCAT Slave Information file (ESI) does apply for the EtherCAT host. There the relevant interface information about the slave is stored. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 14 4x16bit integers and 8x1bit booleans. For further details on how to define your own interface you may want to follow the instructions inside EtherCAT Slave Design Quick Guide.pdf inside SSC tool. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 15 Defining the interface of EtherCAT slave node Generating Slave Stack Code and ESI file Implementation of the application How to test – using TwinCAT2 as host How to test – using TwinCAT3 as host Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 16 Generating Slave Stack Code and ESI file Start the tool and create a new project File >> New Select the configuration file which you find inside the example project. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 17 Generating Slave Stack Code and ESI file Select the Infineon device inside the drop down list and confirm with the OK button. Your project will be created. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 18 Define revision number, serial number, device name, HW/SW version › according to your needs. The vendor ID/name and product code assigned to infineon may be used for › evaluation purpose only. For productive purpose your own vendor ID/name assigned by the EtherCAt Technology Group is obligatory.
  • Page 19 Generating Slave Stack Code and ESI file Import the EXCEL-sheet which defines the interface of your EtherCAT node. Select the EXCEL-file provided inside the example project. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 20: Default Settings

    In this step the destination folder for the EtherCAT Slave Stack Code and the ESI file can be adapted. For this example it is recommended to take the default settings. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 21 2. Copy the ESI file to resp. destination for TwinCAT2: C:\TwinCAT\Io\EtherCAT TwinCAT3: C:\TwinCAT\3.1\Config\Io\EtherCAT 3. Restart TwinCAT System Manager to start re-work of the device description cache. Rebuild the DAVE project with the new files. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 22 Defining the interface of EtherCAT slave node Generating Slave Stack Code and ESI file Implementation of the application How to test – using TwinCAT2 as host How to test – using TwinCAT3 as host Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 23 Inside the generated file XMC_ESC.c the link to your application must be implemented. Modify the source code accordingly which copies the application data to/from ESC memory to the local application memory: Originally generated code: Modified code: Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 24 *OUT_GENERIC, TOBJ6000 *IN_GENERIC); implements the mapping of the input/output data to buttons and LEDs. Therefore please modify the function APPL_Application to call process_app in the following way: Originally generated code: Modified code: Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 25 LED1 to LED8 level on the XMC EtherCAT PHY Board. The integer output data is used to set the duty cycle of the dimmable LED2. The states of the buttons are checked and propagated to the input data (slave->master). Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 26 EtherCAT communication. The EVENT_DETECTOR, EVENT_GENERATOR and INTERRUPT APPs are used inside this example to connect the sync_out_0 and sync_out_1 of the ECAT_SSC APP to the interrupt service routines of the SSC- stack. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 27 Description – Overview on used APPs PWM_CCU8 APP is used to control the dimming level of the LED2 on your Relax Kit and to assign the PWM output to the respective pin. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 28 EtherCAT module. Inside Manual Pin Allocator you can configure the EtherCAT ports for your application. For the example provided, the configuration fits to the XMC4800 Relax EtherCAT Kit. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 29 For distributed clock support, the sync0 and sync1 signals coming from the ethercat peripheral are used to trigger interrupts. Inside the interrupt service routines the respective API functions of the SSC protocol stack are called. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 30 Please see next slides how to setup this configuration inside DAVE™. ATTENTION: With the same approach sync0 and sync1 signals can also be connected to other resources. For example: ADC, ports and timers. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 31 From the context menu select „HW Signal Connections “ to open the HW Signal Connection dialog of the ECAT_SSC APP. Connect the sync_out_0 and sync_out_1 signal to the a/b input of the event detection units. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 32 Double click on the EVENT_DETECTOR APP for SYNC0 and EVENT_DETECTOR APP for SYNC1. Select the respective source signal („A“ for SYNC0 and „B“ for SYNC1) and edge detection „Rising Edge“. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 33 „HW Signal Connections “ to open the HW Signal Connection dialog of the ECAT_SSC APP. Connect the trigger_out signals of the event detection units to the trigger_in signals of the event generation units. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 34 „HW Signal Connections “ to open the HW Signal Connection dialog of the EVENT_GENERATOR APP. Connect the iout of the EVENT_GENERATOR APP for sync0 to INTERRUPT APP of sync0. Proceed respectively for sync1. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 35 Double click on the INTERRUPT APP for sync0 and INTERRUPT for sync1. Set the interrupt service routine for sync0 and sync1 inside the configuration of the respective INTERRUPT APP. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 36 Description – DAVE™settings for distributed clock support Inside main() the interrupt handlers for sync0 and sync1 are implemented. The implementation is calling the respective functions of the SSC protocol stack. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 37 500Hz and the initial duty cycle is set to 50%. The pin P5.8 is allocated to channel1 of CCU8 inside the manual pin allocator (right-click PWM_CCU8 APP). Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 38 ERU (see before) these interrupts need to be handled in addition by the user. For this purpose ECAT_APP is implementing a callback function for user specific implementation: ENABLE_ESC_INT_USER and DISABLE_ESC_INT_USER. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 39 Description – SSC specific enabling/disabling of interrupts [2/2] Within this example you find the implementation of ENABLE_ESC_INT_USER and DISABLE_ESC_INT_USER inside main.c: Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 40 InitECAT_Adapt_LED() and Init_Relax-Button() are used to initialize the buttons and LED1 to 8 of the „XMC EtherCAT PHY Board“. Finally the MainLoop is called cyclically to process the state machine of the slave stack code. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 41 Defining the interface of EtherCAT slave node Generating Slave Stack Code and ESI file Implementation of the application How to test – using TwinCAT2 as host How to test – using TwinCAT3 as host Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 42 2. Start the software by the run button OBSERVATIONS 1. The ERR-LED on the "XMC EtherCAT PHY Board" will turn on and immediately turn off again. 2. The LED2 on the "XMC4800 Relax EtherCAT Kit" will remain turned Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 43 How to test – start the TwinCAT 2 master to run (1/4) ACTIONS After starting the TwinCAT System Manager from windows start menu: 1 Right Click I/O-Devices and select „Append Device…“ 2 Create an EtherCAT master device by double click Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 44 In case the device is not found please install the respective device driver by following the instructions given by TwinCAT through the „Compatible Devices…“ button. 4 Right Click EtherCAT master and select „Scan Boxes…“ Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 45 How to test – start the TwinCAT 2 master to run (3/4) OBSERVATIONS The slave appears as a node on the EtherCAT master bus. The RUN-LED is flashing indicating PREOP-state Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 46 PREOP state. EtherCAT slave view: The PREOP-state of the slave is indicated within the TwinCAT system manager . Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 47 EtherCAT master view: Online status of master shows the slave in OP state. Frames are no more queued. Cyclic counter is incrementing. „XMC EtherCAT PHY Board“: RUN-LED is static turned on indicating OP-state. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 48 How to test – Monitoring slave inputs on master ACTIONS While pushing Button1 on „XMC4800 Relax EtherCAT Kit“ the button state is updated on the host. OBSERVATIONS State of IN_GEN_Bit1 changes according to the state of BUTTON1. Same is true for IN_GEN_Bit2 and BUTTON2.
  • Page 49 Write…“ inside the context menu. Change the value from 0 to 1 to switch on LED1/ from 1 to 0 to switch off LED1. OBSERVATION LED1 „XMC EtherCAT PHY Board“ is turned on/off according to OUT_GEN_Bit1 setting. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 50 Write…“ inside the context menu. Change the value from 0 to 50000. OBSERVATION 1. Brightness of LED2 on „XMC4800 Relax EtherCAT Kit“ is dimmed. The OUT_GEN_INT1 value sets the brightness of LED 2. The lower the value the brighter the LED2. To turn off LED2 just set value to max (65535).
  • Page 51 Defining the interface of EtherCAT slave node Generating Slave Stack Code and ESI file Implementation of the application How to test – using TwinCAT2 as host How to test – using TwinCAT3 as host Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 52 2. Start the software by the run button OBSERVATIONS 1. The ERR-LED on the "XMC EtherCAT PHY Board" will turn on and immediately turn off again. 2. The LED2 on the "XMC4800 Relax EtherCAT Kit" will remain turned Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 53 (1/4) ACTIONS After starting the TwinCAT System Manager from windows start menu: 1 Right Click I/O-Devices and select „Add New Item…“ 2 Create an EtherCAT master device by double click Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 54 In case the device is not found please install the respective device driver by following the instructions given by TwinCAT through the „Compatible Devices…“ button. 4 Right Click EtherCAT master and select „Scan Boxes…“ Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 55 How to test – start the TwinCAT 3 master to run (3/4) OBSERVATIONS The slave appears as a node on the EtherCAT master bus. The RUN-LED is flashing indicating PREOP-state Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 56 PREOP state. EtherCAT slave view: The PREOP-state of the slave is indicated within the TwinCAT system manager . Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 57 EtherCAT master view: Online status of master shows the slave in OP state. Frames are no more queued. Cyclic counter is incrementing. „XMC EtherCAT PHY Board“: RUN-LED is static turned on indicating OP-state. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 58 How to test – Monitoring slave inputs on master ACTIONS While pushing Button1 on „XMC4800 Relax EtherCAT Kit“ the button state is updated on the host. OBSERVATIONS State of IN_GEN_Bit1 changes according to the state of BUTTON1. Same is true for IN_GEN_Bit2 and BUTTON2.
  • Page 59 Write…“ inside the context menu. Change the value from 0 to 1 to switch on LED1/ from 1 to 0 to switch off LED1. OBSERVATION LED1 „XMC EtherCAT PHY Board“ is turned on/off according to OUT_GEN_Bit1 setting. Copyright © Infineon Technologies AG 2016. All rights reserved.
  • Page 60 Write…“ inside the context menu. Change the value from 0 to 50000. OBSERVATION 1. Brightness of LED2 on „XMC4800 Relax EtherCAT Kit“ is dimmed. The OUT_GEN_INT1 value sets the brightness of LED 2. The lower the value the brighter the LED2. To turn off LED2 just set value to max (65535).