Преглед изворни кода

测试版本V0.2.255.6,累计安时积分计算

LAPTOP-KB7QFH2U\ChenJie-PC пре 1 година
родитељ
комит
2b62be5122
4 измењених фајлова са 59 додато и 8 уклоњено
  1. 1 1
      code/app/AppGlobalVar.c
  2. 5 3
      code/app/AppGlobalVar.h
  3. 36 4
      code/app/AppTaskCan.c
  4. 17 0
      code/app/AppTaskUart1.c

+ 1 - 1
code/app/AppGlobalVar.c

@@ -35,7 +35,7 @@ uint16 WebSitePort = 8812;
 #endif
 
 //*全局变量*//
-const uint32 AppSwVersion = 0x00020005;
+const uint32 AppSwVersion = 0x0002FF06;
 const uint8 DataModuleType = 0x02; // 01=NB,02-4G
 const uint16 HwVersion = 0x0102;
 const uint32 BlSwVersion = 0x00000001;

+ 5 - 3
code/app/AppGlobalVar.h

@@ -79,8 +79,10 @@ extern uint8 TcpWorkState;
 extern uint8 DeviceErrNum;
 typedef struct _AppEppType
 {
-    uint32 battDischrgAccCap;
-    uint32 battDischrgAccEnrg;
+    uint32 battDischrgAccCap;//单位mah
+    uint32 battChrgAccCap;//单位mah
+    uint32 battDischrgAccEnrg;//单位wh
+    uint32 battChrgAccEnrg;//单位wh
     uint16 battCycleTimes;
     uint32 AccMileage;
 } AppEppBody;
@@ -90,7 +92,7 @@ typedef struct _AppConfigType
     bool eolFlg;
     uint8 deviceSn[17];
     AppEppBody AppDataInfo;
-    uint8 re[20];
+    uint8 re[128];
 } AppConfigBody;
 extern AppConfigBody AppConfigInfo;
 

+ 36 - 4
code/app/AppTaskCan.c

@@ -15,7 +15,7 @@ static uint8 BattSendFlg = 0;
 static void UDSAnsFunc(uint8 *rawData);
 static void UdsAns(bool PosFlg, uint8 UdsService, uint8 UdsSubService, uint8 Idx, uint8 *AnsData, uint8 AnsDataLen);
 static void BattSendFunc(void);
-
+static void CalAccAhFunc(void);
 void CanTask(void *pvParameters)
 {
 	uint32 timerCANIdle = 0x00;
@@ -66,7 +66,39 @@ void CanTask(void *pvParameters)
 			timerCANIdle = timerCANIdle + 100;
 			BcuRxDiagnose();
 			timerCounterNow = TimerCounter;
+			//累计放电Ah和充电Ah积分计算
+			CalAccAhFunc();
+		}
+	}
+}
+static void CalAccAhFunc(void)//100ms运行一次
+{
+	static float tmp_DischrgAh = 0;//mah
+	static float tmp_ChrgAh = 0;//mah
+	if(BcuRxLongError[3]==0 && (BcuRxLongError[24]==1||BcuRxShortError[24]==1))//在CAN消息正常,且累计丢帧的情况下,高压上电时进行计算
+	{
+		if(BMS_CharSt==1)//1是正在充电
+		{
+			tmp_ChrgAh = tmp_ChrgAh + (float)((BMS_PackCurr - 10000)/360);
+		}
+		else//放电计算
+		{
+			tmp_DischrgAh = tmp_DischrgAh + (float)((BMS_PackCurr - 10000)/360);
+		}
+		if(tmp_ChrgAh>1000)
+		{
+			AppConfigInfo.AppDataInfo.battChrgAccCap = AppConfigInfo.AppDataInfo.battChrgAccCap + (uint32)tmp_ChrgAh;
+			tmp_ChrgAh = 0;
+			AppConfigInfo.appSaveFlg = 1;
+		}
+		if(tmp_DischrgAh>1000)
+		{
+			AppConfigInfo.AppDataInfo.battDischrgAccCap = AppConfigInfo.AppDataInfo.battDischrgAccCap + (uint32)tmp_DischrgAh;
+			tmp_DischrgAh = 0;
+			AppConfigInfo.appSaveFlg = 1;
 		}
+		BMS_TotalCharCapy = AppConfigInfo.AppDataInfo.battChrgAccCap/100;
+		BMS_TotalDisCharCapy = AppConfigInfo.AppDataInfo.battDischrgAccCap/100;
 	}
 }
 // 注意解码超限问题
@@ -1203,9 +1235,9 @@ void BcuRxMsgSetInvalidValue(uint32 ID)
 		BMS_TotalGunCharCapy = 0xFFFFFFFF;
 		break;
 	case 0x18F4D0F3:
-		BMS_TotalCharCapy = 0xFFFFFFFF;
-		BMS_TotalDisCharCapy = 0xFFFFFFFF;
-		BMS_SingleCharCapy = 0xFFFF;
+//		BMS_TotalCharCapy = 0xFFFFFFFF;
+//		BMS_TotalDisCharCapy = 0xFFFFFFFF;
+//		BMS_SingleCharCapy = 0xFFFF;
 		break;
 	case 0x18F5D0F3:
 		BMS_TotalBackCharCapy = 0xFFFFFFFF;

+ 17 - 0
code/app/AppTaskUart1.c

@@ -249,6 +249,23 @@ static void TcpDataSendFeqHandFunc(uint8* DataIdx)
 			*DataIdx = 0;
 		}
 	}
+	//以下为发送频率可变判定
+	if(BMS_CharSt==1)//充电中
+	{
+		TcpDataFeq.GpsFeqCnt[1] = 60*3;
+		TcpDataFeq.TrkBattFeqCnt[1]  = 10;
+	}
+	else if(BMS_Mode==1)//放电中
+	{
+		TcpDataFeq.GpsFeqCnt[1] = 10;
+		TcpDataFeq.TrkBattFeqCnt[1]  = 30;
+	}
+	else//没有上高压状态
+	{
+		TcpDataFeq.GpsFeqCnt[1] = 60;
+		TcpDataFeq.TrkBattFeqCnt[1]  = 60;
+	}
+
 	return;
 }
 sint8 TcpDataSendFunc(sint8 ConnectId,uint8 DataSendIdxIn)