Table of Contents | ||
---|---|---|
|
...
About
This example demonstrates how to configure and use illustrates the process of configuring and utilizing Dynamic PDOs (Process Data Objects) in within an EtherCAT slave device using SubDevice, leveraging the CoE (CANopen over EtherCAT) protocol. Dynamic PDOs allow for facilitate flexible data transfer between the slave and master devices, enabling allowing for the dynamic configuration of data points and their associated attributes.
Setting up a project in netX Studio.
...
...
.
Prerequisites
The actual distribution of the examples can be found here: EtherCAT Slave Examples.
The cifXApplicationDemo project with corresponding ECS_DynamicPDO example can be found in the netXStudio:
...
The active target corresponding to the netX90 use case can be selected as shown on the picture below:
...
Info |
---|
This example is based on the ECS CoE Custom OD example, which provides important details on working with CoE object dictionary |
In this example, the configuration and usage of Dynamic PDO are demonstrated through the following basic steps:
Create a new PDO
Add the PDO to SyncManager
Add Handler for Dynamic PDO
To conclude, we will demonstrate how to assess the behavior using TwinCAT.open
Create a new PDO
In the initial step, a new PDO must be defined in the AppECS_DemoApplication_Config.h and create new object as showed file by incorporating the object description as illustrated below:
Code Block | ||
---|---|---|
| ||
{ .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 Then, the new PDO element shall be created :
Code Block | ||
---|---|---|
| ||
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 Finally, the new PDO shall be added to the Sync Manager:
Code Block | ||
---|---|---|
| ||
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])},
}, |
Add
...
the handling of dynamic PDO
To effectively manage the changes in dynamic PDOs during runtime, the application must be enhanced with a function that notifies the stack of any alterations in the input/output size. This is essential for dynamic PDO changes.Go to the file
The relevant function is located within the specified file: AppECS_DemoApplication_DynPDO_Handler.c
Locate the function named as AppECSCustomOd_WriteObjectInd().
In this This function , you'll find new code that receives provides the code, which reacts on write access to the SyncManager objects 0x1C12 and 0x1C13.
...
The function AppECS_OD_WriteInd_PDOAssignmentParameter
contains two other functions : AppECS_OD_CalculatePdoOffsets()
and AppECS_SetIoSizeReq()
.
When the EtherCAT master sends a synchronization manager object to the slave, the slave's application must determine which PDO the master is interested in. ThenMainDevice writes to the SyncManager object of the SubDevice, the SubDevice application must identify the addressed PDO. Subsequently, the application calculates the new size of the PDO and uses utilizes AppECS_SetIoSizeReq()
to inform notify the EtherCAT stack about of this new updated size.
Due to recent code changesIn this example, the application now has PDO 0x1602 with , which has a size of one 1 byte, is defined. To support accommodate this new PDO, it is necessary essential to modify the AppECS_OD_CalculatePdoOffsets()
function.
EtherCat Master (TwinCAT)
...
Checking behaviour with TwinCAT
In order to check the result with ECM e.g. TwinCAT : Copy TwinCAT, please the new ESI file to the TwinCAT ESI file folder. In the new project now activate PDO assignment.
...
Now The new PDO 0x1602 shall be visible in the list you can see the new PDO 0x1602 of objects:
...
and under Startup also :The PDO will be displayed in the Startup tab, as the MainDevice downloads the PDO to the SyncManager object.
...
The task is has been successfully completed, and you can are free to modify and supplement enhance this example at your own choice and according to your tasksas you see fit, tailoring it to meet your specific requirements.
Conclusion
By following implementing these steps and leveraging utilizing the capabilities features of Dynamic PDOs, you can create flexible develop adaptable and efficient EtherCAT slave devices that can adapt to changing communication requirementsSubDevices that respond effectively to evolving communication needs.