|
@@ -1,11 +1,9 @@
|
|
|
#include "SOC.h"
|
|
|
|
|
|
-boolean_T FirstRun_SOC;
|
|
|
-
|
|
|
//---------------SOC初始化-----------------------------------------------
|
|
|
void SOC_Init(void)
|
|
|
{
|
|
|
- FirstRun_SOC = true;
|
|
|
+ socd_flg_firstRun = true;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -17,7 +15,6 @@ void SOC(void)
|
|
|
static uint16_T socn_pct_battSocEE;
|
|
|
static uint16_T socn_pct_bcuSocEE;
|
|
|
static uint16_T socn_Q_cap;
|
|
|
- //static int16_T socn_ohm_cellRAvrg;
|
|
|
//
|
|
|
real_T Q;
|
|
|
real_T battcurr;
|
|
@@ -58,38 +55,36 @@ void SOC(void)
|
|
|
static real_T ahDelay;
|
|
|
int16_T ahSoc;
|
|
|
//
|
|
|
+ boolean_T socn_flg_ekfDisable;
|
|
|
static uint16_T ekfInvalidCntl;
|
|
|
static boolean_T onceFlg_est;
|
|
|
static int16_T ahSoc0_est;
|
|
|
static uint16_T ekfSoc0_est;
|
|
|
//
|
|
|
- uint16_T socd_V_chrgCCV;
|
|
|
- uint16_T socd_V_disChrgCCV;
|
|
|
+ uint16_T socn_V_chrgCCV;
|
|
|
+ uint16_T socn_V_disChrgCCV;
|
|
|
static boolean_T overFlg;
|
|
|
static boolean_T fulFlg;
|
|
|
- static uint8_T overCntl;
|
|
|
- static uint8_T fulCntl;
|
|
|
+ static uint16_T overCntl;
|
|
|
+ static uint16_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 uint8_T lowCntl;
|
|
|
+ static uint16_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 uint8_T chrgCntl;
|
|
|
- static uint8_T disChrgCntl;
|
|
|
//
|
|
|
//
|
|
|
- static uint8_T statCntl;
|
|
|
- boolean_T statFlg;
|
|
|
- static uint8_T ihd_st_chrgSta_Delay;
|
|
|
- static uint16_T socd_pct_battSoc_Delay;
|
|
|
- static uint16_T socd_pct_battSoc0;
|
|
|
- static uint16_T socd_pct_bcuSoc0;
|
|
|
+ static uint16_T statCntl;
|
|
|
+ static uint8_T socn_st_workStat_Delay;
|
|
|
+ static uint16_T socn_pct_battSoc_Delay;
|
|
|
+ static uint16_T socn_pct_battSoc0;
|
|
|
+ static uint16_T socn_pct_bcuSoc0;
|
|
|
uint16_T delSOC;
|
|
|
uint16_T bcuSoc;
|
|
|
int16_T coinSoc;
|
|
@@ -99,11 +94,11 @@ void SOC(void)
|
|
|
static boolean_T onceFlg_chrg;
|
|
|
static boolean_T onceFlg_dischrg;
|
|
|
|
|
|
- static uint16_T socd_pct_battSoc_save;
|
|
|
- static uint16_T socd_pct_bcuSoc_save;
|
|
|
+ static uint16_T socn_pct_battSoc_save;
|
|
|
+ static uint16_T socn_pct_bcuSoc_save;
|
|
|
uint16_T i;
|
|
|
//
|
|
|
- if (FirstRun_SOC)
|
|
|
+ if (socd_flg_firstRun)
|
|
|
{
|
|
|
onceFlg_est = true;
|
|
|
ekfInvalidCntl = 0;
|
|
@@ -113,24 +108,25 @@ void SOC(void)
|
|
|
overFlg = false;
|
|
|
fulFlg = false;
|
|
|
lowFlg = false;
|
|
|
+ statCntl = 0;
|
|
|
Soc_Delay = 0;
|
|
|
onceFlg_utrckOver = true;
|
|
|
onceFlg_utrckLow = true;
|
|
|
- ihd_st_chrgSta_Delay = 0;
|
|
|
- socd_pct_battSoc_Delay = 0;
|
|
|
+ socn_st_workStat_Delay = 0;
|
|
|
+ socn_pct_battSoc_Delay = 0;
|
|
|
onceFlg_chrg = true;
|
|
|
onceFlg_dischrg = true;
|
|
|
- socd_pct_battSoc_save = 0;
|
|
|
- socd_pct_bcuSoc_save = 0;
|
|
|
+ socn_pct_battSoc_save = 0;
|
|
|
+ socn_pct_bcuSoc_save = 0;
|
|
|
}
|
|
|
|
|
|
//=====================================================================
|
|
|
- ////////////////////////初始值获取//////////////////////////////////////
|
|
|
+ ////////////////////////初始值获取/EE校验//////////////////////////////
|
|
|
//=====================================================================
|
|
|
- if (FirstRun_SOC)
|
|
|
+ if (socd_flg_firstRun)
|
|
|
{ //
|
|
|
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 && sfmd_I_curr < 10 && sfmd_I_curr > -10))
|
|
|
+ (((int16_T)(socd_pct_battSocEi - socd_pct_bcuSocEi) > 300 || (int16_T)(socd_pct_battSocEi - socd_pct_bcuSocEi) < -300) && ihd_tm_parkTime >= cmnc_tm_parkTime && sfmd_I_curr < 10 && sfmd_I_curr > -10))
|
|
|
{
|
|
|
socn_pct_battSocEE = look1_u16tu16(sfmd_V_cellUAvrg, cmnm_V_ocv, cmnm_pct_soc, 13);
|
|
|
socn_pct_bcuSocEE = look1_u16tu16(sfmd_V_cellUAvrg, cmnm_V_ocv, cmnm_pct_soc, 13);
|
|
@@ -138,7 +134,7 @@ void SOC(void)
|
|
|
else
|
|
|
{
|
|
|
socn_pct_battSocEE = socd_pct_battSocEi;
|
|
|
- socn_pct_bcuSocEE = socd_pct_bcuSocEi;
|
|
|
+ socn_pct_bcuSocEE = socd_pct_bcuSocEi;
|
|
|
}
|
|
|
//
|
|
|
if (ihd_tm_parkTime >= cmnc_tm_parkTime && sfmd_I_curr < 10 && sfmd_I_curr > -10)
|
|
@@ -146,7 +142,6 @@ void SOC(void)
|
|
|
socn_pct_battSocEE = look1_u16tu16(sfmd_V_cellUAvrg, cmnm_V_ocv, cmnm_pct_soc, 13);
|
|
|
}
|
|
|
socn_Q_cap = (uint16_T)((uint16_T)((uint32_T)sohd_pct_bcuSoh * cmnc_Q_ratedCp / 2000U) << 1);
|
|
|
- //socn_ohm_cellRAvrg = ArrMean(&sorv_ohm_cellREi[0], cmnc_num_cellUNum);
|
|
|
}
|
|
|
|
|
|
//printf("1---- battSocEi:%d,bcuSocEi:%d,battSocEE:%d,bcuSocEE:%d\n",socd_pct_battSocEi,socd_pct_bcuSocEi,socn_pct_battSocEE,socn_pct_bcuSocEE);
|
|
@@ -157,7 +152,7 @@ void SOC(void)
|
|
|
Q = (real_T)socn_Q_cap * 0.1;
|
|
|
|
|
|
//-------------------------EKFmin---------------------------------------
|
|
|
- if (FirstRun_SOC)
|
|
|
+ if (socd_flg_firstRun)
|
|
|
{
|
|
|
soc_Min_Delay = (real_T)socn_pct_battSocEE * 0.1;
|
|
|
Up_Min_Delay = 0;
|
|
@@ -220,7 +215,7 @@ void SOC(void)
|
|
|
socn_flg_ekfInvalidMin = (deltU > 0.01) || (deltU < -0.01);
|
|
|
//printf("2----socmin:%f,U:%d,R:%f\n",soc_Min_Delay,sfmd_V_cellUMin,Ro);
|
|
|
//------------------------EKFSOCmax-----------------------------------
|
|
|
- if (FirstRun_SOC)
|
|
|
+ if (socd_flg_firstRun)
|
|
|
{
|
|
|
soc_Max_Delay = (real_T)socn_pct_battSocEE * 0.1;
|
|
|
Up_Max_Delay = 0;
|
|
@@ -282,7 +277,7 @@ void SOC(void)
|
|
|
//输出
|
|
|
EKFSOCMax = (uint16_T)(soc_Max_Delay * 10);
|
|
|
socn_flg_ekfInvalidMax = (deltU > 0.01) || (deltU < -0.01);
|
|
|
- //printf("4----socmax:%f,U:%d,R:%f\n\n",soc_Max_Delay,sfmd_V_cellUMax,Ro);
|
|
|
+ //printf("3----socmax:%f,U:%d,R:%f\n\n",soc_Max_Delay,sfmd_V_cellUMax,Ro);
|
|
|
//-----------------------EKFSOC----------------------------------------
|
|
|
socn_flg_ekfInvalid = socn_flg_ekfInvalidMax || socn_flg_ekfInvalidMin;
|
|
|
if (EKFSOCMax > 800)
|
|
@@ -299,10 +294,10 @@ 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);
|
|
|
+ //printf("4----socd_pct_ekfSoc:%d,EKFSOCMax:%d,EKFSOCMin:%d,\n",socd_pct_ekfSoc,EKFSOCMax,EKFSOCMin);
|
|
|
|
|
|
//-------------------------EKFavrg---------------------------------------
|
|
|
- if (FirstRun_SOC)
|
|
|
+ if (socd_flg_firstRun)
|
|
|
{
|
|
|
soc_Avrg_Delay = (real_T)socn_pct_battSocEE * 0.1;
|
|
|
Up_Avrg_Delay = 0;
|
|
@@ -393,7 +388,7 @@ void SOC(void)
|
|
|
//======================================================================
|
|
|
////////////////////////AhSOC//////////////////////////////////////////
|
|
|
//======================================================================
|
|
|
- if (FirstRun_SOC)
|
|
|
+ if (socd_flg_firstRun)
|
|
|
{
|
|
|
ahDelay = (real_T)(socn_pct_battSocEE * 0.1);
|
|
|
}
|
|
@@ -419,16 +414,8 @@ void SOC(void)
|
|
|
//======================================================================
|
|
|
///////////////////////estSOC//////////////////////////////////////////
|
|
|
//======================================================================
|
|
|
- if (!socn_flg_ekfInvalid)
|
|
|
- {
|
|
|
- ekfInvalidCntl = (ekfInvalidCntl + 1) > 250 ? 250 : (ekfInvalidCntl + 1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ekfInvalidCntl = 0;
|
|
|
- }
|
|
|
-
|
|
|
- if (ekfInvalidCntl < 20)
|
|
|
+ socn_flg_ekfDisable = !JudgeTimeSystem(1,!socn_flg_ekfInvalid,&ekfInvalidCntl,20);
|
|
|
+ if (socn_flg_ekfDisable)
|
|
|
{
|
|
|
if (onceFlg_est)
|
|
|
{
|
|
@@ -460,37 +447,12 @@ void SOC(void)
|
|
|
//======================================================================
|
|
|
if (ihd_st_workStat == 2)
|
|
|
{
|
|
|
- disChrgCntl = 0;
|
|
|
- chrgCntl = (chrgCntl + 1) > 250 ? 250 : (chrgCntl + 1);
|
|
|
lowCntl = 0;
|
|
|
lowFlg = false;
|
|
|
- socd_V_chrgCCV = look1_i16tu16(sfmd_I_curr,socm_I_chrgCor,socm_V_chrgCor,3);
|
|
|
- if (sfmd_V_cellUMax >= socd_V_chrgCCV)
|
|
|
- {
|
|
|
- overCntl = (overCntl + 1) > 250 ? 250 : (overCntl + 1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- overCntl = 0;
|
|
|
- }
|
|
|
- if (overCntl > 2 || overFlg)
|
|
|
- {
|
|
|
- overFlg = 1;
|
|
|
- }
|
|
|
- //
|
|
|
- if (sfmd_V_cellUMax >= cmnc_V_chrgFul)
|
|
|
- {
|
|
|
- fulCntl = (fulCntl + 1) > 250 ? 250 : (fulCntl + 1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- fulCntl = 0;
|
|
|
- }
|
|
|
- if ((fulCntl > 2) || fulFlg)
|
|
|
- {
|
|
|
- fulFlg = 1;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ socn_V_chrgCCV = look1_i16tu16(sfmd_I_curr,socm_I_chrgCor,socm_V_chrgCor,3);
|
|
|
+ overFlg = JudgeTimeSystem(1,sfmd_V_cellUMax >= socn_V_chrgCCV,&overCntl,2) || overFlg;
|
|
|
+ fulFlg = JudgeTimeSystem(1,sfmd_V_cellUMax >= cmnc_V_chrgFul,&fulCntl ,2) || fulFlg;
|
|
|
//
|
|
|
if (overFlg)
|
|
|
{
|
|
@@ -502,15 +464,11 @@ void SOC(void)
|
|
|
}
|
|
|
socTemp = (uint16_T)(ahSoc - ahSoc0_utrckOver + estSoc0_utrckOver);
|
|
|
}
|
|
|
- else if (chrgCntl > 2)
|
|
|
+ else
|
|
|
{
|
|
|
onceFlg_utrckOver = true;
|
|
|
socTemp = socd_pct_estSoc > socc_pct_chrgCor ? socc_pct_chrgCor : socd_pct_estSoc;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- socTemp = socd_pct_estSoc;
|
|
|
- }
|
|
|
//
|
|
|
socn_pct_utrackSoc = Soc_Delay + (socTemp > Soc_Delay ? (socTemp - Soc_Delay) : 0);
|
|
|
Soc_Delay = socn_pct_utrackSoc;
|
|
@@ -528,8 +486,6 @@ void SOC(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- chrgCntl = 0;
|
|
|
- disChrgCntl = (disChrgCntl + 1) > 250 ? 250 : (disChrgCntl + 1);
|
|
|
Soc_Delay = 0;
|
|
|
overCntl = 0;
|
|
|
overFlg = false;
|
|
@@ -537,96 +493,73 @@ void SOC(void)
|
|
|
fulCntl = 0;
|
|
|
if (!cdmd_flg_deltOCVDisable)
|
|
|
{
|
|
|
- socd_V_disChrgCCV = look1_i16tu16(sfmd_I_curr,socm_I_disChrgCor,socm_V_disChrgCor,3) + (uint16_T)(sfmd_I_curr * (cdmv_ohm_deltR[sfmd_idx_cellUMin]) * 0.001 * 0.1);
|
|
|
+ socn_V_disChrgCCV = look1_i16tu16(sfmd_I_curr,socm_I_disChrgCor,socm_V_disChrgCor,3) + (uint16_T)(sfmd_I_curr * (cdmv_ohm_deltR[sfmd_idx_cellUMin]) * 0.001 * 0.1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- socd_V_disChrgCCV = look1_i16tu16(sfmd_I_curr,socm_I_disChrgCor,socm_V_disChrgCor,3);
|
|
|
+ socn_V_disChrgCCV = look1_i16tu16(sfmd_I_curr,socm_I_disChrgCor,socm_V_disChrgCor,3);
|
|
|
}
|
|
|
-
|
|
|
- if (sfmd_V_cellUMin <= socd_V_disChrgCCV)
|
|
|
- {
|
|
|
- lowCntl = (lowCntl + 1) > 250 ? 250 : (lowCntl + 1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- lowCntl = 0;
|
|
|
- }
|
|
|
- if (lowCntl > 2 || lowFlg)
|
|
|
- {
|
|
|
- lowFlg = true;
|
|
|
- }
|
|
|
+ lowFlg = JudgeTimeSystem(1,sfmd_V_cellUMin <= socn_V_disChrgCCV,&lowCntl,2) || lowFlg;
|
|
|
//
|
|
|
if (lowFlg)
|
|
|
{
|
|
|
if (onceFlg_utrckLow)
|
|
|
{
|
|
|
onceFlg_utrckLow = false;
|
|
|
- ahSoc0_utrckLow = ahSoc;
|
|
|
+ ahSoc0_utrckLow = ahSoc;
|
|
|
estSoc0_utrckLow = socc_pct_disChrgCor;
|
|
|
}
|
|
|
socn_pct_utrackSoc = (int16_T)(ahSoc - ahSoc0_utrckLow + estSoc0_utrckLow) > 0 ? (uint16_T)(ahSoc - ahSoc0_utrckLow + estSoc0_utrckLow) : 0;
|
|
|
}
|
|
|
- else if (disChrgCntl > 2)
|
|
|
+ else
|
|
|
{
|
|
|
onceFlg_utrckLow = true;
|
|
|
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);
|
|
|
}
|
|
|
- socd_pct_battSoc = socn_pct_utrackSoc;
|
|
|
+ socd_pct_battSoc = socn_pct_utrackSoc;
|
|
|
socd_pct_battSocEo = socn_pct_utrackSoc;
|
|
|
|
|
|
|
|
|
//===============================================================================================================================================================
|
|
|
////////////////////////////////////////////////BCUSOC///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
//===============================================================================================================================================================
|
|
|
- if (sfmd_I_curr < 10 && sfmd_I_curr > -10)
|
|
|
- {
|
|
|
- statCntl = (statCntl + 1) > 250 ? 250 : (statCntl + 1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- 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)(socd_pct_battSoc - socd_pct_battSoc_Delay) > 5 || (int16_T)(socd_pct_battSoc - socd_pct_battSoc_Delay) < -5) || statFlg);
|
|
|
-
|
|
|
- ihd_st_chrgSta_Delay = ihd_st_workStat;
|
|
|
- socd_pct_battSoc_Delay = socd_pct_battSoc;
|
|
|
+ Flg = (socd_flg_firstRun || (socn_st_workStat_Delay == 2 && ihd_st_workStat != 2) || (socn_st_workStat_Delay != 2 && ihd_st_workStat == 2) ||
|
|
|
+ ((int16_T)(socd_pct_battSoc - socn_pct_battSoc_Delay) > 5 || (int16_T)(socd_pct_battSoc - socn_pct_battSoc_Delay) < -5) ||
|
|
|
+ JudgeTimeSystem(1,sfmd_I_curr < 10 && sfmd_I_curr > -10,&statCntl ,3));
|
|
|
+
|
|
|
+ socn_st_workStat_Delay = ihd_st_workStat;
|
|
|
+ socn_pct_battSoc_Delay = socd_pct_battSoc;
|
|
|
|
|
|
//
|
|
|
if (Flg)
|
|
|
{
|
|
|
- socd_pct_battSoc0 = socd_pct_battSoc;
|
|
|
- if (FirstRun_SOC)
|
|
|
+ socn_pct_battSoc0 = socd_pct_battSoc;
|
|
|
+ if (socd_flg_firstRun)
|
|
|
{
|
|
|
- socd_pct_bcuSoc0 = socn_pct_bcuSocEE;
|
|
|
+ socn_pct_bcuSoc0 = socn_pct_bcuSocEE;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- socd_pct_bcuSoc0 = socd_pct_bcuSoc;
|
|
|
+ socn_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);
|
|
|
+ delSOC = socn_pct_battSoc0 > socn_pct_bcuSoc0 ? (socn_pct_battSoc0 - socn_pct_bcuSoc0) : (socn_pct_bcuSoc0 - socn_pct_battSoc0);
|
|
|
+ coinSoc = (socn_pct_battSoc0 > socn_pct_bcuSoc0 ? socn_pct_battSoc0 : socn_pct_bcuSoc0) + (delSOC > 50 ? 50 : delSOC);
|
|
|
|
|
|
- x[0] = socd_pct_battSoc0;
|
|
|
- x[1] = coinSoc > socc_pct_battSocUp ? socc_pct_battSocUp : (uint16_T)coinSoc;
|
|
|
+ x[0] = socn_pct_battSoc0 > socc_pct_battSocUp - 2 ? socc_pct_battSocUp - 2 : socn_pct_battSoc0;
|
|
|
+ x[1] = coinSoc > socc_pct_battSocUp - 1 ? socc_pct_battSocUp - 1: (uint16_T)coinSoc;
|
|
|
x[2] = socc_pct_battSocUp;
|
|
|
|
|
|
- y[0] = socd_pct_bcuSoc0;
|
|
|
- y[1] = coinSoc > socc_pct_battSocUp ? socc_pct_battSocUp : (uint16_T)coinSoc;
|
|
|
+ y[0] = socn_pct_bcuSoc0 > socc_pct_battSocUp - 2 ? socc_pct_battSocUp - 2 : socn_pct_bcuSoc0;;
|
|
|
+ y[1] = coinSoc > socc_pct_battSocUp - 1 ? socc_pct_battSocUp - 1: (uint16_T)coinSoc;
|
|
|
y[2] = socc_pct_battSocUp;
|
|
|
bcuSoc = look1_u16tu16(socd_pct_battSoc, x, y,3);
|
|
|
|
|
@@ -637,6 +570,7 @@ void SOC(void)
|
|
|
onceFlg_dischrg = true;
|
|
|
socd_pct_bcuSoc = bcuSoc;
|
|
|
}
|
|
|
+
|
|
|
socd_pct_bcuSoc = DataFilt(bcuSoc, &socd_pct_bcuSoc, 1);
|
|
|
|
|
|
//
|
|
@@ -648,20 +582,21 @@ void SOC(void)
|
|
|
{
|
|
|
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,socd_pct_bcuSoc:%d\n",x[0],x[1],x[2],y[0],y[1],y[2],bcuSoc,socd_pct_bcuSoc);
|
|
|
+ //printf("10-----x:[%d-%d-%d],y:[%d-%d-%d],battSOC:%d,bcusoc:%d,socd_pct_bcuSoc:%d\n",x[0],x[1],x[2],y[0],y[1],y[2],socd_pct_battSoc,bcuSoc,socd_pct_bcuSoc);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//
|
|
|
- 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));
|
|
|
+ delSOC = socn_pct_battSoc0 > socn_pct_bcuSoc0 ? (socn_pct_battSoc0 - socn_pct_bcuSoc0) : (socn_pct_bcuSoc0 - socn_pct_battSoc0);
|
|
|
+ coinSoc = (int16_T)((socn_pct_battSoc0 < socn_pct_bcuSoc0 ? socn_pct_battSoc0 : socn_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;
|
|
|
+ x[1] = coinSoc < socc_pct_battSocLow + 1 ? socc_pct_battSocLow + 1 : (uint16_T)coinSoc;
|
|
|
+ x[2] = socn_pct_battSoc0 < socc_pct_battSocLow + 2 ? socc_pct_battSocLow + 2 : (uint16_T)socn_pct_battSoc0;
|
|
|
+
|
|
|
y[0] = socc_pct_battSocLow;
|
|
|
- y[1] = coinSoc > socc_pct_battSocLow ? (uint16_T)coinSoc : socc_pct_battSocLow;
|
|
|
- y[2] = socd_pct_bcuSoc0;
|
|
|
+ y[1] = coinSoc < socc_pct_battSocLow + 1 ? socc_pct_battSocLow + 1 : (uint16_T)coinSoc;
|
|
|
+ y[2] = socn_pct_bcuSoc0 < socc_pct_battSocLow + 2 ? socc_pct_battSocLow + 2 : (uint16_T)socn_pct_bcuSoc0;
|
|
|
bcuSoc = look1_u16tu16(socd_pct_battSoc, x, y,3);
|
|
|
|
|
|
//
|
|
@@ -671,7 +606,9 @@ void SOC(void)
|
|
|
onceFlg_dischrg = false;
|
|
|
socd_pct_bcuSoc = bcuSoc;
|
|
|
}
|
|
|
+
|
|
|
socd_pct_bcuSoc = DataFilt(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;
|
|
@@ -680,22 +617,24 @@ void SOC(void)
|
|
|
|
|
|
socd_pct_vcuSoc = (uint16_T)((uint32_T)((socd_pct_bcuSoc - socc_pct_battSocLow) * 1000) / (socc_pct_battSocUp - socc_pct_battSocLow));
|
|
|
|
|
|
- //printf("BattSOC:%d,BCUSOC:%d,VcuSoc:%d\n",socd_pct_battSoc,socd_pct_bcuSoc,socd_pct_vcuSoc);
|
|
|
//================================================================================================
|
|
|
//------------------EEsave-------------------------------------------=============================
|
|
|
//================================================================================================
|
|
|
- if ((int16_T)(socd_pct_battSoc - socd_pct_battSoc_save) > 10 || (int16_T)(socd_pct_battSoc - socd_pct_battSoc_save) < -10 || (int16_T)(socd_pct_bcuSoc - socd_pct_bcuSoc_save) > 10 || (int16_T)(socd_pct_bcuSoc - socd_pct_bcuSoc_save) < -10 )
|
|
|
+ if ((int16_T)(socd_pct_battSoc - socn_pct_battSoc_save) > 10 || (int16_T)(socd_pct_battSoc - socn_pct_battSoc_save) < -10 || (int16_T)(socd_pct_bcuSoc - socn_pct_bcuSoc_save) > 10 || (int16_T)(socd_pct_bcuSoc - socn_pct_bcuSoc_save) < -10 )
|
|
|
{
|
|
|
socd_flg_EEsave = 1;
|
|
|
- socd_pct_battSoc_save = socd_pct_battSoc;
|
|
|
- socd_pct_bcuSoc_save = socd_pct_bcuSoc;
|
|
|
+ socn_pct_battSoc_save = socd_pct_battSoc;
|
|
|
+ socn_pct_bcuSoc_save = socd_pct_bcuSoc;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
socd_flg_EEsave = 0;
|
|
|
}
|
|
|
+
|
|
|
|
|
|
- FirstRun_SOC = false;
|
|
|
+ socd_flg_firstRun = false;
|
|
|
+
|
|
|
+ //printf("\n");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -706,14 +645,10 @@ void SOC(void)
|
|
|
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) +
|
|
|
- -0.00371 * soc) +
|
|
|
- 0.02732;
|
|
|
+ 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) +
|
|
|
+ -0.00371 * soc) +0.02732;
|
|
|
return docv;
|
|
|
}
|
|
|
|