ZHCU083I January 2013 – October 2021 TMS320F2802-Q1 , TMS320F28026-Q1 , TMS320F28026F , TMS320F28027-Q1 , TMS320F28027F , TMS320F28027F-Q1 , TMS320F28052-Q1 , TMS320F28052F , TMS320F28052F-Q1 , TMS320F28052M , TMS320F28052M-Q1 , TMS320F28054-Q1 , TMS320F28054F , TMS320F28054F-Q1 , TMS320F28054M , TMS320F28054M-Q1 , TMS320F2806-Q1 , TMS320F28062-Q1 , TMS320F28062F , TMS320F28062F-Q1 , TMS320F28068F , TMS320F28068M , TMS320F28069-Q1 , TMS320F28069F , TMS320F28069F-Q1 , TMS320F28069M , TMS320F28069M-Q1
函数 softwareUpdate1p6() 是针对 InstaSPIN-FOC v1.6 中的漏洞的应急措施,当使用 user.h 中的电感时,可用于校正电感从亨利转化为标幺值的操作。当使用 InstaSPIN-FOC v1.6 时,每当从 user.h 加载电机参数时,都需要调用此函数。
此补丁中包含以下修复措施:
下面是该补丁的源代码,在每个 InstaSPIN-FOC v1.6 和 InstaSPIN-MOTION 实验示例中均有使用。
void softwareUpdate1p6(CTRL_Handle handle)
{
CTRL_Obj *obj = (CTRL_Obj *)handle;
float_t fullScaleInductance = EST_getFullScaleInductance(obj->estHandle);
float_t Ls_coarse_max = _IQ30toF(EST_getLs_coarse_max_pu(obj->estHandle));
int_least8_t lShift = ceil(log(obj->motorParams.Ls_d/(Ls_coarse_max*fullScaleInductance))/log(2.0));
uint_least8_t Ls_qFmt = 30 - lShift;
float_t L_max = fullScaleInductance * pow(2.0,lShift);
_iq Ls_d_pu = _IQ30(obj->motorParams.Ls_d / L_max);
_iq Ls_q_pu = _IQ30(obj->motorParams.Ls_q / L_max);
float_t RoverL = obj->motorParams.Rs/obj->motorParams.Ls_d;
float_t fullScaleCurrent = EST_getFullScaleCurrent(obj->estHandle);
float_t fullScaleVoltage = EST_getFullScaleVoltage(obj->estHandle);
float_t ctrlPeriod_sec = CTRL_getCtrlPeriod_sec(ctrlHandle);
_iq Kp = _IQ((0.25*obj->motorParams.Ls_d*fullScaleCurrent)/(ctrlPeriod_sec*fullScaleVoltage));
_iq Ki = _IQ(RoverL*ctrlPeriod_sec);
_iq Kd = _IQ(0.0);
// store the results
EST_setLs_d_pu(obj->estHandle,Ls_d_pu);
EST_setLs_q_pu(obj->estHandle,Ls_q_pu);
EST_setLs_qFmt(obj->estHandle,Ls_qFmt);
// set the Id controller gains
PID_setKi(obj->pidHandle_Id,Ki);
CTRL_setGains(ctrlHandle,CTRL_Type_PID_Id,Kp,Ki,Kd);
// set the Iq controller gains
PID_setKi(obj->pidHandle_Iq,Ki);
CTRL_setGains(ctrlHandle,CTRL_Type_PID_Iq,Kp,Ki,Kd);
return;
} // end of softwareUpdate1p6() function