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 question

Hi all

 

 

i have a question for quadrature encode pulse (QEP), for rotating speed detection.
My encoder has 500 lines, and 3 signal A, B, and index. My DSP is ezdsp f28335.

With sampling frequency of 10kHz and a maximum speed is 50 rev / s, then my PI-speed controller works, but if speed is smaller (for example speed = 10 rev / s) , my controller instable. I have ACI motor, I think it is up to speed detection. But I'm not sure.

 

With 500 lines encoder, wmax = 50hz, fsampling = 10kHz, then on a sampling period is the max Impuls_counts_differenz: From w [1 / s] = [delta_counts / (4 * 500 lines)] * fsampling.

 


wmax = 50 = delta_counts_max/(4*500 lines)]* 10 000

===> delta_counts_max  = 10 counts / Period

 

 

The  code looks like that :

 

                EQep1Regs.QDECCTL.bit.QSRC=00;               // QEP quadrature count mode

                EQep1Regs.QEPCTL.bit.FREE_SOFT=2;        //unaffected by emulation suspend

                EQep1Regs.QEPCTL.bit.PCRM=00; // PCRM=00 mode - QPOSCNT reset on

                                                                                                ///index event

                EQep1Regs.QEPCTL.bit.UTE=1;                       // Unit Timeout Enable

                EQep1Regs.QEPCTL.bit.QCLM=1;   // Latch on unit time out

                EQep1Regs.QEPCTL.bit.IEL = 1;                       // IEL_RISING

                EQep1Regs.QEPCTL.bit.IEI = 2;                        // IEL_RISING

                EQep1Regs.QPOSMAX=4*500 - 1;

                EQep1Regs.QEPCTL.bit.QPEN=1;                    // QEP enable

                               

                EALLOW;   // Enable EALLOW

                GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 1;  // GPIO20 is EQEP1A

                GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 1;  // GPIO21 is EQEP1B

                GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 1;  // GPIO23 is EQEP1I

                EDIS;   

 

 

In interrupt routine with 10khz = fsampling

 

interrupt void main_isr(void)

 {

float Tmp1;

……………

…………….

………………

 

 

 

if (SpeedMessungcount == SpeedMessungscaler)

// so I can reduce speed_samplingfrequency
           / /speed_samplingfrequency = fsampling/ SpeedMessungscaler

  {

// Check the position counter for EQEP1

                RawTheta = (Uint16)EQep1Regs.QPOSCNT ;// QPOSCNT 32 bit

      

// Compute the mechanical angle

                MechTheta = RawTheta/(4*500);// floating point

 

 

if ((MechTheta < 0.95)&&(MechTheta > 0.05))

                    Tmp1 = fsampling* SpeedMessungscaler *(MechTheta - OldMechTheta)*60;//rpm

                else Tmp1 = Speed;//rpm

 

 

/*

 

                if (DirectionQep == 0)    // POSCNT is counting down

                      {

                       if (MechTheta  >  OldMechTheta)

                          Tmp1 = -(1.0  - MechTheta +  OldMechTheta)* fsampling*SpeedMessungscaler;

                                                        // x2-x1 should be negativ

                        esle                                                                                                                                           

                        Tmp1 = (MechTheta - OldMechTheta)* fsampling* SpeedMessungscaler;

                       }

                else if (DirectionQep ==1 )     // POSCNT is counting up

                    {

                       if (MechTheta  < OldMechTheta)

                        Tmp1 = (1.0 + MechTheta - OldMechTheta)* fsampling* SpeedMessungscaler;

                       else

                      Tmp1 = (MechTheta - OldMechTheta)* fsampling* SpeedMessungscaler;

                                                                                                                                                     

                  }

                Tmp1 *= 60; //rpm

*/

 

 

// Low-pass filter

 Tmp1 = K2*Speed + K3*Tmp1; // e.g.  fc = 50hz  , 1. Order

 

                 if (Tmp1 > BaseRpm) // BaseRpm = 3000 rpm

                 Speed = BaseRpm;

                 else if (Tmp1 < - BaseRpm)

                Speed = - BaseRpm;     

                else

                 Speed = Tmp1;

 

// Update the angle

   OldMechTheta = MechTheta;

   

                 SpeedMessungcount = 1;

  }

  else SpeedMessungcount++;

}

 

Can you advise me how i change the speed measurement ?

Many thanks in advance!

 

Tequila