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 Problem

Hello,Im reading position with encoder, the problem is that sometimes the count jump to erroneous date, like in the image:

I read position in a interrupt at 10KHz


 

I configure the EQeP fron this way:

void encoder(void)
{
                EQep2Regs.QDECCTL.bit.QSRC=00;  // El modulo cuenta en cuadratura
                EQep2Regs.QEPCTL.bit.FREE_SOFT=2; //unaffected by emulation suspend
                EQep2Regs.QEPCTL.bit.PCRM=00; // QPOSCNT se reseta con cada cero (Un0)
                EQep2Regs.QEPCTL.bit.UTE=0;  //1 Habilita la unidad de Timeout
                EQep2Regs.QEPCTL.bit.QCLM=0;  //1 Latch on unit time out
                EQep2Regs.QEPCTL.bit.IEL = 1; // IEL_RISING
                EQep2Regs.QEPCTL.bit.IEI = 2; // IEL_RISING
                EQep2Regs.QPOSMAX=4*1024 - 1; //  valor maximo del encoder
                EQep2Regs.QEPCTL.bit.QPEN=1;  //1 Habilita QEP
                 //EQep2Regs.QUPRD=150000;  // unidad de tiempo en 100Hz si SYSCLKOTT=150MHz

 

and in the interrupt I have the next code:

 

interrupt void cpu_timer0_isr(void)
{
    CpuTimer0.InterruptCount++;
   
    x_ac= EQep2Regs.QPOSCNT;
   
    if (k<512)
       {Pos[k]=x_ac;
        k=k+1;}   
    else
        {k=0;}

I have a Vector of 512 point so I can storage the information. Can Sombody help me??

  • Wilson,

    Do you have other interrupt sources with higher priorities than cpu_timer0_isr ? If so give cpu_timer0_isr the highest possible priority and see if the problem goes away.

    Thanks

    Noah

  • Hello Noah, i dont have another interrupt, Is just one.

     

      I think the problem may be the configuration of eQEP, the signal from the encoder I have measured with oscilloscope and are Ok.

     

     

  • Hi Wilson

    QEP is running fine, what you most probably see is the effect of storing the data without any trigger. So the values from 0 to 150 are current samples and values from 150 to 512 are from previous acquisition.

    Regards, Mitja

  • Hello Mitja, how do that? trigger data?

  • Hi Wilson,

    one way of doing it is to replace the

    else
        {k=0;}

    statement with something like

    else
        {if ((pos_prev > EQep2Res.QPOSCNT) && (an GPIO == 1)
    )   

            {k = 0;}

        pos_prev = EQep2Res.QPOSCNT;

        }

    obviously you will have to define a variable

    static unsigned int EQep2Res.QPOSCNT;

    so you will start to write in the buffer only and only when you will press a key (you might replace that with a SW switch which you change it through watch windows) and (presuming positive direction of rotation) QPOSCNT will rollover.

    Regards, Mitja

     

    An idea for TI support people: You could overhaul DLOG module so that it would:

    - support long and float types

    - have a separate trigger channel (trigger not bound to buffer1 or *ptr1)

    - support normal scope triggering modes (auto, normal and single shot)

    - support positive and negative slope on the trigger

    - support variable channel number (maybe through preprocesor directives)

     

  • Hello Mijta, I tried to trigger by software and work fine, yo have right! thanks a lot!!