|
@@ -19,8 +19,10 @@ void SOC(void)
|
|
|
//
|
|
|
uint16_T EKFSOCMin;
|
|
|
uint16_T EKFSOCMax;
|
|
|
+ uint16_T EKFSOCAvrg;
|
|
|
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;
|
|
@@ -34,12 +36,17 @@ void SOC(void)
|
|
|
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 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 cellSocMax;
|
|
|
+ uint16_T cellSocMin;
|
|
|
real_T Q;
|
|
|
real_T battcurr;
|
|
|
real_T UL;
|
|
@@ -87,7 +94,7 @@ void SOC(void)
|
|
|
boolean_T Flg;
|
|
|
static boolean_T onceFlg_chrg;
|
|
|
static boolean_T onceFlg_dischrg;
|
|
|
-
|
|
|
+ uint16_T i;
|
|
|
//
|
|
|
if (FirstRun_SOC)
|
|
|
{
|
|
@@ -107,16 +114,17 @@ void SOC(void)
|
|
|
onceFlg_chrg = true;
|
|
|
onceFlg_dischrg = true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//=====================================================================
|
|
|
////////////////////////初始值获取//////////////////////////////////////
|
|
|
//=====================================================================
|
|
|
if (FirstRun_SOC)
|
|
|
{ //
|
|
|
- if ((socd_pct_battSocEi > 1000) || (socd_pct_bcuSocEi > 1000) || (ihd_st_EOLState == 0))
|
|
|
+ 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))
|
|
|
{
|
|
|
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);
|
|
|
+ socn_pct_bcuSocEE = look1_iu16lu16n16tu16_binlcase(sfmd_V_cellUAvrg, (&(cmnm_V_ocv[0])), (&(cmnm_pct_soc[0])), 12U);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -130,14 +138,14 @@ 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//////////////////////////////////////////
|
|
|
//======================================================================
|
|
|
battcurr = (real_T)sfmd_I_curr * 0.1;
|
|
|
Q = (real_T)socn_Q_cap * 0.1;
|
|
|
-
|
|
|
+
|
|
|
//-------------------------EKFmin---------------------------------------
|
|
|
if (FirstRun_SOC)
|
|
|
{
|
|
@@ -157,13 +165,13 @@ void SOC(void)
|
|
|
A[1] = 0;
|
|
|
A[2] = 0;
|
|
|
A[3] = exp(-1 / (Rp * C));
|
|
|
-
|
|
|
+
|
|
|
B[0] = 1 / Q / 3600 * 100;
|
|
|
B[1] = Rp * (1 - exp(-1 / (Rp * C)));
|
|
|
-
|
|
|
+
|
|
|
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;
|
|
@@ -172,15 +180,15 @@ void SOC(void)
|
|
|
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);
|
|
|
-
|
|
|
+
|
|
|
//后验
|
|
|
deltU = (real_T)sfmd_V_cellUMin * 0.001 - UL;
|
|
|
soc_Min_Delay = soc1 + K[0] * deltU;
|
|
|
-
|
|
|
+
|
|
|
if (soc_Min_Delay < (real_T)socc_pct_battSocLow * 0.1)
|
|
|
{
|
|
|
soc_Min_Delay = (real_T)socc_pct_battSocLow * 0.1;
|
|
@@ -189,15 +197,14 @@ void SOC(void)
|
|
|
{
|
|
|
soc_Min_Delay = (real_T)socc_pct_battSocUp * 0.1;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
Up_Min_Delay = Up1 + K[1] * deltU;
|
|
|
- test_UpMin = Up_Min_Delay;
|
|
|
//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]);
|
|
|
-
|
|
|
+
|
|
|
//输出
|
|
|
EKFSOCMin = (uint16_T)(soc_Min_Delay * 10);
|
|
|
socn_flg_ekfInvalidMin = (deltU > 0.01) || (deltU < -0.01);
|
|
@@ -221,31 +228,31 @@ void SOC(void)
|
|
|
A[1] = 0;
|
|
|
A[2] = 0;
|
|
|
A[3] = exp(-1 / (Rp * C));
|
|
|
-
|
|
|
+
|
|
|
B[0] = 1 / Q / 3600 * 100;
|
|
|
B[1] = Rp * (1 - exp(-1 / (Rp * C)));
|
|
|
-
|
|
|
+
|
|
|
H[0] = docvmath(soc_Max_Delay);
|
|
|
H[1] = 1;
|
|
|
-
|
|
|
+
|
|
|
//先验
|
|
|
soc1 = soc_Max_Delay * A[0] + B[0] * battcurr;
|
|
|
Up1 = Up_Max_Delay * A[3] + B[1] * battcurr;
|
|
|
UL = ocv + battcurr * Ro + Up1;
|
|
|
-
|
|
|
+
|
|
|
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);
|
|
|
-
|
|
|
+
|
|
|
//后验
|
|
|
deltU = (real_T)sfmd_V_cellUMax * 0.001 - UL;
|
|
|
soc_Max_Delay = soc1 + K[0] * deltU;
|
|
|
-
|
|
|
+
|
|
|
if (soc_Max_Delay < (real_T)socc_pct_battSocLow * 0.1)
|
|
|
{
|
|
|
soc_Max_Delay = (real_T)socc_pct_battSocLow * 0.1;
|
|
@@ -255,8 +262,7 @@ void SOC(void)
|
|
|
soc_Max_Delay = (real_T)socc_pct_battSocUp * 0.1;
|
|
|
}
|
|
|
Up_Max_Delay = Up1 + K[1] * deltU;
|
|
|
-
|
|
|
- test_UpMax = Up_Max_Delay;
|
|
|
+
|
|
|
//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]);
|
|
@@ -281,9 +287,94 @@ void SOC(void)
|
|
|
factor = (uint16_T)(((uint16_T)(((uint32_T)(EKFSOCMin - 200) << 6) / (800 - (EKFSOCMax - EKFSOCMin) - 200)) * 25U) >> 4);
|
|
|
}
|
|
|
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);
|
|
|
- test_efkSocMin = EKFSOCMin;
|
|
|
- test_efkSocMax = EKFSOCMax;
|
|
|
+
|
|
|
|
|
|
+ //-------------------------EKFavrg---------------------------------------
|
|
|
+ if (FirstRun_SOC)
|
|
|
+ {
|
|
|
+ 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_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;
|
|
|
+ A[3] = exp(-1 / (Rp * C));
|
|
|
+
|
|
|
+ B[0] = 1 / Q / 3600 * 100;
|
|
|
+ B[1] = Rp * (1 - exp(-1 / (Rp * C)));
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+ if (soc_Avrg_Delay < (real_T)socc_pct_battSocLow * 0.1)
|
|
|
+ {
|
|
|
+ soc_Avrg_Delay = (real_T)socc_pct_battSocLow * 0.1;
|
|
|
+ }
|
|
|
+ if (soc_Avrg_Delay > (real_T)socc_pct_battSocUp * 0.1)
|
|
|
+ {
|
|
|
+ soc_Avrg_Delay = (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);
|
|
|
+ //
|
|
|
+ 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;
|
|
|
+ cellSocMax = ArrMax(&socv_pct_cellSoc[0],cmnc_num_cellUNum);
|
|
|
+ cellSocMin = ArrMin(&socv_pct_cellSoc[0],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);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//printf("4----factor:%d,socd_pct_ekfSoc:%d,EKFSOCMax:%d,EKFSOCMin:%d,\n",factor,socd_pct_ekfSoc,EKFSOCMax,EKFSOCMin);
|
|
|
//======================================================================
|
|
|
////////////////////////AhSOC//////////////////////////////////////////
|
|
@@ -321,7 +412,7 @@ void SOC(void)
|
|
|
{
|
|
|
ekfInvalidCntl = 0;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (ekfInvalidCntl < 20)
|
|
|
{
|
|
|
if (onceFlg_est)
|
|
@@ -337,7 +428,7 @@ void SOC(void)
|
|
|
onceFlg_est = true;
|
|
|
socd_pct_estSoc = socd_pct_ekfSoc;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//
|
|
|
if (socd_pct_estSoc > socc_pct_battSocUp)
|
|
|
{
|
|
@@ -382,7 +473,7 @@ void SOC(void)
|
|
|
{
|
|
|
fulFlg = 1;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//
|
|
|
if (overFlg)
|
|
|
{
|
|
@@ -406,7 +497,7 @@ void SOC(void)
|
|
|
//
|
|
|
socn_pct_utrackSoc = Soc_Delay + (socTemp > Soc_Delay ? (socTemp - Soc_Delay) : 0);
|
|
|
Soc_Delay = socn_pct_utrackSoc;
|
|
|
-
|
|
|
+
|
|
|
if (fulFlg)
|
|
|
{
|
|
|
socn_pct_utrackSoc = socc_pct_battSocUp;
|
|
@@ -415,7 +506,7 @@ void SOC(void)
|
|
|
{
|
|
|
socn_pct_utrackSoc = socn_pct_utrackSoc > (socc_pct_battSocUp - 1) ? (socc_pct_battSocUp - 1) : socn_pct_utrackSoc;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//printf("7----overCntl:%d,overFlg:%d,fulCntl:%d,fulFlg:%d,ahSoc0_utrckOver:%d,estSoc0_utrckOver:%d,socn_pct_utrackSoc:%d,socTemp:%d\n",overCntl,overFlg,fulCntl,fulFlg,ahSoc0_utrckOver,estSoc0_utrckOver,socn_pct_utrackSoc,socTemp);
|
|
|
}
|
|
|
else
|
|
@@ -475,11 +566,11 @@ void SOC(void)
|
|
|
{
|
|
|
socd_flg_EEsave = 0;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//=====================================================================
|
|
|
//////////////////////////////BCUSOC///////////////////////////////////
|
|
|
//=====================================================================
|
|
|
-
|
|
|
+
|
|
|
if (sfmd_I_curr < 10 && sfmd_I_curr > -10)
|
|
|
{
|
|
|
statCntl = (statCntl + 1) > 250 ? 250 : (statCntl + 1);
|
|
@@ -489,12 +580,12 @@ void SOC(void)
|
|
|
statCntl = 0;
|
|
|
}
|
|
|
statFlg = statCntl > 2;
|
|
|
-
|
|
|
+
|
|
|
Flg = (FirstRun_SOC || (ihd_st_chrgSta_Delay == 2 && ihd_st_workStat != 2) || (ihd_st_chrgSta_Delay != 2 && ihd_st_workStat == 2) || ((int16_T)(socn_pct_utrackSoc - socn_pct_utrackSoc_Delay) > 20 || (int16_T)(socn_pct_utrackSoc - socn_pct_utrackSoc_Delay) < -20) || statFlg);
|
|
|
-
|
|
|
+
|
|
|
ihd_st_chrgSta_Delay = ihd_st_workStat;
|
|
|
socn_pct_utrackSoc_Delay = socn_pct_utrackSoc;
|
|
|
-
|
|
|
+
|
|
|
//
|
|
|
if (Flg)
|
|
|
{
|
|
@@ -508,23 +599,23 @@ void SOC(void)
|
|
|
socd_pct_bcuSoc0 = socd_pct_bcuSoc;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//printf("9----statCntl:%d,statFlg:%d,Flg:%d,socd_pct_bcuSoc0:%d,socd_pct_bcuSoc0:%d,Flg:%d\n",statCntl,statFlg,Flg,socd_pct_bcuSoc0,socd_pct_bcuSoc0,Flg);
|
|
|
//
|
|
|
if (ihd_st_workStat == 2)
|
|
|
{
|
|
|
delSOC = socd_pct_battSoc0 > socd_pct_bcuSoc0 ? (socd_pct_battSoc0 - socd_pct_bcuSoc0) : (socd_pct_bcuSoc0 - socd_pct_battSoc0);
|
|
|
coinSoc = (socd_pct_battSoc0 > socd_pct_bcuSoc0 ? socd_pct_battSoc0 : socd_pct_bcuSoc0) + (delSOC > 50 ? 50 : delSOC);
|
|
|
-
|
|
|
+
|
|
|
x[0] = socd_pct_battSoc0;
|
|
|
x[1] = coinSoc > socc_pct_battSocUp ? socc_pct_battSocUp : (uint16_T)coinSoc;
|
|
|
x[2] = socc_pct_battSocUp;
|
|
|
-
|
|
|
+
|
|
|
y[0] = socd_pct_bcuSoc0;
|
|
|
y[1] = coinSoc > 1000 ? 1000 : (uint16_T)coinSoc;
|
|
|
y[2] = 1000;
|
|
|
bcuSoc = SOC_LookUp(socd_pct_battSoc, &x[0], &y[0]);
|
|
|
-
|
|
|
+
|
|
|
//
|
|
|
if (onceFlg_chrg)
|
|
|
{
|
|
@@ -533,7 +624,7 @@ void SOC(void)
|
|
|
socd_pct_bcuSoc = 2000;
|
|
|
}
|
|
|
socd_pct_bcuSoc = SOCfitSystem(bcuSoc, &socd_pct_bcuSoc, 1);
|
|
|
-
|
|
|
+
|
|
|
//
|
|
|
if (fulFlg)
|
|
|
{
|
|
@@ -550,7 +641,7 @@ void SOC(void)
|
|
|
//
|
|
|
delSOC = socd_pct_battSoc0 > socd_pct_bcuSoc0 ? (socd_pct_battSoc0 - socd_pct_bcuSoc0) : (socd_pct_bcuSoc0 - socd_pct_battSoc0);
|
|
|
coinSoc = (int16_T)((socd_pct_battSoc0 < socd_pct_bcuSoc0 ? socd_pct_battSoc0 : socd_pct_bcuSoc0) - (delSOC > 50 ? 50 : delSOC));
|
|
|
-
|
|
|
+
|
|
|
x[0] = socc_pct_battSocLow;
|
|
|
x[1] = coinSoc > socc_pct_battSocLow ? (uint16_T)coinSoc : socc_pct_battSocLow;
|
|
|
x[2] = socd_pct_battSoc0;
|
|
@@ -558,7 +649,7 @@ void SOC(void)
|
|
|
y[1] = coinSoc > 0 ? (uint16_T)coinSoc : 0;
|
|
|
y[2] = socd_pct_bcuSoc0;
|
|
|
bcuSoc = SOC_LookUp(socd_pct_battSoc, &x[0], &y[0]);
|
|
|
-
|
|
|
+
|
|
|
//
|
|
|
if (onceFlg_dischrg)
|
|
|
{
|
|
@@ -566,14 +657,14 @@ void SOC(void)
|
|
|
onceFlg_dischrg = false;
|
|
|
socd_pct_bcuSoc = 2000;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
socd_pct_bcuSoc = SOCfitSystem(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);
|
|
|
}
|
|
|
//
|
|
|
socd_pct_bcuSocEo = socd_pct_bcuSoc;
|
|
|
FirstRun_SOC = false;
|
|
|
-
|
|
|
+
|
|
|
//printf("\n");
|
|
|
}
|
|
|
|
|
@@ -582,13 +673,13 @@ 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) +
|
|
|
+ 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;
|
|
|
+ 0.02732;
|
|
|
return docv;
|
|
|
}
|
|
|
////
|
|
@@ -607,7 +698,7 @@ uint16_T SOC_LookUp(uint16_T battsoc, uint16_T x[3], uint16_T y[3])
|
|
|
//
|
|
|
if (battsoc > x[0] && battsoc < x[1]) //(x-x0)*(y1-y0)/(x1-x0)+y0
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
bcusoc = (uint16_T)((real_T)((battsoc - x[0]) * 0.1) * (real_T)((y[1] - y[0]) * 0.1) / (real_T)((x[1] - x[0]) * 0.1) * 10) + y[0];
|
|
|
}
|
|
|
//
|
|
@@ -635,6 +726,6 @@ uint16_T SOCfitSystem(uint16_T SOC, uint16_T *SOCfit, uint16_T m)
|
|
|
{
|
|
|
*SOCfit = SOC;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return *SOCfit;
|
|
|
}
|