Browse Source

V3.2.3_20210108 TC013003-MW2002-V0r3
1、调整母线电压测量的分压系数;
2、增加尾灯作刹车灯的控制方式,提供两种控制模式,一是作行驶灯是低亮,刹车时高亮,二是作行驶灯时高亮,刹车时闪烁;
3、灯的控制放到tim.c中运行;
4、V3.2.3_20210108 TC013003-MW2002-V0r3

dail.zhou 4 years ago
parent
commit
2096e491a7

+ 1 - 1
Core/Src/adc.c

@@ -479,7 +479,7 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
 	
 	//更新母线电压 
 	BusVoltageFltSum += ((ADC1_Result[ADC1_RANK_VIN] << 10) - BusVoltageFltSum) >> 9;
-	MC_RunInfo.BusVoltage = (uint32_t)((BusVoltageFltSum >> 10) * 18382) >> 10;//3300 * 1047 / (4095 * 47)
+	MC_RunInfo.BusVoltage = (uint32_t)((BusVoltageFltSum >> 10) * 18000) >> 10;//3300 * 1047 / (4095 * 47)
 	MC_RunInfo.BusVoltage += (MC_RunInfo.BusCurrent >> 7) * 26; //根据母线电流和估算的线阻进行补偿, 补偿电阻 0.2 * 128 = 25.6
 	
 	//更新母线电流

+ 3 - 3
Core/Src/main.c

@@ -205,7 +205,7 @@ int main(void)
 	
 	//初始化完成标志
 	IsInitFinish_Flag = TRUE;
-
+	
   /* USER CODE END 2 */
 
   /* Infinite loop */
@@ -258,8 +258,8 @@ int main(void)
 			//检测刹车信号
 			Break_Check(&IsBreakTrig_Flag);
 			
-			//Light控制
-			LightDriver_Process(MC_ControlCode.LightSwitch);
+//			//Light控制
+//			LightDriver_Process(IsBreakTrig_Flag, MC_ControlCode.LightSwitch);
 			
 			//续航里程计算
 			if(HAL_GetTick() > 2000)

BIN
MDK-ARM/bin/MC_PSX000-TC013003-MW2002-V3.2.3.0.3_20210108.bin


BIN
MDK-ARM/bin/QD007A_CTL_APP.bin


+ 1 - 1
User/Inc/light_driver.h

@@ -10,6 +10,6 @@
 #define LIGHT_B_GPIO_Port GPIOA
 
 void LightDriver_Init(void);
-void LightDriver_Process(MC_LightSwitch_Struct_t LightSwitchCode);
+void LightDriver_Process(TrueOrFalse_Flag_Struct_t IsBreakFlag, MC_LightSwitch_Struct_t LightSwitchCode);
 
 #endif

+ 74 - 4
User/Src/light_driver.c

@@ -25,16 +25,86 @@ void LightDriver_Init(void)
   HAL_GPIO_Init(LIGHT_B_GPIO_Port, &GPIO_InitStruct);
 }
 
