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.

eQEP failure detection

Hello experts!

I want to implement failure detection for encoder reading on an
F28034. It should catch signal loss for channels A/B and index.

For now I can catch index failures but for A/B channels I got
stuck. Any help appreciated!

The idea was that on every counter over-or underflow there also should
be an index event. So I used this:

      /* failure detetction */
      if (0 < s16Sign)
      {
         /* forward, MAX -> 0 must trigger an index event */
         /* logical XOR: !a != !b */
         if ( !(EQep1Regs.QFLG.bit.IEL) != !(EQep1Regs.QFLG.bit.PCO))
         {
            /* increase error counter */
            s16EncErrCnt++;
         }
      }
      else
      {
         /* backward, 0 -> MAX must trigger an index event */
         /* logical XOR: !a != !b */
         if ( !(EQep1Regs.QFLG.bit.IEL) != !(EQep1Regs.QFLG.bit.PCU))
         {
            /* increase error counter */
            s16EncErrCnt++;
         }
      }

      /* clear event flags */
      EQep1Regs.QCLR.bit.IEL = 1;
      EQep1Regs.QCLR.bit.PCO = 1;
      EQep1Regs.QCLR.bit.PCU = 1;

      /* end failure detection */


Initialisation follows below.

If there is a loss for the index channel this works because there is
an over-or underflow without index event. But if one of A or B is
absent, it doesn't work. I understand from documentation that IEL is
only triggered if the same relative quadrature transition happens and
the problem is probably that if e.g. there is no channel A we don't
get an index event even if there is the correct index edge.

Is there a flag or another possibility to see if we got an index edge?


My initilisation:

   /* QDECCTL defaults to:
      QSRC_QUAD_MODE
      SOEN_DISABLE
      SPSEL_INDEX
      XCR_X2
      SWAP_DISABLE
      IGATE_DISABLE
      QAP_NO_EFFECT
      QBP_NO_EFFECT
      QIP_NO_EFFECT
      QSP_NO_EFFECT

      i.e. EQep1Regs.QDECCTL.all default completely correct
   */
   EQep1Regs.QDECCTL.all = 0;

   /* QEPCTL defaults to:
      PCRM_INDEX
      SEI_DISABLE
      SWI_DISABLE
      SEL_RISING
      QCLM_POSCNT
      WDE_DISABLE
   */
   EQep1Regs.QEPCTL.all = QEP_EMULATION_FREE |
                          IEL_SOFTWARE |
                          IEI_RISING |
                          QPEN_ENABLE | 
                          UTE_ENABLE;
   
   /* QPOSCTL defaults to:
      PCSHDW_DISABLE
      PCLOAD_ZERO
      PCPOL_HIGH
      PCE_DISABLE
      PCSPW = 0
      
      i.e. EQep1Regs.QPOSCTL.all default completely correct
   */
   EQep1Regs.QPOSCTL.all = 0;

   /* QCAPCTL */
   EQep1Regs.QCAPCTL.all = CEN_ENABLE | UPPS_X4 | CCPS_X64;


(I also tried IEL_RISING, there the loss detection would be
easier. But then the normal operation would be worse because my index
isn't synchronious to one channel and one edge would be wrong placed.)

Regards
Volker

  • Hi Volker,

    From my understanding, I believe you are looking at things correctly.  I cannot think of a good way around your issue within the QEP module itself.  If you are not using your eCAP module, I feel like tying your QEPI to an eCAP input will help you determine if a rising/falling edge of the index signal has occurred or not.  This module is designed to capture rising and falling edges. This may provide the missing piece of information needed to solve your problem.

    If you want to figure out if the QEPA, B or I signals have gone missing and you are also controlling the motor, a potentially better way may be to estimate the angle based on the motor's phase voltage/currents.  You could then compare the angle received via the QEP and the estimated angle.

    Good luck in your project!


    Thank you,
    Brett

  • Ok, I see.

    Anyway, thanks for your answer!

    Volker