ECS SimpleConfig Example exercise

1. ECS Setup.

Necessary hardware and sotware for this training

ECS master. For that a standard PC with a ethernet networkcard can be used. Here can be fould a list of supported networkcards.

https://infosys.beckhoff.com/

Get TwinCAT3 and install it on the PC.

(ECS master from Hilscher: NetHost or Cifx Card with Sycon configuration software, but many things can not be done like read object dictionary)

ECS slave: For that use here a NXHX90 hardware revison 3 or 4 together with the netX 90 - EtherCAT Slave - simpleConfig V3.0.0.0 example.

Install for the netX 90 - EtherCAT Slave - simpleConfig V3.0.0.0 example the software netXStudio: V1.0700.1.3056

Connect Port1 of the NXHX90 with an ethernet cable to the PC Networkcard.

Connect with a USB cable the NXHX90 with the PC.

Connect Power Source to the NXHX90.


2. Create the ECS Slave Device

The first step is downloading the example project and netXStudio. After install netxStudio. It is possbile to open the example project with this tool.

For a detailed instruction, use the getting started guide

Downloads netX 90netX Studio CDT - netX 90 development (Revision 8)

  1. Start netXstudio and open the netX90_ECSV5_simpleConfig project:


  2. If netXStudio is used the first time after installation, it is necessary to install some addional tools. Go to help → Install → netX Development Tools

    Install the toolchain and restart netXStudio
  3. Build hardware configuration for internal DPM. For NXHX90 board hardware revision 3 go to folder HWC/netX90_rev0. For NXHX90 board hardware revision 4 go to folder:
    netXStudio_ECSV5_simpleConfig_V3.0.0.0/HWC/netX90.

    This will create 2 files. a *.hwc and a *.mwc file.
  4. Verfy now that the NXHX board has power and is connected over USB to the PC.
  5. Now flash 3 files in the NXHX 90 board.
    Click on the red arrow.


    If the the board can not found, please try an other USB Port on the PC or check power and USB cable
  6. Now use the "Browse" button and choose the *.hwc file and flash it with the "write" button.
    netXStudio_ECSV5_simpleConfig_V3.0.0.0/hardware_config_idpm.hwc
    It is not necessary to fill the fields for Area and Flash Type.

    The same do with the file:
    netXStudio_ECSV5_simpleConfig_V3.0.0.0/LFW/X090F000.nxi (EtherCAT Firmware)
    and the file
    (warning) before overwirte the FDL file, read out first this area and save it or values like MAC address from production will be lost (warning)
    netXStudio_ECSV5_simpleConfig_V3.0.0.0/FDL/FDL_NXHX90-JTAG_7833000r3_20000_ProductionTemplate_UseCaseA.fdl
  7. Now compile the project
  8. Start the project
  9. Choose netX90
  10. Download application

    This will need a bit time. After download the application will start and the sys LED is green and com0/com1 is off.

The device is sucessfull build. If the sys led is yellow, something is not correct. Verfy first that the correct *.hwc file has been used.

3. Start TwinCAT3 ECS Master and Create a Project

  1. Install ESI
    Go to the folder netXStudio_ECSV5_simpleConfig_V3.0.0.0\Components\cifXApplicationDemoECS\DeviceDescription
    and copy the file Hilscher NETX90 RE ECS V5.2.0.xml to the folder TwinCAT3 folder C:\TwinCAT\3.1\Config\Io\EtherCAT
  2. Go to folder C:\TwinCAT\TcSwitchRuntime and start TcSwitchRuntime.exe. Start TwinCAT3.
    (After working with EtherCAT it is good to deactivate TwinCAT3 because as long as TwinCAT3 runs, it is not possible to use
    the PC Networkcard for other things)
  3. Start Twincat3 (TwinCAT XAE Shell) and create a project

  4. Install a networkcard driver

    Choose a network card of the pc and install the driver. If this is not possbile, than you can not use TwinCAT3 as Master with this networkcard.
  5. Add a EtherCAT master to the project


    Choose the networkcard for that the driver could be installed
  6. Verfiy that NXHX 90 Port 0 ist connected to the networkcard and the ECS slave is running. Klick on "Scan" to find the devices.
  7. If this works the slave will be found like this:
  8. Click on the reload button to load this project information in the TwinCAT master

    The slave COM0 LED is now green. That means the ECS slave is in operational state and exchanges processdata.
  9. Input date changes can be seen here:
  10. It is possible to fore output data. For that first set on the NXHX 90 board the dip switch S701.4 to on.

    A LED on the NXHX 90 is now on
  11.  Definiton of Input and Output of this example:

    Change value "1 Byte Out (2)" to 1. This turn on an other LED on the NXHX Board.
    Change value "1 Byte Out (5) to 1 and the "1 Byte In (0-1)" start counting.
    Put the finger on the NXHX90 and the "1 Byte In (2-3) and "1 Byte In (5-6) value change because of temperature changes.
    Change DIP Switches on NXHX90 and the "1 Byte In (8 -9) value changes.

