소스 검색

V3r4r0_20221110
优化指拨推行体验,外环是速度环,内环是电流环,电流环经过加加减减线性增加和减少;

white.xu 2 년 전
부모
커밋
cb697ba183
6개의 변경된 파일2432개의 추가작업 그리고 2415개의 파일을 삭제
  1. 24 2
      J-scope.jscope
  2. 2332 2332
      MDK-ARM/QD007A_CTL_APP/QD007A_CTL_APP_CRC.hex
  3. BIN
      MDK-ARM/bin/QD007A_CTL_APP.bin
  4. 5 1
      User/Src/MC_FOC_Driver.c
  5. 69 78
      User/Src/motor_control.c
  6. 2 2
      User/Src/var.c

+ 24 - 2
J-scope.jscope

@@ -6,7 +6,7 @@
             <JLink>
                 <Options IsRTTSession="0" IsRTTWithTimeStamp="1" SamplingPeriod="100" Connection="1" SerialNo="0" IP="" TargetDevice="Cortex-M3" TargetInterface="SWD" InterfaceSpeed="4000" />
             </JLink>
-            <ElfFile Name="D:\MOTINOVAϵͳ\Motor\TTKZ019X\Volans\QD007E_CTRL_APP\MDK-ARM\QD007A_CTL_APP\QD007A_CTL_APP.axf" />
+            <ElfFile Name="D:\MOTINOVA\Motor\TTKZ019X\Pegasi\TT-KZ-010A_CTRL_APP\MDK-ARM\QD007A_CTL_APP\QD007A_CTL_APP.axf" />
             <DataFile Name="" />
             <RawFile Name="" />
             <Scope>
@@ -17,6 +17,28 @@
             <Graph Show="1" />
             <Watch Show="1" />
         </Windows>
-        <SelectedSymbols />
+        <SelectedSymbols>
+            <Symbol>
+                <Options Name="SpeedSetReal" Address="0x20000124" Type="short" TypeID="11" Size="2" GraphColorRed="0" GraphColorGreen="0" GraphColorBlue="176" YMinSampled="0" YMaxSampled="837" YAvgSampled="2" Offset="4" ShowInGraph="1" YOffset="200" IsAutoConfig="0" YResolution="500" MaxValue="2000" File="..\User\Src\motor_control.c" Scope="0" DrawStyle="0" />
+            </Symbol>
+            <Symbol>
+                <Options Name="motorspeed_RCFlt" Address="0x20001232" Type="ushort" TypeID="7" Size="2" GraphColorRed="160" GraphColorGreen="32" GraphColorBlue="240" YMinSampled="0" YMaxSampled="1297" YAvgSampled="3" Offset="6" ShowInGraph="1" YOffset="200" IsAutoConfig="0" YResolution="500" MaxValue="934" File="..\User\Src\hall_sensor.c" Scope="0" DrawStyle="0" />
+            </Symbol>
+            <Symbol>
+                <Options Name="SpdProportion" Address="0x200000F4" Type="short" TypeID="11" Size="2" GraphColorRed="255" GraphColorGreen="0" GraphColorBlue="0" YMinSampled="279" YMaxSampled="279" YAvgSampled="279" Offset="8" ShowInGraph="1" YOffset="200" IsAutoConfig="1" YResolution="500" MaxValue="1000" File="..\User\Src\motor_control.c" Scope="0" DrawStyle="0" />
+            </Symbol>
+            <Symbol>
+                <Options Name="Ref_Speed_Temp_End" Address="0x20000128" Type="int" TypeID="12" Size="4" GraphColorRed="0" GraphColorGreen="191" GraphColorBlue="255" YMinSampled="-198" YMaxSampled="1806" YAvgSampled="0" Offset="10" ShowInGraph="1" YOffset="200" IsAutoConfig="1" YResolution="1000" MaxValue="2000" File="..\User\Src\motor_control.c" Scope="0" DrawStyle="0" />
+            </Symbol>
+            <Symbol>
+                <Options Name="IqFluxLessRef" Address="0x20000020" Type="int" TypeID="12" Size="4" GraphColorRed="0" GraphColorGreen="100" GraphColorBlue="0" YMinSampled="-99" YMaxSampled="903" YAvgSampled="-98" Offset="14" ShowInGraph="0" YOffset="200" IsAutoConfig="1" YResolution="500" MaxValue="1000" File="..\User\Src\MC_FOC_Driver.c" Scope="1" DrawStyle="0" />
+            </Symbol>
+            <Symbol>
+                <Options Name="IdFluxLessRef" Address="0x2000001C" Type="int" TypeID="12" Size="4" GraphColorRed="0" GraphColorGreen="191" GraphColorBlue="255" YMinSampled="-420" YMaxSampled="0" YAvgSampled="0" Offset="18" ShowInGraph="1" YOffset="200" IsAutoConfig="1" YResolution="500" MaxValue="1000" File="..\User\Src\MC_FOC_Driver.c" Scope="1" DrawStyle="0" />
+            </Symbol>
+            <Symbol>
+                <Options Name="ADC1_Result[1]" Address="0x200015AE" Type="ushort" TypeID="11" Size="2" GraphColorRed="0" GraphColorGreen="100" GraphColorBlue="0" YMinSampled="2700" YMaxSampled="3260" YAvgSampled="3074" Offset="22" ShowInGraph="1" YOffset="0" IsAutoConfig="0" YResolution="500" MaxValue="4000" File="..\Core\Src\adc.c" Scope="0" DrawStyle="0" />
+            </Symbol>
+        </SelectedSymbols>
     </Project>
 </JScopeProject>

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 2332 - 2332
MDK-ARM/QD007A_CTL_APP/QD007A_CTL_APP_CRC.hex


