Sfoglia il codice sorgente

MC_VS7500 TC013039-MB2002&3-V0r1
1、修改转把模式电机转速为最高转速235rpm;
2、转把模式断电速度为8km/h;
3、删除转把模式传动比计算;
4、版本号:MC_VS7500 客户特性描述:TC013039-MB2002&3-V0r1

dail.zhou 4 anni fa
parent
commit
fd7dbb27f9

+ 3 - 3
Core/Src/main.c

@@ -206,6 +206,9 @@ int main(void)
 	//初始化完成标志
 	IsInitFinish_Flag = TRUE;
 
+  //根据客户需求设定参数
+	MC_ConfigParam1.GasCtrlMode_Flag = MC_SUPPORT_ENABLE;
+
   /* USER CODE END 2 */
 
   /* Infinite loop */
@@ -324,9 +327,6 @@ int main(void)
 			//定时发送传感器数据给TE
 			MC_TE_SensorData_Process(&MC_TE_SensorData);
 			
-			//指拨模式计算函数
-			SpdProportion_calculate();
-			
       //车姿态处理函数
 		  BikeAttitude_Process();
 

BIN
MDK-ARM/bin/MC_VS7500-TC013039-MB2002&3-V2.1.6.0.1_20201211.bin


BIN
MDK-ARM/bin/QD007A_CTL_APP.bin


+ 0 - 1
User/Inc/motor_control.h

@@ -98,5 +98,4 @@ extern void MC_CalParam_Cal(MC_WorkMode_Struct_t p_MC_WorkMode,\
                             MC_CalParam_Struct_t* p_MC_CalParam);
 extern void MC_MotorStar(FlagStatus* StarFlag);
 extern void MC_MotorStop(FlagStatus* StarFlag);
-extern void SpdProportion_calculate(void);
 #endif

+ 11 - 176
User/Src/motor_control.c

@@ -207,25 +207,7 @@ MC_AssistRunMode_Struct_t MC_JudgeAsistRunMode_Process(MC_SupportFlag_Struct_t G
 }
 
 /*指拨模式相关变量*/
-
-static int32_t SpdMotorDivWheelFlt=0;
-int16_t SpdProportion=490; //车轮电机速度比
-static uint16_t SpdProportion_buff_CNT=0;
-uint8_t  SpdProportion_CAL_flag=0;
-static uint16_t SpdProportion_Save_CNT=0;
-uint16_t SpdProportion_buff[100]={0};
-float SpdProportion_StandardDeviation=0;
-int32_t test_StandardDeviation=0;
-uint16_t test_SpdProportionAver=0;
 int32_t SpeedSetMiddle=0;
-int16_t dbSpdWheelSet=0;  //调试用
-
-int16_t wheelSpeed=0;
-static int16_t DbSpdMotorPre=0;
-static int16_t wheelSpeedPre=0;
-int16_t SpdMotorDivWheel=0;
-int16_t SpdMotorDivWheelFlted=0;
-int16_t SpeedMax = 0;	// 最高时速
 int16_t SpeedSet = 0;	// 速度设定值
 uint32_t accStep = 0;	// 加速时间步进
 uint32_t decStep = 0;	// 减速时间步进
