浏览代码

【V3.1.254.65】 Soh计算更改,新增观测量,重启原因观测

LAPTOP-EG88H5BE\86151 3 年之前
父节点
当前提交
402eb9ab32

+ 1 - 0
inc/EmbeddedCoder_inc/BCUDisp.h

@@ -52,6 +52,7 @@ extern boolean_T ihd_st_relayControl;
 extern uint8_T ihd_st_heatForceControl;
 extern uint8_T ihd_st_EOLState;
 extern boolean_T ihd_flg_urtRecFlg;
+extern uint8_T ihd_st_reSet;
 
 extern int16_T sfmd_I_curr;                              /*处理后整包电流 */
 extern uint16_T sfmd_T_modTMax;                          /*处理后模组温度最小 */

+ 3 - 3
src/AppTaskTcp.c

@@ -579,11 +579,11 @@ static void TcpDataInfoAssembleSend()
         {
             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",
                     socd_pct_ahSoc, socd_pct_ekfSoc, socd_pct_battSoc, socd_pct_vcuSoc, socd_pct_cellBattSoc, sohv_Q_packCapArrEo[9], cdmv_ohm_deltR[cand_Nr_cellNr - 1],
-                    sfmd_I_curr, maxCellVol, minCellVol, sfmd_V_cellUAvrg, sfmv_V_cellU[0],
-                    cand_Nr_cellNr, cand_Q_cellCap, cand_V_chrgStartStat, ihd_tm_parkTime, sohd_Q_chrgEo,
+                    sfmd_I_curr, maxCellVol, minCellVol, sfmd_V_cellUAvrg, sfmv_V_cellU[1],
+                    cand_Nr_cellNr, cand_Q_cellCap, cand_V_chrgStartStat, ihd_tm_parkTime, sohd_Q_chrgEo, sohd_flg_chrgEndEo,
                     pimd_V_ocv, pimd_R_ohm, pimd_R_polar, pimd_F_polar);
         }
         Debugcounter++;

+ 2 - 1
src/EmbeddedCoder_src/BCU.c

@@ -93,6 +93,7 @@ void BCU(void)
                     // printf("time:%d\n",ihd_tm_parkTime);
                     //
                     //数据获取
+                    ihd_st_reSet = SysResetFlag;
                     ihd_I_curr = (int16_T)(-(battI - 10000));
                     memcpy(ihv_V_cellU, battCellU, sizeof(battCellU));
                     for (i = 0; i < cmnc_num_modTNum; i++)
@@ -175,7 +176,7 @@ void BCU(void)
                 if (TimeCounter % 10 == 0)
                 {
                     ihd_tm_parkTime++;
-                    // printf("time:%d\n",ihd_tm_parkTime);
+                    //printf("time:%d\n",ihd_tm_parkTime);
                 }
                 if (TimeCounter % 1000 == 0)
                 {

+ 1 - 0
src/EmbeddedCoder_src/BCUDisp.c

@@ -52,6 +52,7 @@ boolean_T ihd_st_relayControl;
 uint8_T ihd_st_heatForceControl;             
 uint8_T ihd_st_EOLState;                   
 boolean_T ihd_flg_urtRecFlg;
+uint8_T ihd_st_reSet;
 
 int16_T sfmd_I_curr;                              /*处理后整包电流 */
 uint16_T sfmd_T_modTMax;                          /*处理后模组温度最小 */

+ 4 - 3
src/EmbeddedCoder_src/CDM.c

@@ -21,15 +21,15 @@ void CDM(void)
     real_T K[2];
     real_T arf[cmnc_num_cellUNumMax];
     uint16_T i;
-    static uint8_T ihd_st_workStat_Delay;
+    static uint8_T cmdn_st_workStat_Delay;
     static uint8_T cdmn_N_Cnt;
 
     //
-    if (ihd_st_workStat_Delay != 1 && ihd_st_workStat == 1)
+    if (cmdn_st_workStat_Delay != 1 && ihd_st_workStat == 1)
     {
         FirstRun_CDM = true;
     }
-    ihd_st_workStat_Delay = ihd_st_workStat;
+    
     //
     if (FirstRun_CDM)
     {
@@ -106,6 +106,7 @@ void CDM(void)
     }
 	
     FirstRun_CDM = false;
+	cmdn_st_workStat_Delay = ihd_st_workStat;
 }
 
 

+ 74 - 71
src/EmbeddedCoder_src/PIM.c

@@ -10,16 +10,16 @@ void PIM_Init(void)
 
 void PIM(void)
 {
-    static uint8_T ihd_st_workStat_Delay;
+    static uint8_T pimn_st_workStat_Delay;
     uint16_T i;
     uint16_T j;
     static uint16_T pimn_V_volt[pimd_L_rls];
-    static int16_T  pimn_I_curr[pimd_L_rls];
-    static real_T  pimn_V_ocv;
-    static real_T  pimn_R_ohm;
-    static real_T  pimn_R_polar;
-    static real_T  pimn_F_polar;
-    
+    static int16_T pimn_I_curr[pimd_L_rls];
+    static real_T pimn_V_ocv;
+    static real_T pimn_R_ohm;
+    static real_T pimn_R_polar;
+    static real_T pimn_F_polar;
+
     static uint16_T pimn_N_ctn;
     static real_T pimn_M_P[4][4];
     static real_T theta[4];
@@ -29,151 +29,154 @@ void PIM(void)
     real_T S[4];
     real_T temp;
     //重置
-    if (ihd_st_workStat_Delay != 1 && ihd_st_workStat == 1)
+    if (pimn_st_workStat_Delay != 1 && ihd_st_workStat == 1)
     {
         FirstRun_PIM = true;
     }
-    
-    
+
     //限定记忆长度
     if (FirstRun_PIM)
     {
         for (i = 0; i < pimd_L_rls; i++)
         {
-            pimn_V_volt[i] = sfmv_V_cellU[0];
+            pimn_V_volt[i] = sfmv_V_cellU[1];
             pimn_I_curr[i] = sfmd_I_curr;
         }
-	}
+    }
     else
     {
         for (i = 0; i < pimd_L_rls - 1; i++)
         {
-            pimn_V_volt[i]  = pimn_V_volt[i+1];
-            pimn_I_curr[i] = pimn_I_curr[i+1];
+            pimn_V_volt[i] = pimn_V_volt[i + 1];
+            pimn_I_curr[i] = pimn_I_curr[i + 1];
         }
-        pimn_V_volt[i] = sfmv_V_cellU[0];
+        pimn_V_volt[i] = sfmv_V_cellU[1];
         pimn_I_curr[i] = sfmd_I_curr;
     }
 
-    
     //初值
     if (FirstRun_PIM)
     {
-        pimn_M_P[0][0] = 10; pimn_M_P[0][1] =  0;  pimn_M_P[0][2] =  0;  pimn_M_P[0][3] =  0;
-        pimn_M_P[1][0] =  0; pimn_M_P[1][1] = 10;  pimn_M_P[1][2] =  0;  pimn_M_P[1][3] =  0;
-        pimn_M_P[2][0] =  0; pimn_M_P[2][1] =  0;  pimn_M_P[2][2] = 10;  pimn_M_P[2][3] =  0;
-        pimn_M_P[3][0] =  0; pimn_M_P[3][1] =  0;  pimn_M_P[3][2] =  0;  pimn_M_P[3][3] = 10;
-        
-        pimn_V_ocv   = 3.6;
-        pimn_R_ohm   = 0.002;
-        pimn_R_polar = 0.001;
-        pimn_F_polar = 10;
+        pimn_M_P[0][0] = 10;
+        pimn_M_P[0][1] = 0;
+        pimn_M_P[0][2] = 0;
+        pimn_M_P[0][3] = 0;
+        pimn_M_P[1][0] = 0;
+        pimn_M_P[1][1] = 10;
+        pimn_M_P[1][2] = 0;
+        pimn_M_P[1][3] = 0;
+        pimn_M_P[2][0] = 0;
+        pimn_M_P[2][1] = 0;
+        pimn_M_P[2][2] = 10;
+        pimn_M_P[2][3] = 0;
+        pimn_M_P[3][0] = 0;
+        pimn_M_P[3][1] = 0;
+        pimn_M_P[3][2] = 0;
+        pimn_M_P[3][3] = 10;
+
+        pimn_V_ocv = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(socd_pct_battSoc * 10), (&(cmnm_pct_soc[0])), (&(cmnm_V_ocv[0])), 12U) * 0.001;
+        pimn_R_ohm = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(socd_pct_battSoc * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_ohm[0])), 12U) * 0.001 * 0.001;
+        pimn_R_polar = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(socd_pct_battSoc * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_polar[0])), 12U) * 0.001 * 0.001;
+        pimn_F_polar = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(socd_pct_battSoc * 10), (&(cmnm_pct_soc[0])), (&(cmnm_F_polar[0])), 12U) * 0.001;
         pimn_N_ctn = 0;
-        
     }
     //
-    if(ihd_st_workStat_Delay == 1)
+    if (pimn_st_workStat_Delay == 1)
     {
         pimn_N_ctn = pimn_N_ctn + 1;
         //输入
         A[0] = (real_T)pimn_V_volt[pimd_L_rls - 2] * 0.001;
         A[1] = (real_T)pimn_I_curr[pimd_L_rls - 1] * 0.1;
-        A[2] =-(real_T)pimn_I_curr[pimd_L_rls - 2] * 0.1;
+        A[2] = -(real_T)pimn_I_curr[pimd_L_rls - 2] * 0.1;
         A[3] = 1;
         //参数形变
-        temp = exp(- (pimn_R_ohm + pimn_R_polar)/pimn_R_ohm/pimn_F_polar);
-        theta[0] = 1- pimn_R_ohm * (1 - temp)/(pimn_R_ohm + pimn_R_polar);
+        temp = exp(-(pimn_R_ohm + pimn_R_polar) / pimn_R_ohm / pimn_F_polar);
+        theta[0] = 1 - pimn_R_ohm * (1 - temp) / (pimn_R_ohm + pimn_R_polar);
         theta[1] = pimn_R_ohm;
         theta[2] = pimn_R_ohm * temp;
-        theta[3] = (1 -theta[0]) * pimn_V_ocv;
+        theta[3] = (1 - theta[0]) * pimn_V_ocv;
 
         //增益矩阵
-        temp =  (A[0] * pimn_M_P[0][0] +A[1] * pimn_M_P[1][0] + A[2] * pimn_M_P[2][0] + A[3] * pimn_M_P[3][0]) * A[0] +
-                (A[0] * pimn_M_P[0][1] +A[1] * pimn_M_P[1][1] + A[2] * pimn_M_P[2][1] + A[3] * pimn_M_P[3][1]) * A[1] +
-                (A[0] * pimn_M_P[0][2] +A[1] * pimn_M_P[1][2] + A[2] * pimn_M_P[2][2] + A[3] * pimn_M_P[3][2]) * A[2] +
-                (A[0] * pimn_M_P[0][3] +A[1] * pimn_M_P[1][3] + A[2] * pimn_M_P[2][3] + A[3] * pimn_M_P[3][3]) * A[3];
-        for(i = 0;i < 4;i++)
+        temp = (A[0] * pimn_M_P[0][0] + A[1] * pimn_M_P[1][0] + A[2] * pimn_M_P[2][0] + A[3] * pimn_M_P[3][0]) * A[0] +
+               (A[0] * pimn_M_P[0][1] + A[1] * pimn_M_P[1][1] + A[2] * pimn_M_P[2][1] + A[3] * pimn_M_P[3][1]) * A[1] +
+               (A[0] * pimn_M_P[0][2] + A[1] * pimn_M_P[1][2] + A[2] * pimn_M_P[2][2] + A[3] * pimn_M_P[3][2]) * A[2] +
+               (A[0] * pimn_M_P[0][3] + A[1] * pimn_M_P[1][3] + A[2] * pimn_M_P[2][3] + A[3] * pimn_M_P[3][3]) * A[3];
+        for (i = 0; i < 4; i++)
         {
-            K[i] = (pimn_M_P[i][0] * A[0] + pimn_M_P[i][1] * A[1] + pimn_M_P[i][2] * A[2] + pimn_M_P[i][3] * A[3])/(1 + temp);
+            K[i] = (pimn_M_P[i][0] * A[0] + pimn_M_P[i][1] * A[1] + pimn_M_P[i][2] * A[2] + pimn_M_P[i][3] * A[3]) / (1 + temp);
         }
         //参数更新
         temp = (real_T)pimn_V_volt[pimd_L_rls - 1] * 0.001 - (theta[0] * A[0] + theta[1] * A[1] + theta[2] * A[2] + theta[3] * A[3]);
-        for(i = 0;i < 4;i++)
+        for (i = 0; i < 4; i++)
         {
             theta[i] = theta[i] + K[i] * temp;
         }
         //协方差更新
-        for(i = 0;i < 4;i++)
+        for (i = 0; i < 4; i++)
         {
-            for(j = 0;j < 4;j++)
+            for (j = 0; j < 4; j++)
             {
                 P[i][j] = pimn_M_P[i][j] - K[i] * (A[0] * pimn_M_P[0][j] + A[1] * pimn_M_P[1][j] + A[2] * pimn_M_P[2][j] + A[3] * pimn_M_P[3][j]);
             }
-
         }
-		
+
         //传递下循环
-        for(i = 0;i < 4;i++)
+        for (i = 0; i < 4; i++)
         {
-            for(j = 0;j < 4;j++)
+            for (j = 0; j < 4; j++)
             {
                 pimn_M_P[i][j] = P[i][j];
             }
-            
         }
-        
+
         //=======================================================================
-        if(pimn_N_ctn > pimd_L_rls)
+        if (pimn_N_ctn > pimd_L_rls)
         {
             //输入
             A[0] = (real_T)pimn_V_volt[0] * 0.001;
             A[1] = (real_T)pimn_I_curr[1] * 0.1;
-            A[2] =-(real_T)pimn_I_curr[0] * 0.1;
+            A[2] = -(real_T)pimn_I_curr[0] * 0.1;
             A[3] = 1;
 
             //增益矩阵
-            temp =  (A[0] * pimn_M_P[0][0] +A[1] * pimn_M_P[1][0] + A[2] * pimn_M_P[2][0] + A[3] * pimn_M_P[3][0]) * A[0] +
-                    (A[0] * pimn_M_P[0][1] +A[1] * pimn_M_P[1][1] + A[2] * pimn_M_P[2][1] + A[3] * pimn_M_P[3][1]) * A[1] +
-                    (A[0] * pimn_M_P[0][2] +A[1] * pimn_M_P[1][2] + A[2] * pimn_M_P[2][2] + A[3] * pimn_M_P[3][2]) * A[2] +
-                    (A[0] * pimn_M_P[0][3] +A[1] * pimn_M_P[1][3] + A[2] * pimn_M_P[2][3] + A[3] * pimn_M_P[3][3]) * A[3];
-            for(i = 0;i <4;i++)
+            temp = (A[0] * pimn_M_P[0][0] + A[1] * pimn_M_P[1][0] + A[2] * pimn_M_P[2][0] + A[3] * pimn_M_P[3][0]) * A[0] +
+                   (A[0] * pimn_M_P[0][1] + A[1] * pimn_M_P[1][1] + A[2] * pimn_M_P[2][1] + A[3] * pimn_M_P[3][1]) * A[1] +
+                   (A[0] * pimn_M_P[0][2] + A[1] * pimn_M_P[1][2] + A[2] * pimn_M_P[2][2] + A[3] * pimn_M_P[3][2]) * A[2] +
+                   (A[0] * pimn_M_P[0][3] + A[1] * pimn_M_P[1][3] + A[2] * pimn_M_P[2][3] + A[3] * pimn_M_P[3][3]) * A[3];
+            for (i = 0; i < 4; i++)
             {
-                K[i] = (pimn_M_P[i][0] * A[0] + pimn_M_P[i][1] * A[1] + pimn_M_P[i][2] * A[2] + pimn_M_P[i][3] * A[3])/(1 + temp);
+                K[i] = (pimn_M_P[i][0] * A[0] + pimn_M_P[i][1] * A[1] + pimn_M_P[i][2] * A[2] + pimn_M_P[i][3] * A[3]) / (1 + temp);
             }
 
             //协方差更新
-            for(i = 0;i < 4;i++)
+            for (i = 0; i < 4; i++)
             {
-                for(j = 0;j < 4;j++)
+                for (j = 0; j < 4; j++)
                 {
                     P[i][j] = pimn_M_P[i][j] + K[i] * (A[0] * pimn_M_P[0][j] + A[1] * pimn_M_P[1][j] + A[2] * pimn_M_P[2][j] + A[3] * pimn_M_P[3][j]);
                 }
             }
             //传递下一循环
-            for(i = 0;i < 4;i++)
+            for (i = 0; i < 4; i++)
             {
-                for(j = 0;j < 4;j++)
+                for (j = 0; j < 4; j++)
                 {
                     pimn_M_P[i][j] = P[i][j];
                 }
-                
             }
         }
         //参数求解
-        pimn_V_ocv   = theta[3]/(1 - theta[0]);
-        pimn_R_ohm   = theta[1];
-        pimn_R_polar = (theta[1] - theta[2])/(1 - theta[0]) - theta[1];
-        pimn_F_polar = theta[2] * theta[1] > 0 ?  (pimn_R_ohm + pimn_R_polar)/pimn_R_ohm/ (-log(theta[2]/theta[1])) : (pimn_R_ohm + pimn_R_polar)/pimn_R_ohm;
-        
-        pimd_V_ocv   = (uint16_T)(pimn_V_ocv * 1000);
-        pimd_R_ohm   = (uint16_T)(pimn_R_ohm * 1000 * 1000);
+        pimn_V_ocv = theta[3] / (1 - theta[0]);
+        pimn_R_ohm = theta[1];
+        pimn_R_polar = (theta[1] - theta[2]) / (1 - theta[0]) - theta[1];
+        pimn_F_polar = theta[2] * theta[1] > 0 ? (pimn_R_ohm + pimn_R_polar) / pimn_R_ohm / (-log(theta[2] / theta[1])) : (pimn_R_ohm + pimn_R_polar) / pimn_R_ohm;
+
+        pimd_V_ocv = (uint16_T)(pimn_V_ocv * 1000);
+        pimd_R_ohm = (uint16_T)(pimn_R_ohm * 1000 * 1000);
         pimd_R_polar = (uint16_T)(pimn_R_polar * 1000 * 1000);
         pimd_F_polar = (uint16_T)(pimn_F_polar * 1000);
     }
     //
-    ihd_st_workStat_Delay = ihd_st_workStat;
-    FirstRun_PIM = false; 
+    pimn_st_workStat_Delay = ihd_st_workStat;
+    FirstRun_PIM = false;
 }
-
-
-

+ 29 - 17
src/EmbeddedCoder_src/SOH.c

@@ -35,7 +35,7 @@ void SOH(void)
     uint16_T SumQ;
     //
     static uint16_T sohn_V_chrgStartStat[cmnc_num_cellUNumMax];
-    static uint8_T ihd_st_workStat_Delay;
+    static uint8_T sohn_st_workStat_Delay;
     static boolean_T sohn_flg_chrgEnd_Delay;
     boolean_T sohn_flg_chrgEnd;
     //
@@ -51,12 +51,25 @@ void SOH(void)
         sfmn_flg_currFlt_keep = false;
         sohn_flg_currFlt = false;
         Ahincr = 0;
-        ihd_st_workStat_Delay = 0;
-        sohn_flg_chrgEnd_Delay = false;
-		memset(sohv_V_chrgStartStatEo,0, sizeof(sohv_V_chrgStartStatEo));
-		sohd_Q_chrgEo = 0 ;
-		sohd_flg_chrgEndEo = false;
+        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(FirstRun_SOH)
     {
@@ -156,7 +169,7 @@ void SOH(void)
              memcpy(sohv_Q_cellCapArrEo,sohn_Q_cellCapArrEE, sizeof(sohv_Q_cellCapArrEo));
          }
 		 memcpy(sohv_Q_cellCap,sohv_Q_cellCapArrEo, sizeof(sohv_Q_cellCapArrEo));
