123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- #include "BLC.h"
- ////////////////////////////////////////////////////////////////////////////
- void BLC_Init(void)
- {
- blcd_flg_firstRun = true;
- }
- ///////////////////////////////////////////////////////////////////////////
- void BLC(void)
- {
- uint16_T i;
- static uint16_T blcn_Q_reqCpEE[cmnc_num_cellUNumMax];
- static uint32_T blcn_Q_totalCpEE[cmnc_num_cellUNumMax];
-
- static boolean_T blcn_flg_judge;
- boolean_T blcn_flg_enable;
-
- uint16_T blcn_pct_cellSoc[cmnc_num_cellUNumMax];
- uint16_T blcn_pct_cellSocMin;
- static uint16_T blcn_Q_reqCpNow[cmnc_num_cellUNumMax];
- real_T Qmin;
- real_T QL;
- real_T reqCp;
-
- static uint16_T blcn_Q_reqCpEo_Delay[cmnc_num_cellUNumMax];
- boolean_T blcn_flg_stop[cmnc_num_cellUNumMax];
- boolean_T blcn_flg_pause[cmnc_num_cellUNumMax];
- static real_T temp[cmnc_num_cellUNumMax];
- uint16_T blcn_Q_impleCp[cmnc_num_cellUNumMax];
- if(blcd_flg_firstRun)
- {
- memset(blcn_Q_reqCpEo_Delay,0,sizeof(blcn_Q_reqCpEo_Delay));
- memset(temp,0,sizeof(temp));
- }
- //=========================================================================
- //---------------------------------EE校验----------------------------------
- //=========================================================================
-
- if(blcd_flg_firstRun)
- {
- if(ArrMax(blcv_Q_reqCpEi, cmnc_num_cellUNum) > cmnc_Q_ratedCp)
- {
- memset(blcn_Q_reqCpEE, 0, sizeof(blcn_Q_reqCpEE));
- memset(blcn_Q_totalCpEE,0, sizeof(blcn_Q_totalCpEE));
- }
- else
- {
- memcpy(blcn_Q_reqCpEE, blcv_Q_reqCpEi, sizeof(blcv_Q_reqCpEi));
- memcpy(blcn_Q_totalCpEE,blcv_Q_totalCpEi, sizeof(blcn_Q_totalCpEE));
- }
- }
- //=========================================================================
- //---------------------------------使能判断--------------------------------
- //=========================================================================
- if(blcd_flg_firstRun)
- {
- blcn_flg_judge = (ihd_tm_parkTime >= cmnc_tm_parkTime)&& !sfmd_flg_cellUInval && (sfmd_I_curr > -10 && sfmd_I_curr < 10);
- }
- blcn_flg_enable = ((sfmd_st_fltAct >> 7) & 0x01) != 1;
- //=========================================================================
- //---------------------------------需求计算--------------------------------
- //=========================================================================
- if(blcd_flg_firstRun)
- {
- //压差法
- if(blcn_flg_judge)
- {
- blcn_pct_cellSocMin = look1_u16tu16(sfmd_V_cellUMin,cmnm_V_ocv, cmnm_pct_soc, 13);
- for (i = 0; i < cmnc_num_cellUNum; i++)
- {
- blcn_pct_cellSoc[i] = look1_u16tu16(sfmv_V_cellU[i], cmnm_V_ocv, cmnm_pct_soc, 13);
- }
- for (i = 0; i < cmnc_num_cellUNum; i++)
- {
- if(sfmv_V_cellU[i] - sfmd_V_cellUMin > blcc_V_low)
- {
- blcn_Q_reqCpNow[i] = (uint16_T) ((real_T)(cmnc_Q_ratedCp * 0.1) * (real_T)((blcn_pct_cellSoc[i] - blcn_pct_cellSocMin) * 0.1) /100 * 1000);
- }
- else
- {
- blcn_Q_reqCpNow[i] = 0;
- }
- }
- }
- else
- {
- memcpy(blcn_Q_reqCpNow,blcn_Q_reqCpEE, sizeof(blcn_Q_reqCpEE));
- }
-
-
- /*/ 最大化容量法
- if(blcn_flg_judge)
- {
- Qmin = (real_T)(sohv_Q_cellCap[0] * 0.1) * (real_T)(blcn_pct_cellSoc[0] * 0.1)/100;
- for(i = 0; i < cmnc_num_cellUNum; i++)
- {
- if (Qmin > (real_T)(sohv_Q_cellCap[i] * 0.1) * (real_T)(blcn_pct_cellSoc[i] * 0.1)/100)
- {
- Qmin = (real_T)(sohv_Q_cellCap[i] * 0.1) * (real_T)(blcn_pct_cellSoc[i] * 0.1)/100;
- QL = (real_T)(sohv_Q_cellCap[i] * 0.1) - Qmin;
- }
- }
- for(i = 0; i < cmnc_num_cellUNum; i++)
- {
- reqCp = QL- (real_T)(sohv_Q_cellCap[i] * 0.1)*(real_T)(blcn_pct_cellSoc[i] * 0.1)/100;
- if (reqCp >0.001)
- {
- blcn_Q_reqCpNow[i] =uint16_T(reqCp * 1000);
- }
- }
- }
- else
- {
- memcpy(blcn_Q_reqCpNow,blcn_Q_reqCpEE, sizeof(blcn_Q_reqCpEE));
- } */
- }
- //=========================================================================
- //---------------------------------stop计算--------------------------------
- //=========================================================================
- for(i = 0; i < cmnc_num_cellUNum; i++)
- {
- if(blcn_Q_reqCpEo_Delay[i] > 0)
- {
- blcn_flg_stop[i] = false;
- }
- else
- {
- blcn_flg_stop[i] = true;
- }
- }
-
- //=========================================================================
- //---------------------------------pause计算-------------------------------
- //=========================================================================
- for(i = 0; i < cmnc_num_cellUNum; i++)
- {
- blcn_flg_pause[i] = false;
- }
- //=========================================================================
- //--------------------------------指令及实际均衡容量计算--------------------
- //=========================================================================
- for(i = 0; i < cmnc_num_cellUNum; i++)
- {
- if(blcn_flg_enable && !blcn_flg_pause[i] && ! blcn_flg_stop[i])
- {
- blcv_flg_excute[i] = true ;
- temp[i] = temp[i] + (real_T) (sfmv_V_cellU[i] * 0.001) / (real_T) (blcc_R_esr * 0.1);
- }
- else
- {
- blcv_flg_excute[i] = false ;
- }
- blcn_Q_impleCp[i] = (uint16_T) (temp[i] /3600 * 1000);
- blcv_Q_reqCpEo[i] = ((int16_T)(blcn_Q_reqCpNow[i] - blcn_Q_impleCp[i]) < 0 ? 0 :blcn_Q_reqCpNow[i] - blcn_Q_impleCp[i]);
- blcv_Q_totalCpEo[i] = (uint32_T) (blcn_Q_totalCpEE[i] + blcn_Q_impleCp[i]);
- }
- //
- blcd_flg_firstRun = false;
- memcpy(blcn_Q_reqCpEo_Delay,blcv_Q_reqCpEo, sizeof(blcn_Q_reqCpEE));
- }
|