This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

getting Qei position value problem in LPC-1768

Hi every one

i want to get the exact position alue of the quadrature encoder , in the QEI example of the CMSIS
but when i want to use the QEI_Getposition function the returned value is still zero , so the calculated speed in this example is correct, and i can get the RPM value.

please help me , how i can get the position??

Regards

  • You use Channel A,B,Z of Encoder connect to QEI Module.
    After ,you are calculate position with form " Position = QEIPOS+REV*(pulse/round of Encoder)".
    Note. Channel Z must connect to QEI MOdule.

    QEIPOS= positiopn register in QEI module
    REV = INXCNT register in QEI module

    set pin and parameter
    void initial_QEI(void)
    { LPC_SC->PCONP|=0x40000; //Power on LPC_SC->PCLKSEL1|=0x01; LPC_PINCON->PINSEL3 |=0x14100 ; // turn on PIN QEI LPC_QEI->QEICON |= 0x01; LPC_QEI->CMPOS0 = 0x00; LPC_QEI->CMPOS1 = 0x00; LPC_QEI->CMPOS2 = 0x00; LPC_QEI->INXCMP = 0x00; LPC_QEI->QEILOAD = 0x00; LPC_QEI->VELCOMP = 0x00; LPC_QEI->QEIIEC = 0x01; LPC_QEI->QEICLR = 0x41; LPC_QEI->QEICONF = 0x04; //Cap x4

    }
    /************* Set up ***/round **************/
    void qei_SetuPulse()
    { LPC_QEI->QEIMAXPOS =0x270F; /* set Up pulse/round**/ LPC_QEI->QEILOAD =PCKK/4; LPC_QEI->FILTER = 0x100;
    }