4. Use the state machine

Click on the slave and go to the "online" tap. Here it is possible to control the slave starte.

COM0 off = Init (only register access)

COM0 fast green blinking = PreOp (register and mailbox access)

COM0 slow green blinking = Safe-Op ((register and mailbox access and only input process data exchange)

COM0 green = Op (register and mailbox access and process data exchange)

5. Read out the object dictionary

Bring the slave in the "PreOP" state (Safe-OP and Op are possible to) The access to the mailbox is necessary.

Click on the slave and go to the "CoE - Online" tap. Here it is possible to read out the object dictionary out of the slave.

The "update List" button does not update the list of objects. Click on "advanced" and choose a subset of the objects.

After that go again on "advanced" and choose again all objects. That will force a read of all object from the slave.

6. Exercise 1 Change IO data size

The example has 10 byte input and 6 byte output processdate.

For the 6 byte output the stack needs only to create one PDO object with Index 0x1600. The object 0x1600 has 6 subobject with size 1 byte.

To this POD is mapped the custom specific processdata object 0x2000.

For the 10 byte output the stack needs only to create an other PDO object with index 0x1A00. The object 0x1A00 has 10 subobject with with size 1 byte.

To this POD is mapped the custom specific processdata object 0x3000.


The reason for PDO design can be found in the netX90 simpleConfig example. In the file

netXStudio_ECSV5_simpleConfig_V3.0.0.0\Components\cifXApplicationDemoECS\Sources\AppECS_DemoApplicationFunctions.c is the function

AppECS_ConfigureStack(). With the follwing lines:

 ptConfigReq->tData.tBasicCfg.ulProcessDataOutputSize = sizeof(APP_PROCESS_DATA_INPUT_T); /**< Process Data Output Size from master view */

 ptConfigReq->tData.tBasicCfg.ulProcessDataInputSize = sizeof(APP_PROCESS_DATA_OUTPUT_T); /**< Process Data Input Size from master view */

the application sends to the stack how many IO data the device needs to exachange.

After sending the configuration and the channel init to the stack

the firmware will create all necessary processdata objects.

Now choose for ptConfigReq->tData.tBasicCfg.ulProcessDataOutputSize = 500 and the stack will create this:

PDO 0x1600 with 200 subobjects and 0x2000 with 200 subobjects

PDO 0x1601 with 200 subobjects and 0x2000 with 200 subobjects

PDO 0x1602 with 100 subobjects and 0x2000 with 100 subobjects

The stack can not create a PDO with 500 subobjects, because the limit of subobject in one object are 255 subobjects.


Do it now:

Change in the simpleConfig project the value

ptConfigReq->tData.tBasicCfg.ulProcessDataOutputSize = 500;

Compile the project and load it in the netX90.

Read out with TwinCAT the new object dictionary. This will be the result:

The ESI file is not changed till now. The next step should be updating the ESI file, so that processdata from the device matches with the description of the ESI file.

Hilscher NETX90 RE ECS V5.2.0.xml

7. Exersize 2 Change ESI Values

The example has a Hilscher secondary vendor ID. A customer needs to use his own Vendor ID

In the file netXStudio_ECSV5_simpleConfig_V3.0.0.0\Components\cifXApplicationDemoECS\Sources\AppECS_DemoApplicationFunctions.c  this can be found:

#define ECS_SECONDARY_VENDORID_HILSCHER                               0xE0000044

change this in this training to:

#define ECS_SECONDARY_VENDORID_HILSCHER                               0xE0000FFF

compile the project and load it in the netX90

Go back to TwinCAT3 and delete the netX90 device and "Scan" again for devices.

TwinCAT3 finds the device with the new Vendor ID. But TwinCAT has not the matching ESI file for this Vendor. Klick on yes and TwinCAT will read out

all necessay informations from slave and create something like an ESI file after closing the TwinCAT project. It is named  OnlineDescriptionCacheE0000FFF.xml

and can be found here: C:\TwinCAT\3.1\Config\Io\EtherCAT.

In the next step delete all OnlineDescription files and do the change in the ESI file.

Change in the ESI file the line

<Type ProductCode="#x0000003D" RevisionNo="#x00000001">NETX 90-RE/ECS</Type>

to

<Type ProductCode="#x00000FFF" RevisionNo="#x00000001">NETX 90-RE/ECS</Type>

Copy the ESI in the folder C:\TwinCAT\3.1\Config\Io\EtherCAT.

Now retry Scan the device with TwinCAT.


Other values that should be changed are:

#define ECS_PRODUCTCODE                                               0x0000003d

#define ECS_SECONDARY_VENDORID_HILSCHER                               0xE0000044

#define ECS_REVISIONNUMBER                                            0x00000001

#define DEV_GROUP_TYPE_INFO                                           "netX"

#define DEV_TYPE_INFO                                                 "NETX 90-RE/ECS"

#define DEV_NAME_INFO                                                 "NETX 90-RE/ECS"

and refer to this in the ESI file: