Prechádzať zdrojové kódy

1新增内短路算法ISC
2.修改BCU 休眠到工作模式后的延时
3.修改SOC 平均SOC ekf算法中的错误
4.修改加热常闭故障诊断策略

LAPTOP-EG88H5BE\86151 3 rokov pred
rodič
commit
3e6c0a9cd6

+ 1 - 0
ARMCC/Makefile

@@ -34,6 +34,7 @@ obj-y             += PLAT/project/$(TARGET)/apps/qx_app/src/app.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/BLC.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/CM.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/CDM.o \
+						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/ISC.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/look1_is16lu16n16tu16_binlcase.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/look1_iu16lu16n16tu16_binlcase.o \
 						PLAT/project/$(TARGET)/apps/qx_app/src/EmbeddedCoder_src/BCUCal.o \

+ 3 - 0
inc/AppConfig.h

@@ -123,6 +123,9 @@ typedef struct _AppAlgorithmType
     UINT16 sohd_Q_chrgE;              //充入容量读取量;
     UINT16 sohv_Q_packCapArrE[10];    //10次整包容量(数组)读取量;
     UINT16 sohv_Q_cellCapArrE[28];    //
+	UINT16 iscv_Q_remainCpEE[28];
+	UINT32 iscd_tm_totalEE;
+    BOOL sfmd_flg_iscFltEE;
     BOOL sfmd_flg_mainCirClosFltE;
     BOOL sfmd_flg_heatCirClosFltE;
     BOOL sfmd_flg_heatCirOpenFltE;

+ 1 - 0
inc/AppFunc.h

@@ -23,6 +23,7 @@
 #include "AppConfig.h"
 #include "ec_tcpip_api.h"
 #include "AppSignal.h"
