void CTRL_calcMax_Ls_qFmt(CTRL_Handle handle, uint_least8_t *pLs_qFmt) { CTRL_Obj *obj = (CTRL_Obj *)handle; if((EST_isMotorIdentified(obj->estHandle) == false) && (EST_getState(obj->estHandle) == EST_State_Rs)) { float_t Lhf = CTRL_getLhf(handle); float_t fullScaleInductance = USER_IQ_FULL_SCALE_VOLTAGE_V/(USER_IQ_FULL_SCALE_CURRENT_A*USER_VOLTAGE_FILTER_POLE_rps); float_t Ls_coarse_max = _IQ30toF(EST_getLs_coarse_max_pu(obj->estHandle)); int_least8_t lShift = ceil(log((Lhf/20.0)/(Ls_coarse_max*fullScaleInductance))/log(2.0)); *pLs_qFmt = 30 - lShift; } return; } // end of CTRL_calcMax_Ls_qFmt() function
void USER_softwareUpdate1p6(CTRL_Handle handle) { CTRL_Obj *obj = (CTRL_Obj *)handle; float_t fullScaleInductance = USER_IQ_FULL_SCALE_VOLTAGE_V/(USER_IQ_FULL_SCALE_CURRENT_A*USER_VOLTAGE_FILTER_POLE_rps); float_t Ls_coarse_max = _IQ30toF(EST_getLs_coarse_max_pu(obj->estHandle)); int_least8_t lShift = ceil(log(obj->motorParams.Ls_d_H/(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_H / L_max); _iq Ls_q_pu = _IQ30(obj->motorParams.Ls_q_H / L_max); // 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); return; } // end of softwareUpdate1p6() function
void fft_Exc(uint16_t pos ) { int16* psrc;//FFT变换的首址 uint16_t offset; float fsum_mag_square=0.0; float fsum_mag=0.0; float fbase_wave=0.0; if(pos>5) return; if(pos==0) psrc=(int16*)m_Ua_buf; else if(pos==1)psrc=(int16*)m_Ia_buf; else if(pos==2)psrc=(int16*)m_Ub_buf; else if(pos==3)psrc=(int16*)m_Ib_buf; else if(pos==4)psrc=(int16*)m_Uc_buf; else if(pos==5)psrc=(int16*)m_Ic_buf; for(offset=0;offset<TWO_N;offset++) { fft_data[offset]=(int16_t)psrc[offset]; } fft_R1024(fft_data); // 计算除基波外50次谐波平方和 for(offset=2;offset<52;offset++) { fsum_mag_square=fsum_mag_square+_IQ30toF(mag[offset]); } fsum_mag=sqrt(fsum_mag_square); // 开方后得到谐波比重 fbase_wave=sqrt(_IQ30toF(mag[1])); //计算基波幅值 F_A[pos] = fbase_wave; if(fbase_wave!=0.0) { F_Harm[pos][0]= (fsum_mag/fbase_wave)*100.0; } else { F_Harm[pos][0]=0.0; } for(offset=1;offset<52;offset++) { if(fbase_wave!=0.0) { F_Harm[pos][offset]=(sqrt(_IQ30toF(mag[offset]))/fbase_wave)*100.0; } else { F_Harm[pos][offset]=0.0; } F_angle[pos][offset] = atan2(_IQ30toF(ipcb[offset*2]),_IQ30toF(ipcb[offset*2+1]))/3.1415926*180 ; } DC_Harm[pos]= _IQ30toF(ipcb[0])*65536; //直流分量 if(pos==0) m_DC_Udx[A_PHASE]+=(int32_t)DC_Harm[pos]; else if(pos==1) m_DC_Idx[A_PHASE]+=(int32_t)DC_Harm[pos]; else if(pos==2) m_DC_Udx[B_PHASE]+=(int32_t)DC_Harm[pos]; else if(pos==3) m_DC_Idx[B_PHASE]+=(int32_t)DC_Harm[pos]; else if(pos==4) m_DC_Udx[C_PHASE]+=(int32_t)DC_Harm[pos]; else if(pos==5) m_DC_Idx[C_PHASE]+=(int32_t)DC_Harm[pos]; return; }