Ver Fonte

加入故障诊断代码

CHENJIE-PC\QiXiang_CHENJIE há 2 anos atrás
pai
commit
5a1aa847b1

+ 281 - 47
System/Vehicle/AppFunc.c

@@ -3,7 +3,7 @@
  * @Date         : 2021-12-15 10:40:06
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2022-05-09 16:20:39
+ * @LastEditTime : 2022-05-10 19:26:35
  * @Description  : AppFunc
  * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\AppFunc.c
  */
@@ -22,7 +22,6 @@ void LockAndUnlockCtrl()
 {
 	static uint16 LockDelay = 0;
 	static uint16 UnlockDelay = 0;
-	static uint8 CtrlFlg = 0;
 	static uint16 BleConCounter = 0;
 	static uint16 battSwpeModeCounter = 0;
 	if (ebcd_flg_ebcManCtrlEn) //手动控制使能
@@ -36,7 +35,7 @@ void LockAndUnlockCtrl()
 				{
 					ManuControlTimes++;
 					LockDelay = 0;
-					CtrlFlg = Unlock;
+					ebcd_st_SwitchCtrlFlg = Unlock;
 				}
 			}
 			else if (ebcd_st_unlockSensor == 1) //处于解锁状态,传感器判定一个
@@ -45,17 +44,17 @@ void LockAndUnlockCtrl()
 				if (UnlockDelay > UnlockDelayTime)
 				{
 					UnlockDelay = 0;
-					CtrlFlg = Lock;
+					ebcd_st_SwitchCtrlFlg = Lock;
 				}
 			}
 		}
 		else if (ebcd_flg_ebcManCtrlMode == 2) //控制锁紧
 		{
-			CtrlFlg = Lock;
+			ebcd_st_SwitchCtrlFlg = Lock;
 		}
 		else if (ebcd_flg_ebcManCtrlMode == 3) //控制解锁
 		{
-			CtrlFlg = Unlock;
+			ebcd_st_SwitchCtrlFlg = Unlock;
 		}
 	}
 	else //正常工作模式
@@ -131,12 +130,12 @@ void LockAndUnlockCtrl()
 			}
 			if (bled_flg_unlockCmdForce)
 			{
-				CtrlFlg = Unlock;
+				ebcd_st_SwitchCtrlFlg = Unlock;
 				bled_flg_unlockCmdForce = 0;
 			}
 			if (bled_flg_lockCmdForce)
 			{
-				CtrlFlg = Lock;
+				ebcd_st_SwitchCtrlFlg = Lock;
 				bled_flg_lockCmdForce = 0;
 			}
 			break;
@@ -145,7 +144,7 @@ void LockAndUnlockCtrl()
 	}
 
 	//锁紧解锁执行
-	if (CtrlFlg)
+	if (ebcd_st_SwitchCtrlFlg == Unlock)
 	{
 		UnlockCtrl();
 	}
@@ -219,44 +218,6 @@ void GetDIOState(void)
 	temp[0] = !DINDrv_GetChanState(_DIN_INDEX_READYSENSOR1);
 	temp[1] = !DINDrv_GetChanState(_DIN_INDEX_READYSENSOR2);
 	ebcd_st_pedstSensor = (getbit(temp[1], 0) << 1) | (getbit(temp[0], 0) << 0);
-
-	//根据上述量得到,运动状态值
-	if (ebcd_st_lockSensor == 0x0F)
-	{
-		ebcd_st_lockSucJug = 1;
-	}
-	else if (ebcd_st_lockSensor == 0x00)
-	{
-		ebcd_st_lockSucJug = 0;
-	}
-	else
-	{
-		ebcd_st_lockSucJug = 2;
-	}
-	if (ebcd_st_unlockSensor == 0x0F)
-	{
-		ebcd_st_unlockSucJug = 1;
-	}
-	else if (ebcd_st_unlockSensor == 0x00)
-	{
-		ebcd_st_unlockSucJug = 2;
-	}
-	else
-	{
-		ebcd_st_unlockSucJug = 0;
-	}
-	if (ebcd_st_pedstSucJug == 0x03)
-	{
-		ebcd_st_pedstSucJug = 1;
-	}
-	else if (ebcd_st_pedstSucJug == 0x00)
-	{
-		ebcd_st_pedstSucJug = 0;
-	}
-	else
-	{
-		ebcd_st_pedstSucJug = 2;
-	}
 }
 
 /**
@@ -364,3 +325,276 @@ uint16 Look1_u32u8(uint32 u0, uint32 *bp0, uint8 *table, uint16 MaxLen)
 	}
 	return y;
 }
+/**
+ * @brief : 故障诊断函数,运行时间100ms
+ * @param {*}
+ * @return {*}
+ */
+void FaultDiagnosisFunc(void)
+{
+	UINT8 ErrorNumTemp = 0, ErrRank = 0;
+	static BOOL FuncFirstRun = TRUE;
+	static BOOL sfmd_flg_Temp1Over2;
+	static BOOL sfmd_flg_Temp2Over2;
+	static BOOL sfmd_flg_Temp3Over2;
+	static BOOL sfmd_flg_Temp4Over2;
+	static BOOL sfmd_flg_Temp1Over3;
+	static BOOL sfmd_flg_Temp2Over3;
+	static BOOL sfmd_flg_Temp3Over3;
+	static BOOL sfmd_flg_Temp4Over3;
+	BOOL sfmd_flg_Temp1Openflt = FALSE;
+	BOOL sfmd_flg_Temp2Openflt = FALSE;
+	BOOL sfmd_flg_Temp3Openflt = FALSE;
+	BOOL sfmd_flg_Temp4Openflt = FALSE;
+	if (FuncFirstRun)
+	{
+		FuncFirstRun = FALSE;
+		sfmd_flg_Temp1Over2 = FALSE;
+		sfmd_flg_Temp2Over2 = FALSE;
+		sfmd_flg_Temp3Over2 = FALSE;
+		sfmd_flg_Temp4Over2 = FALSE;
+		sfmd_flg_Temp1Over3 = getbit(sfmv_Num_FltEEsave,0);
+		sfmd_flg_Temp2Over3 = getbit(sfmv_Num_FltEEsave,1);
+		sfmd_flg_Temp3Over3 = getbit(sfmv_Num_FltEEsave,2);
+		sfmd_flg_Temp4Over3 = getbit(sfmv_Num_FltEEsave,3);
+	}
+	/*锁紧与解锁诊断*/
+	if (ebcd_st_SwitchCtrlFlg == Unlock) //解锁诊断
+	{
+		if (ebcd_st_unlockSensor == 0x0F)
+		{
+			ebcd_st_unlockSucJug = 1;
+		}
+		else if (ebcd_st_unlockSensor == 0x00)
+		{
+			ebcd_st_unlockSucJug = 0;
+		}
+		else
+		{
+			ebcd_st_unlockSucJug = 2;
+		}
+	}
+	else //锁紧诊断
+	{
+		if (ebcd_st_lockSensor == 0x0F)
+		{
+			ebcd_st_lockSucJug = 1;
+		}
+		else if (ebcd_st_lockSensor == 0x00)
+		{
+			ebcd_st_lockSucJug = 0;
+		}
+		else
+		{
+			ebcd_st_lockSucJug = 2;
+		}
+	}
+	/*底座到位判断*/
+	if (ebcd_st_pedstSucJug == 0x03)
+	{
+		ebcd_st_pedstSucJug = 1;
+	}
+	else if (ebcd_st_pedstSucJug == 0x00)
+	{
+		ebcd_st_pedstSucJug = 0;
+	}
+	else
+	{
+		ebcd_st_pedstSucJug = 2;
+	}
+	/*温度传感器开路诊断*/
+	sfmd_flg_Temp1Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[0] == 0), DiagErrFaulNum.DiagErrFaulN25, 5U);
+	sfmd_flg_Temp2Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[1] == 0), DiagErrFaulNum.DiagErrFaulN26, 5U);
+	sfmd_flg_Temp3Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[2] == 0), DiagErrFaulNum.DiagErrFaulN27, 5U);
+	sfmd_flg_Temp4Openflt = JudgeTimeSystem(1U, (ebcd_T_plugin[3] == 0), DiagErrFaulNum.DiagErrFaulN28, 5U);
+	/*温度传感器三级过温诊断*/
+	sfmd_flg_Temp1Over3 = DiagThrSystem1(1, !sfmd_flg_Temp1Openflt, ebcd_T_plugin[0], sfmd_Th_Temp1Over3Faul, sfmd_Th_Temp1Over3Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN17, DiagErrRecoNum.DiagErrRecoN17, sfmd_flg_Temp1Over3);
+	sfmd_flg_Temp2Over3 = DiagThrSystem1(1, !sfmd_flg_Temp2Openflt, ebcd_T_plugin[1], sfmd_Th_Temp2Over3Faul, sfmd_Th_Temp2Over3Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN18, DiagErrRecoNum.DiagErrRecoN18, sfmd_flg_Temp2Over3);
+	sfmd_flg_Temp3Over3 = DiagThrSystem1(1, !sfmd_flg_Temp3Openflt, ebcd_T_plugin[2], sfmd_Th_Temp3Over3Faul, sfmd_Th_Temp3Over3Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN19, DiagErrRecoNum.DiagErrRecoN19, sfmd_flg_Temp3Over3);
+	sfmd_flg_Temp4Over3 = DiagThrSystem1(1, !sfmd_flg_Temp4Openflt, ebcd_T_plugin[3], sfmd_Th_Temp4Over3Faul, sfmd_Th_Temp4Over3Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN20, DiagErrRecoNum.DiagErrRecoN20, sfmd_flg_Temp4Over3);
+	/*温度传感器二级过温诊断*/
+	sfmd_flg_Temp1Over2 = DiagThrSystem1(1, !sfmd_flg_Temp1Over3 && !sfmd_flg_Temp1Openflt, ebcd_T_plugin[0], sfmd_Th_Temp1Over2Faul, sfmd_Th_Temp1Over2Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN9, DiagErrRecoNum.DiagErrRecoN9, sfmd_flg_Temp1Over2);
+	sfmd_flg_Temp2Over2 = DiagThrSystem1(1, !sfmd_flg_Temp2Over3 && !sfmd_flg_Temp2Openflt, ebcd_T_plugin[1], sfmd_Th_Temp2Over2Faul, sfmd_Th_Temp2Over2Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN10, DiagErrRecoNum.DiagErrRecoN10, sfmd_flg_Temp2Over2);
+	sfmd_flg_Temp3Over2 = DiagThrSystem1(1, !sfmd_flg_Temp3Over3 && !sfmd_flg_Temp3Openflt, ebcd_T_plugin[2], sfmd_Th_Temp3Over2Faul, sfmd_Th_Temp3Over2Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN11, DiagErrRecoNum.DiagErrRecoN11, sfmd_flg_Temp3Over2);
+	sfmd_flg_Temp4Over2 = DiagThrSystem1(1, !sfmd_flg_Temp4Over3 && !sfmd_flg_Temp4Openflt, ebcd_T_plugin[3], sfmd_Th_Temp4Over2Faul, sfmd_Th_Temp4Over2Reco, 30, 30, DiagErrFaulNum.DiagErrFaulN12, DiagErrRecoNum.DiagErrRecoN12, sfmd_flg_Temp4Over2);
+
+	sfmv_Num_FltEEsave = ((sfmd_flg_Temp4Over3&0x01)<<3)|((sfmd_flg_Temp3Over3&0x01)<<2)|((sfmd_flg_Temp2Over3&0x01)<<1)|(sfmd_flg_Temp1Over3);
+	/*故障代码写入*/
+	if (sfmd_flg_Temp1Openflt)
+	{
+		ErrorNumTemp = 25;
+		ErrRank = 2;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+	if (sfmd_flg_Temp2Openflt)
+	{
+		ErrorNumTemp = 26;
+		ErrRank = 2;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+	if (sfmd_flg_Temp3Openflt)
+	{
+		ErrorNumTemp = 27;
+		ErrRank = 2;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+	if (sfmd_flg_Temp4Openflt)
+	{
+		ErrorNumTemp = 28;
+		ErrRank = 2;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+	if (sfmd_flg_Temp1Over3)
+	{
+		ErrorNumTemp = 17;
+		ErrRank = 3;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+	if (sfmd_flg_Temp2Over3)
+	{
+		ErrorNumTemp = 18;
+		ErrRank = 3;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+	if (sfmd_flg_Temp3Over3)
+	{
+		ErrorNumTemp = 19;
+		ErrRank = 3;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+	if (sfmd_flg_Temp4Over3)
+	{
+		ErrorNumTemp = 20;
+		ErrRank = 3;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+	if (sfmd_flg_Temp1Over2)
+	{
+		ErrorNumTemp = 9;
+		ErrRank = 2;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+	if (sfmd_flg_Temp2Over2)
+	{
+		ErrorNumTemp = 10;
+		ErrRank = 2;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+	if (sfmd_flg_Temp3Over2)
+	{
+		ErrorNumTemp = 11;
+		ErrRank = 2;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+	if (sfmd_flg_Temp4Over2)
+	{
+		ErrorNumTemp = 12;
+		ErrRank = 2;
+		PutErrorNum(ErrArray, sizeof(ErrArray) / 2, ErrorNumTemp + ErrRank * 1000);
+	}
+}
+/**
+ * @brief : 故障判断函数
+ * @param {BOOL} Enable 使能状态
+ * @param {BOOL} Input 判断输入
+ * @param {UINT16} *N 判断次数累计
+ * @param {UINT16} Thr 判断次数阈值
+ * @return {*}
+ */
+BOOL JudgeTimeSystem(BOOL Enable, BOOL Input, UINT8 *N, UINT8 Thr)
+{
+	BOOL Flg = FALSE;
+	if (Input && Enable)
+	{
+		*N = (*N + 1) > 2008 ? 2008 : (*N + 1);
+	}
+	else
+	{
+		*N = 0;
+	}
+	if (*N > Thr && Enable)
+	{
+		Flg = TRUE;
+	}
+	else
+	{
+		Flg = FALSE;
+	}
+	return Flg;
+}
+BOOL DiagThrSystem1(BOOL Enable, BOOL precondition, UINT16 Input, UINT16 fltThr, UINT16 recThr, UINT16 fltNumThr, UINT16 recNumThr, UINT16 *fltNum, UINT16 *recNum, UINT8 *fitFlg)
+{
+	if (Enable && precondition && Input > fltThr)
+	{
+		*fltNum = (*fltNum + 1) > 20000 ? 20000 : (*fltNum + 1);
+	}
+	else
+	{
+		*fltNum = 0;
+	}
+	if (Enable && precondition && Input < recThr)
+	{
+		*recNum = (*recNum + 1) > 20000 ? 20000 : (*recNum + 1);
+	}
+	else
+	{
+		*recNum = 0;
+	}
+	if ((*fltNum > fltNumThr || (*fitFlg && *recNum < recNumThr)) && precondition)
+	{
+		*fitFlg = TRUE;
+	}
+	else
+	{
+		*fitFlg = FALSE;
+	}
+	return *fitFlg;
+}
+/**
+ * @brief : 获取故障码函数,从故障数组中获取故障码,并将之前的故障码向前移动
+ * @param {UINT16} *ErrorArray
+ * @param {UINT8} Errorlen
+ * @return {*}
+ */
+UINT16 GetErrorNum(UINT16 *ErrorArray, UINT8 Errorlen)
+{
+	UINT16 OutNum;
+	OutNum = *(ErrorArray);
+	for (UINT8 i = 0; i < Errorlen - 1; i++)
+	{
+		*(ErrorArray + i) = *(ErrorArray + i + 1);
+		if (*(ErrorArray + i + 1) == 0)
+			break;
+	}
+	return OutNum;
+}
+/**
+ * @brief : 故障码注入函数,将故障码写入到故障数组中,如果存在则不写入,如果存在则不写入
+ * @param {UINT16} *ErrorArray
+ * @param {UINT8} Errorlen
+ * @param {UINT16} ErrorNum
+ * @return {*}
+ */
+UINT8 PutErrorNum(UINT16 *ErrorArray, UINT8 Errorlen, UINT16 ErrorNum)
+{
+	for (UINT8 i = 0; i < Errorlen; i++)
+	{
+		if (*(ErrorArray + i) == 0)
+		{
+			*(ErrorArray + i) = ErrorNum;
+			return 0;
+		}
+		else
+		{
+			if (*(ErrorArray + i) == ErrorNum)
+			{
+				return 1;
+			}
+			else
+			{
+				continue;
+			}
+		}
+	}
+	return 2;
+}

+ 8 - 3
System/Vehicle/AppFunc.h

@@ -3,7 +3,7 @@
  * @Date         : 2021-12-15 10:42:35
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-12-20 14:56:45
+ * @LastEditTime : 2022-05-10 18:56:12
  * @Description  :  AppFuncion.h
  * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\AppFunc.h
  */
@@ -16,16 +16,21 @@
 
 #ifndef SYSTEM_VEHICLE_APPFUNCION_H_
 #define SYSTEM_VEHICLE_APPFUNCION_H_
+#include "CanVar.h"
 void GetHVLockState(void);
 void GetDIOState(void);
 void GetAIOValue(void);
 void LockAndUnlockCtrl();
 uint16 Look1_u32u8(uint32 u0, uint32 *bp0, uint8 *table, uint16 MaxLen);
-
+void FaultDiagnosisFunc(void);
+BOOL JudgeTimeSystem(BOOL Enable, BOOL Input, UINT8 *N, UINT8 Thr);
+BOOL DiagThrSystem1(BOOL Enable, BOOL precondition, UINT16 Input, UINT16 fltThr, UINT16 recThr, UINT16 fltNumThr, UINT16 recNumThr, UINT16 *fltNum, UINT16 *recNum, UINT8 *fitFlg);
+UINT16 GetErrorNum(UINT16 *ErrorArray, UINT8 Errorlen);
+UINT8 PutErrorNum(UINT16 *ErrorArray, UINT8 Errorlen, UINT16 ErrorNum);
 #ifdef _APP_TEST_CODE
 void TestDeviceFun(void);
 #endif
 #ifdef _APP_TEST_MOTOR_CODE
-void MotorControlFunc(UINT8 MotorIdx,UINT8 RotateDirec);
+void MotorControlFunc(UINT8 MotorIdx, UINT8 RotateDirec);
 #endif
 #endif /* SYSTEM_VEHICLE_APPFUNCION_H_ */

+ 33 - 0
System/Vehicle/AppVar.c

@@ -0,0 +1,33 @@
+/*
+ * @Author       : ChenJie
+ * @Date         : 2022-05-10 10:20:13
+ * @Version      : V3.0
+ * @LastEditors  : ChenJie
+ * @LastEditTime : 2022-05-10 20:08:13
+ * @Description  : file content
+ * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\AppVar.c
+ */
+//标定变量
+#include "AppVar.h"
+/*constVar*/
+const UINT8 sfmd_Th_Temp1Over2Faul = 120;
+const UINT8 sfmd_Th_Temp1Over2Reco = 110;
+const UINT8 sfmd_Th_Temp2Over2Faul = 120;
+const UINT8 sfmd_Th_Temp2Over2Reco = 110;
+const UINT8 sfmd_Th_Temp3Over2Faul = 120;
+const UINT8 sfmd_Th_Temp3Over2Reco = 110;
+const UINT8 sfmd_Th_Temp4Over2Faul = 120;
+const UINT8 sfmd_Th_Temp4Over2Reco = 110;
+const UINT8 sfmd_Th_Temp1Over3Faul = 135;
+const UINT8 sfmd_Th_Temp1Over3Reco = 110;
+const UINT8 sfmd_Th_Temp2Over3Faul = 135;
+const UINT8 sfmd_Th_Temp2Over3Reco = 110;
+const UINT8 sfmd_Th_Temp3Over3Faul = 135;
+const UINT8 sfmd_Th_Temp3Over3Reco = 110;
+const UINT8 sfmd_Th_Temp4Over3Faul = 135;
+const UINT8 sfmd_Th_Temp4Over3Reco = 110;
+
+UINT8 ebcd_st_SwitchCtrlFlg = 0; //换电控制器控制状态
+UINT16 ErrArray[10] = {0};
+DiagErrFaulNum_t DiagErrFaulNum;
+DiagErrRecoNum_t DiagErrRecoNum;

+ 76 - 0
System/Vehicle/AppVar.h

@@ -0,0 +1,76 @@
+/*
+ * @Author       : ChenJie
+ * @Date         : 2022-05-10 10:20:28
+ * @Version      : V3.0
+ * @LastEditors  : ChenJie
+ * @LastEditTime : 2022-05-10 20:08:06
+ * @Description  : file content ±ê¶¨±äÁ¿
+ * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\AppVar.h
+ */
+#include "Std_Types.h"
+#include "HardwareLib.h"
+typedef struct
+{
+    UINT8 DiagErrFaulN9;
+    UINT8 DiagErrFaulN10;
+    UINT8 DiagErrFaulN11;
+    UINT8 DiagErrFaulN12;
+    UINT8 DiagErrFaulN13;
+    UINT8 DiagErrFaulN14;
+    UINT8 DiagErrFaulN15;
+    UINT8 DiagErrFaulN16;
+    UINT8 DiagErrFaulN17;
+    UINT8 DiagErrFaulN18;
+    UINT8 DiagErrFaulN19;
+    UINT8 DiagErrFaulN20;
+    UINT8 DiagErrFaulN21;
+    UINT8 DiagErrFaulN22;
+    UINT8 DiagErrFaulN23;
+    UINT8 DiagErrFaulN24;
+    UINT8 DiagErrFaulN25;
+    UINT8 DiagErrFaulN26;
+    UINT8 DiagErrFaulN27;
+    UINT8 DiagErrFaulN28;
+} DiagErrFaulNum_t;
+
+typedef struct
+{
+    UINT8 DiagErrRecoN9;
+    UINT8 DiagErrRecoN10;
+    UINT8 DiagErrRecoN11;
+    UINT8 DiagErrRecoN12;
+    UINT8 DiagErrRecoN13;
+    UINT8 DiagErrRecoN14;
+    UINT8 DiagErrRecoN15;
+    UINT8 DiagErrRecoN16;
+    UINT8 DiagErrRecoN17;
+    UINT8 DiagErrRecoN18;
+    UINT8 DiagErrRecoN19;
+    UINT8 DiagErrRecoN20;
+    UINT8 DiagErrRecoN21;
+    UINT8 DiagErrRecoN22;
+    UINT8 DiagErrRecoN23;
+    UINT8 DiagErrRecoN24;
+} DiagErrRecoNum_t;
+/*ConstVar*/
+extern const UINT8 sfmd_Th_Temp1Over2Faul;
+extern const UINT8 sfmd_Th_Temp1Over2Reco;
+extern const UINT8 sfmd_Th_Temp2Over2Faul;
+extern const UINT8 sfmd_Th_Temp2Over2Reco;
+extern const UINT8 sfmd_Th_Temp3Over2Faul;
+extern const UINT8 sfmd_Th_Temp3Over2Reco;
+extern const UINT8 sfmd_Th_Temp4Over2Faul;
+extern const UINT8 sfmd_Th_Temp4Over2Reco;
+extern const UINT8 sfmd_Th_Temp1Over3Faul;
+extern const UINT8 sfmd_Th_Temp1Over3Reco;
+extern const UINT8 sfmd_Th_Temp2Over3Faul;
+extern const UINT8 sfmd_Th_Temp2Over3Reco;
+extern const UINT8 sfmd_Th_Temp3Over3Faul;
+extern const UINT8 sfmd_Th_Temp3Over3Reco;
+extern const UINT8 sfmd_Th_Temp4Over3Faul;
+extern const UINT8 sfmd_Th_Temp4Over3Reco;
+
+extern UINT8 ebcd_st_SwitchCtrlFlg;
+extern UINT16 ErrArray[10];
+extern DiagErrFaulNum_t DiagErrFaulNum;
+extern DiagErrRecoNum_t DiagErrRecoNum;

+ 9 - 5
System/Vehicle/Communication/BcuCanProtocolFunc.c

@@ -3,7 +3,7 @@
  * @Date         : 2021-12-22 17:09:09
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2022-05-09 14:25:24
+ * @LastEditTime : 2022-05-10 18:53:29
  * @Description  : CAN协议解析与组包
  * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\Communication\BcuCanProtocolFunc.c
  */
@@ -765,6 +765,10 @@ void BcuEncodeFunction(UINT32 ID, UINT8 *rawData)
 		}
 		EBC_State = ebcd_st_ebcWork;
 		EBC_AirPressure = ebcd_P_airSensor;
+		UINT16 ErrTemp = 0;
+		ErrTemp = GetErrorNum(ErrArray, sizeof(ErrArray) / 2);
+		EBC_FtLvl = ErrTemp / 10000;
+		EBC_FtCode = ErrTemp % 10000;
 		*(rawData + 0) = EBC_Counter;
 		*(rawData + 1) = (EBC_CharCnctSt << 6) || (EBC_DisCharCnctSt << 4) || (EBC_CnctSt << 2) || (EBC_LockSt);
 		*(rawData + 2) = 0x00;
@@ -777,10 +781,10 @@ void BcuEncodeFunction(UINT32 ID, UINT8 *rawData)
 	}
 	case 0x18FEF8A7:
 	{
-		ebcd_T_plugin[0] = EBC_DisCharPos1Temp;
-		ebcd_T_plugin[1] = EBC_DischarNeg1Temp;
-		ebcd_T_plugin[2] = EBC_DisCharPos2Temp;
-		ebcd_T_plugin[3] = EBC_DisCharNeg2Temp;
+		EBC_DisCharPos1Temp = ebcd_T_plugin[0];
+		EBC_DischarNeg1Temp = ebcd_T_plugin[1];
+		EBC_DisCharPos2Temp = ebcd_T_plugin[2];
+		EBC_DisCharNeg2Temp = ebcd_T_plugin[3];
 		*(rawData + 0) = EBC_DisCharPos1Temp;
 		*(rawData + 1) = EBC_DischarNeg1Temp;
 		*(rawData + 2) = EBC_DisCharPos2Temp;

+ 4 - 4
System/Vehicle/Communication/CanVar.c

@@ -353,7 +353,7 @@ ebc应
 uint8 ebcd_flg_Can2SendEnbale = 0;	 //应答BLE的使能
 uint8 ebcd_st_toBleAns = 0;			 //应答BLE的指令序号
 uint8 ebcd_P_airSensor = 0;			 //压力传感器气压值:单位Mpa,精度0.01Mpa
-uint8 ebcd_T_plugin[4] = {0};		 //四个接插件温度
+uint8 ebcd_T_plugin[4] = {0};		 //四个接插件温度,加了偏移量40
 uint8 ebcd_flg_forbidHVOn = 0;		 //禁止高压上电 BMS
 uint8 ebcb_flg_reqHvOff = 0;		 //请求高压下电 BMS
 uint8 ebcd_flg_LockErr = 0;			 //锁紧机构故障状态,0-异常,1-正常
@@ -380,7 +380,7 @@ uint8 ebcd_st_lockSucJug;			 //
 uint8 ebcd_st_pedstSensor;			 //底座落座传感器:bit0-bit1:传感器0-1的状态,每bit:1-触发,0-无触发
 uint8 ebcd_st_pedstSucJug;			 //电池底座到位判断:0-完全未到位,1-完全到位,2-未完全到位
 uint8 ebcd_st_pluginLockSig;		 //互锁接插件信号具体状态,1-触发,0-无触发
-uint8 ebcd_st_unlockSensor;			 //解锁传感器信号:bit0-bit3:传感器0-3的状态每,bit:1-触发,0-不触发
+uint8 ebcd_st_unlockSensor;		 //解锁传感器信号:bit0-bit3:传感器0-3的状态每,bit:1-触发,0-不触发
 uint8 ebcd_st_unlockSucJug;			 //解锁完成判断:0-完全未解锁,1-完全解锁,2-未完全解锁
 uint8 m_flg_HVlock1 = 0;			 //互锁状态1,电池换电接插件
 uint8 m_flg_HVlock2 = 0;			 //互锁状态2,整车放电接插件
@@ -390,13 +390,13 @@ uint8 ebcd_flg_ebcManCtrlMode = 0;	 // EBC
 
 #define EEPDATA_START_SEC_VAR
 #include "MemMap.h"
-
 uint16 ebcd_Nr_swapBatt;	//换电次数
 uint16 ebcd_Nr_swapSucBatt; //换电成功次数
-
 uint16 ManuControlTimes = 0;
 uint16 LockDelayTime = 0;	//锁定延时时间(传感器到位以后延时多少时间确定为锁定成功
 uint16 UnlockDelayTime = 0; //解锁延时时间(传感器到位以后延时多少时间确定为解锁成功
+
+uint8 sfmv_Num_FltEEsave = 0;
 #define EEPDATA_STOP_SEC_VAR
 #include "MemMap.h"
 #define APPLAYERVER_START_SEC_VAR

+ 4 - 1
System/Vehicle/Communication/CanVar.h

@@ -3,7 +3,7 @@
  * @Date         : 2021-12-27 11:21:08
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2022-05-09 16:18:44
+ * @LastEditTime : 2022-05-10 18:48:53
  * @Description  : file content
  * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\Communication\CanVar.h
  */
@@ -19,6 +19,7 @@
 #define SYSTEM_VEHICLE_COMMUNICATION_CANVAR_H_
 #include "Std_Types.h"
 #include "HardwareLib.h"
+#include "AppVar.h"
 /************************************************************
  *BCU->Ebc解码变量存放区
  ************************************************************/
@@ -371,6 +372,8 @@ extern uint8 ebcd_flg_ebcManCtrlMode; // EBC
 extern uint16 LockDelayTime;		  //锁定延时时间(传感器到位以后延时多少时间确定为锁定成功
 extern uint16 UnlockDelayTime;		  //解锁延时时间(传感器到位以后延时多少时间确定为解锁成功
 extern uint16 ManuControlTimes;
+
+extern uint8 sfmv_Num_FltEEsave;
 #define EEPDATA_STOP_SEC_VAR
 #include "MemMap.h"
 extern const uint8 T_table[240];

+ 8 - 3
System/Vehicle/VehCo.c

@@ -3,7 +3,7 @@
  * @Date         : 2021-11-25 15:36:06
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-12-15 11:53:14
+ * @LastEditTime : 2022-05-10 19:04:08
  * @Description  : file content
  * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\VehCo.c
  */
@@ -75,7 +75,7 @@ void VehCo_Init(void)
 /*ʾÀý´úÂë*/
 #ifdef _SAMPLE_CODE_
     AccPedCD_Init();
-    //VehCo_uAccPedUW = 0;
+    // VehCo_uAccPedUW = 0;
 #endif //_SAMPLE_CODE_
        /*********************************************************************************************/
 
@@ -93,10 +93,15 @@ void VehCo_Manage10ms(void)
 /*********************************************************************************************/
 /*ÑùÀý´úÂë*/
 #ifdef _SAMPLE_CODE_
-
+    static UINT16 TimerMs = 0;
+    TimerMs = TimerMs + 10;
     VehCo_Ctrl();
     VcuRxDiagnose();
     BcuRxDiagnose();
+    if (TimerMs % 100 == 0)
+    {
+        FaultDiagnosisFunc();
+    }
 
 #endif //_SAMPLE_CODE_
     /*********************************************************************************************/

+ 2 - 1
System/Vehicle/VehCo.h

@@ -3,7 +3,7 @@
  * @Date         : 2021-11-24 14:01:24
  * @Version      : V3.0
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-12-15 11:53:13
+ * @LastEditTime : 2022-05-10 10:26:35
  * @Description  : file content
  * @FilePath     : \VehicleControl\VehicleControl\src\System\Vehicle\VehCo.h
  */
@@ -28,6 +28,7 @@
 #include <AppFunc.h>
 #include "VcuCanProtocolFunc.h"
 #include "BcuCanProtocolFunc.h"
+#include "CanVar.h"
 /********************************************************/
 /*上层与底层的调度接口*/
 //系统初始化