This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TIDM-DELFINO-ETHERCAT: Process Data Mapping.

Part Number: TIDM-DELFINO-ETHERCAT
Other Parts Discussed in Thread: TMS320F28379D

Hello!

I successfully fired sample application for TIDM-DELFINO-ETHERCAT. Now I would like to change process data for my project. I prepared stack code using SSC and I created new application in Excel:

Next, I put ESI XML file in EtherCAT directory.

I prepared mapping too. Here is the code:

void APPL_InputMapping(UINT16* pData)
{
    uint16_t j = 0;
    uint16_t *pTmpData = (uint16_t *)pData;
    uint16_t data;


   for (j = 0; j < sTxPDOassign.u16SubIndex0; j++)
   {
      switch (sTxPDOassign.aEntries[j])
      {
      /* TxPDO  */
      case 0x1A00: // 8 bits
          data = Sinus0x6000;

          * (volatile uint16_t *)pTmpData = data;

         break;
      }
   }
}
void APPL_OutputMapping(UINT16* pData)
{
    uint16_t j = 0;
    uint16_t *pTmpData = (uint16_t *)pData;// allow byte processing
    uint16_t data = 0;
    for (j = 0; j < sRxPDOassign.u16SubIndex0; j++)
    {
        switch (sRxPDOassign.aEntries[j])
        {
        /* RxPDO */
        case 0x1600: //byte (8 bits)
            data = (*(volatile uint16_t *)pTmpData);
            Angle0x7000 = data;
            break;
        }
    }
}

In CCS I can see that my variables were mapped:

But when I fire TwinCAT I can see error which means that SM configuration for input process data is invalid:

I have no idea what I am doing wrong. It's my second day when I am fighting with this and my ideas are done.
Do you know where I am doing a mistake?

