EtherCAT Master Stack demo on Renesas RZ/T2M (RZ/T2M-RSK board)

Architecture and platform integration

This diagram illustrates the integration of the icECAT EtherCAT Master Stack on the Renesas RZ/T2M as supported by the demo software.

icECAT EtherCAT Master Stack on |tgt_system|
  • The MainDevice application is built on the RZ/T2 FSP Flexible Software Package v2.3.0.

  • The icECAT EtherCAT Master Stack runs on an Arm Cortex-R52 core based on FreeRTOS.

  • It interfaces with the GMAC via the FSP driver for the Ethernet peripheral on RZ microprocessor (r_gmac).

  • The built-in icECAT EtherCAT Configuration Library allows online configuration, based on ESI information, dynamically retrieved from the SubDevices’ SII (Slave Information Interface).

  • The icECAT Master Monitor is linked to the MainDevice application and accessible via UART over a serial terminal.

Additional features in the release version:

  • ENI can be linked static to the MainDevice application

  • EtherCAT features, disabled for the demo:

    • Hot-Connect

    • EoE

    • FoE

    • Cable Redundancy

    • SDO Info Service

    • Support for read and write of Explicit Device Identification

    • Mailbox Gateway and Master object dictionary

Prerequisites

To run the icECAT EtherCAT Master Stack demo, you will need:

  • A Renesas Starter Kit+ for RZ/T2M development kit for the RZ/T2M MPU (RZ/T2M-RSK).

  • A mini USB B cable

  • An Ethernet cable

  • One or more EtherCAT SubDevices, optionally with ESI files

  • icECAT EtherCAT Master demo software for Renesas Starter Kit+ for RZ/T2M

Request DEMO SOFTWARE PACKAGE

Demo setup

Hardware setup

The following figure illustrates the hardware setup:

STM32 |tgt_board| setup for EtherCAT MainDevice demo

Follow these steps for the hardware setup:

  • Power the board by connecting the RZ/T2M-RSK board to either the USB Type-C connector (CN5) or the optional center positive supply connector (CN6) using a 2.0 mm barrel power jack. Ensure that the main power supply connected to CN6 provides a minimum of 15W for full functionality. Both CN6 and CN5 require a voltage of 5VDC.

  • Connect ETHERNET RJ45 CN14 to your EtherCAT network.

  • Connect the RZ/T2M-RSK board to a PC using a USB cable (Type-A male to Mini B male) through the USB connector CN16. A serial COM Port will appear on your PC. To find the correct COM port on Windows:

    • Open the Windows Device Manager and check for Serial Ports (COM and LPT) devices.

    • Use the USB Serial Port (COMx) detected port for the UART terminal connection.

  • Connect the RZ/T2M-RSK board to the PC with a further USB cable (Type-A male to Mini B male) through the USB connector CN11. This is necessary for programming the demo application to the flash. No additional serial port is opened as default.

Software setup

To program a memory, go through the following steps:

  • Detailed guide from Renesas for booting from flash: Device Setup Guide for Flash boot

  • Download Renesas Device Setup tool RZ/T2, RZ/N2 Device Setup

    • Prerequisite for Renesas Device Setup tool is Python Download and install the :Python 3.8 or later version

    • After installing Python, enter the following from the command prompt to install pyserial

      pip install pyserial
      
  • Extract the files to a folder, then change the directory to that folder

  • Set SCI (UART) boot mode on the Mode DIP switch SW4 to the following and power cycle the board:

    SW4[1..4]

    SW4[5..8]

    0101

    0000

    MODE DIP Switch on |tgt_board| board
  • Load the device setup program (RZT2M_RSK_DeviceSetup.out.srec) into the device using the device setup tool (device_setup.py)

    • Check the COM port. Use the port number which is assigned to the connection at “CN16”

    • Change to Device_setup directory within the flash utility directory and load the device setup program:

    • Change to Device_setup directory:

      cd ~/Device_setup
      python device_setup.py start --port COM{Your COM number} --boot_mode sci -i .\rzt2m\RZT2M_RSK_DeviceSetup.out.srec
      
      # Successful terminal output:
      SCI Download mode.
      Send program data. (S0)
      -- Load Program to BTCM  ---------------
      Send program data. (S3)
      -- Start Boot Program on BTCM ---------
      
    • Afterwards a new serial port is provided at the connector CN11.

    • Program the icECAT EtherCAT Master demo software into the external flash on RZ/T2M-RSK board:

      • Adjust the COM port number to the new port at CN11. This device appears after the device setup program was started.

      • Adjust the path to your workspace location.

      python device_setup.py writeflash --port COM{new COM number} --addr 60000000 -i ecatm-sample-appl.bin
      
      # Successful terminal output:
      writeflash : Setup success.
      
  • Unplug the board from power.

  • Set xSPI0 boot mode on the Mode DIP switch SW4 to the following:

    SW4[1..4]

    SW4[5..8]

    1111

    0000

