|
@@ -43,7 +43,6 @@ void SOC(void)
|
|
|
real_T Up1;
|
|
|
static real_T Up_Min_Delay;
|
|
|
static real_T Up_Max_Delay;
|
|
|
- real_T docv;
|
|
|
real_T Q;
|
|
|
real_T battcurr;
|
|
|
real_T UL;
|
|
@@ -59,48 +58,43 @@ void SOC(void)
|
|
|
//
|
|
|
static boolean_T overFlg;
|
|
|
static boolean_T fulFlg;
|
|
|
- static uint16_T overCntl;
|
|
|
- static uint16_T fulCntl;
|
|
|
+ static uint8_T overCntl;
|
|
|
+ static uint8_T fulCntl;
|
|
|
static boolean_T onceFlg_utrckOver;
|
|
|
static int16_T ahSoc0_utrckOver;
|
|
|
static uint16_T estSoc0_utrckOver;
|
|
|
static uint16_T Soc_Delay;
|
|
|
static boolean_T lowFlg;
|
|
|
- static uint16_T lowCntl;
|
|
|
+ static uint8_T lowCntl;
|
|
|
static boolean_T onceFlg_utrckLow;
|
|
|
static int16_T ahSoc0_utrckLow;
|
|
|
static uint16_T estSoc0_utrckLow;
|
|
|
uint16_T socn_pct_utrackSoc;
|
|
|
uint16_T socTemp;
|
|
|
- static uint16_T chrgCntl;
|
|
|
- static uint16_T disChrgCntl;
|
|
|
+ static uint8_T chrgCntl;
|
|
|
+ static uint8_T disChrgCntl;
|
|
|
//
|
|
|
static uint16_T socd_pct_battSoc_Delay;
|
|
|
//
|
|
|
- static uint16_T statCntl;
|
|
|
- static boolean_T statFlg;
|
|
|
+ static uint8_T statCntl;
|
|
|
+ boolean_T statFlg;
|
|
|
static uint8_T ihd_st_chrgSta_Delay;
|
|
|
static uint16_T socn_pct_utrackSoc_Delay;
|
|
|
static uint16_T socd_pct_battSoc0;
|
|
|
static uint16_T socd_pct_bcuSoc0;
|
|
|
- static uint16_T socd_pct_bcuSoc_Delay;
|
|
|
uint16_T delSOC;
|
|
|
uint16_T bcuSoc;
|
|
|
int16_T coinSoc;
|
|
|
uint16_T x[3];
|
|
|
uint16_T y[3];
|
|
|
boolean_T Flg;
|
|
|
- static uint16_T SocFitChrg_Delay;
|
|
|
- static uint16_T SocFitdisChrg_Delay;
|
|
|
static boolean_T onceFlg_chrg;
|
|
|
static boolean_T onceFlg_dischrg;
|
|
|
- uint16_T SocFitChrg;
|
|
|
- uint16_T SocFitdisChrg;
|
|
|
//
|
|
|
|
|
|
if(FirstRun_SOC)
|
|
|
{
|
|
|
- onceFlg_est = true;
|
|
|
+ onceFlg_est = true;
|
|
|
ekfInvalidCntl = 0;
|
|
|
overCntl = 0;
|
|
|
fulCntl = 0;
|
|
@@ -108,13 +102,13 @@ void SOC(void)
|
|
|
overFlg = false;
|
|
|
fulFlg = false;
|
|
|
lowFlg = false;
|
|
|
+ Soc_Delay = 0 ;
|
|
|
onceFlg_utrckOver = true;
|
|
|
onceFlg_utrckLow = true;
|
|
|
ihd_st_chrgSta_Delay = 0;
|
|
|
socn_pct_utrackSoc_Delay = 0;
|
|
|
onceFlg_chrg = true;
|
|
|
onceFlg_dischrg = true;
|
|
|
- socd_pct_battSoc_Delay = 0;
|
|
|
}
|
|
|
|
|
|
//=====================================================================
|
|
@@ -122,7 +116,7 @@ void SOC(void)
|
|
|
//=====================================================================
|
|
|
if(FirstRun_SOC)
|
|
|
{ //
|
|
|
- if ((socd_pct_battSocEi > 1000) || (socd_pct_bcuSocEi > 1000) || (socd_pct_bcuSocEi == 0 && socd_pct_battSocEi == 0))
|
|
|
+ if ((socd_pct_battSocEi > 1000) || (socd_pct_bcuSocEi > 1000) )
|
|
|
{
|
|
|
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);
|
|
@@ -133,7 +127,7 @@ void SOC(void)
|
|
|
socn_pct_bcuSocEE = socd_pct_bcuSocEi;
|
|
|
}
|
|
|
//
|
|
|
- if (ihd_tm_parkTime > cmnc_tm_parkTime)
|
|
|
+ if (ihd_tm_parkTime > cmnc_tm_parkTime && 0)
|
|
|
{
|
|
|
socn_pct_battSocEE = look1_iu16lu16n16tu16_binlcase(sfmd_V_cellUAvrg,(&(cmnm_V_ocv[0])), (&(cmnm_pct_soc[0])), 12U);
|
|
|
}
|
|
@@ -144,21 +138,21 @@ void SOC(void)
|
|
|
////////////////////////EKFSOC//////////////////////////////////////////
|
|
|
//======================================================================
|
|
|
battcurr = (real_T)sfmd_I_curr * 0.1;
|
|
|
- Q = (real_T) socn_Q_cap * 0.1;
|
|
|
+ Q = (real_T)socn_Q_cap * 0.1;
|
|
|
|
|
|
//-------------------------EKFmin---------------------------------------
|
|
|
if (FirstRun_SOC)
|
|
|
{
|
|
|
soc_Min_Delay = (real_T)socn_pct_battSocEE * 0.1;
|
|
|
Up_Min_Delay = 0;
|
|
|
- P_Min_Delay[0]=1000;
|
|
|
- P_Min_Delay[1]=0;
|
|
|
- P_Min_Delay[2]=0;
|
|
|
- P_Min_Delay[3]=1000;
|
|
|
+ P_Min_Delay[0] = 1000;
|
|
|
+ P_Min_Delay[1] = 0;
|
|
|
+ P_Min_Delay[2] = 0;
|
|
|
+ P_Min_Delay[3] = 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;
|
|
|
+ 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;
|
|
@@ -169,8 +163,7 @@ void SOC(void)
|
|
|
B[0] = 0.1/Q/3600 * 100;
|
|
|
B[1] = Rp * (1- exp(-0.1/(Rp * C)));
|
|
|
|
|
|
- docvmath(soc_Min_Delay ,&docv);
|
|
|
- H[0] = docv;
|
|
|
+ H[0] = docvmath(soc_Min_Delay);
|
|
|
H[1] = 1;
|
|
|
|
|
|
//先验
|
|
@@ -189,17 +182,17 @@ void SOC(void)
|
|
|
//后验
|
|
|
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;
|
|
|
}
|
|
|
- if (soc_Min_Delay > (real_T)socc_pct_battSocUp * 0.1)
|
|
|
+ if (soc_Min_Delay > (real_T)socc_pct_battSocUp * 0.1)
|
|
|
{
|
|
|
- soc_Min_Delay= (real_T)socc_pct_battSocUp * 0.1;
|
|
|
+ soc_Min_Delay= (real_T)socc_pct_battSocUp * 0.1;
|
|
|
}
|
|
|
|
|
|
Up_Min_Delay = Up1 + K[1] * deltU;
|
|
|
- //Up_Min_Delay = (Up_Min_Delay > 0 ? Up_Min_Delay : 0);
|
|
|
|
|
|
//P更新
|
|
|
P_Min_Delay[0] = (1 - K[0] * H[0]) * P1[0] -K[0]* P1[1];
|
|
@@ -212,21 +205,20 @@ void SOC(void)
|
|
|
socn_flg_ekfInvalidMin= (deltU > 0.005)||(deltU < -0.005);
|
|
|
//printf("2----socmin:%f,Up:%f,U1:%d,sfmd_V_cellUMin:%d,deltU:%f,flg:%d,soc1:%f,K[0]:%f,K[1]:%f\n",soc_Min_Delay,Up_Min_Delay,ihv_V_cellU[0],sfmd_V_cellUMin,deltU,socn_flg_ekfInvalidMin,soc1,K[0],K[1]);
|
|
|
//------------------------EKFSOCmax-----------------------------------
|
|
|
-
|
|
|
if (FirstRun_SOC)
|
|
|
{
|
|
|
- soc_Max_Delay = (real_T)socn_pct_battSocEE * 0.1;
|
|
|
- Up_Max_Delay = 0;
|
|
|
- P_Max_Delay[0]=1000;
|
|
|
- P_Max_Delay[1]=0;
|
|
|
- P_Max_Delay[2]=0;
|
|
|
- P_Max_Delay[3]=1000;
|
|
|
+ soc_Max_Delay = (real_T)socn_pct_battSocEE * 0.1;
|
|
|
+ Up_Max_Delay = 0;
|
|
|
+ P_Max_Delay[0] = 1000;
|
|
|
+ P_Max_Delay[1] = 0;
|
|
|
+ P_Max_Delay[2] = 0;
|
|
|
+ P_Max_Delay[3] = 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;
|
|
|
+ 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;
|
|
@@ -235,14 +227,14 @@ void SOC(void)
|
|
|
B[0] = 0.1/Q/3600 * 100;
|
|
|
B[1] = Rp * (1- exp(-0.1/(Rp * C)));
|
|
|
|
|
|
- docvmath(soc_Max_Delay ,&docv);
|
|
|
- H[0] = docv;
|
|
|
+ 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.002;
|
|
|
P1[1] = P_Max_Delay[1] * A[3] +0.002;
|
|
|
P1[2] = P_Max_Delay[2] * A[3] +0.002;
|
|
@@ -255,21 +247,22 @@ void SOC(void)
|
|
|
//后验
|
|
|
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)
|
|
|
+
|
|
|
+ if (soc_Max_Delay < (real_T)socc_pct_battSocLow * 0.1)
|
|
|
{
|
|
|
- soc_Max_Delay= (real_T)socc_pct_battSocLow * 0.1;
|
|
|
+ soc_Max_Delay = (real_T)socc_pct_battSocLow * 0.1;
|
|
|
}
|
|
|
if (soc_Max_Delay > (real_T)socc_pct_battSocUp * 0.1)
|
|
|
{
|
|
|
- soc_Max_Delay= (real_T)socc_pct_battSocUp * 0.1;
|
|
|
+ soc_Max_Delay = (real_T)socc_pct_battSocUp * 0.1;
|
|
|
}
|
|
|
Up_Max_Delay = Up1 + K[1] * deltU;
|
|
|
- //Up_Max_Delay = (Up_Max_Delay > 0 ? Up_Max_Delay : 0);
|
|
|
+
|
|
|
|
|
|
//P更新
|
|
|
- P_Max_Delay[0] = (1 - K[0] * H[0]) * P1[0] -K[0]* P1[1];
|
|
|
+ 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[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]);
|
|
|
//输出
|
|
|
EKFSOCMax = (uint16_T) (soc_Max_Delay * 10);
|
|
@@ -279,25 +272,17 @@ void SOC(void)
|
|
|
socn_flg_ekfInvalid = socn_flg_ekfInvalidMax || socn_flg_ekfInvalidMin;
|
|
|
if(EKFSOCMax > 800)
|
|
|
{
|
|
|
- factor=100;
|
|
|
+ factor = 100;
|
|
|
}
|
|
|
- else if(EKFSOCMin<200)
|
|
|
+ else if(EKFSOCMin < 200)
|
|
|
{
|
|
|
- factor=0;
|
|
|
+ factor = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
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);
|
|
|
- if (socd_pct_ekfSoc < socc_pct_battSocLow)
|
|
|
- {
|
|
|
- socd_pct_ekfSoc= socc_pct_battSocLow ;
|
|
|
- }
|
|
|
- if (socd_pct_ekfSoc > socc_pct_battSocUp)
|
|
|
- {
|
|
|
- socd_pct_ekfSoc= socc_pct_battSocUp ;
|
|
|
- }
|
|
|
|
|
|
//printf("4----factor:%d,socd_pct_ekfSoc:%d,EKFSOCMax:%d,EKFSOCMin:%d,\n",factor,socd_pct_ekfSoc,EKFSOCMax,EKFSOCMin);
|
|
|
//======================================================================
|
|
@@ -309,14 +294,14 @@ void SOC(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ahDelay = ahDelay + battcurr / (real_T)(cmnc_Q_ratedCp *0.1) /360.0;
|
|
|
- }
|
|
|
- ahSoc =(int16_T)(ahDelay *10);
|
|
|
- if (ahSoc >= socc_pct_battSocUp)
|
|
|
+ ahDelay = ahDelay + battcurr / (real_T)(cmnc_Q_ratedCp * 0.1) /360.0;
|
|
|
+ }
|
|
|
+ ahSoc =(int16_T)(ahDelay * 10);
|
|
|
+ if (ahSoc > socc_pct_battSocUp)
|
|
|
{
|
|
|
socd_pct_ahSoc = socc_pct_battSocUp;
|
|
|
}
|
|
|
- else if (ahSoc <= socc_pct_battSocLow)
|
|
|
+ else if (ahSoc < socc_pct_battSocLow)
|
|
|
{
|
|
|
socd_pct_ahSoc = socc_pct_battSocLow;
|
|
|
}
|
|
@@ -324,13 +309,13 @@ void SOC(void)
|
|
|
{
|
|
|
socd_pct_ahSoc = (uint16_T)ahSoc;
|
|
|
}
|
|
|
- // printf("5----ahDelay:%f,ahSoc:%d,battcurr:%f,sfmd_I_curr:%d\n",ahDelay,ahSoc,battcurr,sfmd_I_curr);
|
|
|
+ //printf("5----ahDelay:%f,ahSoc:%d,battcurr:%f,sfmd_I_curr:%d\n",ahDelay,ahSoc,battcurr,sfmd_I_curr);
|
|
|
//======================================================================
|
|
|
///////////////////////estSOC//////////////////////////////////////////
|
|
|
//======================================================================
|
|
|
if(!socn_flg_ekfInvalid)
|
|
|
{
|
|
|
- ekfInvalidCntl = ( (ekfInvalidCntl + 1) > 60000 ? 60000 :(ekfInvalidCntl + 1));
|
|
|
+ ekfInvalidCntl = (ekfInvalidCntl + 1) > 250 ? 250 :(ekfInvalidCntl + 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -343,21 +328,22 @@ void SOC(void)
|
|
|
{
|
|
|
ahSoc0_est = ahSoc;
|
|
|
ekfSoc0_est = socd_pct_ekfSoc;
|
|
|
+ onceFlg_est = false;
|
|
|
}
|
|
|
- socd_pct_estSoc = (((int16_T)(ahSoc - ahSoc0_est) + ekfSoc0_est)>0 ? (uint16_T)((int16_T)(ahSoc - ahSoc0_est) + ekfSoc0_est) : 0);
|
|
|
- onceFlg_est = false;
|
|
|
+ socd_pct_estSoc = (int16_T)(ahSoc - ahSoc0_est + ekfSoc0_est) > 0 ? (uint16_T)(ahSoc - ahSoc0_est + ekfSoc0_est) : 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
onceFlg_est = true;
|
|
|
socd_pct_estSoc = socd_pct_ekfSoc;
|
|
|
}
|
|
|
-
|
|
|
- if (socd_pct_estSoc >= socc_pct_battSocUp)
|
|
|
+
|
|
|
+ //
|
|
|
+ if (socd_pct_estSoc > socc_pct_battSocUp)
|
|
|
{
|
|
|
socd_pct_estSoc = socc_pct_battSocUp;
|
|
|
}
|
|
|
- if (socd_pct_estSoc <= socc_pct_battSocLow)
|
|
|
+ if (socd_pct_estSoc < socc_pct_battSocLow)
|
|
|
{
|
|
|
socd_pct_estSoc = socc_pct_battSocLow;
|
|
|
}
|
|
@@ -367,13 +353,13 @@ void SOC(void)
|
|
|
//======================================================================
|
|
|
if (ihd_st_workStat == 2)
|
|
|
{
|
|
|
- disChrgCntl=0;
|
|
|
- chrgCntl = ((chrgCntl+1) >60000 ? 60000 : (chrgCntl+1));
|
|
|
- lowCntl=0;
|
|
|
- lowFlg = 0;
|
|
|
- if(sfmd_V_cellUMax >= look1_is16lu16n16tu16_binlcase(sfmd_I_curr, (&(socm_I_chrgCor[0])),(&(socm_V_chrgCor[0])), 3U))
|
|
|
+ disChrgCntl = 0;
|
|
|
+ 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))
|
|
|
{
|
|
|
- overCntl = ( (overCntl + 1) > 60000 ? 60000 : (overCntl + 1));
|
|
|
+ overCntl = (overCntl + 1) > 250 ? 250 : (overCntl + 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -386,11 +372,11 @@ void SOC(void)
|
|
|
//
|
|
|
if(sfmd_V_cellUMax >= cmnc_V_chrgFulV)
|
|
|
{
|
|
|
- fulCntl = ( (fulCntl + 1) > 60000 ? 60000 : (fulCntl + 1));
|
|
|
+ fulCntl = (fulCntl + 1) > 250 ? 250 : (fulCntl + 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- fulCntl=0;
|
|
|
+ fulCntl = 0;
|
|
|
}
|
|
|
if(fulCntl > 20 || fulFlg)
|
|
|
{
|
|
@@ -402,45 +388,48 @@ void SOC(void)
|
|
|
{
|
|
|
if (onceFlg_utrckOver)
|
|
|
{
|
|
|
+ onceFlg_utrckOver = false;
|
|
|
ahSoc0_utrckOver = ahSoc;
|
|
|
- estSoc0_utrckOver = socd_pct_estSoc;
|
|
|
+ estSoc0_utrckOver = socd_pct_estSoc > socc_pct_chrgCor ? socd_pct_estSoc : socc_pct_chrgCor;
|
|
|
}
|
|
|
- estSoc0_utrckOver = (estSoc0_utrckOver > 950 ? estSoc0_utrckOver : 950);
|
|
|
- socTemp = (uint16_T)((int16_T)(ahSoc - ahSoc0_utrckOver) + estSoc0_utrckOver);
|
|
|
- onceFlg_utrckOver = false;
|
|
|
+ socTemp = (uint16_T)(ahSoc - ahSoc0_utrckOver + estSoc0_utrckOver);
|
|
|
}
|
|
|
- else if (chrgCntl >20)
|
|
|
+ else if (chrgCntl > 20)
|
|
|
{
|
|
|
-
|
|
|
onceFlg_utrckOver = true;
|
|
|
- socTemp = (socd_pct_estSoc > 950 ? 950 : socd_pct_estSoc);
|
|
|
+ socTemp = socd_pct_estSoc > socc_pct_chrgCor ? socc_pct_chrgCor : socd_pct_estSoc;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
socTemp = socd_pct_estSoc;
|
|
|
}
|
|
|
-
|
|
|
- socn_pct_utrackSoc = Soc_Delay + ( (int16_T) (socTemp - Soc_Delay) > 0 ? (socTemp - Soc_Delay) :0);
|
|
|
+ //
|
|
|
+ socn_pct_utrackSoc = Soc_Delay + (socTemp > Soc_Delay ? (socTemp - Soc_Delay) : 0);
|
|
|
Soc_Delay = socn_pct_utrackSoc;
|
|
|
- socn_pct_utrackSoc =(socn_pct_utrackSoc > 999 ? 999 : socn_pct_utrackSoc);
|
|
|
+
|
|
|
if (fulFlg)
|
|
|
{
|
|
|
- socn_pct_utrackSoc= 1000;
|
|
|
+ socn_pct_utrackSoc = socc_pct_battSocUp;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ 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\n",overCntl,overFlg,fulCntl,fulFlg,ahSoc0_utrckOver,estSoc0_utrckOver,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
|
|
|
- { chrgCntl=0;
|
|
|
- disChrgCntl = ((disChrgCntl+1) >60000 ? 60000 : (disChrgCntl+1));
|
|
|
+ {
|
|
|
+ chrgCntl = 0;
|
|
|
+ disChrgCntl = (disChrgCntl + 1) > 250 ? 250 : (disChrgCntl + 1);
|
|
|
Soc_Delay = 0;
|
|
|
overCntl = 0;
|
|
|
- overFlg = 0;
|
|
|
- fulFlg = 0;
|
|
|
+ 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))
|
|
|
+ if(sfmd_V_cellUMin <= look1_is16lu16n16tu16_binlcase(sfmd_I_curr, (&(socm_I_disChrgCor[0])),(&(socm_V_disChrgCor[0])), 2U))
|
|
|
{
|
|
|
- lowCntl = ( (lowCntl + 1) > 60000 ? 60000 : (lowCntl + 1));
|
|
|
+ lowCntl = (lowCntl + 1) > 250 ? 250 : (lowCntl + 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -448,35 +437,34 @@ void SOC(void)
|
|
|
}
|
|
|
if(lowCntl > 20 || lowFlg)
|
|
|
{
|
|
|
- lowFlg = 1;
|
|
|
+ lowFlg = true;
|
|
|
}
|
|
|
//
|
|
|
if (lowFlg)
|
|
|
{
|
|
|
- if (onceFlg_utrckLow)
|
|
|
+ if (onceFlg_utrckLow)
|
|
|
{
|
|
|
+ onceFlg_utrckLow = false;
|
|
|
ahSoc0_utrckLow = ahSoc;
|
|
|
- estSoc0_utrckLow = socd_pct_estSoc;
|
|
|
+ estSoc0_utrckLow = socd_pct_estSoc < socc_pct_disChrgCor ? socd_pct_estSoc : socc_pct_disChrgCor;
|
|
|
}
|
|
|
- estSoc0_utrckLow = (estSoc0_utrckLow < 50 ? estSoc0_utrckLow : 50);
|
|
|
- socn_pct_utrackSoc = (((int16_T)(ahSoc - ahSoc0_utrckLow) + estSoc0_utrckLow)>0 ? (uint16_T)((int16_T)(ahSoc - ahSoc0_utrckLow) + estSoc0_utrckLow) : 0);
|
|
|
- onceFlg_utrckLow = false;
|
|
|
+ socn_pct_utrackSoc = (int16_T)(ahSoc - ahSoc0_utrckLow + estSoc0_utrckLow) > 0 ? (uint16_T)(ahSoc - ahSoc0_utrckLow + estSoc0_utrckLow) : 0;
|
|
|
}
|
|
|
else if(disChrgCntl > 20)
|
|
|
{
|
|
|
onceFlg_utrckLow = true;
|
|
|
- socn_pct_utrackSoc = (socd_pct_estSoc < 50 ? 50 :socd_pct_estSoc);
|
|
|
+ socn_pct_utrackSoc = socd_pct_estSoc < socc_pct_disChrgCor ? socc_pct_disChrgCor : socd_pct_estSoc;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
socn_pct_utrackSoc = socd_pct_estSoc;
|
|
|
}
|
|
|
- // 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);
|
|
|
+ //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;
|
|
|
+ socd_pct_battSoc = socn_pct_utrackSoc;
|
|
|
socd_pct_battSocEo = socn_pct_utrackSoc;
|
|
|
if ( (int16_T)(socd_pct_battSoc - socd_pct_battSoc_Delay) > 10 || (int16_T)(socd_pct_battSoc - socd_pct_battSoc_Delay) <- 10 )
|
|
|
{
|
|
@@ -492,21 +480,22 @@ void SOC(void)
|
|
|
//////////////////////////////BCUSOC///////////////////////////////////
|
|
|
//=====================================================================
|
|
|
|
|
|
-
|
|
|
if(sfmd_I_curr < 100 && sfmd_I_curr > -100)
|
|
|
{
|
|
|
- statCntl= (statCntl >60000 ? 60000 :statCntl);
|
|
|
+ statCntl= (statCntl + 1) > 250 ? 250 : (statCntl + 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- statCntl=0;
|
|
|
+ statCntl = 0;
|
|
|
}
|
|
|
- statFlg = statCntl > 20 || statFlg;
|
|
|
+ statFlg = statCntl > 20;
|
|
|
|
|
|
- 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;
|
|
|
+ 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)
|
|
|
{
|
|
@@ -517,170 +506,133 @@ void SOC(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- socd_pct_bcuSoc0 = socd_pct_bcuSoc_Delay;
|
|
|
+ socd_pct_bcuSoc0 = socd_pct_bcuSoc;
|
|
|
}
|
|
|
}
|
|
|
- //printf("9------socd_pct_battSoc:%d\n",socd_pct_battSoc);
|
|
|
- //printf("9----statCntl:%d,statFlg:%d,Flg:%d,socd_pct_bcuSoc0:%d,socd_pct_bcuSoc0:%d\n",statCntl,statFlg,Flg,socd_pct_bcuSoc0,socd_pct_bcuSoc0);
|
|
|
+
|
|
|
+ //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 = ((int16_T) (socd_pct_battSoc0 - socd_pct_bcuSoc0) > 0 ? (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);
|
|
|
+ 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> 1000 ? 1000 : (uint16_T)coinSoc);;
|
|
|
- x[2] = 1000;
|
|
|
+ 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[1] = coinSoc > 1000 ? 1000 : (uint16_T)coinSoc;
|
|
|
y[2] = 1000;
|
|
|
-
|
|
|
- SOC_LookUp( socd_pct_battSoc, &x[0], &y[0], &bcuSoc);
|
|
|
-
|
|
|
+ bcuSoc = SOC_LookUp( socd_pct_battSoc, &x[0], &y[0]);
|
|
|
|
|
|
//
|
|
|
- onceFlg_dischrg = true;
|
|
|
if (onceFlg_chrg)
|
|
|
{
|
|
|
- SocFitChrg_Delay = 2000;
|
|
|
- }
|
|
|
- //printf("onceFlg_chrg:%d,SocFitChrg_Delay:%d\n",onceFlg_chrg,SocFitChrg_Delay);
|
|
|
- onceFlg_chrg =false;
|
|
|
- if ((int16_T)(bcuSoc - SocFitChrg_Delay ) > 1)
|
|
|
- {
|
|
|
- SOCfit_IfActionSubsystem1( bcuSoc, SocFitChrg_Delay, &SocFitChrg, 1);
|
|
|
- }
|
|
|
- if ((int16_T)(bcuSoc - SocFitChrg_Delay ) <-1 && (int16_T)(bcuSoc - SocFitChrg_Delay ) > -1000)
|
|
|
- {
|
|
|
- SOCfit_IfActionSubsystem2( bcuSoc, SocFitChrg_Delay, &SocFitChrg, 1);
|
|
|
+ onceFlg_chrg =false;
|
|
|
+ onceFlg_dischrg = true;
|
|
|
+ socd_pct_bcuSoc = 2000;
|
|
|
}
|
|
|
- if (((int16_T)(bcuSoc - SocFitChrg_Delay ) <=1 &&(int16_T)(bcuSoc - SocFitChrg_Delay ) >=-1 )||((int16_T)(bcuSoc - SocFitChrg_Delay ) <=-1000))
|
|
|
- {
|
|
|
-
|
|
|
- SocFitChrg = bcuSoc;
|
|
|
- }
|
|
|
- SocFitChrg_Delay = SocFitChrg;
|
|
|
+ socd_pct_bcuSoc = SOCfitSystem(bcuSoc,&socd_pct_bcuSoc, 1);
|
|
|
|
|
|
//
|
|
|
if (fulFlg)
|
|
|
{
|
|
|
- socd_pct_bcuSoc =1000;
|
|
|
+ socd_pct_bcuSoc =socc_pct_battSocUp;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- socd_pct_bcuSoc =(SocFitChrg > 999 ? 999 : SocFitChrg);
|
|
|
+ socd_pct_bcuSoc = socd_pct_bcuSoc > socc_pct_battSocUp -1 ? socc_pct_battSocUp - 1 : socd_pct_bcuSoc;
|
|
|
}
|
|
|
- //printf("10-----x:[%d-%d-%d],y:[%d-%d-%d],bcusoc:%d,SocFitChrg:%d,socd_pct_bcuSoc:%d\n",x[0],x[1],x[2],y[0],y[1],y[2],bcuSoc,SocFitChrg,socd_pct_bcuSoc);
|
|
|
+ //printf("10-----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);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
//
|
|
|
- delSOC = ((int16_T) (socd_pct_battSoc0 - socd_pct_bcuSoc0) > 0 ? (socd_pct_battSoc0 - socd_pct_bcuSoc0) : (socd_pct_bcuSoc0 - socd_pct_battSoc0));
|
|
|
+ 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] = 0;
|
|
|
- x[1] = (coinSoc > 0 ? (uint16_T)coinSoc : 0);
|
|
|
+ x[0] = socc_pct_battSocLow;
|
|
|
+ x[1] = coinSoc > socc_pct_battSocLow ? (uint16_T)coinSoc : socc_pct_battSocLow;
|
|
|
x[2] = socd_pct_battSoc0;
|
|
|
y[0] = 0;
|
|
|
- y[1] = (coinSoc > 0 ? (uint16_T)coinSoc : 0);
|
|
|
+ y[1] = coinSoc > 0 ? (uint16_T)coinSoc : 0;
|
|
|
y[2] = socd_pct_bcuSoc0;
|
|
|
- SOC_LookUp( socd_pct_battSoc, &x[0], &y[0], &bcuSoc);
|
|
|
+ bcuSoc = SOC_LookUp( socd_pct_battSoc, &x[0], &y[0]);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//
|
|
|
- onceFlg_chrg = true;
|
|
|
- if (onceFlg_dischrg)
|
|
|
- {
|
|
|
- SocFitdisChrg_Delay = 2000;
|
|
|
- }
|
|
|
- onceFlg_dischrg =false;
|
|
|
-
|
|
|
-
|
|
|
- if ((int16_T)(bcuSoc - SocFitdisChrg_Delay ) > 1)
|
|
|
- {
|
|
|
- SOCfit_IfActionSubsystem1( bcuSoc, SocFitdisChrg_Delay, &SocFitdisChrg, 1);
|
|
|
- }
|
|
|
- if ((int16_T)(bcuSoc - SocFitdisChrg_Delay ) <-1 && (int16_T)(bcuSoc - SocFitdisChrg_Delay ) > -1000)
|
|
|
+ if (onceFlg_dischrg)
|
|
|
{
|
|
|
- SOCfit_IfActionSubsystem2( bcuSoc, SocFitdisChrg_Delay, &SocFitdisChrg, 1);
|
|
|
+ onceFlg_chrg = true;
|
|
|
+ onceFlg_dischrg = false;
|
|
|
+ socd_pct_bcuSoc = 2000;
|
|
|
}
|
|
|
- if (((int16_T)(bcuSoc - SocFitdisChrg_Delay ) <=1 &&(int16_T)(bcuSoc - SocFitdisChrg_Delay ) >=-1 )||((int16_T)(bcuSoc - SocFitdisChrg_Delay ) <=-1000))
|
|
|
- {
|
|
|
-
|
|
|
- SocFitdisChrg = bcuSoc;
|
|
|
- }
|
|
|
- SocFitdisChrg_Delay = SocFitdisChrg;
|
|
|
-
|
|
|
-
|
|
|
- socd_pct_bcuSoc = SocFitdisChrg;
|
|
|
+
|
|
|
+ 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;
|
|
|
- socd_pct_bcuSoc_Delay = socd_pct_bcuSoc;
|
|
|
FirstRun_SOC= false;
|
|
|
-
|
|
|
+ //printf("\n");
|
|
|
}
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
-void docvmath(real_T soc ,real_T *docv)
|
|
|
-{
|
|
|
- *docv = ((((((-2.8104E-13 * pow(soc, 7.0) + 1.0283E-10 * pow(soc, 6.0)) +
|
|
|
+real_T docvmath(real_T soc)
|
|
|
+{
|
|
|
+ real_T docv;
|
|
|
+ docv = ((((((-2.8104E-13 * pow(soc, 7.0) + 1.0283E-10 * pow(soc, 6.0)) +
|
|
|
-1.5072E-8 * pow(soc, 5.0)) + 1.1295E-6 * pow(soc, 4.0)) +
|
|
|
-4.588E-5 * pow(soc, 3.0)) + soc * soc * 0.000993) +
|
|
|
-0.010548 * soc) + 0.04876;
|
|
|
+ return docv;
|
|
|
}
|
|
|
////
|
|
|
-void SOC_LookUp(uint16_T battsoc, uint16_T x[], uint16_T y[],uint16_T *bcusoc)
|
|
|
+uint16_T SOC_LookUp(uint16_T battsoc, uint16_T x[3], uint16_T y[3])
|
|
|
{
|
|
|
- //
|
|
|
+ uint16_T bcusoc;
|
|
|
if (battsoc <= x[0])
|
|
|
{
|
|
|
- *bcusoc = y[0];
|
|
|
+ bcusoc = y[0];
|
|
|
}
|
|
|
//
|
|
|
if (battsoc >= x[2])
|
|
|
{
|
|
|
- *bcusoc = y[2];
|
|
|
+ bcusoc = y[2];
|
|
|
}
|
|
|
//
|
|
|
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];
|
|
|
+ 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];
|
|
|
}
|
|
|
//
|
|
|
if (battsoc >= x[1] && battsoc < x[2]) //(x-x1)*(y2-y1)/(x2-x1)+y1
|
|
|
{
|
|
|
- *bcusoc = (uint16_T) ((real_T)((battsoc - x[1]) * 0.1) * (real_T)((y[2] - y[1]) * 0.1) /(real_T)((x[2] - x[1]) * 0.1) * 10)+ y[1];
|
|
|
+ bcusoc = (uint16_T) ((real_T)((battsoc - x[1]) * 0.1) * (real_T)((y[2] - y[1]) * 0.1) /(real_T)((x[2] - x[1]) * 0.1) * 10)+ y[1];
|
|
|
}
|
|
|
+ return bcusoc;
|
|
|
}
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
-void SOCfit_IfActionSubsystem1(uint16_T SOC, uint16_T SOCfit_Delay, uint16_T *SOCfit, uint16_T m)
|
|
|
+uint16_T SOCfitSystem(uint16_T SOC,uint16_T *SOCfit, uint16_T m)
|
|
|
{
|
|
|
- if ((int16_T)(SOC - SOCfit_Delay) > m)
|
|
|
+ int16_T socdelt;
|
|
|
+ socdelt = (int16_T)(SOC - *SOCfit);
|
|
|
+ if( socdelt > m)
|
|
|
{
|
|
|
- *SOCfit = SOCfit_Delay + m;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- *SOCfit = SOC;
|
|
|
- }
|
|
|
-}
|
|
|
-//-------------------------------------------------------------------------
|
|
|
- void SOCfit_IfActionSubsystem2(uint16_T SOC, uint16_T SOCfit_Delay, uint16_T *SOCfit, uint16_T m)
|
|
|
-{
|
|
|
- if ((int16_T)(SOC - SOCfit_Delay) < -m)
|
|
|
- {
|
|
|
- *SOCfit = SOCfit_Delay - m;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- *SOCfit = SOC;
|
|
|
+ *SOCfit = *SOCfit + (socdelt > m ? m : socdelt);
|
|
|
}
|
|
|
+ if(socdelt <- m && socdelt > -1000)
|
|
|
+ {
|
|
|
+ *SOCfit = *SOCfit + (socdelt < -m ? -m : socdelt);
|
|
|
+ }
|
|
|
+ if((socdelt <= m && socdelt >= -m) || socdelt <= -1000)
|
|
|
+ {
|
|
|
+ *SOCfit = SOC;
|
|
|
+ }
|
|
|
+
|
|
|
+ return *SOCfit;
|
|
|
}
|