Browse Source

【V3.1.0.48】CDM测试

CHENJIE-PC\QiXiang_CHENJIE 3 years ago
parent
commit
a2120bf3d5
3 changed files with 57 additions and 62 deletions
  1. 2 2
      inc/AppConfig.h
  2. 2 2
      src/AppTaskTcp.c
  3. 53 58
      src/EmbeddedCoder_src/CDM.c

+ 2 - 2
inc/AppConfig.h

@@ -2,7 +2,7 @@
  * @Author       : ChenJie
  * @Date         : 2021-10-14 09:27:15
  * @LastEditors  : ChenJie
- * @LastEditTime : 2021-11-22 18:24:08
+ * @LastEditTime : 2021-11-23 09:35:03
  * @Description  : App Config H file 配置文件,可以针对不同参数进行更改
  * @FilePath     : \PLAT\project\ec616_0h00\apps\qx_app\inc\AppConfig.h
  */
@@ -14,7 +14,7 @@
 #define DATA_MODULE_TYPE (1)           //1表示NB模块,2表示4G cat1
 #define EOLSTATE (0)                   //1表示下线检测跳过,使用默认值,0表示使用下线检测
 #define DEFAULT_SN "RLTEST00000000001" //默认上传的SN编码
-#define APPSWVERSION 0x0301002F        //数据模块软件版本号
+#define APPSWVERSION 0x03010030        //数据模块软件版本号
 #define RELAYCONFIG 1                  //继电器配置
 #define TCP_ADD "iotp.fast-fun.cn"     //数据上传的地址
 #define TCP_PORT 8712                  //数据上传的端口

+ 2 - 2
src/AppTaskTcp.c

@@ -584,9 +584,9 @@ static void TcpDataInfoAssembleSend()
             {
                 temp = max(temp, cdmv_ohm_deltR[i]);
             }
-            sprintf((char *)rbuf, "B-%d,%d,%d,%d,%d,%d,%d,%d,%d,,\
+            sprintf((char *)rbuf, "B-%d,%d,%d,%d,%d,%d,%d,%d,%d,,%d,%d,,\
                                 %d,%d,%d",
-                    socd_pct_ahSoc, socd_pct_ekfSoc, socd_pct_estSoc, socd_pct_battSoc, socd_pct_bcuSoc, battSOC * 10, socd_pct_cellBattSoc, sohv_Q_packCapArrEo[9], temp,
+                    socd_pct_ahSoc, socd_pct_ekfSoc, socd_pct_estSoc, socd_pct_battSoc, socd_pct_bcuSoc, battSOC * 10, socd_pct_cellBattSoc, sohv_Q_packCapArrEo[9], temp, test_curr, test_U,
                     battI - 10000, maxCellVol, minCellVol);
         }
         Debugcounter++;

+ 53 - 58
src/EmbeddedCoder_src/CDM.c

@@ -1,6 +1,5 @@
 #include "CDM.h"
 
-
 static boolean_T FirstRun_CDM;
 
 void CDM_Init(void)
@@ -8,7 +7,6 @@ void CDM_Init(void)
     FirstRun_CDM = true;
 }
 
-
 void CDM(void)
 {
     real_T cmdn_V_cellUDelt[cmnc_num_cellUNumMax];
@@ -16,107 +14,104 @@ 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 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 int16_T sfmd_I_curr_Delay;
-	static uint8_T Cnt;
-	
+    static int16_T sfmd_I_curr_Delay;
+    static uint8_T Cnt;
+
     //
-    if(ihd_st_workStat_Delay == 2 && ihd_st_workStat != 2)
+    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++)
+        for (i = 0; i < cmnc_num_cellUNum; i++)
         {
             P[0][i] = 10;
             P[1][i] = 0;
             P[2][i] = 0;
             P[3][i] = 10;
             Lambda = 0.991;
-            deltaE[i] =  0;
-            deltaR[i] =  0;
-			deltaES[i] = 0;
+            deltaE[i] = 0;
+            deltaR[i] = 0;
+            deltaES[i] = 0;
             deltaRS[i] = 0;
-			Cnt = 0;
-			test_curr =0;
-			test_U=5000;
+            Cnt = 0;
+            test_curr = 0;
+            test_U = 5000;
         }
     }
     //