Starting the demo

  • Open a serial terminal (e.g. PuTTY) on the COM port provided at CN16 with the settings: 115200 baud, 8 data bits, no parity, 1 stop bit

  • Power on the development board. The terminal should display:

                            __            ________   ______    ______   ________
          ....... <<<<<<<  /  |          /        | /      \  /      \ /        |
        : ------- <<<<<    ##/   _______ ########/ /######  |/######  |########/
      : / ....... <<<      /  | /       |## |__    ## |  ##/ ## |__## |   ## |
     : / :....... <<<<<    ## |/#######/ ##    |   ## |      ##    ## |   ## |
    : | ::        <<<<<<<  ## |## |      #####/    ## |   __ ######## |   ## |
    : | ::        :: | :   ## |## \_____ ## |_____ ## \__/  |## |  ## |   ## |   __
     : \ ::......:: / :    ## |##       |##       |##    ##/ ## |  ## |   ## |  /  |
      : \ :......: / :     ##/  #######/ ########/  ######/  ##/   ##/    ##/   ##/
        : -------- :
          ........         EtherCAT Master Stack for Embedded Systems
                           Limited Demo Version >1.12.4<
    
    
        Copyright (c) by IBV - Echtzeit- und Embedded GmbH & Co. KG
        https://www.ibv-augsburg.de/icecat
    
        This is a demo application for the
    
           icECAT EtherCAT Master Stack for Embedded Systems
    
        The EtherCAT MainDevice software is designed for use on
        microcontrollers, microprocessors and PC systems
          > Optimal performance
          > Small footprint
          > Project based source code license, royalty free
    
      > Press ENTER to continue...
    

After initialization, the system prompts for configuration:

  • Network setup: Connect a physical EtherCAT network.

  • EtherCAT network configuration: Scan the network.

  • Cycle time configuration

  • Output options: icECAT Master Monitor, performance monitor, or extended logging

For an initial test, select 0 for all options.

The MainDevice demo then starts. The terminal should display:

=== init EtherCAT master
=== create link layer driver  options ><)

-[COPYRIGHT]-------------------------------------------------------------------
   (C) IBV - Echtzeit- und Embedded GmbH & Co. KG
   https://www.ibv-augsburg.de/icecat
-[PRODUCT]---------------------------------------------------------------------
   icECAT - EtherCAT Master Stack
   Version:               1.12...
-[SYSTEM]----------------------------------------------------------------------
   Operating System:      ...
   Target Architecture:   ...
   Link Layer Driver[0]:  ...
-[DEMO-VERSION]----------------------------------------------------------------
!! USE ONLY FOR DEMONSTRATION PURPOSES                                       !!
!! FOR USE IN PRODUCTION SYSTEMS, A COMMERCIAL LICENSE IS NECESSARY.         !!
-------------------------------------------------------------------------------

=== create linked monitor
=== create icECAT Configuration Library instance

-[COPYRIGHT]-------------------------------------------------------------------
   (C) IBV - Echtzeit- und Embedded GmbH & Co. KG
   https://www.ibv-augsburg.de/icecat
-[PRODUCT]---------------------------------------------------------------------
   icECAT - EtherCAT Configuration Library/Tool
   Version:               1.16...
-[SYSTEM]----------------------------------------------------------------------
   Operating System:      ...
   Target Architecture:   ...
-[DEMO-VERSION]----------------------------------------------------------------
!! USE ONLY FOR DEMONSTRATION PURPOSES                                       !!
!! FOR USE IN PRODUCTION SYSTEMS, A COMMERCIAL LICENSE IS NECESSARY.         !!
-------------------------------------------------------------------------------

=== run main loop
=== activate master
=== Request startup state:8

Afterwards the MainDevice tries to setup the network to OPERATIONAL state. If successful, the ACTIVITY LED on your EtherCAT SubDevice(s) should blink and the RUN LED should be on. If the setup fails, restart the demo and enable extended logging for troubleshooting.

Furthermore, the icECAT Master monitor is shown on top of the log output in blue color. The selectable screens and their hotkeys are listed.

EtherCAT MainDevice demo application

The MainDevice demo application can be used to control the EtherCAT MainDevice stack with help of the icECAT Master Monitor tool. In the release version, a programming API is provided to control the network, access the process data, etc.

EtherCAT network configuration

If no ENI (EtherCAT Network Information) file is provided, the application automatically scans the network for connected EtherCAT SubDevices. It retrieves the ESI (EtherCAT Slave Information) data from the SII (SubDevice Information Interface) repository or, if unavailable, reads the SII data from the SubDevice’s EEPROM.

An ENI is generated using the integrated icECAT Configuration Library, stored in RAM and linked to the MainDevice stack. This configuration defines the network topology, the initialization for the process variables, and the structure of the cyclic frames.

Here is a sample of the related output:

Start network scan...
Network scan done. Found 3 devices.
List of devices found in network scan:
   dev#-1 prod=0x00000000 rev=0x00000000 <icECAT EVAL Master       > type=
   dev#00 prod=0x044C2C52 rev=0x00120000 <EVAL Slave 01 ()         > type=
   dev#01 prod=0x07113052 rev=0x00110000 <EVAL Slave 02 ()         > type=
   dev#02 prod=0x0AF93052 rev=0x00120000 <EVAL Slave 03 ()         > type=
