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.

F2812 QEP new issue

Hi everyone!

I`m havin a bag time with the QEP whit a F2812 so I would apreciate some help.

My issue is the one that follows:

I`m reading my QEP ports, trying to mesuare speed, but my mesuare doesn`t varaity significanly with the speed, have ypu any idea, why it could be?

the is my code: (i´m using the mask M_INT5 for the interruptions activation)

//Configuration of QEP

void conf_QEP (void){

DemoQEP.position = 0x0000;

// configure shared pins as capture input pins
EALLOW;
GpioMuxRegs.GPAMUX.all = 0x73F; // EVA CAP/QEP pins
EDIS;

EvaRegs.GPTCONA.bit.T2TOADC = 0; // configure GPTCONA not to start ADC on GPT2 Event
// set GPT2 configuration register
EvaRegs.T2CON.all = TxCON_INI_QEP; // T2CON prepared to use for QEP, x/1

// configure Capture Control Register CAPCONA
EvaRegs.CAPCON.bit.CAPQEPN = 3; // enable QEP in CAPCONA register

}

//using the QEP

med_veloc++;
//res_ma[k]=cont;

//===========================================
if (med_veloc==1){ //Se lanza el contador de pulsos
// Setup Timer 2 Registers (EV A)
EvaRegs.T2PR = T2PR_INI; // initialize GPT2 timer period
EvaRegs.T2CNT = TxCNT_INI_QEP; // reset GPT2 counter register
// start timer 2
EvaRegs.T2CON.bit.TENABLE = 1; // Start GPT2 counter to count QEP circuit pulses
EvaRegs.CAPCON.bit.CAPQEPN = 3; // enable QEP in CAPCONA register

} //Pasaron 50 microsegundos y se hace el calculo de la velocidad

if (med_veloc==2){
EvaRegs.T2CON.bit.TENABLE = 0;
med_veloc=0;
cont = EvaRegs.T2CNT;

if( k<20480){
res_ma[k]=cont;
k++;
}

I`m triying with diferent speeds, but my measure goes (as it follows):

res_ma[k]=[1 2 4 3 5 2 1 .......]

whe I increas the speed, the rank spand, but not for to much.

Wen I turn my motor in the oder way de mesuare goes:

res_ma[k]=[65533 65532 65534 65533 65535 65532 65531 .......]

So, could I maybe mess up with some scale? 

Thanks for the help!

  • Hi Alan,

    According to what I can observe from your findings is that, yes there seems to be some scaling issues! 

    The scale you've mentioned : res_ma[k]=[65533 65532 65534 65533 65535 65532 65531 .......]  is the highest limit.

    Did you go through the sample projects?

    Regards,

    Gautam

  • Hi Gautam, thank you for the answer, this is the sample project

    void EvaDemo()
    {
    // configure shared pins as capture input pins
    EALLOW;
    GpioMuxRegs.GPAMUX.all = EVA_QEPENMSK; //* EVA CAP/QEP pins
    EDIS;

    // Enable EVA clock
    SysCtrlRegs.PCLKCR.bit.EVAENCLK=1;

    // Setup Timer 2 Registers (EV A)
    EvaRegs.GPTCONA.bit.T2TOADC = 0; //* configure GPTCONA not to start ADC on GPT2 Event
    EvaRegs.T2PR = T2PR_INI; //* initialize GPT2 timer period
    EvaRegs.T2CNT = TxCNT_INI_QEP; //* reset GPT2 counter register


    // set GPT2 configuration register
    EvaRegs.T2CON.all = TxCON_INI_QEP; //* T2CON prepared to use for QEP, x/1

    // start timer 2
    EvaRegs.T2CON.bit.TENABLE = 1; //* Start GPT2 counter to count QEP circuit pulses

    // configure Capture Control Register CAPCONA
    EvaRegs.CAPCON.bit.CAPQEPN = 3; //* enable QEP in CAPCONA register


    while (!DemoQEP.stop)
    {
    // read and store position from encoder
    DemoQEP.position = EvaRegs.T2CNT; // read GPT2 current counter value and store into 'position' variable

    // call monitor
    DemoQEP.ret_val_mon = (*callmon2812)();

    }

    // Generate system reset
    DINT;
    EALLOW;
    SysCtrlRegs.SCSR.bit.WDOVERRIDE =1; // Set WDOVERRIDE bit to allow the Watchdog enable
    SysCtrlRegs.WDCR = 0x000F; // Enable Watchdog and write incorrect WD Check Bits
    // (001 in lieu of 101) to force a system reset
    }

    Ii`s similat for what I wrote, but it only mesure position (I need speed), you think that for the same reason (scaling) my vectos res_ma goes [ 1 3 4 3 2 4 2... ] too when I make it run in the other direction?

    the main diferent I saw it`s

    In the example

    EALLOW;
    GpioMuxRegs.GPAMUX.all = EVA_QEPENMSK; // EVA_QEPENMSK;=0x700
    EDIS;

    and

    In my project

    EALLOW;
    GpioMuxRegs.GPAMUX.all = EVA_QEPENMSK; // EVA_QEPENMSK;=0x7C3
    EDIS;

    But it doesn´t afect the behaivor of the program if I change it

    How could I change it?

  • Hi Alan,

    The EVA_QEPENMSK variable has to be altered in the global section and not in the comment section; you know that right?

    Secondly, while editing the sample project please check for all the modified steps and spot the change that gives you a faulty output.

    Regards,

    Gautam

  • Hi Gautam.

    I´m not sure what you mean but:

    for the first suggestion, the EVA_QEPENMSK  is uncomented, define it in Global gives me the same answer.

    for the second suggestion, the proyect has all the element of the example proyect, but i can´t vary the speed mesuare (changin the motor speed), so my main problem is res_ma[k]=cont; (obs: there are all Uint16, so I don´t think that that could be an isuue) I should get diferent speed measure, (well I have some kind of diferent scales, but there are no too diferents from each others) but i Don´t really know why?

    Regards