SOE.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "SOE.h"
  2. void SOE_Init(void)
  3. {
  4. soed_flg_firstRun = true;
  5. }
  6. //-------------------------------------------------------------------------
  7. void SOE(void)
  8. {
  9. uint32_T soen_V_battOcv;
  10. uint16_T i;
  11. // 满电能量
  12. if(soed_flg_firstRun)
  13. {
  14. soen_V_battOcv = 0;
  15. for(i = socc_pct_battSocUp ;i >= socc_pct_battSocLow + 1;i--)
  16. {
  17. soen_V_battOcv = soen_V_battOcv + look1_u16tu16(i, cmnm_pct_soc, cmnm_V_ocv, 13) * cmnc_num_cellUNum;
  18. }
  19. soed_E_fullEng = (uint16_T) ( (real_T)(soen_V_battOcv * 0.001) * (real_T)(cmnc_Q_ratedCp * 0.1) * (real_T)(sohd_pct_bcuSoh * 0.1 * 0.01)/1000);
  20. }
  21. //当前SOC的剩余能量
  22. if(socd_pct_battSoc > socc_pct_battSocLow)
  23. {
  24. soen_V_battOcv = 0;
  25. for(i = socd_pct_battSoc;i >= socc_pct_battSocLow + 1;i--)
  26. {
  27. soen_V_battOcv = soen_V_battOcv + look1_u16tu16(i, cmnm_pct_soc, cmnm_V_ocv, 13) * cmnc_num_cellUNum;
  28. }
  29. soed_E_nowEng = (uint16_T) ( (real_T)(soen_V_battOcv * 0.001) * (real_T)(cmnc_Q_ratedCp * 0.1) * (real_T)(sohd_pct_bcuSoh * 0.1 * 0.01) /1000);
  30. }
  31. else
  32. {
  33. soed_E_nowEng = 0;
  34. }
  35. soed_pct_nowStat = (uint16_T)((uint32_T)(soed_E_nowEng * 1000)/soed_E_fullEng);
  36. soed_flg_firstRun = false;
  37. }