-    if(ihd_st_workStat != 2 &&  (sfmd_I_curr_Delay - sfmd_I_curr > 10 ||sfmd_I_curr_Delay - sfmd_I_curr < -10 ||sfmd_I_curr_Delay ==0 && sfmd_I_curr == 0))
+    if (ihd_st_workStat != 2 && (sfmd_I_curr_Delay - sfmd_I_curr > 10 || sfmd_I_curr_Delay - sfmd_I_curr < -10 || sfmd_I_curr_Delay == 0 && sfmd_I_curr == 0))
     {
-        for (i = 0;i < cmnc_num_cellUNum;i++)
+        for (i = 0; i < cmnc_num_cellUNum; i++)
         {
-            cmdn_V_cellUDelt[i] = (real_T)(sfmv_V_cellU[i]  - sfmd_V_cellUAvrg) * 0.001;
+            cmdn_V_cellUDelt[i] = (real_T)(sfmv_V_cellU[i] - sfmd_V_cellUAvrg) * 0.001;
         }
-        cdmn_I_curr = (real_T) sfmd_I_curr * 0.1;
+        cdmn_I_curr = (real_T)sfmd_I_curr * 0.1;
         //
         cdmd_flg_deltOCVDisable = false;
-        for (i = 0;i < cmnc_num_cellUNum;i++)
+        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);
-            K[1] = (P[2][i]  + cdmn_I_curr * P[3][i])/(Lambda + P[0][i] + cdmn_I_curr * P[2][i] + ( P[1][i] + cdmn_I_curr * P[3][i]) * cdmn_I_curr);
+            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);
+            K[1] = (P[2][i] + cdmn_I_curr * P[3][i]) / (Lambda + P[0][i] + cdmn_I_curr * P[2][i] + (P[1][i] + cdmn_I_curr * P[3][i]) * cdmn_I_curr);
             arf[i] = cmdn_V_cellUDelt[i] - (deltaE[i] + cdmn_I_curr * deltaR[i]);
             deltaE[i] = deltaE[i] + K[0] * arf[i];
             deltaR[i] = deltaR[i] + K[1] * arf[i];
-            P[0][i] = ((1 -K[0])* P[0][i] -P[2][i] * K[0] * cdmn_I_curr) /Lambda;
-            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)
+            P[0][i] = ((1 - K[0]) * P[0][i] - P[2][i] * K[0] * cdmn_I_curr) / Lambda;
+            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 = true;
             }
-	    }
+        }
         //
-		Cnt = Cnt + 1;
+        Cnt = Cnt + 1;
 
-        for (i = 0;i < cmnc_num_cellUNum;i++)
-        {   
+        for (i = 0; i < cmnc_num_cellUNum; i++)
+        {
             deltaES[i] = deltaES[i] + deltaE[i];
-			deltaRS[i] = deltaRS[i] + deltaR[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;
+        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;
 
-				 if(deltaR[i] > 5000 &&test_U==5000)
-				 {
+                if (deltaR[i] > 5000 && test_U == 5000)
+                {
                     test_curr = ihd_I_curr;
-                    test_U =ihv_V_cellU[i];
-				 }
-
-				
-             }
-		     Cnt = 0;
-		}
+                    test_U = ihv_V_cellU[i];
+                }
+            }
+            Cnt = 0;
+        }
     }
     else
     {
         cdmd_flg_deltOCVDisable = true;
     }
-	//printf("u_:%f %f %f\n",arf[0],arf[1],arf[2]);
-	//printf("E_:%d %d %d\n",cdmv_V_deltOCV[0],cdmv_V_deltOCV[1],cdmv_V_deltOCV[2]);
-	//printf("R_:%d %d %d\n",cdmv_ohm_deltR[0],cdmv_ohm_deltR[1],cdmv_ohm_deltR[2]);
-	//printf("\n");
-	cdmd_flg_deltOCVDisable = true;  ////////
-	sfmd_I_curr_Delay = sfmd_I_curr;
+    //printf("u_:%f %f %f\n",arf[0],arf[1],arf[2]);
+    //printf("E_:%d %d %d\n",cdmv_V_deltOCV[0],cdmv_V_deltOCV[1],cdmv_V_deltOCV[2]);
+    //printf("R_:%d %d %d\n",cdmv_ohm_deltR[0],cdmv_ohm_deltR[1],cdmv_ohm_deltR[2]);
+    //printf("\n");
+    cdmd_flg_deltOCVDisable = true; ////////
+    sfmd_I_curr_Delay = sfmd_I_curr;
     FirstRun_CDM = false;
-	
 }