Introduction
This example demonstrates how to configure and use Dynamic PDOs (Process Data Objects) in an EtherCAT slave device using the CoE (CANopen over EtherCAT) protocol. Dynamic PDOs allow for flexible data transfer between the slave and master devices, enabling dynamic configuration of data points and their attributes.
Setting up a project in netX Studio.
Create a new PDO
This example is based on the ECS CoE Custom OD example.
open the AppECS_DemoApplication_Config.h and create new object as showed below:
{ .eCommand = OD_CREATE_OBJECT, .pszName = "3. RxPDO", .uCreate.tObject = { .usIndex = 0x1602, .bMaxNumOfSubObjs = 2, .bObjectCode = ODV3_OBJCODE_RECORD, .usAccessFlags = 0, .bValueInfo = 0, .bIndicationFlags = 0, .usDataType = ECAT_OD_DTYPE_PDO_MAPPING, .usAccessRights = ECAT_OD_ACCESS_ALL, .ulMaxFieldUnits = 0, }, .tInitial = {NULL, 0}, .tDefault = {NULL, 0}, .tMinimum = {NULL, 0}, .tMaximum = {NULL, 0}, },
create new PDO :
static const uint32_t s_ab1602_Elements[] = { PDOMAPPING(0x2002, 1, 8), }; static const uint8_t s_b1602_NumElements = HIL_CNT_ELEMENT(s_ab1602_Elements);
add new PDO to Sync Manager
static const uint16_t s_aus1C12_Entries[] = { 0x1600, 0x1601, 0x1602}; { .eCommand = OD_CREATE_SUBOBJECT, .pszName = NULL, .uCreate.tSubObject = { .usIndex = 0x1C12, .bSubindex = 3, .bValueInfo = ODV3_VALUE_INFO_INITIAL_VALUE, .bIndicationFlags = 0, .usDataType = ECAT_OD_DTYPE_UNSIGNED16, .usAccessRights = ECAT_OD_READ_ALL | ECAT_OD_WRITE_PREOP, .ulMaxFieldUnits = 1, }, .tInitial = {&s_aus1C12_Entries[2], sizeof(s_aus1C12_Entries[2])}, },
EtherCat Master (TwinCAT)
You can check the result with ECM e.g. TwinCAT :
Conclusion
By following these steps and leveraging the capabilities of Dynamic PDOs, you can create flexible and efficient EtherCAT slave devices that can adapt to changing communication requirements.