Other Parts Discussed in Thread: C2000WARE
I am trying to use the eQEP module for speed and position detection, with the eqep_posspeed example from c2000ware on a Launchpad device. The motor is running from a sensorless algorithm on another microcontroller. I am reading its encoder pulses on the TI board to estimate speed and position. Speed estimation is working fine. The only problem is that electrical theta as observed on oscilloscope is not synchronized to the index. The response is as if no index signal is being received by the board.
Here is the poss_speed function that i am using (tweaked from the example)
void POSSPEED_Init(void)
{
EQep1Regs.QUPRD = 1000000; // Unit Timer for 100Hz at 100 MHz (CLOCK/fm)
// SYSCLKOUT
EQep1Regs.QDECCTL.bit.QSRC = 00; // QEP quadrature count mode
EQep1Regs.QEPCTL.bit.FREE_SOFT = 2;
EQep1Regs.QEPCTL.bit.PCRM = 00;//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 = 0x1F3F; //7999 = 8000-1 Counts
EQep1Regs.QEPCTL.bit.QPEN = 1; // QEP enable
EQep1Regs.QCAPCTL.bit.UPPS = 5; // 1/32 for unit position
EQep1Regs.QCAPCTL.bit.CCPS = 6; // 1/64 for CAP clock
EQep1Regs.QCAPCTL.bit.CEN = 1; // QEP Capture Enable
}
Also, I see that the code has a portion to check if an index pulse has occurred and if the angle has sychronized to it.
// Check an index occurrence
//
if(EQep1Regs.QFLG.bit.IEL== 1)//EQep1Regs.QFLG.bit.IEL
{
p->index_sync_flag = 0x00F0; // This number is 240
EQep1Regs.QCLR.bit.IEL = 1; // Clear __interrupt flag
}
I am trying to observe the index_sync_flag in the expressions window but reads zero, indicating that no index pulse has been received (even though the index pulse is being received by the board). I have ensured eQEP GPIO initialization is correct.