+#include "BCUCal.h"
 typedef struct _Fota_Type
 {
     BOOL Fota_update_error;

+ 14 - 2
inc/EmbeddedCoder_inc/BCUDisp.h

@@ -2,15 +2,16 @@
 #include "rtwtypes.h"
 #include "BCUCal.h"
 
-extern uint8_T tmsd_st_heatAct;                          /*热管理请求状态; */
 extern uint16_T appv_V_cellU[cmnc_num_cellUNumMax];                        /* 静态电压 */
-extern boolean_T ihd_flg_HVILFlt;                        /* 保护板上传的高压互锁故障 */
+extern uint8_T appd_st_preCyc;
+
 extern uint16_T blcv_Q_reqCpEi[cmnc_num_cellUNumMax];                      /*均衡需求容量 读取量(数组); */
 extern uint16_T blcv_Q_reqCpEo[cmnc_num_cellUNumMax];                      /*均衡需求容量 写入量(数组); */
 extern uint32_T blcv_Q_totalCpEi[cmnc_num_cellUNumMax];                    /*累计均衡容量 读取量(数组); */
 extern uint32_T blcv_Q_totalCpEo[cmnc_num_cellUNumMax];                    /*累计均衡容量 写入量(数组); */
 extern boolean_T blcv_flg_excute[cmnc_num_cellUNumMax];                    /*均衡执行请求标志位 (数组); */
 
+extern boolean_T ihd_flg_HVILFlt;                        /* 保护板上传的高压互锁故障 */
 extern boolean_T ihd_flg_DTCClear;                       /* 上位机发送的故障清楚指令;*/
 extern uint8_T ihd_st_authFaild;                         /* 底层诊断的认证失败故障;*/
 extern int16_T ihd_I_curr;                               /*电池包电流; */
@@ -80,6 +81,8 @@ extern boolean_T sfmd_flg_heatCirOpenFltEi;              /*加热回路常开故
 extern boolean_T sfmd_flg_heatCirOpenFltEo;              /*加热回路常开故障写入量 */  
 extern boolean_T sfmd_flg_heatRunFltEi;
 extern boolean_T sfmd_flg_heatRunFltEo;
+extern boolean_T sfmd_flg_iscFltEi;
+extern boolean_T sfmd_flg_iscFltEo;
 
 extern uint16_T socd_pct_ahSoc;                          /*安时SOC; */
 extern uint16_T socd_pct_estSoc;                         /*估算SOC;*/
@@ -94,6 +97,7 @@ extern uint16_T socd_pct_bcuSocEo;                       /*电池显示SOC写入
 extern uint16_T socd_pct_bcuSoc_Delay;                   /*电池显示SOC延时; */
 extern uint16_T socv_pct_cellSoc[cmnc_num_cellUNumMax];
 extern uint16_T socd_pct_cellBattSoc;
+extern boolean_T socd_flg_cellSocDisable;
 
 extern uint16_T sohd_Q_chrgEi;                           /*充入容量读取量; */
 extern uint16_T sohd_Q_chrgEo;                           /*充入容量写入量; */
@@ -111,6 +115,14 @@ extern uint16_T sohv_Q_packCapArrEo[10];                 /*10次整包容量(
 extern uint16_T sohv_V_chrgStartStatEi[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)读取量; */
 extern uint16_T sohv_V_chrgStartStatEo[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)写入量; */
 
+extern boolean_T iscd_flg_flt;
+extern uint16_T iscv_Q_remainCpEi[cmnc_num_cellUNumMax];
+extern uint32_T iscd_tm_totalEi;
+extern uint16_T iscv_Q_remainCpEo[cmnc_num_cellUNumMax];
+extern uint32_T iscd_tm_totalEo;
+
+extern uint8_T tmsd_st_heatAct;                          /*热管理请求状态; */
+
 extern uint8_T cmd_st_chrgMod;                           /* 充电模式  */
 extern uint8_T cmd_st_chrgSt;                            /* 充电状态  */
 extern int16_T cmd_I_chrgCurrReq;                       /* 充电需求电流  */

+ 8 - 0
inc/EmbeddedCoder_inc/ISC.h

@@ -0,0 +1,8 @@
+#include <math.h>
+#include "BCUCal.h"
+#include "BCUDisp.h"
+extern boolean_T FirstRun_ISC;
+extern void ISC_Init(void);
+extern void ISC(void);
+
+extern int16_T ArrMean(int16_T *Data, uint16_T m);

+ 7 - 5
src/AppFunc.c

@@ -1297,17 +1297,19 @@ static void setDefaultBcuDataInfo(void)
 {
 	memset(&BcuDataInfo, 0x00, sizeof(BcuDataInfo));
 	BcuDataInfo.appDataModify = false;
-	memset(BcuDataInfo.blcv_Q_totalCpE, 0x00, 28 * sizeof(UINT32));
-	memset(BcuDataInfo.blcv_Q_reqCpE, 0x00, 28 * sizeof(UINT16));
+	memset(BcuDataInfo.blcv_Q_totalCpE, 0x00, cmnc_num_cellUNumMax * sizeof(UINT32));
+	memset(BcuDataInfo.blcv_Q_reqCpE, 0x00, cmnc_num_cellUNumMax * sizeof(UINT16));
 	BcuDataInfo.socd_pct_bcuSocE = 1200;
 	BcuDataInfo.socd_pct_battSocE = 1200;
 	BcuDataInfo.sohd_tm_chrgStartStatE = 0;
 	BcuDataInfo.sohd_flg_chrgEndE = 0;
-	BcuDataInfo.sohv_Q_cellCapArrE[28];
-	memset(BcuDataInfo.sohv_Q_cellCapArrE, 0, 28 * sizeof(UINT16));
-	memset(BcuDataInfo.sohv_V_chrgStartStatE, 0, 28 * sizeof(UINT16));
+	memset(BcuDataInfo.sohv_Q_cellCapArrE, 0, cmnc_num_cellUNumMax * sizeof(UINT16));
+	memset(BcuDataInfo.sohv_V_chrgStartStatE, 0, cmnc_num_cellUNumMax * sizeof(UINT16));
 	BcuDataInfo.sohd_Q_chrgE = 0;
 	memset(BcuDataInfo.sohv_Q_packCapArrE, 0, 10 * sizeof(UINT16));
+	memset(BcuDataInfo.iscv_Q_remainCpEE, 0,cmnc_num_cellUNumMax * sizeof(UINT16));
+	BcuDataInfo.iscd_tm_totalEE = 0;
+	BcuDataInfo.sfmd_flg_iscFltEE = 0;
 	BcuDataInfo.sfmd_flg_mainCirClosFltE = 0;
 	BcuDataInfo.sfmd_flg_heatCirClosFltE = 0;
 	BcuDataInfo.sfmd_flg_heatCirOpenFltE = 0;

+ 149 - 111
src/EmbeddedCoder_src/BCU.c

@@ -17,8 +17,8 @@ void BCU(void)
     while (TRUE)
     {
         if (UartRecvFlag == 1 || RecvCounter >= 15)
-        {   
-            //osDelay(1000);
+        {
+            RecvCounter = 0;
             break;
         }
         else
@@ -26,132 +26,166 @@ void BCU(void)
             RecvCounter++;
             osDelay(1000);
         }
-		//printf("RecvCounter:%d\n ",RecvCounter);
+        //printf("RecvCounter:%d\n ",RecvCounter);
     }
-	
+    
     PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
     while (TRUE)
     {
         switch (gProcess_Bcu_Task)
         {
-        //=========================初始化===============================
-        case PROCESS_STATE_INIT:
-        {
-            BCU_Init();
-            memcpy(blcv_Q_totalCpEi, BcuDataInfo.blcv_Q_totalCpE, sizeof(blcv_Q_totalCpEi));
-            memcpy(blcv_Q_reqCpEi, BcuDataInfo.blcv_Q_reqCpE, sizeof(blcv_Q_reqCpEi));
-            socd_pct_bcuSocEi = BcuDataInfo.socd_pct_bcuSocE;
-            socd_pct_battSocEi = BcuDataInfo.socd_pct_battSocE;
-            sohd_tm_chrgStartStatEi = BcuDataInfo.sohd_tm_chrgStartStatE;
-            sohd_flg_chrgEndEi = BcuDataInfo.sohd_flg_chrgEndE;
-            memcpy(sohv_V_chrgStartStatEi, BcuDataInfo.sohv_V_chrgStartStatE, sizeof(sohv_V_chrgStartStatEi));
-            sohd_Q_chrgEi = BcuDataInfo.sohd_Q_chrgE;
-            memcpy(sohv_Q_packCapArrEi, BcuDataInfo.sohv_Q_packCapArrE, sizeof(sohv_Q_packCapArrEi));
-            memcpy(sohv_Q_cellCapArrEi, BcuDataInfo.sohv_Q_cellCapArrE, sizeof(sohv_Q_cellCapArrEi));
-            sfmd_flg_mainCirClosFltEi = BcuDataInfo.sfmd_flg_mainCirClosFltE;
-            sfmd_flg_heatCirClosFltEi = BcuDataInfo.sfmd_flg_heatCirClosFltE;
-            sfmd_flg_heatCirOpenFltEi = BcuDataInfo.sfmd_flg_heatCirOpenFltE;
-            sfmd_flg_heatRunFltEi = BcuDataInfo.sfmd_flg_heatRunFltE;
-            ihd_st_EOLState = AppNVMData.EOLState;
-
-            PROC_BCU_STATE_SWITCH(PROCESS_STATE_WORK);
-            break;
-        }
-        //============================工作模式==========================
-        case PROCESS_STATE_WORK:
-        {
-            while (TRUE)
+            //=========================初始化===============================
+            case PROCESS_STATE_INIT:
             {
-                if (TimeCounter % 10 == 0)
-                {
-                    if (gProcess_app == LISTEN)
-                    {
-                        PROC_BCU_STATE_SWITCH(PROCESS_STATE_SLEEP);
-                        break;
-                    }
-                    //数据获取
-                    if (BattWorkStateDelay == 0 && battI == 10000)
+                BCU_Init();
+                memcpy(blcv_Q_totalCpEi, BcuDataInfo.blcv_Q_totalCpE, sizeof(blcv_Q_totalCpEi));
+                memcpy(blcv_Q_reqCpEi, BcuDataInfo.blcv_Q_reqCpE, sizeof(blcv_Q_reqCpEi));
+                socd_pct_bcuSocEi = BcuDataInfo.socd_pct_bcuSocE;
+                socd_pct_battSocEi = BcuDataInfo.socd_pct_battSocE;
+                sohd_tm_chrgStartStatEi = BcuDataInfo.sohd_tm_chrgStartStatE;
+                sohd_flg_chrgEndEi = BcuDataInfo.sohd_flg_chrgEndE;
+                memcpy(sohv_V_chrgStartStatEi, BcuDataInfo.sohv_V_chrgStartStatE, sizeof(sohv_V_chrgStartStatEi));
+                sohd_Q_chrgEi = BcuDataInfo.sohd_Q_chrgE;
+                memcpy(sohv_Q_packCapArrEi, BcuDataInfo.sohv_Q_packCapArrE, sizeof(sohv_Q_packCapArrEi));
+                memcpy(sohv_Q_cellCapArrEi, BcuDataInfo.sohv_Q_cellCapArrE, sizeof(sohv_Q_cellCapArrEi));
+                memcpy((iscv_Q_remainCpEi), BcuDataInfo.iscv_Q_remainCpEE, sizeof(iscv_Q_remainCpEi));
+                iscd_tm_totalEi = BcuDataInfo.iscd_tm_totalEE;
+                sfmd_flg_mainCirClosFltEi = BcuDataInfo.sfmd_flg_mainCirClosFltE;
+                sfmd_flg_heatCirClosFltEi = BcuDataInfo.sfmd_flg_heatCirClosFltE;
+                sfmd_flg_heatCirOpenFltEi = BcuDataInfo.sfmd_flg_heatCirOpenFltE;
+                sfmd_flg_heatRunFltEi = BcuDataInfo.sfmd_flg_heatRunFltE;
+                sfmd_flg_iscFltEi = BcuDataInfo.sfmd_flg_iscFltEE;
+                ihd_st_EOLState = AppNVMData.EOLState;
+                
+                
+                PROC_BCU_STATE_SWITCH(PROCESS_STATE_WORK);
+                break;
+            }
+            //============================工作模式==========================
+            case PROCESS_STATE_WORK:
+            {
+                 while (TRUE)
+                 {
+                      if (UartRecvFlag == 1 || RecvCounter >= 15)
+                      {
+                           RecvCounter = 0;
+                           break;
+                       }
+                      else
+                     {
+                          RecvCounter++;
+                          osDelay(1000);
+                     }
+                 }
+			
+                while (TRUE)
+                {   			    
+                    if (TimeCounter % 10 == 0)
                     {
-                        memcpy(appv_V_cellU, battCellU, sizeof(appv_V_cellU));
+                        if (gProcess_app == LISTEN)
+                        {
+                            PROC_BCU_STATE_SWITCH(PROCESS_STATE_SLEEP);
+                            break;
+                        }
+                        //
+                        
+                        //数据获取
+                        ihd_I_curr = (int16_T)(-(battI - 10000));
+                        memcpy(ihv_V_cellU, battCellU, sizeof(battCellU));
+                        for (i = 0; i < cmnc_num_modTNum; i++)
+                        {
+                            ihv_T_modT[i] = battCellTemp[i];
+                        }
+                        ihd_T_mosT = MOSTemp;
+                        ihd_T_DCPlugT = fastChargeTemp;
+                        ihd_T_ACPlugT = normalChargeTemp;
+                        ihd_T_heatPanT1 = heatTemp1;
+                        ihd_T_heatPanT2 = heatTemp2;
+                        ihd_pct_soc = battSOC * 10;
+                        ihd_pct_soh = battSOH * 10;
+                        ihd_flg_HVILFlt = Lockstatus;
+                        ihd_st_workStat = BattWorkStateDelay;
+                        ihd_flg_urtRecFlt = UartErrorFlag;
+                        ihd_flg_urtRecFlg = UartRecvFlag;
+                        ihd_st_chrgConnect = chargerConnectState;
+                        ihd_flg_cellULowFlt = ((battWarningState)&0x01) == 1;
+                        ihd_flg_battULowFlt = ((battWarningState >> 1) & 0x01) == 1;
+                        ihd_flg_cellUOverFlt = ((battWarningState >> 2) & 0x01) == 1;
+                        ihd_flg_battUOverFlt = ((battWarningState >> 3) & 0x01) == 1;
+                        ihd_flg_disChrgCurrOverFlt = ((battWarningState >> 4) & 0x01) == 1;
+                        ihd_flg_chrgCurrOverFlt = ((battWarningState >> 5) & 0x01) == 1;
+                        ihd_flg_disChrgModTOverFlt = ((battWarningState >> 6) & 0x01) == 1;
+                        ihd_flg_chrgModTOverFlt = ((battWarningState >> 7) & 0x01) == 1;
+                        ihd_flg_chrgMosTOverFlt = ((battWarningState >> 11) & 0x01) == 1;
+                        ihd_flg_disChrgMosClosFlt = ((battWarningState >> 18) & 0x01) == 1;
+                        ihd_flg_chrgMosClosFlt = ((battWarningState >> 19) & 0x01) == 1;
+                        ihd_flg_disChrgModTLowFlt = ((battWarningState >> 22) & 0x01) == 1;
+                        ihd_flg_chrgModTLowFlt = ((battWarningState >> 23) & 0x01) == 1;
+                        ihd_flg_currOpenFlt = 0;
+                        ihd_st_heatForceControl = HeatForceControl;
+                        ihd_st_chrgMosControl = ChargeForbiddenControl == 0;
+                        ihd_st_disChrgMosControl = DisChargeForbiddenControl == 0;
+                        ihd_st_relayControl = RelayForbiddenControl == 0;
+                        //ihd_flg_DTCClear = 1;   //////clear
+                        //调用算法
+                        SFM();
+                        TMS();
+                        CM();
+                        SPM();
+                        ISC();
+                        //实时存储
+                        if (socd_flg_EEsave == 1 || ihd_flg_DTCClear)
+                        {
+                            BCUEEDataSave();
+                            ihd_flg_DTCClear = false;
+                        }
+
+						//
+                        if (BattWorkStateDelay == 0 && battI == 10000)
+                        {
+                            memcpy(appv_V_cellU, battCellU, sizeof(appv_V_cellU));
+                        }
+                        
+                        if (ihd_tm_parkTime >= cmnc_tm_parkTime && battI == 10000)
+                        {
+                            appd_st_preCyc = 1 ;
+                        }
+                        else
+                        {
+                            appd_st_preCyc = 0;
+                        }
+     
                     }
-                    ihd_I_curr = (int16_T)(-(battI - 10000));
-                    memcpy(ihv_V_cellU, battCellU, sizeof(battCellU));
-                    for (i = 0; i < cmnc_num_modTNum; i++)
+                    osDelay(100);
+                }
+                break;
+            }
+            //======================休眠模式===============================
+            case PROCESS_STATE_SLEEP:
+            {
+                BCUEEDataSave();
+                ihd_tm_parkTime = 0;
+                while (TRUE)
+                {
+                    if (TimeCounter % 10 == 0)
                     {
-                        ihv_T_modT[i] = battCellTemp[i];
+                        ihd_tm_parkTime++;
+                       
                     }
-                    ihd_T_mosT = MOSTemp;
-                    ihd_T_DCPlugT = fastChargeTemp;
-                    ihd_T_ACPlugT = normalChargeTemp;
-                    ihd_T_heatPanT1 = heatTemp1;
-                    ihd_T_heatPanT2 = heatTemp2;
-                    ihd_pct_soc = battSOC * 10;
-                    ihd_pct_soh = battSOH * 10;
-                    ihd_flg_HVILFlt = Lockstatus;
-                    ihd_st_workStat = BattWorkStateDelay;
-                    ihd_flg_urtRecFlt = UartErrorFlag;
-					ihd_flg_urtRecFlg = UartRecvFlag;
-                    ihd_st_chrgConnect = chargerConnectState;
-                    ihd_flg_cellULowFlt = ((battWarningState)&0x01) == 1;
-                    ihd_flg_battULowFlt = ((battWarningState >> 1) & 0x01) == 1;
-                    ihd_flg_cellUOverFlt = ((battWarningState >> 2) & 0x01) == 1;
-                    ihd_flg_battUOverFlt = ((battWarningState >> 3) & 0x01) == 1;
-                    ihd_flg_disChrgCurrOverFlt = ((battWarningState >> 4) & 0x01) == 1;
-                    ihd_flg_chrgCurrOverFlt = ((battWarningState >> 5) & 0x01) == 1;
-                    ihd_flg_disChrgModTOverFlt = ((battWarningState >> 6) & 0x01) == 1;
-                    ihd_flg_chrgModTOverFlt = ((battWarningState >> 7) & 0x01) == 1;
-                    ihd_flg_chrgMosTOverFlt = ((battWarningState >> 11) & 0x01) == 1;
-                    ihd_flg_disChrgMosClosFlt = ((battWarningState >> 18) & 0x01) == 1;
-                    ihd_flg_chrgMosClosFlt = ((battWarningState >> 19) & 0x01) == 1;
-                    ihd_flg_disChrgModTLowFlt = ((battWarningState >> 22) & 0x01) == 1;
-                    ihd_flg_chrgModTLowFlt = ((battWarningState >> 23) & 0x01) == 1;
-                    ihd_flg_currOpenFlt = 0;
-                    ihd_st_heatForceControl = HeatForceControl;
-                    ihd_st_chrgMosControl = ChargeForbiddenControl == 0;
-                    ihd_st_disChrgMosControl = DisChargeForbiddenControl == 0;
-                    ihd_st_relayControl = RelayForbiddenControl == 0;
-                    //ihd_flg_DTCClear = 1;   //////clear
-                    //调用算法
-                    SFM();
-                    TMS();
-                    CM();
-                    SPM();
-                    //实时存储
-                    if (socd_flg_EEsave == 1 || ihd_flg_DTCClear)
+                    if (gProcess_app == WORK)
                     {
-                        BCUEEDataSave();
-                        ihd_flg_DTCClear = false;
+                        PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
+                        break;
                     }
+                    osDelay(100);
                 }
-                osDelay(100);
+                break;
             }
-            break;
-        }
-        //======================休眠模式===============================
-        case PROCESS_STATE_SLEEP:
-        {
-            BCUEEDataSave();
-            ihd_tm_parkTime = 0;
-            while (TRUE)
+            default:
             {
-                if (TimeCounter % 10 == 0)
-                {
-                    ihd_tm_parkTime++;
-                }
-                if (gProcess_app == WORK)
-                {
-                    PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
-                    break;
-                }
-                osDelay(100);
+                PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
+                break;
             }
-            break;
-        }
-        default:
-        {
-            PROC_BCU_STATE_SWITCH(PROCESS_STATE_INIT);
-            break;
-        }
         }
     }
 }
@@ -163,6 +197,7 @@ void BCU_Init(void)
     TMS_Init();
     CM_Init();
     SPM_Init();
+    ISC_Init();
 }
 
 //==========================主线程调用======================================
@@ -192,9 +227,12 @@ void BCUEEDataSave(void)
     BcuDataInfo.sohd_Q_chrgE = sohd_Q_chrgEo;
     memcpy(BcuDataInfo.sohv_Q_packCapArrE, sohv_Q_packCapArrEo, sizeof(sohv_Q_packCapArrEo));
     memcpy(BcuDataInfo.sohv_Q_cellCapArrE, sohv_Q_cellCapArrEo, sizeof(sohv_Q_cellCapArrEo));
+    memcpy(BcuDataInfo.iscv_Q_remainCpEE, iscv_Q_remainCpEo, sizeof(iscv_Q_remainCpEo));
+    BcuDataInfo.iscd_tm_totalEE = iscd_tm_totalEo;
     BcuDataInfo.sfmd_flg_mainCirClosFltE = sfmd_flg_mainCirClosFltEo;
     BcuDataInfo.sfmd_flg_heatCirClosFltE = sfmd_flg_heatCirClosFltEo;
     BcuDataInfo.sfmd_flg_heatCirOpenFltE = sfmd_flg_heatCirOpenFltEo;
     BcuDataInfo.sfmd_flg_heatRunFltE = sfmd_flg_heatRunFltEo;
+    BcuDataInfo.sfmd_flg_iscFltEE = sfmd_flg_iscFltEo;
     BcuDataInfo.appDataModify = TRUE;
 }

+ 14 - 2
src/EmbeddedCoder_src/BCUDisp.c

@@ -2,15 +2,16 @@
 
 #include "BCUDisp.h"
 
-uint8_T tmsd_st_heatAct;                          /*热管理请求状态; */
 uint16_T appv_V_cellU[cmnc_num_cellUNumMax];
-boolean_T ihd_flg_HVILFlt;
+uint8_T appd_st_preCyc;
+
 uint16_T blcv_Q_reqCpEi[cmnc_num_cellUNumMax];                      /*均衡需求容量 读取量(数组); */
 uint16_T blcv_Q_reqCpEo[cmnc_num_cellUNumMax];                      /*均衡需求容量 写入量(数组); */
 uint32_T blcv_Q_totalCpEi[cmnc_num_cellUNumMax];                    /*累计均衡容量 读取量(数组); */
 uint32_T blcv_Q_totalCpEo[cmnc_num_cellUNumMax];                    /*累计均衡容量 写入量(数组); */
 boolean_T blcv_flg_excute[cmnc_num_cellUNumMax];                    /*均衡执行请求标志位 (数组) */
 
+boolean_T ihd_flg_HVILFlt;
 boolean_T ihd_flg_DTCClear;
 uint8_T ihd_st_authFaild;                         
 int16_T ihd_I_curr;                               /*电池包电流; */
