Jelajahi Sumber

平峰项目测试软件

CHENJIE-PC\QiXiang_CHENJIE 2 tahun lalu
induk
melakukan
00a84794aa
7 mengubah file dengan 61 tambahan dan 15 penghapusan
  1. 5 3
      src/AppGlobalVar.c
  2. 5 3
      src/AppGlobalVar.h
  3. 31 1
      src/AppTaskCan.c
  4. 1 1
      src/AppTaskCan.h
  5. 2 2
      src/AppTaskUart1.c
  6. 13 1
      src/hal_adapter.c
  7. 4 4
      src/main.c

+ 5 - 3
src/AppGlobalVar.c

@@ -71,11 +71,10 @@ uint32 bmsSwVersion = 0;
 uint16 battCellU[BMS_CELLNUM];	 //电池电压
 uint16 battI = 0;				 // BMS电流(tcp上传)
 uint16 battPackVol = 0;			 // bms电压
-
 uint16 maxCellVol = 0;			 //最大单体电压
 uint16 minCellVol = 0;			 //最小单体电压
-uint16 socd_pct_vcuSoc = 0;		 // soc(tcp上传,精度0.1)
-uint16 sohd_pct_bcuSoh = 0;		 // soh(tcp上传,精度0.1)
+//uint16 socd_pct_vcuSoc = 0;		 // soc(tcp上传,精度0.1)
+//uint16 sohd_pct_bcuSoh = 0;		 // soh(tcp上传,精度0.1)
 uint32 battBalanceoInfo = 0;  //
 uint32 battProtectState = 0;	 // bms保护状态
 uint32 battWarningState = 0;	 // bms告警状态
@@ -98,4 +97,7 @@ uint8 battConverState = 0;
 uint8 battSeparateEnable = 0;
 uint8 battSeparateEnableState = 0;
 uint16 ErrorArray[5] = {0};
+
+//test
+uint32 BattTempR[4] = {0xFF};
 #endif

+ 5 - 3
src/AppGlobalVar.h

@@ -26,7 +26,7 @@
 #define HWVERSION 0x0001
 #define BLSWVERSION 0x00000001
 #define DRVSWVERSION 0x00000001
-#define APPSWVERSION 0x00000002
+#define APPSWVERSION 0x00000003
 #define BMS_MANUFACTURE 0xFF
 #define BMS_INFO 0xFF
 #define DATA_MODULE_TYPE 0x02
@@ -80,8 +80,8 @@ extern uint16 battPackVol;              // bms
 
 extern uint16 maxCellVol;               //最大单体电压
 extern uint16 minCellVol;               //最小单体电压
-extern uint16 socd_pct_vcuSoc;          // soc(tcp上传,精度0.1)
-extern uint16 sohd_pct_bcuSoh;          // soh(tcp上传,精度0.1)
+//extern uint16 socd_pct_vcuSoc;          // soc(tcp上传,精度0.1)
+//extern uint16 sohd_pct_bcuSoh;          // soh(tcp上传,精度0.1)
 extern uint32 battBalanceoInfo;
 extern uint32 battProtectState;         // bms保护状态
 extern uint32 battWarningState;         // bms告警状态
@@ -105,4 +105,6 @@ extern uint8 battSeparateEnable ;
 extern uint8 battSeparateEnableState ;
 extern uint16 ErrorArray[5];
 
+//test
+extern uint32 BattTempR[4];
 #endif /* APPGLOBALVAR_H_ */

+ 31 - 1
src/AppTaskCan.c

@@ -47,10 +47,40 @@ void CanTask(void *pvParameters)
 				}
 			}
 		}while(ret == pdPASS);
-		if(TimerCounter%100==0&&timerCounterNow!=TimerCounter)
+		if(TimerCounter%1000==0&&timerCounterNow!=TimerCounter)
 		{
 			timerCounterNow = TimerCounter;
+
+			//ζȲɼ¯
+			for (ADC_TP_Channel_Type channel = 0; channel < ChannelCounter; channel++)
+			{
+				ADC_ReadValue(channel, &BattTempR[channel]);
+			}
 		}
+//		if(BattTempR[1]==0x00)
+//		{
+//			Dio_WriteChannel(DioConf_DioChannel_PTD15_GPIO_OUT_MCU_BUZ_EN, STD_ON);
+//		}
+//		else
+//		{
+//			Dio_WriteChannel(DioConf_DioChannel_PTD15_GPIO_OUT_MCU_BUZ_EN, STD_OFF);
+//		}
+//		if(BattTempR[2]==0x00)
+//		{
+//			Dio_WriteChannel(DioConf_DioChannel_PTD16_GPIO_OUT_MCU_RELAY_POW_EN, STD_ON);
+//		}
+//		else
+//		{
+//			Dio_WriteChannel(DioConf_DioChannel_PTD16_GPIO_OUT_MCU_RELAY_POW_EN, STD_OFF);
+//		}
+//		if(BattTempR[3]==0x00)
+//		{
+//			Dio_WriteChannel(DioConf_DioChannel_PTA11_GPIO_OUT_MCU_BMS_WAKEUP_EN, STD_ON);
+//		}
+//		else
+//		{
+//			Dio_WriteChannel(DioConf_DioChannel_PTA11_GPIO_OUT_MCU_BMS_WAKEUP_EN, STD_OFF);
+//		}
 	}
 }
 //×¢Òâ½âÂ볬ÏÞÎÊÌâ

