|
@@ -60,6 +60,8 @@ void SOC(void)
|
|
|
static int16_T ahSoc0_est;
|
|
|
static uint16_T ekfSoc0_est;
|
|
|
//
|
|
|
+ uint16_T socd_V_chrgCCV;
|
|
|
+ uint16_T socd_V_disChrgCCV;
|
|
|
static boolean_T overFlg;
|
|
|
static boolean_T fulFlg;
|
|
|
static uint8_T overCntl;
|
|
@@ -138,7 +140,7 @@ void SOC(void)
|
|
|
}
|
|
|
socn_Q_cap = (uint16_T)((uint16_T)((uint32_T)sohd_pct_bcuSoh * cmnc_Q_ratedCp / 2000U) << 1);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//printf("1---- battSocEi:%d,bcuSocEi:%d,battSocEE:%d,bcuSocEE:%d\n",socd_pct_battSocEi,socd_pct_bcuSocEi,socn_pct_battSocEE,socn_pct_bcuSocEE);
|
|
|
//======================================================================
|
|
|
////////////////////////EKFSOC//////////////////////////////////////////
|
|
@@ -157,10 +159,10 @@ void SOC(void)
|
|
|
P_Min_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_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;
|
|
|
A[0] = 1;
|
|
|
A[1] = 0;
|
|
|
A[2] = 0;
|
|
@@ -220,10 +222,10 @@ void SOC(void)
|
|
|
P_Max_Delay[3] = 10;
|
|
|
}
|
|
|
// 参数查表
|
|
|
- ocv = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Max_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_V_ocv[0])), 12U) * 0.001;
|
|
|
- Ro = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Max_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_ohm[0])), 12U) * 0.001 * 0.001;
|
|
|
- Rp = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Max_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_polar[0])), 12U) * 0.001 * 0.001;
|
|
|
- C = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Max_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_F_polar[0])), 12U) * 0.001 * 1000;
|
|
|
+ ocv = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Max_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_V_ocv[0])), 12U) * 0.001;
|
|
|
+ Ro = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Max_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_ohm[0])), 12U) * 0.001 * 0.001;
|
|
|
+ Rp = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Max_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_polar[0])), 12U) * 0.001 * 0.001;
|
|
|
+ C = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Max_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_F_polar[0])), 12U) * 0.001 * 1000;
|
|
|
A[0] = 1;
|
|
|
A[1] = 0;
|
|
|
A[2] = 0;
|
|
@@ -288,6 +290,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 (FirstRun_SOC)
|
|
@@ -300,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_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;
|
|
|
A[0] = 1;
|
|
|
A[1] = 0;
|
|
|
A[2] = 0;
|
|
@@ -356,7 +359,7 @@ void SOC(void)
|
|
|
{
|
|
|
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;
|
|
|
+ //socn_flg_ekfInvalid = 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)
|
|
@@ -373,9 +376,9 @@ void SOC(void)
|
|
|
}
|
|
|
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);
|
|
|
|
|
|
+
|
|
|
|
|
|
-
|
|
|
- //printf("4----factor:%d,socd_pct_ekfSoc:%d,EKFSOCMax:%d,EKFSOCMin:%d,\n",factor,socd_pct_ekfSoc,EKFSOCMax,EKFSOCMin);
|
|
|
+
|
|
|
//======================================================================
|
|
|
////////////////////////AhSOC//////////////////////////////////////////
|
|
|
//======================================================================
|
|
@@ -385,7 +388,7 @@ void SOC(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ahDelay = ahDelay + battcurr / (real_T)(cmnc_Q_ratedCp * 0.1) / 36.0;
|
|
|
+ ahDelay = ahDelay + battcurr / (real_T)(cmnc_Q_ratedCp * 0.1) / 36.0;//cmnc_Q_ratedCp
|
|
|
}
|
|
|
ahSoc = (int16_T)(ahDelay * 10);
|
|
|
if (ahSoc > socc_pct_battSocUp)
|
|
@@ -400,6 +403,8 @@ void SOC(void)
|
|
|
{
|
|
|
socd_pct_ahSoc = (uint16_T)ahSoc;
|
|
|
}
|
|
|
+ // printf("S_%d %d %d %d %d %d %d %d\n",socd_pct_cellBattSoc,cellSocMax,cellSocMin,socd_pct_ekfSoc,EKFSOCMax,EKFSOCMin,ahSoc,EKFSOCAvrg);
|
|
|
+ // printf("E_%d %d %d %d %d %d %d %d\n",cdmv_V_deltOCV[0],cdmv_V_deltOCV[1],cdmv_V_deltOCV[15],cdmv_V_deltOCV[16],cdmv_ohm_deltR[0],cdmv_ohm_deltR[1],cdmv_ohm_deltR[15],cdmv_ohm_deltR[16]);
|
|
|
//printf("5----ahDelay:%f,ahSoc:%d,battcurr:%f,sfmd_I_curr:%d\n",ahDelay,ahSoc,battcurr,sfmd_I_curr);
|
|
|
//======================================================================
|
|
|
///////////////////////estSOC//////////////////////////////////////////
|
|
@@ -416,8 +421,8 @@ void SOC(void)
|
|
|
if (ekfInvalidCntl < 20)
|
|
|
{
|
|
|
if (onceFlg_est)
|
|
|
- {
|
|
|
- ahSoc0_est = ahSoc;
|
|
|
+ {
|
|
|
+ ahSoc0_est = ahSoc;
|
|
|
ekfSoc0_est = socd_pct_ekfSoc;
|
|
|
onceFlg_est = false;
|
|
|
}
|
|
@@ -448,7 +453,9 @@ void SOC(void)
|
|
|
chrgCntl = (chrgCntl + 1) > 250 ? 250 : (chrgCntl + 1);
|
|
|
lowCntl = 0;
|
|
|
lowFlg = false;
|
|
|
- if (sfmd_V_cellUMax >= look1_is16lu16n16tu16_binlcase(sfmd_I_curr, (&(socm_I_chrgCor[0])), (&(socm_V_chrgCor[0])), 2U))
|
|
|
+ //socd_V_chrgCCV = look1_iu16lu16n16tu16_binlcase(socc_pct_chrgCor, (&(cmnm_pct_soc[0])), (&(cmnm_V_ocv[0])), 12U) + sfmd_I_curr * (look1_iu16lu16n16tu16_binlcase(socc_pct_chrgCor, (&(cmnm_pct_soc[0])), (&(cmnm_R_ohm[0])), 12U) + cdmv_ohm_deltR[sfmd_idx_cellUMax]) * 0.001 * 0.1;
|
|
|
+ socd_V_chrgCCV = look1_is16lu16n16tu16_binlcase(sfmd_I_curr,&socm_I_chrgCor[0],&socm_V_chrgCor[0],2U);
|
|
|
+ if (sfmd_V_cellUMax >= socd_V_chrgCCV)
|
|
|
{
|
|
|
overCntl = (overCntl + 1) > 250 ? 250 : (overCntl + 1);
|
|
|
}
|
|
@@ -518,7 +525,9 @@ void SOC(void)
|
|
|
overFlg = false;
|
|
|
fulFlg = false;
|
|
|
fulCntl = 0;
|
|
|
- if (sfmd_V_cellUMin <= look1_is16lu16n16tu16_binlcase(sfmd_I_curr, (&(socm_I_disChrgCor[0])), (&(socm_V_disChrgCor[0])), 2U))
|
|
|
+
|
|
|
+ socd_V_disChrgCCV = look1_iu16lu16n16tu16_binlcase(socc_pct_disChrgCor, (&(cmnm_pct_soc[0])), (&(cmnm_V_ocv[0])), 12U) + sfmd_I_curr * (look1_iu16lu16n16tu16_binlcase(socc_pct_chrgCor, (&(cmnm_pct_soc[0])), (&(cmnm_R_ohm[0])), 12U) + cdmv_ohm_deltR[sfmd_idx_cellUMin]) * 0.001 * 0.1;
|
|
|
+ if (sfmd_V_cellUMin <= socd_V_disChrgCCV)
|
|
|
{
|
|
|
lowCntl = (lowCntl + 1) > 250 ? 250 : (lowCntl + 1);
|
|
|
}
|
|
@@ -552,7 +561,7 @@ void SOC(void)
|
|
|
}
|
|
|
// printf("8----lowCntl:%d,lowFlg:%d,ahSoc0_utrckLow:%d,estSoc0_utrckLow:%d,socn_pct_utrackSoc:%d\n",lowCntl,lowFlg,ahSoc0_utrckLow,estSoc0_utrckLow,socn_pct_utrackSoc);
|
|
|
}
|
|
|
- //===================================================================
|
|
|
+ //===================================================================
|
|
|
//------------------EEsave
|
|
|
//==================================================================
|
|
|
socd_pct_battSoc = socn_pct_utrackSoc;
|
|
@@ -567,9 +576,9 @@ void SOC(void)
|
|
|
socd_flg_EEsave = 0;
|
|
|
}
|
|
|
|
|
|
- //=====================================================================
|
|
|
- //////////////////////////////BCUSOC///////////////////////////////////
|
|
|
- //=====================================================================
|
|
|
+ //===============================================================================================================================================================
|
|
|
+ ////////////////////////////////////////////////////////////////////BCUSOC///////////////////////////////////////////////////////////////////////////////////////
|
|
|
+ //===============================================================================================================================================================
|
|
|
|
|
|
if (sfmd_I_curr < 10 && sfmd_I_curr > -10)
|
|
|
{
|
|
@@ -664,7 +673,6 @@ void SOC(void)
|
|
|
//
|
|
|
socd_pct_bcuSocEo = socd_pct_bcuSoc;
|
|
|
FirstRun_SOC = false;
|
|
|
-
|
|
|
//printf("\n");
|
|
|
}
|
|
|
|