ECS CustomOD Example

1 Example project

The location for the ECS CustomOD Example is in our Knowledge Base

KB → Software → LFW Host Examples → EtherCAT Slave

For netX90:

2 ECS Sources

The ECS Sources in the ECS CustomOD Example are in the folder:

netXStudio_ECSV5_simpleConfig_V2.1.0.0\netX 90 - EtherCAT Slave - simpleConfig V2.1.0.0\Components\cifXApplicationDemoECS\Sources


3 Configuration packet

The ECS Configuration packet is in the file AppECS_DemoApplicationFuction.c. The Configuration packet is explained in the SimpleConfig Example.

In the CustomOD Example the ECAT_SET_CONFIG_COE is used:


ptConfigReq->tData.tBasicCfg.ulComponentInitialization |= ECAT_SET_CONFIG_DEVICEINFO | ECAT_SET_CONFIG_COE;


Then this structure needs to be filled:


ECAT_SET_CONFIG_COE_T* ptCoECfg;


  ptCoECfg = &ptConfigReq->tData.tComponentsCfg.tCoECfg;

  ptCoECfg->bCoeFlags = ECAT_SET_CONFIG_COEFLAGS_USE_CUSTOM_OD;

  ptCoECfg->bCoeDetails = ECAT_SET_CONFIG_COEDETAILS_ENABLE_SDO

                        | ECAT_SET_CONFIG_COEDETAILS_ENABLE_SDOINFO

                        | ECAT_SET_CONFIG_COEDETAILS_ENABLE_UPLOAD

                        | ECAT_SET_CONFIG_COEDETAILS_ENABLE_SDOCOMPLETEACCESS;


  ptCoECfg->ulOdIndicationTimeout = 1000;

  ptCoECfg->ulDeviceType          = 0;


This: “ECAT_SET_CONFIG_COEFLAGS_USE_CUSTOM_OD” activates the custom OD. The stack will now only create the Object 0x1000 for device Type and the object 0x1018 for VendorID, Productcode, Revision Number and SerialNumber

All other Objects need to be created by application.

4 Create Object dictionary

The file AppECS_DemoObjectDictionary.h has a tables of objects and subobjects.

OBJECT_DESCRIPTION_T g_tObjects[] has the object table with the Indexs:

0x1600  → RxPDO

0x1A00 → TxPDO

0x1C00 → Sync Manager Comunication Type

0x1C12 → Sync Manger 1 PDO Assignment

0x1C13 → Sync Manger 1 PDO Assignment

0x2000 → Manufacture specific Outputs

0x3000 → Manufacture specific Inptus

0x4000 → Hello World Object

Each of the objects has a table of subobjects.


In the file AppECS_DemoApplicationFuction.c are the functions.

AppECS_OD_SendCreateObjectReq() and

AppECS_OD_SendCreateSubObjectReq()


5 Start Sequenz

The Object Dictionary must be created between Channel Init and Bus ON. This is done in AppECS_ConfigureStack():



  /* initialize channel to use the configured data */

  App_SysPkt_AssembleChannelInitReq(&ptAppData->tPacket);

  ulRet = Pkt_SendReceivePacket( ptAppData->hChannel[0], &ptAppData->tPacket, TXRX_TIMEOUT );

  if( ulRet != CIFX_NO_ERROR )

      return ulRet;


  /* Create Objects */

  AppECS_OD_SendCreateObjectReq(ptAppData, &g_customOd);

  //ulRet = Pkt_SendReceivePacket( ptAppData->hChannel, &ptAppData->tPacket, TXRX_TIMEOUT );

    if( ulRet != CIFX_NO_ERROR )

      return ulRet;


  App_SysPkt_AssembleStartStopCommReq( &ptAppData->tPacket, true );

  ulRet = Pkt_SendReceivePacket( ptAppData->hChannel[0], &ptAppData->tPacket, TXRX_TIMEOUT );

  if( ulRet != CIFX_NO_ERROR )

      return ulRet;

6 ECM Master

As soon as the ECS Stack in successfully configured and the Start Communication Request / Bus On is done, the EtherCAT Slave goes into Init State.

The EtherCAT Master can read out the Object dictionary in Pre-Operation State.


Bring device in Preop with TwinCAT:

Read out the Object dictionary:

List of All Objects:

and Subobjects

6 Structure of Manufacturer Object dictionary for processdata.

In the CustomOD Example only one PDO (0x1600) is used. One Object can have 255 subobjects. If each Subobject represents 1 Byte and the number of Byte is more then 255 Byte, it is necessary to create an second PDO Object 0x1601.

Example for Processdata structue with more than one PDO.

SM2 ObjectPDO Objects List

Manufacturer

Objects

Suboabjects in the

Manufacturer Object

For Example a Device

with a little struktue
0x1C12

0x1600

0x1601

0x1602

...

0x2000

0x2001

0x2002

....

0x2000:01 ; ...

0x2001:01 ; 0x2001:02 ;  0x2001:03 ; ...

0x2002:01 ; 0x2002:02 ;  ...

...

Command (1 Byte)

Zero level (3 Byte)

Speed Value (2 Byte)

...

SM3 Object





0x1C13

0x1A00

0x1A01

0x1A02

...

0x3000

0x3001

0x3002

...

0x3000:01 ; 0x3000:02 ;  ...

0x3001:01 ; 0x3001:02 ; 0x3001:03 ...

0x3002:01 ; 0x3002:02 ; ...

...

Status Byte (2 Byte)

Sensor Data 1 (255 Byte)

Sensor Data 2 (2 Byte )

...


The Manufacturer Object can have the Index 0x2000 till 0x5FFF. The Values 0x2000 and 0x3000 can be changed.

In a profile device the object does not have a Index between 0x2000 till 0x5FFF. In this case, the Index has a range of 0x6000 - 0x9FFF.

SM2 ObjectPDO Objects List

Profiel

Objects

Suboabjects in the

ProfielObject

For Example a MDP Device

with IO Link profile

0x1C12

0x1600

0x1601

0x1602

...

0x6000

0x6001

0x6002

....

0x6000:01 ; 0x6000:02 ; 0x6000:03 ...

0x6001:01 ; 0x6001:02 ; 0x6001:03 ...

0x6002:01 ; 0x6002:02 ; 0x6002:03 ...

...

IO Link Sensor 1 (4 Byte)

IO Link Sensor 2 (10 Byte)

IO Link Sensor 3 (64 Byte)

...

SM3 Object





0x1C13

0x1A00

0x1A01

0x1A02

...

0x7000

0x7001

0x7002

...

0x7000:01 ; 0x7000:02 ; 0x7000:03 ...

0x7001:01 ; 0x7001:02 ; 0x7001:03 ...

0x7002:01 ; 0x7002:02 ; 0x7002:03 ...

....

IO Link Sensor 1 (4 Byte)

IO Link Sensor 2 (10 Byte)

IO Link Sensor 3 (64 Byte)

...


This picture shows the Linking of this objects:

A Sync Manager Object has a table of PDOs with PDO objects and subobjects. The PDO objects and subobjects are linked to manufacturer obects or profile objects.