...
open the AppECS_DemoApplication_Config.h and create new object as showed 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 new PDO :
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 new PDO to 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])},
}, |
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.