|
@@ -1,6 +1,4 @@
|
|
|
#include "SOC.h"
|
|
|
-#include "look1_is16lu16n16tu16_binlcase.h"
|
|
|
-#include "look1_iu16lu16n16tu16_binlcase.h"
|
|
|
|
|
|
boolean_T FirstRun_SOC;
|
|
|
|
|
@@ -134,8 +132,8 @@ void SOC(void)
|
|
|
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))
|
|
|
{
|
|
|
- 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_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);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -145,7 +143,7 @@ void SOC(void)
|
|
|
//
|
|
|
if (ihd_tm_parkTime >= cmnc_tm_parkTime && sfmd_I_curr < 10 && sfmd_I_curr > -10)
|
|
|
{
|
|
|
- socn_pct_battSocEE = look1_iu16lu16n16tu16_binlcase(sfmd_V_cellUAvrg, (&(cmnm_V_ocv[0])), (&(cmnm_pct_soc[0])), 12U);
|
|
|
+ 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);
|
|
@@ -169,10 +167,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;
|
|
|
- RC = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Min_Delay * 10),(&(cmnm_pct_soc[0])), (&(cmnm_F_polar[0])), 12U) * 0.001;
|
|
|
+ ocv = (real_T)look1_u16tu16((uint16_T)(soc_Min_Delay * 10), cmnm_pct_soc, cmnm_V_ocv, 13) * 0.001;
|
|
|
+ Ro = (real_T)look1_u16tu16((uint16_T)(soc_Min_Delay * 10), cmnm_pct_soc, cmnm_R_ohm, 13) * 0.001 * 0.001;
|
|
|
+ Rp = (real_T)look1_u16tu16((uint16_T)(soc_Min_Delay * 10), cmnm_pct_soc, cmnm_R_polar,13) * 0.001 * 0.001;
|
|
|
+ RC = (real_T)look1_u16tu16((uint16_T)(soc_Min_Delay * 10), cmnm_pct_soc, cmnm_F_polar,13) * 0.001;
|
|
|
A[0] = 1;
|
|
|
A[1] = 0;
|
|
|
A[2] = 0;
|
|
@@ -232,10 +230,11 @@ 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;
|
|
|
- RC = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Max_Delay * 10),(&(cmnm_pct_soc[0])), (&(cmnm_F_polar[0])), 12U) * 0.001;
|
|
|
+ ocv = (real_T)look1_u16tu16((uint16_T)(soc_Max_Delay * 10), cmnm_pct_soc, cmnm_V_ocv, 13) * 0.001;
|
|
|
+ Ro = (real_T)look1_u16tu16((uint16_T)(soc_Max_Delay * 10), cmnm_pct_soc, cmnm_R_ohm, 13) * 0.001 * 0.001;
|
|
|
+ Rp = (real_T)look1_u16tu16((uint16_T)(soc_Max_Delay * 10), cmnm_pct_soc, cmnm_R_polar,13) * 0.001 * 0.001;
|
|
|
+ RC = (real_T)look1_u16tu16((uint16_T)(soc_Max_Delay * 10), cmnm_pct_soc, cmnm_F_polar,13) * 0.001;
|
|
|
+
|
|
|
A[0] = 1;
|
|
|
A[1] = 0;
|
|
|
A[2] = 0;
|
|
@@ -313,10 +312,11 @@ void SOC(void)
|
|
|
P_avrg_Delay[3] = 10;
|
|
|
}
|
|
|
//参数查表
|
|
|
- ocv = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Avrg_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_V_ocv[0])), 12U) * 0.001;
|
|
|
- Ro = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Avrg_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_ohm[0])), 12U) * 0.001 * 0.001;
|
|
|
- Rp = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Avrg_Delay * 10), (&(cmnm_pct_soc[0])), (&(cmnm_R_polar[0])), 12U) * 0.001 * 0.001;
|
|
|
- RC = (real_T)look1_iu16lu16n16tu16_binlcase((uint16_T)(soc_Avrg_Delay * 10),(&(cmnm_pct_soc[0])), (&(cmnm_F_polar[0])), 12U) * 0.001 ;
|
|
|
+ ocv = (real_T)look1_u16tu16((uint16_T)(soc_Avrg_Delay * 10), cmnm_pct_soc, cmnm_V_ocv, 13) * 0.001;
|
|
|
+ Ro = (real_T)look1_u16tu16((uint16_T)(soc_Avrg_Delay * 10), cmnm_pct_soc, cmnm_R_ohm, 13) * 0.001 * 0.001;
|
|
|
+ Rp = (real_T)look1_u16tu16((uint16_T)(soc_Avrg_Delay * 10), cmnm_pct_soc, cmnm_R_polar,13) * 0.001 * 0.001;
|
|
|
+ RC = (real_T)look1_u16tu16((uint16_T)(soc_Avrg_Delay * 10), cmnm_pct_soc, cmnm_F_polar,13) * 0.001;
|
|
|
+
|
|
|
A[0] = 1;
|
|
|
A[1] = 0;
|
|
|
A[2] = 0;
|
|
@@ -368,11 +368,13 @@ void SOC(void)
|
|
|
//
|
|
|
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);
|
|
|
+ socv_pct_cellSoc[i] = look1_u16tu16((look1_u16tu16(EKFSOCAvrg, cmnm_pct_soc, cmnm_V_ocv, 13) + cdmv_V_deltOCV[i]), cmnm_V_ocv, cmnm_pct_soc, 13);
|
|
|
}
|
|
|
socd_flg_cellSocDisable = socn_flg_ekfInvalidAvrg || cdmd_flg_deltOCVDisable;
|
|
|
- cellSocMax = ArrMax(&socv_pct_cellSoc[0],cmnc_num_cellUNum);
|
|
|
- cellSocMin = ArrMin(&socv_pct_cellSoc[0],cmnc_num_cellUNum);
|
|
|
+
|
|
|
+ cellSocMax = ArrMax(socv_pct_cellSoc,cmnc_num_cellUNum);
|
|
|
+ cellSocMin = ArrMin(socv_pct_cellSoc,cmnc_num_cellUNum);
|
|
|
+
|
|
|
if (cellSocMax > 800)
|
|
|
{
|
|
|
factor = 100;
|
|
@@ -387,8 +389,6 @@ 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);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
|
|
|
//======================================================================
|
|
|
////////////////////////AhSOC//////////////////////////////////////////
|
|
@@ -415,6 +415,7 @@ 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);
|
|
|
+
|
|
|
//======================================================================
|
|
|
///////////////////////estSOC//////////////////////////////////////////
|
|
|
//======================================================================
|
|
@@ -463,7 +464,7 @@ void SOC(void)
|
|
|
chrgCntl = (chrgCntl + 1) > 250 ? 250 : (chrgCntl + 1);
|
|
|
lowCntl = 0;
|
|
|
lowFlg = false;
|
|
|
- socd_V_chrgCCV = look1_is16lu16n16tu16_binlcase(sfmd_I_curr,&socm_I_chrgCor[0],&socm_V_chrgCor[0],2U);
|
|
|
+ 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);
|
|
@@ -536,14 +537,14 @@ void SOC(void)
|
|
|
fulCntl = 0;
|
|
|
if (!cdmd_flg_deltOCVDisable)
|
|
|
{
|
|
|
- socd_V_disChrgCCV = look1_is16lu16n16tu16_binlcase(sfmd_I_curr,&socm_I_disChrgCor[0],&socm_V_disChrgCor[0],2U) + (uint16_T)(sfmd_I_curr * (cdmv_ohm_deltR[sfmd_idx_cellUMin]) * 0.001 * 0.1);
|
|
|
+ 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);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- socd_V_disChrgCCV = look1_is16lu16n16tu16_binlcase(sfmd_I_curr,&socm_I_disChrgCor[0],&socm_V_disChrgCor[0],2U);
|
|
|
+ socd_V_disChrgCCV = look1_i16tu16(sfmd_I_curr,socm_I_disChrgCor,socm_V_disChrgCor,3);
|
|
|
}
|
|
|
|
|
|
- if (sfmd_V_cellUMin <= socd_V_disChrgCCV)
|
|
|
+ if (sfmd_V_cellUMin <= socd_V_disChrgCCV)
|
|
|
{
|
|
|
lowCntl = (lowCntl + 1) > 250 ? 250 : (lowCntl + 1);
|
|
|
}
|
|
@@ -627,16 +628,16 @@ void SOC(void)
|
|
|
y[0] = socd_pct_bcuSoc0;
|
|
|
y[1] = coinSoc > socc_pct_battSocUp ? socc_pct_battSocUp : (uint16_T)coinSoc;
|
|
|
y[2] = socc_pct_battSocUp;
|
|
|
- bcuSoc = SOC_LookUp(socd_pct_battSoc, &x[0], &y[0]);
|
|
|
+ bcuSoc = look1_u16tu16(socd_pct_battSoc, x, y,3);
|
|
|
|
|
|
//
|
|
|
if (onceFlg_chrg)
|
|
|
{
|
|
|
onceFlg_chrg = false;
|
|
|
onceFlg_dischrg = true;
|
|
|
- socd_pct_bcuSoc = 2000;
|
|
|
+ socd_pct_bcuSoc = bcuSoc;
|
|
|
}
|
|
|
- socd_pct_bcuSoc = SOCfitSystem(bcuSoc, &socd_pct_bcuSoc, 1);
|
|
|
+ socd_pct_bcuSoc = DataFilt(bcuSoc, &socd_pct_bcuSoc, 1);
|
|
|
|
|
|
//
|
|
|
if (fulFlg)
|
|
@@ -661,16 +662,16 @@ void SOC(void)
|
|
|
y[0] = socc_pct_battSocLow;
|
|
|
y[1] = coinSoc > socc_pct_battSocLow ? (uint16_T)coinSoc : socc_pct_battSocLow;
|
|
|
y[2] = socd_pct_bcuSoc0;
|
|
|
- bcuSoc = SOC_LookUp(socd_pct_battSoc, &x[0], &y[0]);
|
|
|
+ bcuSoc = look1_u16tu16(socd_pct_battSoc, x, y,3);
|
|
|
|
|
|
//
|
|
|
if (onceFlg_dischrg)
|
|
|
{
|
|
|
onceFlg_chrg = true;
|
|
|
onceFlg_dischrg = false;
|
|
|
- socd_pct_bcuSoc = 2000;
|
|
|
+ socd_pct_bcuSoc = bcuSoc;
|
|
|
}
|
|
|
- socd_pct_bcuSoc = SOCfitSystem(bcuSoc, &socd_pct_bcuSoc, 1);
|
|
|
+ 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;
|
|
@@ -717,50 +718,7 @@ real_T docvmath(real_T soc)
|
|
|
}
|
|
|
|
|
|
////
|
|
|
-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];
|
|
|
- }
|
|
|
- //
|
|
|
- if (battsoc >= x[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];
|
|
|
- }
|
|
|
- //
|
|
|
- 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];
|
|
|
- }
|
|
|
- return bcusoc;
|
|
|
-}
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
-uint16_T SOCfitSystem(uint16_T SOC, uint16_T *SOCfit, uint16_T m)
|
|
|
-{
|
|
|
- int16_T socdelt;
|
|
|
- socdelt = (int16_T)(SOC - *SOCfit);
|
|
|
- if (socdelt > m)
|
|
|
- {
|
|
|
- *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;
|
|
|
-}
|
|
|
+
|
|
|
|