-        // printf("sohv_Q_cellCapArrEo[16]:%d,update:%d,En:%d\n",sohv_Q_cellCapArrEo[16],sohn_flg_update,sohn_flg_countEn);
+
  
          SumQ = 0;
          for(i = 0; i < 10;i++)
@@ -180,7 +193,7 @@ void SOH(void)
          memcpy(sohn_V_chrgStartStat,sfmv_V_cellU, sizeof(sfmv_V_cellU));
      }
      //
-     if((ihd_st_workStat == 2) && (ihd_st_workStat_Delay != 2))
+     if((ihd_st_workStat == 2) && (sohn_st_workStat_Delay != 2))
      {
         memcpy(sohv_V_chrgStartStatEo,sohn_V_chrgStartStat, sizeof(sohv_V_chrgStartStatEo));
      }
@@ -211,23 +224,22 @@ void SOH(void)
 	 //=======================================================================================
     //----------------------充电结速信息------------------------------------------------------
     //=======================================================================================
-    if((ihd_st_workStat != 2) && (ihd_st_workStat_Delay == 2))
+    if((ihd_st_workStat != 2) && (sohn_st_workStat_Delay == 2))
     {
-       sohn_flg_chrgEnd = true; 
+       sohd_flg_chrgEndEo = true; 
     }
     else
     {
-      sohn_flg_chrgEnd = ( sfmd_I_curr < 10 && sfmd_I_curr > -10) && sohn_flg_chrgEnd_Delay;
+      sohd_flg_chrgEndEo = ( sfmd_I_curr < 10 && sfmd_I_curr > -10) && sohd_flg_chrgEndEo;
     }
-	
-    sohn_flg_chrgEnd_Delay = sohn_flg_chrgEnd;
-    sohd_flg_chrgEndEo =  !sohn_flg_currFlt && sohn_flg_chrgEnd;
-    ihd_st_workStat_Delay = ihd_st_workStat;
+    sohd_flg_chrgEndEo =  !sohn_flg_currFlt && sohd_flg_chrgEndEo;
+
+    //
+    sohn_st_workStat_Delay = ihd_st_workStat;
 	FirstRun_SOH = false;	
-	//printf("sohd_flg_chrgEndEo:%d\n",sohd_flg_chrgEndEo);
+	
 }
 
-
 ////////////////////////////////////////////////////////////////
 uint16_T  ArrMax(uint16_T *Data, uint16_T m)
 {