Prechádzať zdrojové kódy

20221108
增加恒压制动功能

white.xu 2 rokov pred
rodič
commit
28fb6fa448

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2314 - 2314
MDK-ARM/QD007A_CTL_APP/QD007A_CTL_APP_CRC.hex


BIN
MDK-ARM/bin/QD007A_CTL_APP.bin


+ 19 - 13
User/Src/MC_FOC_Driver.c

@@ -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;	

+ 2 - 2
User/Src/MC_PID_regulators.c

@@ -294,7 +294,7 @@ const PID_Struct_t PID_MotorSpd_Pegasi =
   (int16_t)0,           //hKd_Gain
   (uint16_t)1024,       //hKd_Divisor
   (int32_t)0,           //wPreviousError
-  (int32_t)-1050,       //hLower_Limit_Output
+  (int32_t)-100,       //hLower_Limit_Output
   (int32_t)1050,        //hUpper_Limit_Output
   (int32_t)-358400,     //wLower_Limit_Integral
   (int32_t)358400,      //wUpper_Limit_Integral
@@ -391,7 +391,7 @@ const PID_Struct_t PID_MotorSpd_Pegasi_Plus =
   (int16_t)0,           //hKd_Gain
   (uint16_t)1024,       //hKd_Divisor
   (int32_t)0,           //wPreviousError
-  (int32_t)-1050,       //hLower_Limit_Output
+  (int32_t)-100,       //hLower_Limit_Output
   (int32_t)1050,        //hUpper_Limit_Output
   (int32_t)-358400,     //wLower_Limit_Integral
   (int32_t)358400,      //wUpper_Limit_Integral

+ 0 - 2
User/Src/motor_control.c

@@ -426,8 +426,6 @@ MC_CalParam_Struct_t MC_AssistRunMode_Gas_Process(uint16_t SensorData, MC_GearSt
 	
 	/* 电机速度闭环 */
 	//最大力矩为4档的力矩参数
-	PID_MotorSpd.hLower_Limit_Output= -(MC_AssisParam.Gear_TURBO.Upper_Iq / 2);
-	PID_MotorSpd.hUpper_Limit_Output= (MC_AssisParam.Gear_TURBO.Upper_Iq / 2);
 	TorQueBySpd = PID_Regulator(SpeedSetReal, MC_HallSensorData.motorspeed_RCFlt, &PID_MotorSpd);
 
 	TorQueBySpd += SpdMotorByIdc;

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov