فهرست منبع

soh更新情况观测

tengfei.qi@fast-fun.com.cn 2 سال پیش
والد
کامیت
1829cbbfe1
4فایلهای تغییر یافته به همراه101 افزوده شده و 182 حذف شده
  1. 2 3
      src/AppTaskTcp.c
  2. 1 1
      src/EmbeddedCoder_src/ISC.c
  3. 78 164
      src/EmbeddedCoder_src/SOC.c
  4. 20 14
      src/EmbeddedCoder_src/SOH.c

+ 2 - 3
src/AppTaskTcp.c

@@ -579,13 +579,12 @@ static void TcpDataInfoAssembleSend()
         static UINT8 Debugcounter = 0;
         sprintf((char *)rbuf, "B-%d,%d,%d,%d,%d,,\
                                 %d,%d,%d,%d,%d,,\
-                                %d,%d,%d,%d,%d,,\
-                                %d,%d,%d,%d,%d,,\
+                                %d,%d,%d,%d,%d,%d,%d,%d,,\
                                 %d,%d,%d,%d,%d,%d,%d,%d,,\
                                 %d,%d,%d,,",
                 socd_pct_ahSoc, socd_pct_ekfSoc, socd_pct_battSoc, socd_pct_bcuSoc, pimd_pct_battSoc,
                 sfmd_I_curr, sfmd_V_cellUMax, sfmd_V_cellUMin, sfmv_V_cellU[0],ihd_tm_parkTime,
-                cand_idx_cellNr, cand_Q_cellCap, sohd_Q_chrgEo, iscv_Q_remainCpEi[cand_idx_cellNr - 1], iscd_tm_totalEi,
+                cand_idx_cellNr, cand_Q_cellCap,sohv_V_chrgStartStatEi[cand_idx_cellNr - 1], sohv_V_chrgStartStatEo[cand_idx_cellNr - 1],sohd_Q_chrgEo,sohd_flg_chrgEndEi, iscv_Q_remainCpEi[cand_idx_cellNr - 1], iscd_tm_totalEi,
                 pimd_V_ocv, pimd_R_ohm, pimd_R_polar, pimd_F_polar, pimd_flg_inval, pimv_R_cellOhm[sfmd_idx_cellUMin],ArrMax(pimv_R_cellOhm, 20),ArrMin(pimv_R_cellOhm, 20),
                 iscd_flg_flt[0], iscd_flg_flt[1], iscd_flg_flt[2]);
         if (Debugcounter % 5 == 0)

+ 1 - 1
src/EmbeddedCoder_src/ISC.c

@@ -54,7 +54,7 @@ void ISC(void)
             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)
+        if((iscd_tm_totalEE + ihd_tm_parkTime >= 20 * 3600 || iscd_tm_totalEE == 0) && ihd_tm_parkTime >= cmnc_tm_parkTime && socd_pct_battSoc > 850 && sfmd_I_curr > -10 && sfmd_I_curr < 10)
         {
             for(i = 0; i < cmnc_num_cellUNum;i++)
             {

+ 78 - 164
src/EmbeddedCoder_src/SOC.c

@@ -20,7 +20,6 @@ void SOC(void)
     real_T battcurr;
     boolean_T socn_flg_ekfInvalidMin;
     boolean_T socn_flg_ekfInvalidMax;
-    boolean_T socn_flg_ekfInvalidAvrg;
     boolean_T socn_flg_ekfInvalid;
     real_T ocv;
     real_T Ro;
@@ -28,34 +27,26 @@ void SOC(void)
     real_T RC;
     real_T deltU;
 	real_T UL;
-    real_T A[4];
+    real_T A[2][2];
     real_T B[2];
     real_T H[2];
     real_T K[2];
-    real_T P1[4];
-    static real_T P_Min_Delay[4];
-    static real_T P_Max_Delay[4];
-    static real_T P_avrg_Delay[4];
+    real_T P1[2][2];
+    static real_T P_Min_Delay[2][2];
+    static real_T P_Max_Delay[2][2];
     real_T soc1;
     static real_T soc_Min_Delay;
-    static real_T soc_Avrg_Delay;
     static real_T soc_Max_Delay;
     real_T Up1;
     static real_T Up_Min_Delay;
     static real_T Up_Max_Delay;
-    static real_T Up_Avrg_Delay;
 	uint16_T EKFSOCMin;
     uint16_T EKFSOCMax;
-	
-    uint16_T EKFSOCAvrg;
-	uint16_T cellSocMax;
-    uint16_T cellSocMin;
     uint16_T factor;
     //
     static real_T ahDelay;
     int16_T ahSoc;
     //
-    boolean_T socn_flg_ekfDisable;
     static uint16_T  ekfInvalidCntl;
     static boolean_T onceFlg_est;
     static int16_T   ahSoc0_est;
@@ -97,6 +88,7 @@ void SOC(void)
 	static uint16_T socn_pct_battSoc_save;
 	static uint16_T socn_pct_bcuSoc_save;
     uint16_T i;
+	static uint16_T kk;
     //
     if (socd_flg_firstRun)
     {
@@ -118,7 +110,9 @@ void SOC(void)
         onceFlg_dischrg = true;
 		socn_pct_battSoc_save = 0;
 		socn_pct_bcuSoc_save = 0;
+		kk=0;
     }
+
     
     //=====================================================================
     ////////////////////////初始值获取/EE校验//////////////////////////////
@@ -143,6 +137,8 @@ void SOC(void)
         }
         socn_Q_cap = (uint16_T)((uint16_T)((uint32_T)sohd_pct_bcuSoh * cmnc_Q_ratedCp / 2000U) << 1);
     }
+	//socn_pct_battSocEE =600;
+
     //printf("1----  battSocEi:%d,bcuSocEi:%d,battSocEE:%d,bcuSocEE:%d\n",socd_pct_battSocEi,socd_pct_bcuSocEi,socn_pct_battSocEE,socn_pct_bcuSocEE);
     //======================================================================
     ////////////////////////EKFSOC//////////////////////////////////////////
@@ -155,75 +151,77 @@ void SOC(void)
     {
         soc_Min_Delay = (real_T)socn_pct_battSocEE * 0.1;
         Up_Min_Delay = 0;
-        P_Min_Delay[0] = 10;
-        P_Min_Delay[1] = 0;
-        P_Min_Delay[2] = 0;
-        P_Min_Delay[3] = 10;
+        P_Min_Delay[0][0] = 1000;
+        P_Min_Delay[0][1] = 0;
+        P_Min_Delay[1][0] = 0;
+        P_Min_Delay[1][1] = 1000;
     }
     //参数查表
     ocv = (real_T)look1_u16tu16((uint16_T)(soc_Min_Delay * 10), cmnm_pct_soc, cmnm_V_ocv,  13) * 0.001;
     Ro  = (real_T)look1_u16tu16((uint16_T)(soc_Min_Delay * 10), cmnm_pct_soc, cmnm_R_ohm,  13) * 0.001 * 0.001;
     Rp  = (real_T)look1_u16tu16((uint16_T)(soc_Min_Delay * 10), cmnm_pct_soc, cmnm_R_polar,13) * 0.001 * 0.001;
     RC  = (real_T)look1_u16tu16((uint16_T)(soc_Min_Delay * 10), cmnm_pct_soc, cmnm_F_polar,13) * 0.001;
-    A[0] = 1;
-    A[1] = 0;
-    A[2] = 0;
-    A[3] = exp(-1 / RC);
-    
+    A[0][0] = 1;
+    A[0][1] = 0;
+    A[1][0] = 0;
+    A[1][1] = exp(-1 / RC);
+  
     B[0] = 1 / Q / 3600 * 100;
     B[1] = Rp * (1 - exp(-1 / RC));
-    
+
     H[0] = docvmath(soc_Min_Delay);
     H[1] = 1;
-    
+
     //先验
-    soc1 = soc_Min_Delay * A[0] + B[0] * battcurr;
-    Up1 = Up_Min_Delay * A[3] + B[1] * battcurr;
+    soc1 = soc_Min_Delay * A[0][0] + B[0] * battcurr;
+    Up1  =  Up_Min_Delay * A[1][1] + B[1] * battcurr;
     UL = ocv + battcurr * Ro + Up1;
-    P1[0] = P_Min_Delay[0] + 0.001;
-    P1[1] = P_Min_Delay[1] * A[3] + 0.001;
-    P1[2] = P_Min_Delay[2] * A[3] + 0.001;
-    P1[3] = P_Min_Delay[3] * A[3] * A[3] + 0.001;
-    
-    //增益
-    K[0] = (P1[0] * H[0] + P1[2]) / (H[0] * P1[0] * H[0] + P1[1] * H[0] + H[0] * P1[2] + P1[3] + 0.5);
-    K[1] = (P1[1] * H[0] + P1[3]) / (H[0] * P1[0] * H[0] + P1[1] * H[0] + H[0] * P1[2] + P1[3] + 0.5);
-    
+    P1[0][0] = A[0][0] * P_Min_Delay[0][0] * A[0][0] + 0.001;
+    P1[0][1] = A[0][0] * P_Min_Delay[0][1] * A[1][1] + 0.001;
+    P1[1][0] = A[1][1] * P_Min_Delay[1][0] * A[0][0] + 0.001;
+    P1[1][1] = A[1][1] * P_Min_Delay[1][1] * A[1][1] + 0.001;
+
+    //增益PH/(HPH'+ 0.5)
+    K[0] = (P1[0][0] * H[0] + P1[1][0] * H[1]) / (H[0] * P1[0][0] * H[0] + H[1] * P1[0][1] * H[0] + H[0] * P1[1][0] * H[1] + H[1] * P1[1][1] * H[1] + 0.5);
+    K[1] = (P1[1][0] * H[0] + P1[1][1] * H[1]) / (H[0] * P1[0][0] * H[0] + H[1] * P1[0][1] * H[0] + H[0] * P1[1][0] * H[1] + H[1] * P1[1][1] * H[1] + 0.5);
+
     //后验
     deltU = (real_T)sfmd_V_cellUMin * 0.001 - UL;
     soc_Min_Delay = soc1 + K[0] * deltU;
     soc_Min_Delay = Saturation_r(soc_Min_Delay, (real_T)socc_pct_battSocLow * 0.1, (real_T)socc_pct_battSocUp * 0.1);
     Up_Min_Delay  = Up1 + K[1] * deltU;
+
+
     //P更新
-    P_Min_Delay[0] = (1 - K[0] * H[0]) * P1[0] - K[0] * P1[1];
-    P_Min_Delay[1] = -K[1] * H[0] * P1[0] + P1[1] * (1 - K[1]);
-    P_Min_Delay[2] = (1 - K[0] * H[0]) * P1[2] - K[0] * P1[3];
-    P_Min_Delay[3] = -K[1] * H[0] * P1[2] + P1[3] * (1 - K[1]);
-    
+    P_Min_Delay[0][0] = (1 - K[0] * H[0]) * P1[0][0] + (0 - K[0] * H[1]) * P1[1][0];
+    P_Min_Delay[0][1] = (1 - K[0] * H[0]) * P1[0][1] + (0 - K[0] * H[1]) * P1[1][1];
+    P_Min_Delay[1][0] = (0 - K[1] * H[0]) * P1[0][0] + (1 - K[1] * H[1]) * P1[1][0];
+    P_Min_Delay[1][1] = (0 - K[1] * H[0]) * P1[0][1] + (1 - K[1] * H[1]) * P1[1][1];
+
     //输出
     EKFSOCMin = (uint16_T)(soc_Min_Delay * 10);
     socn_flg_ekfInvalidMin = (deltU > 0.02) || (deltU < -0.02);
-    //printf("2----socmin:%f,U:%d,R:%f\n",soc_Min_Delay,sfmd_V_cellUMin,Ro);
+	//printf("2----socmin:%f,U:%d  %f\n",soc_Min_Delay,sfmd_V_cellUMin,deltU);
 	//------------------------EKFSOCmax-----------------------------------
-    if (socd_flg_firstRun)
+	if (socd_flg_firstRun)
     {
         soc_Max_Delay = (real_T)socn_pct_battSocEE * 0.1;
         Up_Max_Delay = 0;
-        P_Max_Delay[0] = 10;
-        P_Max_Delay[1] = 0;
-        P_Max_Delay[2] = 0;
-        P_Max_Delay[3] = 10;
+        P_Max_Delay[0][0] = 1000;
+        P_Max_Delay[0][1] = 0;
+        P_Max_Delay[1][0] = 0;
+        P_Max_Delay[1][1] = 1000;
     }
-    // 参数查表
+    //参数查表
     ocv = (real_T)look1_u16tu16((uint16_T)(soc_Max_Delay * 10), cmnm_pct_soc, cmnm_V_ocv,  13) * 0.001;
     Ro  = (real_T)look1_u16tu16((uint16_T)(soc_Max_Delay * 10), cmnm_pct_soc, cmnm_R_ohm,  13) * 0.001 * 0.001;
     Rp  = (real_T)look1_u16tu16((uint16_T)(soc_Max_Delay * 10), cmnm_pct_soc, cmnm_R_polar,13) * 0.001 * 0.001;
     RC  = (real_T)look1_u16tu16((uint16_T)(soc_Max_Delay * 10), cmnm_pct_soc, cmnm_F_polar,13) * 0.001;
 
-    A[0] = 1;
-    A[1] = 0;
-    A[2] = 0;
-    A[3] = exp(-1 / RC);
+	A[0][0] = 1;
+    A[0][1] = 0;
+    A[1][0] = 0;
+    A[1][1] = exp(-1 / RC);
     
     B[0] = 1 / Q / 3600 * 100;
     B[1] = Rp * (1 - exp(-1 / RC));
@@ -232,34 +230,35 @@ void SOC(void)
     H[1] = 1;
     
     //先验
-    soc1 = soc_Max_Delay * A[0] + B[0] * battcurr;
-    Up1 = Up_Max_Delay * A[3] + B[1] * battcurr;
+    soc1 = soc_Max_Delay * A[0][0] + B[0] * battcurr;
+    Up1  =  Up_Max_Delay * A[1][1] + B[1] * battcurr;
     UL = ocv + battcurr * Ro + Up1;
+
+	P1[0][0] = A[0][0] * P_Max_Delay[0][0] * A[0][0] + 0.001;
+    P1[0][1] = A[0][0] * P_Max_Delay[0][1] * A[1][1] + 0.001;
+    P1[1][0] = A[1][1] * P_Max_Delay[1][0] * A[0][0] + 0.001;
+    P1[1][1] = A[1][1] * P_Max_Delay[1][1] * A[1][1] + 0.001;
     
-    P1[0] = P_Max_Delay[0] + 0.001;
-    P1[1] = P_Max_Delay[1] * A[3] + 0.001;
-    P1[2] = P_Max_Delay[2] * A[3] + 0.002;
-    P1[3] = P_Max_Delay[3] * A[3] * A[3] + 0.001;
-    
-    //增益
-    K[0] = (P1[0] * H[0] + P1[2]) / (H[0] * P1[0] * H[0] + P1[1] * H[0] + H[0] * P1[2] + P1[3] + 0.5);
-    K[1] = (P1[1] * H[0] + P1[3]) / (H[0] * P1[0] * H[0] + P1[1] * H[0] + H[0] * P1[2] + P1[3] + 0.5);
+    //增益PH/(HPH'+ 0.5)
+    K[0] = (P1[0][0] * H[0] + P1[1][0] * H[1]) / (H[0] * P1[0][0] * H[0] + H[1] * P1[0][1] * H[0] + H[0] * P1[1][0] * H[1] + H[1] * P1[1][1] * H[1] + 0.5);
+    K[1] = (P1[1][0] * H[0] + P1[1][1] * H[1]) / (H[0] * P1[0][0] * H[0] + H[1] * P1[0][1] * H[0] + H[0] * P1[1][0] * H[1] + H[1] * P1[1][1] * H[1] + 0.5);
     
     //后验
     deltU = (real_T)sfmd_V_cellUMax * 0.001 - UL;
     soc_Max_Delay = soc1 + K[0] * deltU;
-	soc_Max_Delay = Saturation_r(soc_Max_Delay, (real_T)socc_pct_battSocLow * 0.1, (real_T)socc_pct_battSocUp * 0.1);
-    Up_Max_Delay = Up1 + K[1] * deltU;
-    
+    soc_Max_Delay = Saturation_r(soc_Max_Delay, (real_T)socc_pct_battSocLow * 0.1, (real_T)socc_pct_battSocUp * 0.1);
+    Up_Max_Delay  = Up1 + K[1] * deltU;
     //P更新
-    P_Max_Delay[0] = (1 - K[0] * H[0]) * P1[0] - K[0] * P1[1];
-    P_Max_Delay[1] = -K[1] * H[0] * P1[0] + P1[1] * (1 - K[1]);
-    P_Max_Delay[2] = (1 - K[0] * H[0]) * P1[2] - K[0] * P1[3];
-    P_Max_Delay[3] = -K[1] * H[0] * P1[2] + P1[3] * (1 - K[1]);
+    P_Max_Delay[0][0] = (1 - K[0] * H[0]) * P1[0][0] + (0 - K[0] * H[1]) * P1[1][0];
+    P_Max_Delay[0][1] = (1 - K[0] * H[0]) * P1[0][1] + (0 - K[0] * H[1]) * P1[1][1];
+    P_Max_Delay[1][0] = (0 - K[1] * H[0]) * P1[0][0] + (1 - K[1] * H[1]) * P1[1][0];
+    P_Max_Delay[1][1] = (0 - K[1] * H[0]) * P1[0][1] + (1 - K[1] * H[1]) * P1[1][1];
+   
     //输出
     EKFSOCMax = (uint16_T)(soc_Max_Delay * 10);
     socn_flg_ekfInvalidMax = (deltU > 0.02) || (deltU < -0.02);
-    //printf("3----socmax:%f,U:%d,R:%f\n\n",soc_Max_Delay,sfmd_V_cellUMax,Ro);
+    //printf("3----socmax:%f,U:%d  %f\n",soc_Max_Delay,sfmd_V_cellUMax,deltU);
+    
     //-----------------------EKFSOC----------------------------------------
     socn_flg_ekfInvalid = socn_flg_ekfInvalidMax || socn_flg_ekfInvalidMin;
     if (EKFSOCMax > 800)
@@ -277,88 +276,7 @@ void SOC(void)
     socd_pct_ekfSoc = (uint16_T)(((1 - (real_T)(factor * 0.01)) * (real_T)(EKFSOCMin * 0.1) + (real_T)(factor * 0.01) * (real_T)(EKFSOCMax * 0.1)) * 10);
    
    //printf("4----socd_pct_ekfSoc:%d,EKFSOCMax:%d,EKFSOCMin:%d,\n",socd_pct_ekfSoc,EKFSOCMax,EKFSOCMin);
-/*
-   //-------------------------EKFavrg---------------------------------------
-    if (socd_flg_firstRun)
-    {
-        soc_Avrg_Delay = (real_T)socn_pct_battSocEE * 0.1;
-        Up_Avrg_Delay = 0;
-        P_avrg_Delay[0] = 10;
-        P_avrg_Delay[1] = 0;
-        P_avrg_Delay[2] = 0;
-        P_avrg_Delay[3] = 10;
-    }
-    //参数查表
-    ocv = (real_T)look1_u16tu16((uint16_T)(soc_Avrg_Delay * 10), cmnm_pct_soc, cmnm_V_ocv,  13) * 0.001;
-    Ro  = (real_T)look1_u16tu16((uint16_T)(soc_Avrg_Delay * 10), cmnm_pct_soc, cmnm_R_ohm,  13) * 0.001 * 0.001;
-    Rp  = (real_T)look1_u16tu16((uint16_T)(soc_Avrg_Delay * 10), cmnm_pct_soc, cmnm_R_polar,13) * 0.001 * 0.001;
-    RC  = (real_T)look1_u16tu16((uint16_T)(soc_Avrg_Delay * 10), cmnm_pct_soc, cmnm_F_polar,13) * 0.001;
 
-    A[0] = 1;
-    A[1] = 0;
-    A[2] = 0;
-    A[3] = exp(-1 / RC);
-    
-    B[0] = 1 / Q / 3600 * 100;
-    B[1] = Rp * (1 - exp(-1 / RC));
-    
-    H[0] = docvmath(soc_Avrg_Delay);
-    H[1] = 1;
-    
-    //先验
-    soc1 = soc_Avrg_Delay * A[0] + B[0] * battcurr;
-    Up1 = Up_Avrg_Delay * A[3] + B[1] * battcurr;
-    UL = ocv + battcurr * Ro + Up1;
-    P1[0] = P_avrg_Delay[0] + 0.001;
-    P1[1] = P_avrg_Delay[1] * A[3] + 0.001;
-    P1[2] = P_avrg_Delay[2] * A[3] + 0.001;
-    P1[3] = P_avrg_Delay[3] * A[3] * A[3] + 0.001;
-    
-    //增益
-    K[0] = (P1[0] * H[0] + P1[2]) / (H[0] * P1[0] * H[0] + P1[1] * H[0] + H[0] * P1[2] + P1[3] + 0.5);
-    K[1] = (P1[1] * H[0] + P1[3]) / (H[0] * P1[0] * H[0] + P1[1] * H[0] + H[0] * P1[2] + P1[3] + 0.5);
-    
-    //后验
-    deltU = (real_T)sfmd_V_cellUAvrg * 0.001 - UL;
-    soc_Avrg_Delay = soc1 + K[0] * deltU;
-    
-    soc_Avrg_Delay = Saturation_r(soc_Avrg_Delay, (real_T)socc_pct_battSocLow * 0.1, (real_T)socc_pct_battSocUp * 0.1);
-    Up_Avrg_Delay = Up1 + K[1] * deltU;
-    //P更新
-    P_avrg_Delay[0] = (1 - K[0] * H[0]) * P1[0] - K[0] * P1[1];
-    P_avrg_Delay[1] = -K[1] * H[0] * P1[0] + P1[1] * (1 - K[1]);
-    P_avrg_Delay[2] = (1 - K[0] * H[0]) * P1[2] - K[0] * P1[3];
-    P_avrg_Delay[3] = -K[1] * H[0] * P1[2] + P1[3] * (1 - K[1]);
-    
-    //输出
-    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_u16tu16((look1_u16tu16(EKFSOCAvrg, cmnm_pct_soc, cmnm_V_ocv, 13) + cdmv_V_deltOCV[i]), cmnm_V_ocv, cmnm_pct_soc, 13);
-    }
-    socd_flg_cellSocDisable = socn_flg_ekfInvalidAvrg || cdmd_flg_deltOCVDisable;
-	
-    cellSocMax = ArrMax(socv_pct_cellSoc,cmnc_num_cellUNum);
-    cellSocMin = ArrMin(socv_pct_cellSoc,cmnc_num_cellUNum);
-	
-    if (cellSocMax > 800)
-    {
-        factor = 100;
-    }
-    else if (cellSocMin < 200)
-    {
-        factor = 0;
-    }
-    else
-    {
-        factor = (uint16_T)(((uint16_T)(((uint32_T)(cellSocMin - 200) << 6) / (800 - (cellSocMax - cellSocMin) - 200)) * 25U) >> 4);
-    }
-    socd_pct_cellBattSoc = (uint16_T)(((1 - (real_T)(factor * 0.01)) * (real_T)(cellSocMin * 0.1) + (real_T)(factor * 0.01) * (real_T)(cellSocMax * 0.1)) * 10);
-    
-*/
     //======================================================================
     ////////////////////////AhSOC//////////////////////////////////////////
     //======================================================================
@@ -368,18 +286,18 @@ void SOC(void)
     }
     else
     {
-        ahDelay = ahDelay + battcurr / (real_T)(cmnc_Q_ratedCp * 0.1) / 36.0;//cmnc_Q_ratedCp
+        ahDelay = ahDelay + battcurr / (real_T)(socn_Q_cap * 0.1) / 36.0;//cmnc_Q_ratedCp
     }
     ahSoc = (int16_T)(ahDelay * 10);
 	
-	socd_pct_ahSoc = Saturation_u(ahSoc < 0 ? 0 : (uint16_T)ahSoc, socc_pct_battSocLow, socc_pct_battSocUp);
+	socd_pct_ahSoc = Saturation_u((ahSoc < 0 ? 0 : (uint16_T)ahSoc), socc_pct_battSocLow, socc_pct_battSocUp);
 	//printf("5----ahDelay:%f,ahSoc:%d,battcurr:%f,sfmd_I_curr:%d\n",ahDelay,ahSoc,battcurr,sfmd_I_curr);
 	
     //======================================================================
     ///////////////////////estSOC//////////////////////////////////////////
     //======================================================================
-    socn_flg_ekfDisable = !JudgeTimeSystem(1,!socn_flg_ekfInvalid,&ekfInvalidCntl,2);
-    if (socn_flg_ekfDisable)
+
+    if (!JudgeTimeSystem(1,!socn_flg_ekfInvalid,&ekfInvalidCntl,2))
     {
         if (onceFlg_est)
         {  
@@ -415,8 +333,8 @@ void SOC(void)
             if (onceFlg_utrckOver)
             {
                 onceFlg_utrckOver = false;
-                ahSoc0_utrckOver = ahSoc;
-                estSoc0_utrckOver = socd_pct_estSoc > socc_pct_chrgCor ? socd_pct_estSoc : socc_pct_chrgCor;
+                ahSoc0_utrckOver  = ahSoc;
+                estSoc0_utrckOver = socc_pct_chrgCor;
             }
             socTemp = (uint16_T)(ahSoc - ahSoc0_utrckOver + estSoc0_utrckOver);
         }
@@ -564,15 +482,13 @@ void SOC(void)
 		
         socd_pct_bcuSoc = DataFilt(bcuSoc, &socd_pct_bcuSoc, 1);
 		
-        //printf("11-----x:[%d-%d-%d],y:[%d-%d-%d],bcusoc:%d,socd_pct_bcuSoc:%d\n",x[0],x[1],x[2],y[0],y[1],y[2],bcuSoc,socd_pct_bcuSoc);
+       //printf("11-----x:[%d-%d-%d],y:[%d-%d-%d],bcusoc:%d,socd_pct_bcuSoc:%d\n",x[0],x[1],x[2],y[0],y[1],y[2],bcuSoc,socd_pct_bcuSoc);
     }
 	socd_pct_bcuSoc = Saturation_u(socd_pct_bcuSoc, socc_pct_battSocLow, socc_pct_battSocUp);
     socd_pct_bcuSocEo = socd_pct_bcuSoc;
 
 	//=======================================VCUSOC========================================================================================
-	
     socd_pct_vcuSoc =  (uint16_T)((uint32_T)((socd_pct_bcuSoc - socc_pct_battSocLow) * 1000) / (socc_pct_battSocUp - socc_pct_battSocLow)); 
-	
     //================================================================================================
     //------------------EEsave-------------------------------------------=============================
     //================================================================================================
@@ -586,7 +502,6 @@ void SOC(void)
     {
         socd_flg_EEsave = 0;
     }
-
 	
     socd_flg_firstRun = false;
 
@@ -601,10 +516,9 @@ void SOC(void)
 real_T docvmath(real_T soc)
 {
     real_T docv;
-    docv = ((((((-1.0936E-13 * pow(soc, 7.0) +3.9249E-11 * pow(soc, 6.0)) +
-            -5.5776E-9 * pow(soc, 5.0)) + 3.996E-7 * pow(soc, 4.0)) +
-            -1.5332E-5 * pow(soc, 3.0)) +soc * soc * 0.0003192) +
-           -0.00371 * soc) +0.02732;
+    docv =   6.725e-16 * 9.0 * pow(soc, 8.0) + (-3.304e-13) * 8.0 * pow(soc, 7.0) + 6.833e-11 *   7.0 * pow(soc, 6.0) + (-7.706e-09 ) * 6.0 * pow(soc, 5.0) + 5.133e-07 * 5.0 * pow(soc, 4.0) + 
+          (-2.047e-05) * 4.0 * pow(soc, 3.0) +  0.0004758   * 3.0 * pow(soc, 2.0) + (-0.006105) * 2.0 * pow(soc, 1.0) +  0.04572;
+           
     return docv;
 }
 

+ 20 - 14
src/EmbeddedCoder_src/SOH.c

@@ -48,18 +48,6 @@ void SOH(void)
         sohn_flg_currFlt = false;
         Ahincr = 0;
         sohn_st_workStat_Delay = 0;
-        if (ihd_st_reSet == 1)
-        {
-            memcpy(sohv_V_chrgStartStatEo, sohv_V_chrgStartStatEi, sizeof(sohv_V_chrgStartStatEo));
-            sohd_Q_chrgEo = sohd_Q_chrgEi;
-            sohd_flg_chrgEndEo = sohd_flg_chrgEndEi;
-        }
-        else
-        {
-            memset(sohv_V_chrgStartStatEo, 0, sizeof(sohv_V_chrgStartStatEo));
-            sohd_Q_chrgEo = 0;
-            sohd_flg_chrgEndEo = 0;
-        }
     }
 
     if (sohd_flg_firstRun)
@@ -96,13 +84,30 @@ void SOH(void)
             sohn_tm_chrgStartStatEE = sohd_tm_chrgStartStatEi;
             sohn_flg_chrgEndEE = sohd_flg_chrgEndEi;
         }
+		
+		//若重启,则Eo=Ei
+        if (ihd_st_reSet == 1)
+        {
+            memcpy(sohv_V_chrgStartStatEo, sohv_V_chrgStartStatEi, sizeof(sohv_V_chrgStartStatEo));
+            sohd_Q_chrgEo = sohd_Q_chrgEi;
+            sohd_flg_chrgEndEo = sohd_flg_chrgEndEi;
+        }
+        else
+        {
+            memset(sohv_V_chrgStartStatEo, 0, sizeof(sohv_V_chrgStartStatEo));
+            sohd_Q_chrgEo = 0;
+            sohd_flg_chrgEndEo = 0;
+        }
+
+
+		
         //=======================================================================================
         //--------------------------计算使能-------------------------------------------------------
         //=======================================================================================
         if (ihd_tm_parkTime >= cmnc_tm_parkTime && sohn_flg_chrgEndEE && sohn_Q_chrgEE > sohc_Q_countThr && !sfmd_flg_cellUInval && sfmd_I_curr < 10 && sfmd_I_curr > -10 && ArrMin(sohn_V_chrgStartStatEE, cmnc_num_cellUNum) > 3300)
         {
             sohn_flg_countEn = true;
-            sohd_flg_chrgEndEo = 0;
+            //sohd_flg_chrgEndEo = 0;
         }
         else
         {
@@ -117,10 +122,11 @@ void SOH(void)
             sohn_flg_update = true;
             for (i = 0; i < cmnc_num_cellUNum; i++)
             {
-                soc2[i] = look1_u16tu16(sfmv_V_cellU[i], cmnm_V_ocv, cmnm_pct_soc, 13U);
+                soc2[i] = look1_u16tu16(sfmv_V_cellU[i],           cmnm_V_ocv, cmnm_pct_soc, 13U);
                 soc1[i] = look1_u16tu16(sohn_V_chrgStartStatEE[i], cmnm_V_ocv, cmnm_pct_soc, 13U);
                 deltSoc[i] = soc2[i] - soc1[i];
                 sohv_Q_cellCapArrEo[i] = (uint16_T)((real_T)(sohn_Q_chrgEE * 0.1) / (real_T)(deltSoc[i] * 0.1 / 100) * 10);
+				//sohv_Q_cellCapArrEo[i] = (uint16_T)((uint32_T)sohn_Q_chrgEE * 1000 / deltSoc[i]);
 
                 if ((int16_T)(sohv_Q_cellCapArrEo[i]) - sohn_Q_cellCapArrEE[i] > sohc_Q_updateDeltThr || (int16_T)(sohv_Q_cellCapArrEo[i]) - sohn_Q_cellCapArrEE[i] < -sohc_Q_updateDeltThr)
                 {