+ 1 - 1
src/AppTaskCan.h

@@ -13,5 +13,5 @@
 #include "UDSTask.h"
 #include "Hal_Wdg.h"
 void BcuDecodeFunction(uint32 ID, uint8 *rawData);
-
+void CanTask(void *pvParameters);
 #endif /* APPTASKCAN_H_ */

+ 2 - 2
src/AppTaskUart1.c

@@ -839,8 +839,8 @@ void TcpDataEncode(uint32 *PtrSendAddr, uint16 *SendLen)
 		*(SendBuffer + 45) = battPackVol >> 8;								 //µçѹ-46
 		*(SendBuffer + 46) = battPackVol & 0xFF;							 //µçѹ-47
 		*(SendBuffer + 47) = battMOSSwitchState;							 // mos״̬-48
-		*(SendBuffer + 48) = (uint8)(socd_pct_vcuSoc / 10);					 // soc-49
-		*(SendBuffer + 49) = (uint8)(sohd_pct_bcuSoh / 10);					 // soh-50
+		*(SendBuffer + 48) = (uint8)(battSOC);					 // soc-49
+		*(SendBuffer + 49) = (uint8)(battSOH);					 // soh-50
 		*(SendBuffer + 50) = (battBalanceoInfo >> 24) & 0xFF;
 		*(SendBuffer + 51) = (battBalanceoInfo >> 16) & 0xFF;
 		*(SendBuffer + 52) = (battBalanceoInfo >> 8) & 0xFF;

+ 13 - 1
src/hal_adapter.c

@@ -384,7 +384,19 @@
 	 REFL = Buffer[2];
 	 for(int i = 3; i < NUM_RESULTS; i++)
 	 {
-		 ConvertedValueR[i] = (TP_Value_Type)((float)(10000 * Buffer[i]/(float)(REFH - REFL))/(1-(float)(Buffer[i]/(float)(REFH - REFL))));
+//		 ConvertedValueR[i] = (TP_Value_Type)((float)(10000 * Buffer[i]/(float)(REFH - REFL))/(1-(float)(Buffer[i]/(float)(REFH - REFL))));
+		if(Buffer[i] >= REFH)
+		{
+		 ConvertedValueR[i] = 40930000;
+		}
+		else if(Buffer[i] <=REFL)
+		{
+			ConvertedValueR[i] = 0x00;
+		}
+		else
+		{
+		 ConvertedValueR[i] = (TP_Value_Type)((float)(10000 * (Buffer[i] - REFL)/(float)(REFH - REFL))/(1-(float)((Buffer[i]- REFL)/(float)(REFH - REFL))));
+		}
 	 }
  }
 

+ 4 - 4
src/main.c

@@ -131,10 +131,9 @@ int main(void)
 	{
 		// if so, the adc is failed to Calibrate;
 	}
-	TP_Value_Type value = 0;
 	for (ADC_TP_Channel_Type channel = 0; channel < ChannelCounter; channel++)
 	{
-		ADC_ReadValue(channel, &value);
+		ADC_ReadValue(channel, &BattTempR[channel]);
 	}
 
 	Boot_CheckDownlaodAPPStatus();
@@ -159,9 +158,10 @@ int main(void)
 	Dio_WriteChannel(DioConf_DioChannel_PTE9_GPIO_OUT_MCU_LED5, STD_OFF);
 
 	xTaskCreate(MainTask, (const char *const)"MainTask", 128, (void *)0, main_TASK_PRIORITY + 3, NULL);
-	xTaskCreate(Uart_4G_Task, (const char *const)"Uart_4G_Task", 2048, (void *)0, main_TASK_PRIORITY + 0, NULL);
-	xTaskCreate(Uart0Task, (const char *const)"Uart0_Bms_Task", 256, (void *)0, main_TASK_PRIORITY + 1, NULL);
+	xTaskCreate(Uart0Task, (const char *const)"Uart0_Bms_Task", 256, (void *)0, main_TASK_PRIORITY + 2, NULL);
+	xTaskCreate(CanTask, (const char *const)"CanTask", 512, (void *)0, main_TASK_PRIORITY + 2, NULL);
 	xTaskCreate(GpsTask, (const char *const)"GpsTask", 512, (void *)0, main_TASK_PRIORITY + 1, NULL);
+	xTaskCreate(Uart_4G_Task, (const char *const)"Uart_4G_Task", 2048, (void *)0, main_TASK_PRIORITY + 0, NULL);
 	vTaskStartScheduler();
 	for (;;)
 	{