@@ -240,75 +222,18 @@ MC_CalParam_Struct_t MC_AssistRunMode_Gas_Process(uint16_t SensorData, MC_GearSt
 	int16_t TorQueBySpd = 0;
 	int32_t Ref_Speed_Temp;
 	int16_t SpdMotorByIdc = 0;
+	uint16_t SpeedMax = 235;
 	
 	MC_CalParam_Struct_t p_MC_CalParam = {MC_AssistRunMode_INVALID, 0,	0, RESET};
 	
-  //...插入指拨处理
-
-	/*车轮速度使用原始数据,滤波后的数据有滞后,影响控制回路*/
-	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 ))
-	{
-		/*加速时,更新速比,比较法*/
-		if((wheelSpeed - wheelSpeedPre ) > 5)
-		{
-			if(( MC_RunInfo.MotorSpeed - DbSpdMotorPre ) > 0)
-			{
-				SpdProportion = SpdMotorDivWheel ;
-			}
-			DbSpdMotorPre = MC_RunInfo.MotorSpeed;
-		}
-		wheelSpeedPre = wheelSpeed;
-			
-		/*求标准差,速比稳定后,更新速比*/
-		/*此处将数据保存到数组中,标准差计算,时间较长,放在主循环进行*/
-		if((SpdProportion_CAL_flag==0) && (MC_CalParam.Ref_Speed > 25))  //电机力矩控制量低于25时,认为是空载,此时不更新速比
-		{
-			SpdProportion_Save_CNT++;
-			/*40ms保存一次数据到数组*/
-			if(SpdProportion_Save_CNT >= 40 )
-			{
-				SpdProportion_Save_CNT = 0;
-				
-				SpdProportion_buff[SpdProportion_buff_CNT] = SpdMotorDivWheelFlted;
-				SpdProportion_buff_CNT++;
-				if( SpdProportion_buff_CNT >=50 )
-				{
-					SpdProportion_buff_CNT = 0;
-					
-					/*标志位置1,主循环里求标准差*/
-					SpdProportion_CAL_flag = 1;
-				}
-			}
-		}
-	}
-	else
-	{
-	  wheelSpeedPre = wheelSpeed;
-		DbSpdMotorPre = MC_RunInfo.MotorSpeed;
-	}
-
-	/*电机最高速度,上位机配置参数*/
-	SpeedMax = MC_MotorParam.Rate_Speed;
 	Tmp = SensorData + 50 ;  //加50偏移量,确保能达到最大值2048
 	Tmp = Tmp > 2048 ? 2048 : Tmp; 
 	
-	/*调试用,根据车速限速值,换算指拨对应的设定车速*/
-	dbSpdWheelSet = (Tmp * MC_ConfigParam1.SpeedLimit * 10 )>> 11;	
-
 	/*电机转速设定,根据指拨大小、车轮限速值和速比,换算*/
-	SpeedSet = ((Tmp * MC_ConfigParam1.SpeedLimit  * SpdProportion) / 10  >> 11);			//(Tmp >> 11) * cd_Speedlimit * ( SpdProportion / 10)
-	
+	SpeedSet = (Tmp * SpeedMax >> 11);//马达最高转速200rpm
+		
 	//超过限速值,设定电机转速为0
-	if(wheelSpeed > (MC_ConfigParam1.SpeedLimit * 10 + 20))
+	if(MC_RunInfo.BikeSpeed > (8 * 10))
 	{
 		SpeedSet = 0;
 	}
@@ -320,16 +245,16 @@ 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, 6912);
 			break;
 		case 0x02:
-			accStep = StepCalc(SpeedMax, 1, 6000);
+			accStep = StepCalc(SpeedMax, 1, 5760);
 			break;
 		case 0x03:
-			accStep = StepCalc(SpeedMax, 1, 5500);
+			accStep = StepCalc(SpeedMax, 1, 4800);
 			break;
 		case 0x04:
-			accStep = StepCalc(SpeedMax, 1, 5000);
+			accStep = StepCalc(SpeedMax, 1, 4000);
 			break;
 		default:
 			/*计算周期1ms, 加减速时间为 5.00s  加减速步进计算*/
@@ -343,7 +268,6 @@ MC_CalParam_Struct_t MC_AssistRunMode_Gas_Process(uint16_t SensorData, MC_GearSt
 	/* 跟踪启动 */
 	if(MC_CalParam.Foc_Flag  == RESET)			
 	{
-		//MotorStartFlg = 1;
 		if(MC_RunInfo.MotorSpeed > 100)
 		{
 			SpeedSetReal = MC_RunInfo.MotorSpeed;
@@ -351,83 +275,13 @@ MC_CalParam_Struct_t MC_AssistRunMode_Gas_Process(uint16_t SensorData, MC_GearSt
 		}
 	}
 		
-	/*速度指令的加减速处理*/
-	#if 1  //根据档位设定最高速度
-	
-	switch(GearSt & 0x0F)
-	{
-	  case 0x01:
-			SpeedSetReal = accDecProcess((SpeedSet * 9) >> 4, accStep, decStep, &SpeedSetMiddle);  
-			break;
-		case 0x02:
-			SpeedSetReal = accDecProcess((SpeedSet * 11) >> 4, accStep, decStep, &SpeedSetMiddle);  
-			break;
-		case 0x03:
-			SpeedSetReal = accDecProcess((SpeedSet * 13) >> 4, accStep, decStep, &SpeedSetMiddle);  
-			break;
-		case 0x04:
-			SpeedSetReal = accDecProcess(SpeedSet, accStep, decStep, &SpeedSetMiddle);  
-			break;
-		default:
-			SpeedSetReal = accDecProcess(SpeedSet, accStep, decStep, &SpeedSetMiddle);  
-			break;
-	}
-	
-	#else
-	
+	//速度指令的加减速处理
 	SpeedSetReal = accDecProcess(SpeedSet, accStep, decStep, &SpeedSetMiddle);  
-	
-	#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档的力矩参数
+	//电机速度闭环
 	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_RunInfo.MotorSpeed, &PID_MotorSpd);
@@ -1263,7 +1117,6 @@ void MC_CalParam_Cal(MC_WorkMode_Struct_t p_MC_WorkMode, \
 			MC_AssistRunMode_ShiftFlag = SET;
 			
 			SpeedSetMiddle = 0;  //指拨模式,清零速度中间量
-			SpdMotorDivWheelFlt = 0;
 		}
 	}
 	//助力模式处理