@@ -80,6 +81,8 @@ boolean_T sfmd_flg_heatCirOpenFltEi;              /*加热回路常开故障读
 boolean_T sfmd_flg_heatCirOpenFltEo;              /*加热回路常开故障写入量 */  
 boolean_T sfmd_flg_heatRunFltEi;
 boolean_T sfmd_flg_heatRunFltEo;
+boolean_T sfmd_flg_iscFltEi;
+boolean_T sfmd_flg_iscFltEo;
 
 uint16_T socd_pct_ahSoc;                          /*安时SOC; */
 uint16_T socd_pct_estSoc;                         /*估算SOC;*/
@@ -94,6 +97,7 @@ uint16_T socd_pct_bcuSocEo;                       /*电池显示SOC写入量;
 uint16_T socd_pct_bcuSoc_Delay;                   /*电池显示SOC延时; */
 uint16_T socv_pct_cellSoc[cmnc_num_cellUNumMax];
 uint16_T socd_pct_cellBattSoc;
+boolean_T socd_flg_cellSocDisable;
 
 uint16_T sohd_Q_chrgEi;                           /*充入容量读取量; */
 uint16_T sohd_Q_chrgEo;                           /*充入容量写入量; */
@@ -111,6 +115,14 @@ uint16_T sohv_Q_packCapArrEo[10];                 /*10次整包容量(数组
 uint16_T sohv_V_chrgStartStatEi[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)读取量; */
 uint16_T sohv_V_chrgStartStatEo[cmnc_num_cellUNumMax];              /*充电开始时刻的单体电压(数组)写入量; */
 
+boolean_T iscd_flg_flt;
+uint16_T iscv_Q_remainCpEi[cmnc_num_cellUNumMax];
+uint32_T iscd_tm_totalEi;
+uint16_T iscv_Q_remainCpEo[cmnc_num_cellUNumMax];
+uint32_T iscd_tm_totalEo;
+
+uint8_T tmsd_st_heatAct;                          /*热管理请求状态; */
+
 uint8_T cmd_st_chrgMod;                           /* 充电模式  */
 uint8_T cmd_st_chrgSt;                            /* 充电状态  */
 int16_T cmd_I_chrgCurrReq;                       /* 充电需求电流  */

+ 1 - 1
src/EmbeddedCoder_src/BLC.c

@@ -66,7 +66,7 @@ void BLC(void)
     //=========================================================================
     if(FirstRun_BLC)
     {
-		blcn_flg_judge	= (ihd_tm_parkTime > cmnc_tm_parkTime)&& !sfmd_flg_cellUDisable && (sfmd_I_curr > -10 && sfmd_I_curr < 10);
+		blcn_flg_judge	= (ihd_tm_parkTime >= cmnc_tm_parkTime)&& !sfmd_flg_cellUDisable && (sfmd_I_curr > -10 && sfmd_I_curr < 10);
     }
     blcn_flg_enable = ((sfmd_st_fltAct >> 7) & 0x01) != 1;
 

+ 39 - 16
src/EmbeddedCoder_src/CDM.c

@@ -16,32 +16,39 @@ void CDM(void)
     static real_T P[4][cmnc_num_cellUNumMax];
     static real_T deltaE[cmnc_num_cellUNumMax];
     static real_T deltaR[cmnc_num_cellUNumMax];
+	static real_T deltaES[cmnc_num_cellUNumMax];
+    static real_T deltaRS[cmnc_num_cellUNumMax];
     static real_T Lambda;
     real_T K[2];
     real_T arf[cmnc_num_cellUNumMax];
     uint16_T i;
     static uint8_T ihd_st_workStat_Delay;
+	static uint8_T Cnt;
     //
-    if(ihd_st_workStat_Delay != 1 && ihd_st_workStat == 1)
+    if(ihd_st_workStat_Delay == 2 && ihd_st_workStat != 2)
     {
         FirstRun_CDM = true;
     }
     ihd_st_workStat_Delay = ihd_st_workStat;
+	//
     if (FirstRun_CDM)
     {
         for (i = 0;i < cmnc_num_cellUNum;i++)
         {
-            P[0][i] = 0.001;
+            P[0][i] = 10;
             P[1][i] = 0;
             P[2][i] = 0;
-            P[3][i] = 0.001;
-            Lambda = 1;
-            deltaE[i] = 0;
-            deltaR[i] = 0;
+            P[3][i] = 10;
+            Lambda = 0.991;
+            deltaE[i] =  0;
+            deltaR[i] =  0;
+			deltaES[i] = 0;
+            deltaRS[i] = 0;
+			Cnt = 0;
         }
     }
-    
-    if(ihd_st_workStat == 1)
+    //
+    if(ihd_st_workStat != 2)
     {
         for (i = 0;i < cmnc_num_cellUNum;i++)
         {
@@ -49,7 +56,7 @@ void CDM(void)
         }
         cdmn_I_curr = (real_T) sfmd_I_curr * 0.1;
         //
-   
+        cdmd_flg_deltOCVDisable = false;
         for (i = 0;i < cmnc_num_cellUNum;i++)
         {
             K[0] = (P[0][i]  + cdmn_I_curr * P[1][i])/(Lambda + P[0][i] + cdmn_I_curr * P[2][i] + ( P[1][i] + cdmn_I_curr * P[3][i]) * cdmn_I_curr);
@@ -61,23 +68,39 @@ void CDM(void)
             P[1][i] = ((1 -K[0])* P[1][i] -P[3][i] * K[0] * cdmn_I_curr) /Lambda;
             P[2][i] = (-K[1] *P[0][i] +P[2][i] * (1 - K[1] * cdmn_I_curr))/Lambda;
             P[3][i] = (-K[1] *P[1][i] +P[3][i] * (1 - K[1] * cdmn_I_curr))/Lambda;
+			
+			if(arf[i] > 0.04 || arf[i] < -0.04)
+            {
+                cdmd_flg_deltOCVDisable = true;
+			   
+            }
 	    }
         //
-        cdmd_flg_deltOCVDisable = false;
+		Cnt = Cnt + 1;
+
         for (i = 0;i < cmnc_num_cellUNum;i++)
         {   
-            cdmv_V_deltOCV[i] = (int16_T) (deltaE[i]  * 1000);
-            cdmv_ohm_deltR[i] = (int16_T) (deltaR[i]  * 1000 * 1000);
-            if(arf[i] > 0.05 && arf[i] < -0.05)
-            {
-                cdmd_flg_deltOCVDisable = true;
-            }
+            deltaES[i] = deltaES[i] + deltaE[i];
+			deltaRS[i] = deltaRS[i] + deltaR[i];
         }
+
+		if (Cnt >= 10)
+		{
+             for (i = 0;i < cmnc_num_cellUNum;i++)
+             {   
+                 cdmv_V_deltOCV[i] = (int16_T) (deltaES[i]/Cnt  * 1000);
+                 cdmv_ohm_deltR[i] = (int16_T) (deltaRS[i]/Cnt  * 1000 * 1000);
+			     deltaES[i] = 0;
+                 deltaRS[i] = 0;
+             }
+		     Cnt = 0;
+		}
     }
     else
     {
         cdmd_flg_deltOCVDisable = false;
     }
+	
     FirstRun_CDM = false;
 	
 }

+ 189 - 0
src/EmbeddedCoder_src/ISC.c