ESI not available for all devices => use online SII as fallback
Start SII reading ...
SII read done: (4)
Generate basic ENI
lib-ecatmcfg EVENT >00h00m01.176 INFO  EMCFG_EVTC_ENI_PROCESS_START: Processing ENI ... <
lib-ecatmcfg EVENT >00h00m01.184 INFO  EMCFG_EVTC_ENI_PROCESS_END: Processing ENI finished. <
List of devices found in network scan:
   dev#-1 prod=0x00000000 rev=0x00000000 <icECAT EVAL Master       > type=
   dev#00 prod=0x044C2C52 rev=0x00120000 <EVAL Slave 01 (EK1100)   > type=EK1100
   dev#01 prod=0x07113052 rev=0x00110000 <EVAL Slave 02 (EL1809)   > type=EL1809
   dev#02 prod=0x0AF93052 rev=0x00120000 <EVAL Slave 03 (EL2809)   > type=EL2809
Request linking of network scan ENI
use ENI from network scan
create cyclic task (cycidx=0; prio=1; cyctime:1000us)
=== run cyclic task (cycidx=0, cyctime:1000 us)
=== activate master
=== Request startup state:8

EtherCAT Network Configuration with an external configuration tool

As an alternative to an automatic online configuration, an ENI can be generated with an external tool and provided to the stack as XML file (eni.xml).

IBV provides the icECAT EtherCAT Configuration Library with a GUI tool for generating a network configuration. Ask IBV for an evaluation version. As alternative, you could use Beckhoff TwinCAT 3 to generate an ENI.

EtherCAT network state

Enter the EtherCAT network screen by pressing SHIFT+N in the monitor.

../../_images/ecatm-mon-network.png

In this screen, the states of the MainDevice and of all SubDevices are shown. Select the device with the UP/DOWN keys and start a state transition with one of the keys i / b / p / s / o as indicated on the bottom status line.

If the SubDevice reports a problem, the AL_STATUS code is shown in column ALCODE.

Loading of an ENI file can be initiated by pressing “l” (small “L”) . By typing “scan” as ENI file name, an online network scan is triggered.

PDO access (process variables)

Enter the screen with I/O variables (PDOs) by pressing SHIFT+I in the monitor.

../../_images/ecatm-mon-iovar.png

In this screen, select the process variables with the UP/DOWN keys. The current value is shown on the right side.

If an output value is selected, it can be modified by pressing ENTER and by entering the new value as decimal number or as hexadecimal number with 0x as prefix.

When working with a CiA402 drive, the CiA402 state machine can be controlled by writing the CONTROL WORD and inspecting the STATUS WORD.

SDO upload and download

A SubDevice related screen can be entered by selecting the SubDevice in the network screen and pressing ENTER. The LEFT / RIGHT keys select the previous or the next SubDevice.

../../_images/ecatm-mon-slvinfo.png

If the selected SubDevice supports the CoE mailbox protocol you can read (=upload) SDOs by pressing “u” and entering the SDO index and subindex, e.g. 0x1008:0

If the SDO is writable, you can press “d” and enter the SDO index and subindex. Afterwards the value can be entered as hex bytes in little endian format.

ESC register access

The registers of the ESC (EtherCAT SubDevice Controller) of a SubDevice can be inspected by selecting the device the network screen and pressing SHIFT+R.

../../_images/ecatm-mon-slvesc.png

Scroll in the ESC register list with the UP/DOWN keys. By pressing ENTER, you can enter a new value to be written to the register. Example: Writing to the AL Control register (0x0120) will modify the application layer state of a SubDevice.

Diagnostic information

A screen with MainDevice related statistics and diagnostic information can be entered by pressing SHIFT+M.

../../_images/ecatm-mon-mstinfo.png

In the middle, of the screen DC (Distributed Clocks) timing statistics are shown. For a reliable operation in DC mode, the counter missed shall be 0.

In the lower part, statistic counters of the Ethernet link layer driver are shown.

Performance monitor

The MainDevice demo application contains a built-in performance monitor. It can be activated when starting the demo. The performance monitor shows live values as well as min/max values of the EtherCAT timing as soon as the MainDevice enters the OPERATIONAL state:

plat_perfm_image

Performance values for the platform Renesas Starter Kit+ for RZ/T2M

The values in the table at the bottom of the screen are:

  • CRX: Time for receiving (getting and evaluating) the response frame from the last cycle

  • CPRC: Time for processing the data on application level (0 in demo application)

  • CTX: Time for transmitting (passing the frame to the Ethernet controller for transmission)

  • CTOT: Total operation time in cyclic task for one cycle

  • ATOT: Total operation time in acyclic task for one cycle

  • CTJ: Latency/jitter of the cyclic timer. This value is related to the hardware / RTOS performance and results in a frame jitter (CFJ) in the same range.

  • CFJ: Jitter of the cyclic frame measured with the clock of the DC reference slave. If this min/max value is out of the bandwidth shown in the Performance Monitor screen, then the SubDevices did not get updated information for the next cycle in time.