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(0.5),_IQ(-0.5)); //_IQsat(A, long P, long N)//IQ数值的限幅函数 把A限制到[N P]之间
pwmData_sat_dc = pwmData_sat + _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
这个函数能不能讲解一下?
Johnson Chen1:
简单老说,计算的相电压位_IQ(-0.5)到_IQ(0.5),输出电压为50%占空比对于0电压,因此需要先将其转换成PWM输出占空比_IQ(0)到_IQ(1.0)
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(0.5),_IQ(-0.5)); //_IQsat(A, long P, long N)//IQ数值的限幅函数 把A限制到[N P]之间
pwmData_sat_dc = pwmData_sat + _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
这个函数能不能讲解一下?
user1303469:
回复 Johnson Chen1:
还是不太明白,为什么先乘 -1
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(0.5),_IQ(-0.5)); //_IQsat(A, long P, long N)//IQ数值的限幅函数 把A限制到[N P]之间
pwmData_sat_dc = pwmData_sat + _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
这个函数能不能讲解一下?
user5947112:
回复 Johnson Chen1:
您好,此占空比是由 电压标幺值直接计算出来的,但是电压标幺值是由实际电压除上USER_IQ_FULL_SCALE_VOLTAGE_V得到的,而占空比直接相关的是母线电压,母线电压比USER_IQ_FULL_SCALE_VOLTAGE_V要小很多,所以直接把电压标幺值作为占空比,不会导致输出电压要小于实际所需电压吗