...
Necessary hardware and sotware for this training
The same like in ECS SimpleConfig Example exercise. Follow the steps 1 till 3 and use here now netX 90 - EtherCAT Slave - dynamicPDO V3.0.0.0
...
Code Block | ||
---|---|---|
| ||
uint32_t AppECS_Write_ObjectInd(APP_DATA_T *ptAppData, CIFX_PACKET* ptPkt) { ... switch ( ptInd->tData.usIndex ) { ... case 0x1C12: lRet = OD_WriteInd_PDOAssignmentParameter(&tAppECSData, ptAppData, ptReq); break; case 0x1C13: lRet = OD_WriteInd_PDOAssignmentParameter(&tAppECSData, ptAppData, ptReq); break; default: lRet = CIFX_INVALID_PARAMETER; break; } ... } |
Inside of the fuction function OD_WriteInd_PDOAssignmentParameter is the fuction OD_CalculatePdoOffsets() where the application uses the and Ecat_SetIoSizeReq().
That means, if the EtherCAT master writes a sync mangermangerobject to the ECS slave, the slave application will get this object and it needs to check wtich PDO the EhterCAT master wants and . The Slave applicaton caclulate the new size PDO size .Because of the new 1 Byte 0x1602, add now some code for and uses Ecat_SetIoSizeReq() to tell the stack this.
With the sourcode chages now the application has the PDO 0x1602 with one Byte. I is necessary to change the OD_CalculatePdoOffsets() to support the new PDO 0x1602:
Code Block | ||
---|---|---|
| ||
static uint32_t OD_CalculatePdoOffsets(APP_ECS_DATA_T *ptAppEcsData, APP_DATA_T *ptAppData, ODV3_WRITE_OBJECT_REQ_T* ptPck) { ... switch (ptPck->tData.usIndex) { case 0x1C12: { for (j = 0; j < ECS_NUMBER_OF_RX_SUBINDX_INCL_SUB0; j++) { /* add offset of PDO to list and calculate next offset, * usTotalInpuSize was set to 0 before 1st function call*/ ptAppEcsData->tAssignment.tAssign1C12Temp.OffsetInProcessData[j] = ptAppEcsData->usTotalOutputSize; if (ptAppEcsData->tAssignment.tAssign1C12Temp.SubindexEntry[j] == 0x1600) { /* calculate next offset */ ptAppEcsData->usTotalOutputSize += 6; } else if (ptAppEcsData->tAssignment.tAssign1C12Temp.SubindexEntry[j] == 0x1601) { /* calculate next offset */ ptAppEcsData->usTotalOutputSize += 4; } else if (ptAppEcsData->tAssignment.tAssign1C12Temp.SubindexEntry[j] == 0x1602) { /* calculate next offset */ ptAppEcsData->usTotalOutputSize += 1; } } ... } break; ... } return lRet; } |
After OD_CalculatePdoOffsets() the application calls Ecat_SetIoSizeReq()
go to file AppECS_DemoApplication.h and change the ECS_NUMBER_OF_RX_SUBINDX_INCL_SUB0 for 3 to 4.
Code Block | ||
---|---|---|
| ||
#define ECS_NUMBER_OF_RX_SUBINDX_INCL_SUB0 4 |
Hint:
The slave application allways needs to decide if the requested PDO data from EtherCAT master is possbil or is not possible.
If the slave has plugable input and output hardware, the application need to check what is connectd. If the slave has only connected input hardware and in the EtherCAT master project is choosen output hardware, than the EtherCAT slave can handle only input data and no output data.
4. ESI Change
add the new PDO in the ESI file
Code Block | ||
---|---|---|
| ||
<Index>#x1602</Index> <Name>3. RxPDO</Name> <Entry> <Index>#x2002</Index> <SubIndex>1</SubIndex> <BitLen>8</BitLen> <Name>1 Byte Out (0)</Name> <DataType>BYTE</DataType> </Entry> |
Hilscher NETX90 RE ECS V5.2.0.xml
5. TwinCAT
Copy the new ESI file to the TwinCAT ESI file folder. In the new project now activate PDO assignment.
under Stuatup the new PDO 1602 can be seen.
set a braekpoint in netX Studio and click on relaod of TwinCAT