BIN
MDK-ARM/bin/QD007A_CTL_APP.bin


+ 5 - 1
User/Src/MC_FOC_Driver.c

@@ -47,7 +47,11 @@ void FOC_Model(int16_t Ref, int16_t MotorSpeed, uint16_t SVM_Angle)	  //
 	if( ADC1_Result[ADC1_RANK_VIN] < 3100) //55648mV  17.951  3100
 	{
 		IqFluxLessRef = Ref;
-		IdFluxLessRef = 0;
+		if(IdFluxLessRef<(-4))
+		{
+			IdFluxLessRef += 4;
+		}
+		else IdFluxLessRef = 0;			
 	}
 	else if( ADC1_Result[ADC1_RANK_VIN] < 3310 ) //59417mV 3310
 	{

+ 69 - 78
User/Src/motor_control.c

@@ -228,16 +228,17 @@ int16_t SpeedSet = 0;	// 
 uint32_t accStep = 0;	// 加速时间步进
 uint32_t decStep = 0;	// 减速时间步进
 int16_t SpeedSetReal = 0;	// 速度设定真实值
-
+int32_t Ref_Speed_Temp_End = 0; //速度环最终输出
+FlagStatus ExitGasModeFlag = RESET;
 /*指拨模式相关变量*/
 
 //指拨模式处理
 MC_CalParam_Struct_t MC_AssistRunMode_Gas_Process(uint16_t SensorData, MC_GearSt_Struct_t GearSt)
 {
 	int32_t Tmp;
-	int16_t TorQueBySpd = 0;
+	static int16_t TorQueBySpd = 0;
 	int32_t Ref_Speed_Temp;
-	int16_t SpdMotorByIdc = 0;
+	static int16_t SpdMotorByIdc = 0;
 	
 	MC_CalParam_Struct_t p_MC_CalParam = {MC_AssistRunMode_INVALID, 0,	0, RESET};
 	
@@ -245,16 +246,15 @@ MC_CalParam_Struct_t MC_AssistRunMode_Gas_Process(uint16_t SensorData, MC_GearSt
 
 	/*车轮速度使用原始数据,滤波后的数据有滞后,影响控制回路*/
 	wheelSpeed = (int16_t)MC_SpeedSensorData.Speed_Data;
-	
-	/*实时计算电机转速与车轮速的比值*/
-	SpdMotorDivWheel = 	(uint32_t)(MC_RunInfo.MotorSpeed * 100) / wheelSpeed ;
-	Tmp = SpdMotorDivWheel;
-	SpdMotorDivWheelFlt += ((Tmp << 8) - SpdMotorDivWheelFlt) >> 6;
-	SpdMotorDivWheelFlted = SpdMotorDivWheelFlt >> 8;
-	
+
 	/*在电机转速与车轮速比值,与实际速比一致时,更新速比*/
 	if(( MC_RunInfo.MotorSpeed > 100 ) && ( wheelSpeed > 0 ))
 	{
+		/*实时计算电机转速与车轮速的比值*/
+		SpdMotorDivWheel = 	(uint32_t)(MC_RunInfo.MotorSpeed * 100) / wheelSpeed ;
+		Tmp = SpdMotorDivWheel;
+		SpdMotorDivWheelFlt += ((Tmp << 8) - SpdMotorDivWheelFlt) >> 6;
+		SpdMotorDivWheelFlted = SpdMotorDivWheelFlt >> 8;
 		/*加速时,更新速比,比较法*/
 		if((wheelSpeed - wheelSpeedPre ) > 5)
 		{
@@ -296,12 +296,9 @@ MC_CalParam_Struct_t MC_AssistRunMode_Gas_Process(uint16_t SensorData, MC_GearSt
 
 	/*电机最高速度,上位机配置参数*/
 	SpeedMax = MC_MotorParam.Rate_Speed;
-	Tmp = SensorData + 50 ;  //加50偏移量,确保能达到最大值2048
+	Tmp = SensorData-50;  //指拨100启动,减去50能控低速
 	Tmp = Tmp > 2048 ? 2048 : Tmp; 
-	
-	/*调试用,根据车速限速值,换算指拨对应的设定车速*/
-	dbSpdWheelSet = (Tmp * MC_ConfigParam1.SpeedLimit * 10 )>> 11;	
-
+	Tmp = (Tmp*Tmp)/2048;   //指拨值改为抛物线,低速控制行程变大
 	/*电机转速设定,根据指拨大小、车轮限速值和速比,换算*/
 	SpeedSet = ((Tmp * MC_ConfigParam1.SpeedLimit  * SpdProportion) / 10  >> 11);			//(Tmp >> 11) * cd_Speedlimit * ( SpdProportion / 10)
 	
@@ -318,25 +315,24 @@ MC_CalParam_Struct_t MC_AssistRunMode_Gas_Process(uint16_t SensorData, MC_GearSt
 	switch (GearSt & 0x0F)
 	{
 		case 0x01:
-			accStep = StepCalc(SpeedMax, 1, 6500);
+			accStep = StepCalc(SpeedMax, 1, 2000);
 			break;
 		case 0x02:
-			accStep = StepCalc(SpeedMax, 1, 6000);
+			accStep = StepCalc(SpeedMax, 1, 1500);
 			break;
 		case 0x03:
-			accStep = StepCalc(SpeedMax, 1, 5500);
+			accStep = StepCalc(SpeedMax, 1, 1000);
 			break;
 		case 0x04:
-			accStep = StepCalc(SpeedMax, 1, 5000);
+			accStep = StepCalc(SpeedMax, 1, 500);
 			break;
 		default:
 			/*计算周期1ms, 加减速时间为 5.00s  加减速步进计算*/
-			accStep = StepCalc(SpeedMax, 1, 5000);
+			accStep = StepCalc(SpeedMax, 1, 1000);
 			break;
 	}
-	
 	/*减速步进*/
-	decStep = StepCalc(SpeedMax, 1, 5500);
+	decStep = StepCalc(SpeedMax, 1, 1000);
 
 	/* 跟踪启动 */
 	if(MC_CalParam.Foc_Flag  == RESET)			
@@ -377,58 +373,15 @@ MC_CalParam_Struct_t MC_AssistRunMode_Gas_Process(uint16_t SensorData, MC_GearSt
 	
 	#endif
 
-	/*限制母线电流*/
-	#if 0 //根据档位设定最大电流,电流环在内环,不稳定
-	
-	static uint16_t CurrentLimitPresent;     //限流实际值,做升降速处理
-	uint16_t CurrentLimitSet;                //限流设置值,不同助力档位更新
-
-	switch(GearSt & 0x0F)
-	{
-	  case 0x01://ECO
-		{
-		  CurrentLimitSet = (uint32_t)(MC_AssisParam.Gear_ECO.CurrentMax_K * MC_ConfigParam1.CurrentLimit * 1000 >> 17);
-			CurrentLimitPresent = MC_DataSet_Linear_Process(CurrentLimitSet, CurrentLimitPresent, 5 ,1);
-			break;
-		}
-		case 0x02://NORM
-		{
-		  CurrentLimitSet = (uint32_t)(MC_AssisParam.Gear_NORM.CurrentMax_K * MC_ConfigParam1.CurrentLimit * 1000 >> 17);
-			CurrentLimitPresent = MC_DataSet_Linear_Process(CurrentLimitSet, CurrentLimitPresent, 5 ,1);
-			break;
-		}
-		case 0x03://SPORT
-		{
-		  CurrentLimitSet = (uint32_t)(MC_AssisParam.Gear_SPORT.CurrentMax_K * MC_ConfigParam1.CurrentLimit * 1000 >> 17);
-			CurrentLimitPresent = MC_DataSet_Linear_Process(CurrentLimitSet, CurrentLimitPresent, 5 ,1);
-			break;
-		}
-		case 0x04://TURBO			
-		{
-		  CurrentLimitSet = (uint32_t)(MC_AssisParam.Gear_TURBO.CurrentMax_K * MC_ConfigParam1.CurrentLimit * 1000 >> 17);
-			CurrentLimitPresent = MC_DataSet_Linear_Process(CurrentLimitSet, CurrentLimitPresent, 5 ,1);
-			break;
-		}
-		default://SMART
-		{
-		  CurrentLimitSet = (uint32_t)(MC_AssisParam.Gear_SMART.CurrentMax_K * MC_ConfigParam1.CurrentLimit * 1000 >> 17);
-			CurrentLimitPresent = MC_DataSet_Linear_Process(CurrentLimitSet, CurrentLimitPresent, 5 ,1);
-			break;
-		}
-	}
-	SpdMotorByIdc = PID_Regulator(CurrentLimitPresent, MC_RunInfo.BusCurrent >> 7, &PID_ConstantPower);
-	
-	#else
-	
-	SpdMotorByIdc = PID_Regulator((MC_ConfigParam1.CurrentLimit * 1000) >> 7, MC_RunInfo.BusCurrent >> 7, &PID_ConstantPower);
-	
-	#endif
-	
 	/* 电机速度闭环 */
 	//最大力矩为4档的力矩参数
-	TorQueBySpd = PID_Regulator(SpeedSetReal, MC_HallSensorData.motorspeed_RCFlt, &PID_MotorSpd);
-
-	TorQueBySpd += SpdMotorByIdc;
+	PID_MotorSpd.hLower_Limit_Output = -200;
+	PID_MotorSpd.hUpper_Limit_Output = 2100;
+	TorQueBySpd = PID_Regulator(SpeedSetReal>>1, MC_HallSensorData.motorspeed_RCFlt>>1, &PID_MotorSpd);
+	PID_MotorSpd.hLower_Limit_Output = -100;
+	PID_MotorSpd.hUpper_Limit_Output = 1050;	
+	/*限制母线电流*/
+	SpdMotorByIdc = PID_Regulator((MC_ConfigParam1.CurrentLimit * 1000) >> 7, MC_RunInfo.BusCurrent >> 7, &PID_ConstantPower);
 	
 	#if 1
 	static uint16_t K_ByVoltage_Set_Old = 1024;
@@ -455,6 +408,29 @@ MC_CalParam_Struct_t MC_AssistRunMode_Gas_Process(uint16_t SensorData, MC_GearSt
 	
 	#endif
 	
+
+	
+	Ref_Speed_Temp = ((int32_t)TorQueBySpd * K_ByVoltage_Result) >> 10;
+	Ref_Speed_Temp = ((int32_t)Ref_Speed_Temp * K_ByTemperature_Result) >> 10;
+	
+	if(ExitGasModeFlag == RESET)
+	{
+		if((Ref_Speed_Temp - Ref_Speed_Temp_End) > 2)
+		{
+			Ref_Speed_Temp_End += 2;
+		}
+		else if((Ref_Speed_Temp - Ref_Speed_Temp_End) < (-3))
+		{
+			Ref_Speed_Temp_End -= 3;
+		}
+	}
+	else
+	{
+		if( Ref_Speed_Temp_End > 10) Ref_Speed_Temp_End -= 9;
+		else ExitGasModeFlag = RESET;
+	}
+	
+	if(Ref_Speed_Temp_End < -200) Ref_Speed_Temp_End=-200;
 	//速度环控制量为0时停机,防止电机出现异响
 	if(SpeedSetReal == 0)
 	{
@@ -466,10 +442,7 @@ MC_CalParam_Struct_t MC_AssistRunMode_Gas_Process(uint16_t SensorData, MC_GearSt
 		MC_MotorStar(&MC_StarFlag);
 	}
 	
-	Ref_Speed_Temp = ((int32_t)TorQueBySpd * K_ByVoltage_Result) >> 10;
-	Ref_Speed_Temp = ((int32_t)Ref_Speed_Temp * K_ByTemperature_Result) >> 10;
-
-	p_MC_CalParam.Ref_Speed = (int16_t)(Ref_Speed_Temp);
+	p_MC_CalParam.Ref_Speed = (int16_t)((Ref_Speed_Temp_End+SpdMotorByIdc)>>1);
 	p_MC_CalParam.Foc_Flag = SET;
 	p_MC_CalParam.AssistRunMode = MC_AssistRunMode_GAS;
 	
@@ -1268,8 +1241,26 @@ void MC_CalParam_Cal(MC_WorkMode_Struct_t p_MC_WorkMode, \
 	  	MC_AssistRunMode_Temp = MC_AssistRunMode_INVALID;
 			MC_AssistRunMode_ShiftFlag = SET;
 			
-			SpeedSetMiddle = 0;  //指拨模式,清零速度中间量
-			SpdMotorDivWheelFlt = 0;
+			
+			if(p_MC_CalParam->AssistRunMode==MC_AssistRunMode_GAS) //退出指拨模式
+			{
+				if(Ref_Speed_Temp_End > 20)
+				{
+					MC_AssistRunMode_Temp = MC_AssistRunMode_GAS;
+					MC_AssistRunMode_ShiftFlag = RESET;	
+					ExitGasModeFlag = SET;
+				}
+				else
+				{
+					SpdMotorDivWheelFlt = 0;
+					SpeedSetMiddle = 0;
+					SpeedSetReal = 0;
+					Ref_Speed_Temp_End=0;
+					ExitGasModeFlag = RESET;
+					MC_AssistRunMode_Temp = MC_AssistRunMode_INVALID;
+					MC_AssistRunMode_ShiftFlag = SET;
+				}
+			}
 		}
 	}
 	//助力模式处理

+ 2 - 2
User/Src/var.c

@@ -503,9 +503,9 @@ void Var_Init(void)
 	strncpy(MC_VerInfo.HW_Version, (char*)"TTKZ010D.       ", 16);
 	
 	#if BaudRate250K
-  strncpy(MC_VerInfo.FW_Version, (char*)"V7r2r0_20221108C", 16);
+  strncpy(MC_VerInfo.FW_Version, (char*)"V7r2r0_20221110C", 16);
 	#else
-	strncpy(MC_VerInfo.FW_Version, (char*)"V3r4r0_20221108C", 16);
+	strncpy(MC_VerInfo.FW_Version, (char*)"V3r4r0_20221110C", 16);
 	#endif
 	
   #if NormalWork

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.