@@ -0,0 +1,189 @@
+#include "ISC.h"
+#include "look1_is16lu16n16tu16_binlcase.h"
+
+boolean_T FirstRun_ISC;
+
+void ISC_Init(void)
+{
+    FirstRun_ISC = true;
+}
+//-------------------------------------------------------------------------
+
+void ISC(void)
+{
+    uint16_T i;
+    static uint32_T iscd_tm_totalEE;
+    static uint16_T iscv_Q_remainCpEE[cmnc_num_cellUNumMax];
+    uint16_T iscn_pct_cellSoc1[cmnc_num_cellUNumMax];
+    uint16_T iscn_pct_cellSoc2[cmnc_num_cellUNumMax];
+    int16_T iscn_Q_deltAh[cmnc_num_cellUNumMax];
+    uint16_T iscn_Q_cellAh[cmnc_num_cellUNumMax];
+    static uint16_T iscn_Q_cellAh0[cmnc_num_cellUNumMax];
+    static boolean_T iscd_flg_timedWakeUpFlt;
+    static boolean_T iscd_flg_disChrgFlt;
+    static uint16_T TimeCtn;
+    static uint16_T RunCtn;
+    static uint16_T iscn_N_fltNr[cmnc_num_cellUNumMax];
+    static boolean_T iscd_flg_fulStat;
+    //初值
+    if(FirstRun_ISC)
+    {
+        iscd_flg_timedWakeUpFlt = false;
+        iscd_flg_disChrgFlt = false;
+        memset(iscn_Q_cellAh0,0, sizeof(iscn_Q_cellAh0));
+		memset(iscn_pct_cellSoc1,0, sizeof(iscn_pct_cellSoc1));
+		memset(iscn_pct_cellSoc2,0, sizeof(iscn_pct_cellSoc2));
+		memset(iscn_Q_cellAh,0, sizeof(iscn_Q_cellAh));
+		memset(iscn_Q_deltAh,0, sizeof(iscn_Q_deltAh));
+        memset(iscn_N_fltNr,0, sizeof(iscn_N_fltNr));
+        TimeCtn = 0;
+        RunCtn = 0;
+    }
+    //=====================================================================
+    //================高端SOC点诊断=================================== 0.1A
+    //=====================================================================
+    RunCtn = (RunCtn + 1) > 60000 ? 60000 : (RunCtn + 1);
+    if(FirstRun_ISC)
+    {
+        //
+        if(ArrMax(iscv_Q_remainCpEi,cmnc_num_cellUNum) > cmnc_Q_ratedCp)
+        {
+            memset(iscv_Q_remainCpEE,0, sizeof(iscv_Q_remainCpEi));
+            iscd_tm_totalEE =  0;
+        }
+        else
+        {
+            memcpy(iscv_Q_remainCpEE,iscv_Q_remainCpEi, sizeof(iscv_Q_remainCpEi));
+            iscd_tm_totalEE = iscd_tm_totalEi;
+        }
+        //
+        if((iscd_tm_totalEE + ihd_tm_parkTime >= 20 * 3600 || iscd_tm_totalEE == 0) && ihd_tm_parkTime >= cmnc_tm_parkTime && socd_pct_battSoc > 900 && sfmd_I_curr > -10 && sfmd_I_curr < 10)
+        {
+            for(i = 0; i < cmnc_num_cellUNum;i++)
+            {
+                iscn_pct_cellSoc1[i] = look1_iu16lu16n16tu16_binlcase(sfmv_V_cellU[i], (&(cmnm_V_ocv[0])), (&(cmnm_pct_soc[0])), 12U);
+                iscn_Q_cellAh[i] = (uint16_T)((uint16_T)((uint32_T) iscn_pct_cellSoc1[i]  * sohv_Q_cellCap[i] / 2000U) << 1);
+                iscn_Q_deltAh[i] = (int16_T) (iscn_Q_cellAh[i] - iscv_Q_remainCpEE[i]);
+            }
+            for(i = 0; i < cmnc_num_cellUNum;i++)
+            {
+                if((real_T)(ArrMean(&iscn_Q_deltAh[0],cmnc_num_cellUNum) -  iscn_Q_deltAh[i]) * 0.1/(iscd_tm_totalEE + ihd_tm_parkTime) * 3600 > 0.1)
+                {
+                    iscd_flg_fulStat = true && iscd_tm_totalEE !=0;
+                }
+            }
+            memcpy(iscv_Q_remainCpEo,iscn_Q_cellAh, sizeof(iscn_Q_cellAh));
+            iscd_tm_totalEE = 0 ;
+        }
+        else
+        {
+            memcpy(iscv_Q_remainCpEo,iscv_Q_remainCpEi, sizeof(iscv_Q_remainCpEi));
+            iscd_tm_totalEE = iscd_tm_totalEE + ihd_tm_parkTime;
+        }
+    }
+	if(iscv_Q_remainCpEo[0] != 0)
+	{
+        iscd_tm_totalEo = iscd_tm_totalEE + RunCtn;
+	}
+	
+    //=====================================================================
+    //================定时唤醒诊断======================================1A
+    //=====================================================================
+    if(appd_st_preCyc == 1 && ihd_tm_parkTime >= cmnc_tm_parkTime && sfmd_I_curr < 10 && sfmd_I_curr > -10 && FirstRun_ISC)
+    {
+        for (i = 0; i < cmnc_num_cellUNum;i++)
+        {
+            iscn_pct_cellSoc1[i] = look1_iu16lu16n16tu16_binlcase(appv_V_cellU[i], (&(cmnm_V_ocv[0])), (&(cmnm_pct_soc[0])), 12U);
+            iscn_pct_cellSoc2[i] = look1_iu16lu16n16tu16_binlcase(sfmv_V_cellU[i], (&(cmnm_V_ocv[0])), (&(cmnm_pct_soc[0])), 12U);
+            iscn_Q_deltAh[i] = (int16_T)((uint16_T)((uint32_T) iscn_pct_cellSoc2[i]  * sohv_Q_cellCap[i] / 2000U) << 1) - (int16_T)((uint16_T)((uint32_T) iscn_pct_cellSoc1[i]  * sohv_Q_cellCap[i] / 2000U) << 1);
+        }
+        for (i = 0; i < cmnc_num_cellUNum;i++)
+        {
+            if(ArrMean(&iscn_Q_deltAh[0],cmnc_num_cellUNum) -  iscn_Q_deltAh[i] > 10)
+            {
+                iscd_flg_timedWakeUpFlt = true;
+            }
+        }
+		
+    }
+   
+	
+    
+    //=====================================================================
+    //================放电过程中诊断=================================== 2A
+    //=====================================================================
+    if(!socd_flg_cellSocDisable)
+    {
+        TimeCtn = TimeCtn + 1;
+        for (i = 0; i < cmnc_num_cellUNum;i++)
+        {
+            //Ah[i] =(int16_T)((uint16_T)((uint32_T) socv_pct_cellSoc[i]  * sohv_Q_cellCap[i] / 2000U) << 1);
+            iscn_Q_cellAh[i]=(uint16_T) ((real_T)( socv_pct_cellSoc[i] * 0.1) * (real_T)( sohv_Q_cellCap[i] * 0.1)/100 * 100);
+        }
+        if (TimeCtn == 60)
+        {
+            memcpy(iscn_Q_cellAh0,iscn_Q_cellAh, sizeof(iscn_Q_cellAh));
+        }
+        if (TimeCtn > 60 + 360)
+        {
+            for (i = 0; i < cmnc_num_cellUNum;i++)
+            {
+                iscn_Q_deltAh[i] = (int16_T)(iscn_Q_cellAh[i] - iscn_Q_cellAh0[i]);
+            }
+            for (i = 0; i < cmnc_num_cellUNum;i++)
+            {
+                if((real_T)(ArrMean(&iscn_Q_deltAh[0],cmnc_num_cellUNum) -  iscn_Q_deltAh[i]) * 0.01/(TimeCtn - 60) * 3600 > 2 )
+                {
+                    iscn_N_fltNr[i] =  (iscn_N_fltNr[i] + 1) > 60000 ? 60000 : (iscn_N_fltNr[i] + 1);
+                }
+                else
+                {
+                    iscn_N_fltNr[i] = 0;
+                }
+                if (iscn_N_fltNr[i] > 600)
+                {
+                    iscd_flg_disChrgFlt = true;
+                }
+            }
+        }
+		if(TimeCtn > 3600)
+		{
+		   TimeCtn =60;
+		}
+    }
+    else
+    {
+        TimeCtn = 0;
+    }
+	
+    /////
+    iscd_flg_flt = iscd_flg_disChrgFlt||iscd_flg_timedWakeUpFlt ||iscd_flg_fulStat;
+  /*
+    printf("R-%d,%d,%d\n",cdmv_ohm_deltR[0],cdmv_ohm_deltR[1],cdmv_ohm_deltR[2]);
+	printf("E-%d,%d,%d\n",cdmv_V_deltOCV[0],cdmv_V_deltOCV[1],cdmv_V_deltOCV[2]);
+	printf("S-%d,%d,%d\n",socv_pct_cellSoc[0],socv_pct_cellSoc[1],socv_pct_cellSoc[2]);
+	printf("a-%d,%d,%d\n",iscn_Q_cellAh[0],iscn_Q_cellAh[1],iscn_Q_cellAh[2]);
+    printf("a-%d,%d,%d\n",iscn_Q_cellAh0[0],iscn_Q_cellAh0[1],iscn_Q_cellAh0[2]);
+	for(i=0;i<3;i++)
+		{
+	 printf("%f    ",(real_T)(ArrMean(&iscn_Q_deltAh[0],cmnc_num_cellUNum) -  iscn_Q_deltAh[i]) * 0.01/(TimeCtn - 60) * 3600);
+		}
+    printf("\nTimeCtn:%d\n\n",TimeCtn);
+    */
+	FirstRun_ISC = false;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+int16_T ArrMean(int16_T *Data, uint16_T m)
+{
+    uint16_T i;
+    int32_T Sum = 0;
+    int16_T DataMean;
+    
+    for (i = 0;i < m ;i++)
+    {
+        Sum = Sum + Data[i];
+    }
+    DataMean = (int16_T)Sum /m;
+    return DataMean;
+}

+ 16 - 10
src/EmbeddedCoder_src/SFM.c

@@ -246,6 +246,8 @@ void SFM(void)
         sfmd_flg_heatCirClosFltEo = false;
         sfmd_flg_heatRunFltEi = false;
         sfmd_flg_heatRunFltEo = false;
+		sfmd_flg_iscFltEi = false;
+		sfmd_flg_iscFltEi = false;
     }
 
     //=======================================================================================
