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.

CCS/LAUNCHXL-F28377S: Rotary encoder given wrong value

Part Number: LAUNCHXL-F28377S


Tool/software: Code Composer Studio

Hello,

I am using a 1024 ppr rotary enconder with LAUNCHXL-F28377S via QEP_A pins. I am also using the serial communication port to send that to the computer to plot the speed x time graph. The problem is that when the motor is about 750 rpm the values comes with error. see the picture belllow.

//Part of the code from Example_posspeed.h

#define POSSPEED_DEFAULTS {0x0, 0x0,0x0,0x0,0x0,16382,2,0,0x0,\
                           50,0,6000,0,\
                           0,0,0,\
                           (void (*)(long))POSSPEED_Init,\
                           (void (*)(long))POSSPEED_Calc }

////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Part from Example_posspeed.c

void  POSSPEED_Init(void)
{
    EQep1Regs.QUPRD = 2000000;            // Unit Timer for 100Hz at 200 MHz
                                          // SYSCLKOUT
    EQep1Regs.QDECCTL.bit.QSRC = 00;      // QEP quadrature count mode
    EQep1Regs.QEPCTL.bit.FREE_SOFT = 2;
    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.QPOSMAX = 0xffffffff;
    EQep1Regs.QEPCTL.bit.QPEN = 1;        // QEP enable
    EQep1Regs.QCAPCTL.bit.UPPS = 3;       //
    EQep1Regs.QCAPCTL.bit.CCPS = 6;       // 
    EQep1Regs.QCAPCTL.bit.CEN = 1;        // QEP Capture Enable
}

Does anyone have any idea how to solve this problem?

  • Hi Ryan,

    Looks like the code is working as expected and speed measurements are correct except for the specific condition you mentioned above.
    You can check a few things to see QEP operation is as expected.

    - Have you noticed any error flags getting set in QEP?
    - Can you monitor the A/B/I inputs and check if there is any noise?
    - Have you checked this?

    Also, Is the error repeatable and resulting in same value?

    -Bharathi.
  • Ryan,

    Looking at the speed vs. time plots the problem doesn't look like it's QEP related. The harmonic nature of the speed variation feels more like a control problem than a measurement error. Are you seeing an actual physical disturbance in motor shaft movement above 700 rpm?

    Adding to Bharathi's questions, are you using IQmath and if so, what is your GLOBAL_Q setting?

    Regards,

    Richard
  • Hi Bharathi and Richard,

    Thanks for your reply, I used the freqcal Example to check each pulse frequecy and it seems that chanel B of my encoder has a problem when it reach aroud 750 rpm. Now I know that it is not a code problem.
    Thanks for your attention.

    Ryan