I appreciate any help.
BR,
Dawid.

  • Dawid,
    Thanks for the feedback on the provided collateral, glad it helped.

    If you take a look at the AN_ET9300 document, this is available with the SSC tool. Open SSC tool->Help->Documentation->ET9300 Application Note, refer to section 6.5, in addition to what you did you need to perform step 9 , define the RXPDO and TXPDO as explained in the document. Follow the steps in this section and you should be able to do what you intend do.

    The alternate way is to add the PDO mappings and Syncmanager assignments in the EXCEL.

    I used to create below entries in the excel, in addition to the inputs/outputs (like you did). See if it helps this way, add the below to your excel where it guides you to do and then save the project and recreate the ESI file, EEPROM binary file and SSC code and try.


    //0x16nn RxPDO Mapping (0x1600 - 0x17FF) | NOTE: if no RxPDO mapping object is defined the will be created automatically
    0x1600 RECORD RX PDO Mapping RX PDO Mapping
    0x01 UNSIGNED32 Angle 0x70000110 M S ro rx Mapping to 16 bit Angle

    //0x18nn TxPDO Paramter (0x1800 - 0x19FF)


    //0x1Ann TxPDO Mapping (0x1A00 - 0x1BFF) | NOTE: if no TxPDO mapping object is defined the will be created automatically
    0x1A00 RECORD TX PDO Mapping TX PDO Mapping
    0x01 UNSIGNED32 Sinus 0x60000110 M S ro tx Mapping to 16 bit Sinus

    //0x1C12 SyncManager 2 Assignment | NOTE: if this object is not defined it will be created automatically
    0x1C12 ARRAY RX PDO Assign RX PDO assignment to SM2
    0x01 UNSIGNED16 Entry1 0x1600 M S rw rx Entry 1 assignment to Angle

    //0x1C13 SyncManager 3 Assignment | NOTE: if this object is not defined it will be created automatically
    0x1C13 ARRAY TX PDO Assign TX PDO assignment to SM3
    0x01 UNSIGNED16 Entry1 0x1A00 M S rw tx Entry1 assignment to Sinus


    Hope this helps.

    Best Regards
    Santosh Athuru
  • Santosh,

    thank you for your help. I found this chapter in ET9300 you mentioned. I will try doing the mapping both ways, but I don't understand where in Excel file I should type additional information you provide in your post. I mean, I don't understand where to put this:

    //0x16nn	RxPDO Mapping (0x1600 - 0x17FF) | NOTE: if no RxPDO mapping object is defined the will be created automatically 
    0x1600	RECORD	RX PDO Mapping	RX PDO Mapping
    0x01	UNSIGNED32	Angle	0x70000110	M	S	ro	rx	Mapping to 16 bit Angle 
    
    //0x18nn	TxPDO Paramter (0x1800 - 0x19FF)	
    
    
    //0x1Ann	TxPDO Mapping (0x1A00 - 0x1BFF) | NOTE: if no TxPDO mapping object is defined the will be created automatically 
    0x1A00	RECORD	TX PDO Mapping	TX PDO Mapping
    0x01	UNSIGNED32	Sinus	0x60000110	M	S	ro	tx	Mapping to 16 bit Sinus 
    
    //0x1C12	SyncManager 2 Assignment | NOTE: if this object is not defined it will be created automatically 
    0x1C12	ARRAY	RX PDO Assign	RX PDO assignment to SM2
    0x01	UNSIGNED16	Entry1	0x1600	M	S	rw	rx	Entry 1 assignment to Angle
    
    //0x1C13	SyncManager 3 Assignment | NOTE: if this object is not defined it will be created automatically 
    0x1C13	ARRAY	TX PDO Assign	TX PDO assignment to SM3
    0x01	UNSIGNED16	Entry1	0x1A00	M	S	rw	tx	Entry1 assignment to Sinus

    Do I understand correct I should put this in Excel Application template? If so, in which line?

    BR,
    Dawid.

  • Dawid,
    I was referring to the excel template from SSC tool(SSC -> Tool -> Application -> Create new), if you look at ROW 35 there is a "+" sign (at #0x6nnx), expand that ROW by clicking the + symbol and you will see options to put in for 0x1600, 0x1A00, 0x1C12 and 0x1C13.


    Best Regards
    Santosh Athuru

  • I can see it now. I didn't notice that earlier.

    But tell me one thing - it is note here: NOTE: if no TxPDO mapping object is defined the will  be created automatically 


    What the difference when I'll do it manually if it is created automitacally?

    BR,
    Dawid.

  • yes, I saw that. I didn't get to experiment again with that. If I had time I would first just enter the inputs/outputs and then the RXPDO Mappaing and TXPDO Mapping and generate ESI and source files and see how the objects and code is generated and compare it with source generated from entering RXPDO and TXPDO in addition to mapping and i/o entries.

    Let me know if you see any thing and if the tool is automatically generating the RX and TX PDOs, I could see that it could be automated.

    Best Regards
    Santosh Athuru
  • Santosh,

    I tried to put data in Excel as you mentioned. I got this error:

    And here is my Excel:

    I typed data you provided. Did I do something wrong?

    BR,
    Dawid.

  • Dawid,

    you are missing the S.I (sub Index) one column before UINT16 in the ROW below 0x1C13. Each Entry should have a sub index.

    0x1C13 ARRAY TX PDO Assign TX PDO assignment to SM3

    0x01 UNSIGNED16 Entry1 0x1A00 M S rw tx Entry1 assignment to Sinus

    Best Regards
    Santosh Athuru

  • Ok, I corrected that and it fired.

    There are some differences. For example, here is code when I type in Excel just variables:

    /******************************************************************************
    *                    Object 0x1600 : Angle process data mapping
    ******************************************************************************/
    /**
    * \addtogroup 0x1600 0x1600 | Angle process data mapping
    * @{
    * \brief Object 0x1600 (Angle process data mapping) definition
    */
    #ifdef _OBJD_
    /**
    * \brief Object entry descriptions<br>
    * <br>
    * SubIndex 0<br>
    * SubIndex 1 - Reference to 0x7000.0<br>
    */
    OBJCONST TSDOINFOENTRYDESC    OBJMEM asEntryDesc0x1600[] = {
    { DEFTYPE_UNSIGNED8 , 0x8 , ACCESS_READ },
    { DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ }}; /* Subindex1 - Reference to 0x7000.0 */
    
    /**
    * \brief Object/Entry names
    */
    OBJCONST UCHAR OBJMEM aName0x1600[] = "Angle process data mapping\000"
    "SubIndex 001\000\377";
    #endif //#ifdef _OBJD_
    
    #ifndef _TMDSECATCNCD379_D_ETHER_CATSLAVE_ASYNC16_OBJECTS_H_
    /**
    * \brief Object structure
    */
    typedef struct OBJ_STRUCT_PACKED_START {
    UINT16 u16SubIndex0;
    UINT32 SI1; /* Subindex1 - Reference to 0x7000.0 */
    } OBJ_STRUCT_PACKED_END
    TOBJ1600;
    #endif //#ifndef _TMDSECATCNCD379_D_ETHER_CATSLAVE_ASYNC16_OBJECTS_H_
    
    /**
    * \brief Object variable
    */
    PROTO TOBJ1600 AngleProcessDataMapping0x1600
    #if defined(_TMDSECATCNCD379_D_ETHER_CATSLAVE_ASYNC16_) && (_TMDSECATCNCD379_D_ETHER_CATSLAVE_ASYNC16_ == 1)
    ={1,0x70000010}
    #endif
    ;
    /** @}*/

    and here is code when I type in excel PDO Mapping:

    /******************************************************************************
    *                    Object 0x1600 : RxPDOMapping
    ******************************************************************************/
    /**
    * \addtogroup 0x1600 0x1600 | RxPDOMapping
    * @{
    * \brief Object 0x1600 (RxPDOMapping) definition
    */
    #ifdef _OBJD_
    /**
    * \brief Object entry descriptions<br>
    * <br>
    * SubIndex 0<br>
    * SubIndex 1 - Angle<br>
    */
    OBJCONST TSDOINFOENTRYDESC    OBJMEM asEntryDesc0x1600[] = {
    { DEFTYPE_UNSIGNED8 , 0x8 , ACCESS_READ },
    { DEFTYPE_UNSIGNED32 , 0x20 , ACCESS_READ | OBJACCESS_RXPDOMAPPING }}; /* Subindex1 - Angle */
    
    /**
    * \brief Object/Entry names
    */
    OBJCONST UCHAR OBJMEM aName0x1600[] = "RxPDOMapping\000"
    "Angle\000\377";
    #endif //#ifdef _OBJD_
    
    #ifndef _TMDSECATCNCD379_D_ETHER_CATSLAVE_ASYNC16_OBJECTS_H_
    /**
    * \brief Object structure
    */
    typedef struct OBJ_STRUCT_PACKED_START {
    UINT16 u16SubIndex0;
    UINT32 SI1; /* Subindex1 -  */
    } OBJ_STRUCT_PACKED_END
    TOBJ1600;
    #endif //#ifndef _TMDSECATCNCD379_D_ETHER_CATSLAVE_ASYNC16_OBJECTS_H_
    
    /**
    * \brief Object variable
    */
    PROTO TOBJ1600 RxPDOMapping0x1600
    #if defined(_TMDSECATCNCD379_D_ETHER_CATSLAVE_ASYNC16_) && (_TMDSECATCNCD379_D_ETHER_CATSLAVE_ASYNC16_ == 1)
    ={1,0x70000110}
    #endif
    ;
    /** @}*/

    What do you think about that?

    BR,
    Dawid.

  • Dawid,
    actually looks like they will result in same thing, with few name changes here and there.

    There is another error I see in your excel entry for 0x6000 and 0x7000. The Entries should be in the next ROW of 0x6000 and 0x7000 respectively.

    for ex:- like below.

    0x6000 VARIABLE sinus sinus is input to master and outputf rom slave
    0x01 UINT16 Sinus 0x0 M S ro tx Sinus Input to Master


    please correct your excel for 0x6000 and 0x7000 entries and regenerate the code.


    Best Regards
    Santosh Athuru
  • Did you mean this?

  • Dawid,
    the above looks good. I don't think you need the object code (VARIABLE) for the entries in the input/ouput records.

    so, do you still get the SM config error with the updated excel and code?

    Best Regards
    Santosh Athuru
  • Santosh,

    I'll answer about that error in tomorrow morning when I'll be back in the lab. I haven't got ethercat hardware at home :)

    BR,

    Dawid.

  • Santosh,

    still the same error with above configuration.

    BR,
    Dawid.

  • Santosh,

    still no results. I checked one more thing. When description is loaded from xml file here is what I can see:

    But when I click "Load PDO info from device then Sync Manager and PDO Assignment are different:

    I have no idea where I am doing a mistake.

    BR,
    Dawid.

  • Dawid,

    did you generate the new ESI file for your configuration, remove the older one from TwinCAT and put the new one in TwinCAT folders?

    did you program the new ESI (EEPROM) image on to the slave node from master?

    The size of your inputs is 2 bytes and outputs is 2 bytes, so did you perform the above steps?

    Best Regards

    Santosh Athuru

  • Santosh,

    1. I generated new ESI file for my configuration and I removed old one and I placed new. Then I reloaded devices descriptions in TwinCAT.
    2. I did program new ESI image on my slave device.

    I found the leak in another place. Please, read carefully below information because it is important notice and I think it is a mistake in C28x patch to SSC Tool which TI develops to controlCARD kit.


    First of all, I checked mapping function and parameters: "nPdInputSize" and "nPdOutputSize" - they should be equal 2 but they aren't. I checked it in here:

    Here is screenshot from CCS watch expressions:

    Here we should have 0, 2, 2. 30 = 0x1E so this is equal to my AL Status Code from TwinCAT.

    This information brought me to APPL_GenerateMapping function - and here is the issue.

    Below APPL_GenerateMapping code fragment from generated by SSC Tool (C28x with sample application):

    and here is  APPL_GenerateMapping code fragment generated by SSC Tool (C28x without sample application - with application I made by excel file):

    As you can see generated line is comment out in EchoBack example and bit shift is 4 right not 3! When I correct this line just like in EchoBack example (so now I have bit shift 4 right) everything fires correctly! There is no more problem in TwinCAT.

    This little change resolved my issue.

    BR,
    Dawid.

  • David,
    yes, you are absolutely right, the shift should be by 4 on C28 as shown in the TI EchoBack sample application. But, the tool is also right and did what it is supposed to do when generating the SSC code for C28 without TI C28 sample application. Below is the explanation.

    APPL_GenerateMapping function is part of the application files that customer has to write/port onto C28x. We provide a patch with sample application (echoback) to show how the APPL_GenerateMapping should handle the PDO sizes. This is the whole purpose of having our own sample application because we cannot be sure of what other application customer will generate the SSC code with and we cannot patch an application function without knowing the application.

    User should refer to the EchoBack application functions that are generated by the GREEN block config you shown in above snapshot and include the C28 port and/or analyze how TI handles the inputs and outputs and implement it in their application with the SCC generated code with user application (without C28x sample application).

    The minumum unit of data that can be addressed on C28 is 16 bits so customer application has to aware of this when handling PDOs and Input/outputs. So refer to the C28 provided echoback application and implement the data handling in similar fashion.

    It would have helped if I included the above detail in the user guide, I will mark it up for addition.


    Best Regards
    Santosh Athuru
  • It would be nice if this notice would be in manual for controlCARD ethercat kit. E.g. chapter in manual about creating your own application with tips how to map objects.

    I didn't come up with checking APPL_GenerateMapping() because in raw generated files from SSC warnings are in three places: inputMapping, outputMapping and application. What about adding a warning in APPL_GenerateMapping() in next release?

    One more thing - I am a little bit confused because you wrote that c28x is 16bit but on tms320f28379d product site I can see that this is 32bit. What I don't understand this time?

    BR,

    Dawid.

  • Dawid,
    We will add the chapter about creating your own application tips to the user document.

    On C28, 32-bit access is allowed and possible, what I meant to say is that a byte access is not possible by default unless you use some byte intrinsics. On C28 a single address in memory points to 16 bits, unlike on a cortex ARM M3 for ex: a single address in memory point to a byte.


    Hope this helps.

    Best Regards
    Santosh Athuru
  • Santosh,

    thank you for your help. I think we solved main issue of the topic.

    It is pleasure to work with you :)

    BR,
    Dawid.
  • When using the latest SSC Tool (V.1.4.2) the function APPL_GenerateMapping is correct and you don't need to adapt the function manually.

    download : www.ethercat.org/.../stack_code.aspx

  • Rainer,
    thanks for the update, this helps.

    Best Regards
    Santosh Athuru