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!