-void LightDriver_Process(MC_LightSwitch_Struct_t LightSwitchCode)
+void LightDriver_Process(TrueOrFalse_Flag_Struct_t IsBreakFlag, MC_LightSwitch_Struct_t LightSwitchCode)
 {
-  if(LightSwitchCode == MC_LightSwitch_ON)
+  if(HAL_GetTick() < 3000)
+	{
+	  return;
+	}
+	
+	//前灯
+	if(LightSwitchCode == MC_LightSwitch_ON)
 	{
 		HAL_GPIO_WritePin(LIGHT_F_GPIO_Port, LIGHT_F_Pin, GPIO_PIN_SET);
-		HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
 	}
 	else if(LightSwitchCode == MC_LightSwitch_OFF)
 	{
 		HAL_GPIO_WritePin(LIGHT_F_GPIO_Port, LIGHT_F_Pin, GPIO_PIN_RESET);
-		HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
+	}
+	
+	//尾灯
+	static uint16_t FlashTimeCnt = 0;
+	if(strncmp("FLASH", (char*)UserString2, 5) == 0)//利用UserString2作为尾灯刹车时显示状态
+	{
+		if(IsBreakFlag == TRUE)//刹车时,快闪
+		{
+			if(FlashTimeCnt < 600)
+			{
+				HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
+			}
+			else if(FlashTimeCnt < 1200)
+			{
+				HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
+			}
+			else
+			{
+				FlashTimeCnt = 0;
+			}
+			FlashTimeCnt++;
+		}
+		else//无刹车时,开灯亮
+		{
+			if(LightSwitchCode == MC_LightSwitch_ON)
+			{
+				HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
+			}
+			else if(LightSwitchCode == MC_LightSwitch_OFF)
+			{
+				HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
+			}
+			FlashTimeCnt = 0;
+		}	
+	}
+	else
+	{
+		if(IsBreakFlag == TRUE)//刹车时,高亮
+		{
+			HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
+			FlashTimeCnt = 0;
+		}
+		else//无刹车时,开灯低亮
+		{
+			if(LightSwitchCode == MC_LightSwitch_ON)
+			{
+				if(FlashTimeCnt < 138)
+				{
+					HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
+				}
+				else if(FlashTimeCnt < 200)
+				{
+					HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
+				}
+				else
+				{
+					FlashTimeCnt = 0;
+				}
+				FlashTimeCnt++;
+			}
+			else if(LightSwitchCode == MC_LightSwitch_OFF)
+			{
+				HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
+				FlashTimeCnt = 0;
+			}
+		}
 	}
 }

+ 5 - 0
User/Src/tim.c

@@ -43,6 +43,8 @@
 #include "MC_Globals.h"
 #include "MC_FOC_Driver.h"
 #include "protect_check.h"
+#include "light_driver.h"
+#include "key_driver.h"
 
 /* USER CODE END 0 */
 
@@ -385,6 +387,9 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
 	}
 	#endif
 	
+	//Light¿ØÖÆ
+	LightDriver_Process(IsBreakTrig_Flag, MC_ControlCode.LightSwitch);
+	
 	//ADC²É¼¯·ÖƵ
 	ADC_PreCnt++;
 	if(ADC_PreCnt >= 5)

+ 2 - 2
User/Src/var.c

@@ -490,8 +490,8 @@ void Var_Init(void)
 		
 	//MC版本信息初始化,Mode和SN从EEPROM读取
   strncpy(MC_VerInfo.HW_Version, (char*)"TT_KZ_010D.     ", 16);
-	strncpy(MC_VerInfo.FW_Version, (char*)"V3r2r3_20210107.", 16);
-	strncpy(Firmware_Special, (char*)"TC013003-MW2002-V0r2.           ", 32);
+	strncpy(MC_VerInfo.FW_Version, (char*)"V3r2r3_20210108.", 16);
+	strncpy(Firmware_Special, (char*)"TC013003-MW2002-V0r3.           ", 32);
 	
 	//电机型号
 	strncpy(MC_VerInfo.Mode, (char*)"PG8000 & PSX000.", 16);

+ 5 - 1
修改说明.txt

@@ -350,7 +350,11 @@ V3.2.3_20210107 TC013003-MW2002-V0r2
 4、修改过热保护的判断条件;
 5、V3.2.3_20210107 TC013003-MW2002-V0r2。
 
-
+V3.2.3_20210108 TC013003-MW2002-V0r3
+1、调整母线电压测量的分压系数;
+2、增加尾灯作刹车灯的控制方式,提供两种控制模式,一是作行驶灯是低亮,刹车时高亮,二是作行驶灯时高亮,刹车时闪烁;
+3、灯的控制放到tim.c中运行;
+4、V3.2.3_20210108 TC013003-MW2002-V0r3