@@ -1359,21 +1212,3 @@ void MC_MotorStar(FlagStatus* StarFlag)
 		*StarFlag = SET;
 	}
 }	
-
-/*
-指拨模式计算速比,计算费时,在主循环调用
-*/
-void SpdProportion_calculate(void)
-{
-	if(SpdProportion_CAL_flag==1)
-	{
-		SpdProportion_StandardDeviation = Standard_deviation_aver(SpdProportion_buff, 50, &test_SpdProportionAver);
-		test_StandardDeviation = (int32_t)(SpdProportion_StandardDeviation );
-		SpdProportion_CAL_flag = 0;
-		/*更新速比*/
-		if(test_StandardDeviation < 30)
-		{
-			SpdProportion = test_SpdProportionAver;
-		}
-	}
-}

+ 2 - 3
User/Src/tasks.c

@@ -60,9 +60,6 @@ void HAL_SYSTICK_Callback(void)
 		TorqueOffSetData_Present_Update(&TorqueOffSetData.PresentData, ADC1_Result[ADC1_RANK_TORQUE_SENSOR], MC_TorqueCorrectParam.K, &MC_ErrorCode);
 	}
 		
-	//更新指拨零点值
-	GasSensorOffSetData_Update(&GasSensor_OffSet, ADC1_Result[ADC1_RANK_GAS], &MC_ErrorCode);
-	
 	//ADC数据滑动滤波计算
 	ADC_SensorData_Filt(ADC1_Result_Filt, ADC2_Result_Filt);
 	
@@ -83,6 +80,8 @@ void HAL_SYSTICK_Callback(void)
 	{
 	  TimeCnt_10ms = 0;
 
+		//更新指拨零点值
+	  GasSensorOffSetData_Update(&GasSensor_OffSet, ADC1_Result[ADC1_RANK_GAS], &MC_ErrorCode);
 	}
 	
 	//50ms任务

+ 3 - 3
User/Src/var.c

@@ -489,11 +489,11 @@ void Var_Init(void)
 		
 	//MC版本信息初始化,Mode和SN从EEPROM读取
   strncpy(MC_VerInfo.HW_Version, (char*)"QD007H.         ", 16);
-	strncpy(MC_VerInfo.FW_Version, (char*)"V2r1r6_20201203.", 16);
-	strncpy(Firmware_Special, (char*)"TC011000-MS0000-V0r0.           ", 32);
+	strncpy(MC_VerInfo.FW_Version, (char*)"V2r1r6_20201211.", 16);
+	strncpy(Firmware_Special, (char*)"TC013039-MB2002&3-V0r1.         ", 32);
 		
 	//电机型号
-	strncpy(MC_VerInfo.Mode, (char*)"VL6500 & VS7500.", 16);
+	strncpy(MC_VerInfo.Mode, (char*)"VS7500.", 16);
 	
 	//电机序列号
 	strncpy(MC_VerInfo.SN_Num, (char*)"0000000000000000", 16);

+ 5 - 1
修改说明.txt

@@ -346,7 +346,11 @@ V2.1.6_20201203
 1、修改刹车和GearSensor信号的检测方法,增加延时,避免信号抖动引起异常停机;
 2、版本号:V2.1.6_20201203
 
-
+MC_VS7500 TC013039-MB2002&3-V0r1
+1、修改转把模式电机转速为最高转速235rpm;
+2、转把模式断电速度为8km/h;
+3、删除转把模式传动比计算;
+4、版本号:MC_VS7500 客户特性描述:TC013039-MB2002&3-V0r1