|
@@ -25,9 +25,9 @@ void FOC_Model(int16_t Ref, int16_t MotorSpeed, uint16_t SVM_Angle) //
|
|
|
int32_t VoltSquare = 0; //弱磁控制预留
|
|
|
int32_t VoltMax = 0;
|
|
|
#endif
|
|
|
- int32_t IdFluxLessRef = 0;
|
|
|
+ static int32_t IdFluxLessRef = 0, IqFluxLessRef = 0;
|
|
|
int32_t UqCal = 0;
|
|
|
-
|
|
|
+ static int32_t FOC_IqLim = 0;
|
|
|
Curr_Components Stat_Curr_a_b; // Stator currents Ia,Ib
|
|
|
Curr_Components Stat_Curr_alfa_beta; // Ialpha & Ibeta, Clarke's transformations of Ia & Ib
|
|
|
Volt_Components Stat_Volt_alfa_beta; // Valpha & Vbeta, RevPark transformations of Vq & Vd
|
|
@@ -44,19 +44,25 @@ void FOC_Model(int16_t Ref, int16_t MotorSpeed, uint16_t SVM_Angle) //
|
|
|
IdFdbFlt += (((int32_t)(Stat_Curr_q_d.qI_Component2 << 10)) - IdFdbFlt)>>10; // KFlt = 2ms
|
|
|
IdFdb = IdFdbFlt >> 10;
|
|
|
|
|
|
- #if FluxWeak_Control // Debug 没调好,暂时关闭
|
|
|
- /* 增加弱磁处理 add Bike 20171007 */
|
|
|
- Tmp = ((int32_t)Stat_Volt_q_d.qV_Component1 * Stat_Volt_q_d.qV_Component1) + ((int32_t)Stat_Volt_q_d.qV_Component2 * Stat_Volt_q_d.qV_Component2); //2*Q30
|
|
|
- Tmp = Tmp >> 10; //Q20
|
|
|
- VoltSquareFlt += ((Tmp<<4) - VoltSquareFlt) >> 12;
|
|
|
- VoltSquare = VoltSquareFlt >> 4;
|
|
|
- VoltMax = 314641;
|
|
|
- IdFluxLessRef = PID_Regulator(VoltMax, VoltSquare, &PID_Weak_InitStructure) >> 10;
|
|
|
- #else
|
|
|
+ if( ADC1_Result[ADC1_RANK_VIN] < 3100) //55648mV 17.951 3100
|
|
|
+ {
|
|
|
+ IqFluxLessRef = Ref;
|
|
|
IdFluxLessRef = 0;
|
|
|
- #endif
|
|
|
+ }
|
|
|
+ else if( ADC1_Result[ADC1_RANK_VIN] < 3310 ) //59417mV 3310
|
|
|
+ {
|
|
|
+ FOC_IqLim = 1050 - (ADC1_Result[ADC1_RANK_VIN] - 3100)*5;
|
|
|
+ IqFluxLessRef = Ref<FOC_IqLim ? Ref : FOC_IqLim;
|
|
|
+ IdFluxLessRef -= 2;
|
|
|
+ if(IdFluxLessRef<-420) IdFluxLessRef = -420;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IqFluxLessRef=0;
|
|
|
+ IdFluxLessRef = -420;
|
|
|
+ }
|
|
|
|
|
|
- UqVoltTmp = PID_Regulator(Ref,\
|
|
|
+ UqVoltTmp = PID_Regulator(IqFluxLessRef,\
|
|
|
IqFdb,\
|
|
|
&PID_Torque_InitStructure); // 电流闭环输出q轴电压
|
|
|
UqVoltFlt += ((UqVoltTmp << 9) - UqVoltFlt) >> 3;
|