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.

TMS320F28379S: EnDat library. Command Set 2.1 / 2.2

Part Number: TMS320F28379S

Hello,

I had already post some question about Endat library on the propagation delay.

But I was facing a strange problem. If I send the Command 2.2: ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA it is Ok, but If I send the command 2.1 : ENCODER_SEND_POSITION_VALUES the receive position is ok, but the computed CRC is not the same than received!..

Bellow is the init phase and run phase I apply, which is extract from the example:

Init phase

Phase with Reset etc...

(void)PM_endat22_setupCommand (SELECTION_OF_MEMORY_AREA, 0xA1, 0x5555, 0);  /* data1=MRS; data2=any */
PM_endat22_startOperation();
wait endat22Data.dataReady == 1
(void)PM_endat22_receiveData(SELECTION_OF_MEMORY_AREA, 0);
CRC5_Result =  PM_endat22_getCrcNorm(endat22Data.address, endat22Data.data, DV_EnDat_CRCTable);
-> CRC is Ok


(void)PM_endat22_setupCommand (ENCODER_SEND_PARAMETER, 0xD, 0xAAAA, 0);  /* data1=address; data2=any */
  PM_endat22_startOperation();
wait endat22Data.dataReady == 1
(void)PM_endat22_receiveData(ENCODER_SEND_PARAMETER, 0);
  CRC5_Result =  PM_endat22_getCrcNorm(endat22Data.address, endat22Data.data, DV_EnDat_CRCTable);
-> Crc is Ok
-> endat22Data.position_clocks = endat22Data.data & 0x0FF;


(void)PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA, 0, 0, 0);
PM_endat22_startOperation();
wait endat22Data.dataReady == 1
(void)PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA, 0);
CRC5_Result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT22, endat22Data.position_lo,
                                     endat22Data.position_hi, endat22Data.error1, endat22Data.error2, DV_EnDat_CRCTable);
-> Crc is Ok
Delay1 = PM_endat22_getDelayCompVal

(void)PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA, 0, 0, 0);
PM_endat22_startOperation();
wait endat22Data.dataReady == 1
(void)PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA, 0);
CRC5_Result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT22, endat22Data.position_lo,
                                     endat22Data.position_hi, endat22Data.error1,endat22Data.error2, DV_EnDat_CRCTable);
-> Crc is Ok
Delay2 = PM_endat22_getDelayCompVal

DV_EnDat_Data.delay_comp = (Delay1 + Delay2) >> 1;

Then this init phase is Ok for me..

After that, two solution. THe first which working:

(void)PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA, 0, 0, 0);
PM_endat22_startOperation();
wait endat22Data.dataReady == 1
(void)PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA, 0);
CRC5_Result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT22, endat22Data.position_lo,
                                     endat22Data.position_hi, endat22Data.error1, endat22Data.error2, DV_EnDat_CRCTable);
-> Crc is Ok

Then I get the position ok.

The second which lead to a bad CRC comparision:

(void)PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES, 0, 0, 0);
PM_endat22_startOperation();
wait endat22Data.dataReady == 1
void)PM_endat22_receiveData(ENCODER_SEND_POSITION_VALUES, 0);
  CRC5_Result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT21*, endat22Data.position_lo,
                                      endat22Data.position_hi, endat22Data.error1, endat22Data.error2, DV_EnDat_CRCTable);

-> Crc is not Ok, but the read position is ok and move with the motor move...

*tryed with ENDAT22 with same result..

Is i me something bad into init phase or on the sequence to read the position with endat 2.1 command?

The aim of this command is to use less the SPi bus because less byte is transmitted then this is faster. !!

Thank

 

  • Hi,

    But can you try the following?

    If you are using ENDAT21 below
    CRC5_Result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT21*,

    You should set #define ENCODER_TYPE 21 in endat.h. Not sure if you've already set this.
    Also, what is the result if you did,

    CRC5_Result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT22,

    You can keep the same type definition in endat.h and the PM_endat22_getCrcPos function calls.
    Note that ENCODER_SEND_POSITION_VALUES is a valid command in ENDAT22 as well. It's backward compatible.

    I'm not exactly sure why you are seeing the CRC mismatch either way.
    Is the encoder using a different CRC polynomial for EnDat21 mode? Please check the encoder specification as well.

  • The define ENCODER_TYPE is just for the example which send some command diffrerent.

    But in the example, the are these comments:

    // Enable Additional data 1 - to read out no. of  clock pulses to shift out position value
    // MRS code 0x45    - Acknowledge memory content LSB

        retval1 = PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA, 0x45, 0, 0);
    ...

    // Enable Additional data 2 - to read out Operating status and error sources
     // MRS code 0x59    - operating status on additional data 2
     // Additional data enabled before this command is 1, after this command 2
        retval1 = PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES_AND_SELECTION_OF_THE_MEMORY_AREA, 0x59, 0, 1);
    ...

    and

    // Read out position value with 2 additional data previously enabled
    // Additional data enabled at this time is 2
        retval1 = PM_endat22_setupCommand (ENCODER_SEND_POSITION_VALUES_WITH_ADDITIONAL_DATA, 0, 0, 2);
    ...

    Is this configuration is in NON volatile memory into the EnDat Encoder? THis could explain my coder has mandatory some additional parameter... If yes, I don't know where find de code value to send ("MRS" code") to return to "No additional" data...

    I think my coder is conform to the HEIDENAIN specifications:

    https://www.heidenhain.fr/fileadmin/pdb/media/img/383942-28_EnDat_2-2_en.pdf

    I not seen any note about the CRC polynome, then I don't know it and I don't know if it is the same into 2.1 and 2.2?...

  • Hi,

    A GIR said:
    The define ENCODER_TYPE is just for the example which send some command diffrerent.


    That's correct. But what i'm also saying is that you use same encoder type for command

    CRC5_Result =  PM_endat22_getCrcPos(endat22Data.position_clocks, ENDAT22,

    The position of data bits may be different in endat22 vs endat21 format of the received data.
    Did you try this?

  • Yes, I tried both with ENDAT22 and ENDAT21 without any success.

    May be I will test wit a scope and read the real frame to see if it is coherent with the received data at the out of the library.

    Also, is somebody know which is the CRC polynom?

    The Idea I have is the encoder wand send the position and additional data, but like we ask to the driver, we only read the number of bit of the position and we take the "additional" data like the CRC..and then we not read the end of frame... may be this is has no sense, because we send the instruction to read only the position..

    If I know the CRC polynom, I could read the Real frame with the scope and determine if the coder send the good CRC or not....

  • Hi,

    A GIR said:
    Also, is somebody know which is the CRC polynom?


    Generally, the CRC poly for ENDAT is 0xB. 
    This is also defined in PM_endat22_Include.h file as ENDAT_CRC_POLYNOMIAL