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-02007: Question about eQEP

Part Number: TIDM-02007

Hi Team,

I am working in a project,use TIDM-02007.Now I meet some problem about eQEP.

We need to use eQEP reset in index, so I change the code from 

EQEP_setPositionCounterConfig(obj->qepHandle,EQEP_POSITION_RESET_MAX_POS,((4 * M2_ENCODER_LINES) - 1) );

to

EQEP_setPositionCounterConfig(obj->qepHandle,EQEP_POSITION_RESET_IDX ,((4 * M1_ENCODER_LINES) - 1) );

But when I go to test I found it can not work.I check the eqep register,and found PCEF(position-counter error flag) is 1.

So I would like to know, why will cause this error? and why the the latched value is not equal to 0 or QPOSMAX?

Is this caused by the configuration of the code? Or is it possible that my eqep signal has noisy?

Thanks for your help.

 

Jenson

  • Hi Jenson,

    For the eQEP configuration you're wanting to use, I suggest reviewing the corresponding section in the device TRM. See "Position Counter Reset on Index Event (QEPCTL[PCRM]=00)" section which is section 21.5.1.1 of the F28004x device TRM for example:

    https://www.ti.com/lit/sprui33

    See details below on PCEF register bit description:

    The position-counter value is latched to the QPOSILAT register and direction information is recorded in the
    QEPSTS[QDLF] bit on every index event marker. The position-counter error flag (QEPSTS[PCEF]) and error
    interrupt flag (QFLG[PCE]) are set if the latched value is not equal to 0 or QPOSMAX. The position-counter error
    flag (QEPSTS[PCEF]) is updated on every index event marker and an interrupt flag (QFLG[PCE]) will be set on
    error that can be cleared only through software.

    It could be that QPOSMAX is not properly configured for your encoder.

    Best,

    Kevin

  • Hi kevin,

    I have read TRM and I have a few questions about it

    1.After position-counter error occurs, what effect will it have on EQEP? Or is it just a flag.

    (Because I have two motors, I use the first motor, which can work normally in RESET_MAX_POS/RESET_IDX, but PCEF is 1 in RESET_IDX. But the second motor can only work at RESET_MAX_POS, and at RESET_IDX, the motor will run at full speed and cannot be controlled.)

    2.When set to RESET_IDX, does it mean that the motor needs to start running from the index signal so that PCEF will not occur? (That is, start to rotate from position 0, and the index signal is just MAX when the index signal comes, so that PCEF will not occur)

    3.I tried to use fclVars[0].ptrQEP->QCLR.all = 0x0002; to clear PCEF. But I found that I cannot clear it, and it still shows as 1 in the expression. How can I clear this error correctly?

    Thanks for your help!

    Jenson

  • Hi Jenson,

    1.After position-counter error occurs, what effect will it have on EQEP? Or is it just a flag.

    It's just a notification flag.

    2.When set to RESET_IDX, does it mean that the motor needs to start running from the index signal so that PCEF will not occur? (That is, start to rotate from position 0, and the index signal is just MAX when the index signal comes, so that PCEF will not occur)

    I think that is right. To avoid the error flag the eQEP should start counting right at or after the index signal.

    3.I tried to use fclVars[0].ptrQEP->QCLR.all = 0x0002; to clear PCEF. But I found that I cannot clear it, and it still shows as 1 in the expression. How can I clear this error correctly?

    When PCEF does get set you could check QPOSILAT register to understand further and see what value is actually getting latched. It will keep getting set anytime the latched value does not match QPOSMAX or 0 at the index signal (bit gets set or cleared on each index signal).

    Best,

    Kevin

  • Hi kevin,

    Thanks for your help

    The problem I'm having now is very strange, I have two motors, I use the first motor, which can work normally in RESET_MAX_POS/RESET_IDX, but PCEF is 1 in RESET_IDX. But the second motor can only work at RESET_MAX_POS, and at RESET_IDX, the motor will run at full speed and cannot be controlled.

    I checked the parameters of the runaway motor, the speed loop PI is normal, but the output of Iq,Id looks strange, as shown in the picture below, the calculated value of the output of id should not be -0.32, which may be one of the errors , and the calculation of iq is also incorrect,

    I don't know what kind of error is going on here, do you have any comments on this?

    (This error happened when I just changed RESET_MAX_POS to RESET_IDX)

    Thanks.

    Jenson 

  • Hi Jenson,

    I'm going to pass your latest question and notes to one of our motor control experts for comment. They will get back to you soon.

    Thanks,

    Kevin

  • EQEP_setPositionCounterConfig(obj->qepHandle,EQEP_POSITION_RESET_MAX_POS,((4 * M2_ENCODER_LINES) - 1) );

    to

    EQEP_setPositionCounterConfig(obj->qepHandle,EQEP_POSITION_RESET_IDX ,((4 * M1_ENCODER_LINES) - 1) );

    Are the same motors used for dual motor control? Why M1_ENCODER_LINES is used for motor 2?

    You may try to use the "FCL_LEVEL2" to verify the speed and rotor angle measurement with encoder if you change anything in the example lab, and only run a motor during this phase.

  • Hi Yanming,

    Thanks for your help first!

    I have two motors, I use the first motor, which can work normally in RESET_MAX_POS and RESET_IDX, but PCEF is 1 in RESET_IDX.

    But the second motor can only work at RESET_MAX_POS, when I set EQEP in RESET_IDX, the motor will run at full speed and cannot be controlled.

    So I think it's weird because motor2 works fine with RESET_MAX_POS set.

    Following your suggestion, I checked the waveforms at RESET_MAX_POS (which works fine at level 4) and RESET_IDX, (which doesn't workat level 4) at LEVEL 2, and it doesn't seem to be a problem.

    RESET_MAX_POS waveforms:

    RESET_IDX waveforms

    So at present I haven't found the source of the problem. Under Level4, the exception I can check is that the PI parameter output of the current loop IQ and ID is not normal (as shown in the previous answer), but I don't know if it is What is causing this problem and do you have any comments on it?

    (The only changes to the program are RESET_MAX_POS to RESET_IDX)

     

    Thanks!

    Jenson

  • Did you make the calibration for encoder and set correct offset value for index reset? The reset value should be offset value, not zero if you change the reset mode for QEP.

  • Hi Yanming,

    No other modifications were made in the code. I would like to know, if I change the RESET_MAX_POS in the code to RESET_INDEX. Do I need to make other modifications to the code?such as angle compensation, etc.?

    Thanks.

    Jenson

  • You have to change the offset calibration function, not only change the control register for QEP.