@@ -274,6 +276,8 @@ void SFM(void)
     {
         sfmd_flg_HVILFlt = false;
     }
+   //16
+    sfmd_flg_iscFltEo = iscd_flg_flt ||sfmd_flg_iscFltEi||sfmd_flg_iscFltEo;
 
     //22 充电Mos失效故障
     sfmd_flg_chrgMosClosFlt = JudgeTimeSystem(!sfmd_flg_interComFlt, ihd_flg_chrgMosClosFlt, &DiagTime.N22, 2);
@@ -382,7 +386,8 @@ void SFM(void)
         }
         else
         {
-            sfmd_V_cellUAvrg = SumU / UNum;
+            //sfmd_V_cellUAvrg = SumU / UNum;
+			sfmd_V_cellUAvrg = (SumU - sfmd_V_cellUMax - sfmd_V_cellUMin) / (UNum - 2);
         }
 
 
@@ -578,7 +583,7 @@ void SFM(void)
             }
         }
     }
-
+	
     //69 加热板温度全部开路故障
     sfmd_flg_heatPanTAllFlt = (sfmd_flg_heatPanT1OpenFlt || sfmd_flg_heatPanT1RationFlt) && (sfmd_flg_heatPanT2OpenFlt || sfmd_flg_heatPanT2RationFlt);
 
@@ -874,7 +879,7 @@ void SFM(void)
 		  SumT0 = 0;
 	    }
     }	
-    
+
     if (!sfmd_flg_heatPanT1OpenFlt && !sfmd_flg_heatPanT1RationFlt && (int16_T)(ihd_T_heatPanT1 - ihd_T_heatPanT1_Delay1) > -10 && (int16_T)(ihd_T_heatPanT1 - ihd_T_heatPanT1_Delay1) < 20 )
     {
         if (FirstRun_SFM)
@@ -926,17 +931,18 @@ void SFM(void)
         }
     }
     ihd_T_heatPanT2_Delay1 =ihd_T_heatPanT2;
+	
     //32 加热回路常闭故障
-    deltaTEn1  = !sfmd_flg_heatPanT1OpenFlt && !sfmd_flg_heatPanT1RationFlt && !sfmd_flg_ACPlugTOpenFlt &&!sfmd_flg_ACPlugTRationFlt && !sfmd_flg_DCPlugTOpenFlt &&!sfmd_flg_DCPlugTRationFlt && ((ihd_T_heatPanT1 > ihd_T_ACPlugT + 5) && (ihd_T_heatPanT1 > ihd_T_DCPlugT + 5));
-    deltaTEn2  = !sfmd_flg_heatPanT2OpenFlt && !sfmd_flg_heatPanT2RationFlt && !sfmd_flg_ACPlugTOpenFlt &&!sfmd_flg_ACPlugTRationFlt && !sfmd_flg_DCPlugTOpenFlt &&!sfmd_flg_DCPlugTRationFlt && ((ihd_T_heatPanT2 > ihd_T_ACPlugT + 5) && (ihd_T_heatPanT2 > ihd_T_DCPlugT + 5));
+    //deltaTEn1  = !sfmd_flg_heatPanT1OpenFlt && !sfmd_flg_heatPanT1RationFlt && !sfmd_flg_ACPlugTOpenFlt &&!sfmd_flg_ACPlugTRationFlt && !sfmd_flg_DCPlugTOpenFlt &&!sfmd_flg_DCPlugTRationFlt && ((ihd_T_heatPanT1 > ihd_T_ACPlugT + 5) && (ihd_T_heatPanT1 > ihd_T_DCPlugT + 5));
+    //deltaTEn2  = !sfmd_flg_heatPanT2OpenFlt && !sfmd_flg_heatPanT2RationFlt && !sfmd_flg_ACPlugTOpenFlt &&!sfmd_flg_ACPlugTRationFlt && !sfmd_flg_DCPlugTOpenFlt &&!sfmd_flg_DCPlugTRationFlt && ((ihd_T_heatPanT2 > ihd_T_ACPlugT + 5) && (ihd_T_heatPanT2 > ihd_T_DCPlugT + 5));
 	Enable1 = JudgeTimeSystem(1, tmsd_st_heatAct == 0, &DiagTime.N32, 600);
-    sfmd_flg_heatCirClosFltEo = (((int16_T)(heatT2Arr[9] - heatT2Arr[0]) > 5 || (int16_T)(heatT1Arr[9] - heatT1Arr[0]) > 5) && (modTMaxArr[9] > modTMaxArr[0] + 3) && Enable1 && (deltaTEn1 || deltaTEn2)) || sfmd_flg_heatCirClosFltEo || sfmd_flg_heatCirClosFltEi;
+    sfmd_flg_heatCirClosFltEo = (((int16_T)(heatT2Arr[9] - heatT2Arr[0]) > 5 || (int16_T)(heatT1Arr[9] - heatT1Arr[0]) > 5) && (modTMaxArr[9] > modTMaxArr[0] + 4) && Enable1 ) || sfmd_flg_heatCirClosFltEo || sfmd_flg_heatCirClosFltEi;
 
+	
     //33 加热回路常开故障
     Enable2 = JudgeTimeSystem(1, tmsd_st_heatAct == 1, &DiagTime.N33, 600);
     sfmd_flg_heatCirOpenFltEo = (((int16_T)(heatT2Arr[9] - heatT2Arr[0]) < 5 && (int16_T)(heatT1Arr[9] - heatT1Arr[0]) < 5) && Enable2) || sfmd_flg_heatCirOpenFltEo || sfmd_flg_heatCirOpenFltEi;
 
-    //printf("%d   %d  %d   %d   %d  %d  %d\n",sfmd_flg_Udrop,sfmd_flg_volFlt_keep,sfmd_flg_Tup,sfmd_flg_modTOpenFlt_keep,CntB,sfmd_flg_heatclear,sfmd_flg_heatRunFltEo) ;
 
     //================================================================================================================================================================
     //================================================================================================================================================================
@@ -1007,9 +1013,9 @@ void SFM(void)
     FltLevel[14] = 0;
     FltAct[14] = 0; //15 绝缘告警
     
-    FltFlg[15] = 0;
-    FltLevel[15] = 0;
-    FltAct[15] = 0; //16 预留5
+    FltFlg[15] = sfmd_flg_iscFltEo;
+    FltLevel[15] = 4;
+    FltAct[15] = 250; //16 
     
     FltFlg[16] = 0;
     FltLevel[16] = 0;

+ 11 - 10
src/EmbeddedCoder_src/SOC.c

