Part Number:TMS320F28377D
Hello
I'm working on a BLDC motor control.
My board is very similar to the demo board with the ControlCard F28377
The software base from the exemple IDDK v2.0.
My feedback is the Qep + Hall.
In a Calibration step, I get the number of Qep increment between the Electrical zero and the TopZ Event.
Then After that, the Qep is configured to Reset on TopZ event. compute the Electrical angle by retreive this angle to obtain RawValue = 0 on the true electrical angle.
In a normal life, I get the Hall captor and apply to the Qep Counter the position according the captor (+Angle Shift given by calibration step)
On the First Hall sensor change value, I make the same because now, we sure we are exactly on the transition of two hall combination.
Then on the TopZ event, the Qep counter is set to 0 and then now, I'm exactly on the good position.
This work correctly, BUT sometime, between the Hal Captor rising edge and the TopZ, I see the QepCnt reset to 0 without any reason! (No Top Z FLG.IEL = 0)
I'm using the QEP computation given on the IDDK exemple, the flag IndexSyncFlag is not set.
What could be Reset the QEP counter excepted the TopZ in my case???
The Qep Config is following:
/*-----------------------------------------------------------------------------
Initialization states for EQEP Decode Control Register
------------------------------------------------------------------------------*/
#define DV_QEP_QDECCTL_INIT_STATE ( XCR_X2 + QSRC_QUAD_MODE )
/*-----------------------------------------------------------------------------
Initialization states for EQEP Control Register
------------------------------------------------------------------------------*/
#define DV_QEP_QEPCTL_INIT_STATE ( QEP_EMULATION_FREE + \
PCRM_INDEX + \
0 + \
IEL_RISING + \
QPEN_ENABLE + \
QCLM_TIME_OUT + \
/*UTE_ENABLE*/0 )
/*-----------------------------------------------------------------------------
Initialization states for EQEP Position-Compare Control Register
------------------------------------------------------------------------------*/
#define DV_QEP_QPOSCTL_INIT_STATE PCE_DISABLE
/*-----------------------------------------------------------------------------
Initialization states for EQEP Capture Control Register
------------------------------------------------------------------------------*/
#define DV_QEP_QCAPCTL_INIT_STATE ( UPPS_X32 + \
CCPS_X128 + \
CEN_ENABLE )
The computation of the Electrical angle is following:
{ \
float32 ElecThetaTemp; \
/* Check the rotational direction */ \
IF_MotorPosition_iQep.DirectionQep = (*DV_Qep_Regs[2]).QEPSTS.bit.QDF; \
\
/* Check the position counter for EQEP1 */ \
IF_MotorPosition_iQep.RawTheta = (*DV_Qep_Regs[2]).QPOSCNT - IF_MotorPosition_iQep.InitTheta; \
\
if (IF_MotorPosition_iQep.RawTheta < 0) \
IF_MotorPosition_iQep.RawTheta = IF_MotorPosition_iQep.RawTheta + (*DV_Qep_Regs[2]).QPOSMAX + 1; \
else if (IF_MotorPosition_iQep.RawTheta > (*DV_Qep_Regs[2]).QPOSMAX) \
IF_MotorPosition_iQep.RawTheta = IF_MotorPosition_iQep.RawTheta - (*DV_Qep_Regs[2]).QPOSMAX - 1; \
\
/* Compute the mechanical angle */ \
IF_MotorPosition_iQep.MechTheta= IF_MotorPosition_iQep.MechScaler*IF_MotorPosition_iQep.RawTheta; \
/* Compute the electrical angle */ \
ElecThetaTemp = IF_MotorPosition_iQep.PolePairs*IF_MotorPosition_iQep.MechTheta; \
IF_MotorPosition_iQep.ElecTheta = (ElecThetaTemp) -floor(ElecThetaTemp); \
\
/* Check an index occurrence*/ \
if (((*DV_Qep_Regs[2]).QFLG.bit.IEL == 1)) \
{ \
IF_MotorPosition_iQep.IndexSyncFlag = 0x00F0; \
IF_MotorPosition_iQep.QepCountIndex = (*DV_Qep_Regs[2]).QPOSILAT; \
((*DV_Qep_Regs[2]).QCLR.bit.IEL = 1); /* Clear interrupt flag */ \
} \
\
/* Check unit Time out-event for speed calculation: */ \
/* Unit Timer is configured for 100Hz in INIT function*/ \
if((*DV_Qep_Regs[2]).QFLG.bit.UTO == 1) \
{ \
/***** Low Speed Calculation ****/ \
if(((*DV_Qep_Regs[2]).QEPSTS.bit.COEF || (*DV_Qep_Regs[2]).QEPSTS.bit.CDEF)) \
{ /* Capture Counter overflowed, hence do no compute speed*/ \
(*DV_Qep_Regs[2]).QEPSTS.all = 0x000C; \
} \
else if((*DV_Qep_Regs[2]).QCPRDLAT!=0xffff) \
/* Compute lowspeed using capture counter value*/ \
IF_MotorPosition_iQep.QepPeriod = (*DV_Qep_Regs[2]).QCPRDLAT; \
} \
}
This comes only before the TRUE real TopZ signal. Never after.
Thank for your help.