为什么我在28027上面的SVPWM没有看到扇区的识别代码,求大神帮忙解决,具体代码如下:
sta
tic inline void SVGEN_run(SVGEN_Handle handle,const MATH_vec2 *pVab,MATH_vec3 *pT)
{
_iq Vmax,Vmin,Vcom;
_iq Va,Vb,Vc;
_iq Va_tmp = -(pVab->value[0]>>1);
_iq Vb_tmp = _IQmpy(SVGEN_SQRT3_OVER_2,pVab->value[1]);
Va = pVab->value[0]; //alpha
Vb = Va_tmp + Vb_tmp; //-0.5*alpha + sqrt(3)/2 * beta;
Vc = Va_tmp - Vb_tmp; //-0.5*alpha - sqrt(3)/2 * beta;
Vmax=0;
Vmin=0;
// find order Vmin,Vmid,Vmax
if (Va > Vb)
{
Vmax = Va;
Vmin = Vb;
}
else
{
Vmax = Vb;
Vmin = Va;
}
if (Vc > Vmax)
{
Vmax = Vc;
}
else if (Vc < Vmin)
{
Vmin = Vc;
}
Vcom = _IQmpy(Vmax+Vmin, _IQ(0.5));
// Subtract common-mode term to achieve SV modulation
pT->value[0] = (Va - Vcom);
pT->value[1] = (Vb - Vcom);
pT->value[2] = (Vc - Vcom);
return;
}
SVGEN_run(obj->svgenHandle,CTRL_getVab_out_addr(handle),&(pPwmData->Tabc))
static inline void HAL_writePwmData(HAL_Handle handle,HAL_PwmData_t *pPwmData)
{
uint_least8_t cnt;
HAL_Obj *obj = (HAL_Obj *)handle;
PWM_Obj *pwm;
_iq period;
_iq pwmData_neg;
_iq pwmData_sat;
_iq pwmData_sat_dc;
_iq value;
uint16_t value_sat;
for(cnt=0;cnt<3;cnt++)
{
pwm = (PWM_Obj *)obj->pwmHandle[cnt];
period = (_iq)pwm->TBPRD;
pwmData_neg = _IQmpy(pPwmData->Tabc.value[cnt],_IQ(-1.0));
pwmData_sat = _IQsat(pwmData_neg,_IQ(1.0),_IQ(-1.0));
pwmData_sat_dc = _IQmpy(pwmData_sat + _IQ(1.0), _IQ(0.5));
value = _IQmpy(pwmData_sat_dc, period);
value_sat = (uint16_t)_IQsat(value, period, _IQ(0.0));
// write the PWM data
PWM_write_CmpA(obj->pwmHandle[cnt],value_sat);
}
return;
} // end of HAL_writePwmData() function
CB-SVPWM跟SPWM一样嘛?
扇区判断的部分省略的,直接使用的是va、vb、vc的大小比较。这个是可以的。
一周热门 更多>