@@ -123,7 +123,7 @@ void SOC(void)
     if (FirstRun_SOC)
     { //
         if (socd_pct_battSocEi > 1000 || socd_pct_bcuSocEi > 1000 || ihd_st_EOLState == 0 ||
-                (((int16_T)(socd_pct_battSocEi - socd_pct_bcuSocEi) > 300 || (int16_T)(socd_pct_battSocEi - socd_pct_bcuSocEi) < -300) && ihd_tm_parkTime > cmnc_tm_parkTime))
+                (((int16_T)(socd_pct_battSocEi - socd_pct_bcuSocEi) > 300 || (int16_T)(socd_pct_battSocEi - socd_pct_bcuSocEi) < -300) && ihd_tm_parkTime >= cmnc_tm_parkTime))
         {
             socn_pct_battSocEE = look1_iu16lu16n16tu16_binlcase(sfmd_V_cellUAvrg, (&(cmnm_V_ocv[0])), (&(cmnm_pct_soc[0])), 12U);
             socn_pct_bcuSocEE  = look1_iu16lu16n16tu16_binlcase(sfmd_V_cellUAvrg, (&(cmnm_V_ocv[0])), (&(cmnm_pct_soc[0])), 12U);
@@ -134,7 +134,7 @@ void SOC(void)
             socn_pct_bcuSocEE = socd_pct_bcuSocEi;
         }
         //
-        if (ihd_tm_parkTime > cmnc_tm_parkTime)
+        if (ihd_tm_parkTime >= cmnc_tm_parkTime)
         {
             socn_pct_battSocEE = look1_iu16lu16n16tu16_binlcase(sfmd_V_cellUAvrg, (&(cmnm_V_ocv[0])), (&(cmnm_pct_soc[0])), 12U);
         }
@@ -210,8 +210,8 @@ void SOC(void)
     //输出
     EKFSOCMin = (uint16_T)(soc_Min_Delay * 10);
     socn_flg_ekfInvalidMin = (deltU > 0.01) || (deltU < -0.01);
-    //printf("2----socmin:%f,Up:%f,U1:%d,sfmd_V_cellUMin:%d,deltU:%f,flg:%d,soc1:%f,K[0]:%f,K[1]:%f\n",soc_Min_Delay,Up_Min_Delay,ihv_V_cellU[0],sfmd_V_cellUMin,deltU,socn_flg_ekfInvalidMin,soc1,K[0],K[1]);
-    //------------------------EKFSOCmax-----------------------------------
+    //printf("2----soc:%f,Up:%f,U:%d,deltU:%f,K[0]:%f,K[1]:%f\n",soc_Min_Delay,Up_Min_Delay,sfmd_V_cellUMin,deltU,K[0],K[1]);  
+	//------------------------EKFSOCmax-----------------------------------
     if (FirstRun_SOC)
     {
         soc_Max_Delay = (real_T)socn_pct_battSocEE * 0.1;
@@ -273,7 +273,7 @@ void SOC(void)
     //输出
     EKFSOCMax = (uint16_T)(soc_Max_Delay * 10);
     socn_flg_ekfInvalidMax = (deltU > 0.01) || (deltU < -0.01);
-    //printf("3----socmax:%f,Up:%f,sfmd_V_cellUMax:%d,deltU:%f,flg:%d\n",soc_Max_Delay,Up_Max_Delay,sfmd_V_cellUMax,deltU,socn_flg_ekfInvalidMax);
+    //printf("4----soc:%f,Up:%f,U:%d,deltU:%f,K[0]:%f,K[1]:%f\n",soc_Max_Delay,Up_Max_Delay,sfmd_V_cellUMax,deltU,K[0],K[1]);
     //-----------------------EKFSOC----------------------------------------
     socn_flg_ekfInvalid = socn_flg_ekfInvalidMax || socn_flg_ekfInvalidMin;
     if (EKFSOCMax > 800)
@@ -303,10 +303,10 @@ void SOC(void)
         P_avrg_Delay[3] = 10;
     }
     //参数查表
-    ocv = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Min_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_V_ocv[0])),   12U) * 0.001;
-    Ro  = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Min_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_ohm[0])),   12U) * 0.001 * 0.001;
-    Rp  = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Min_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_polar[0])), 12U) * 0.001 * 0.001;
-    C   = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Min_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_F_polar[0])), 12U) * 0.001 * 1000;
+    ocv = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Avrg_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_V_ocv[0])),   12U) * 0.001;
+    Ro  = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Avrg_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_ohm[0])),   12U) * 0.001 * 0.001;
+    Rp  = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Avrg_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_polar[0])), 12U) * 0.001 * 0.001;
+    C   = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Avrg_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_F_polar[0])), 12U) * 0.001 * 1000;
     A[0] = 1;
     A[1] = 0;
     A[2] = 0;
@@ -354,12 +354,13 @@ void SOC(void)
     //输出
     EKFSOCAvrg = (uint16_T)(soc_Avrg_Delay * 10);
     socn_flg_ekfInvalidAvrg = (deltU > 0.01) || (deltU < -0.01);
+	//printf("4----soc:%f,Up:%f,U:%d,deltU:%f,K[0]:%f,K[1]:%f\n\n",soc_Avrg_Delay,Up_Avrg_Delay,sfmd_V_cellUAvrg,deltU,K[0],K[1]);
     //
     for(i = 0;i < cmnc_num_cellUNum;i++)
     {
         socv_pct_cellSoc[i] = look1_iu16lu16n16tu16_binlcase((look1_iu16lu16n16tu16_binlcase(EKFSOCAvrg, (&(cmnm_pct_soc[0])), (&(cmnm_V_ocv[0])), 12U) + cdmv_V_deltOCV[i]), (&(cmnm_V_ocv[0])),(&(cmnm_pct_soc[0])),12U);
     }
-    //socn_flg_ekfInvalid = socn_flg_ekfInvalidAvrg || cdmd_flg_deltOCVDisable;
+    socd_flg_cellSocDisable = socn_flg_ekfInvalidAvrg || cdmd_flg_deltOCVDisable;
     cellSocMax = ArrMax(&socv_pct_cellSoc[0],cmnc_num_cellUNum);
     cellSocMin = ArrMin(&socv_pct_cellSoc[0],cmnc_num_cellUNum);
     if (cellSocMax > 800)

+ 3 - 2
src/EmbeddedCoder_src/SOH.c

@@ -95,7 +95,7 @@ void SOH(void)
  		//=======================================================================================
         //--------------------------计算使能-------------------------------------------------------
         //=======================================================================================
-        if(ihd_tm_parkTime > cmnc_tm_parkTime && sohn_flg_chrgEndEE && sohn_Q_chrgEE > sohc_Q_countThr && !sfmd_flg_cellUDisable && sfmd_I_curr < 10 && sfmd_I_curr > -10)
+        if(ihd_tm_parkTime >= cmnc_tm_parkTime && sohn_flg_chrgEndEE && sohn_Q_chrgEE > sohc_Q_countThr && !sfmd_flg_cellUDisable && sfmd_I_curr < 10 && sfmd_I_curr > -10)
         {
             sohn_flg_countEn = true;
         }
@@ -152,7 +152,8 @@ void SOH(void)
              memcpy(sohv_Q_packCapArrEo,sohn_Q_packCapArrEE, sizeof(sohv_Q_packCapArrEo));
              memcpy(sohv_Q_cellCapArrEo,sohn_Q_cellCapArrEE, sizeof(sohv_Q_cellCapArrEo));
          }
- 
+		 memcpy(sohv_Q_cellCap,sohv_Q_cellCapArrEo, sizeof(sohv_Q_cellCapArrEo));
+
  
          SumQ = 0;
          for(i = 0; i < 10;i++)