ISC.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #include "ISC.h"
  2. void ISC_Init(void)
  3. {
  4. iscd_flg_firstRun = true;
  5. }
  6. //-------------------------------------------------------------------------
  7. void ISC(void)
  8. {
  9. uint16_T i;
  10. static uint32_T iscd_tm_totalEE;
  11. static uint16_T iscv_Q_remainCpEE[cmnc_num_cellUNumMax];
  12. uint16_T iscn_pct_cellSoc1[cmnc_num_cellUNumMax];
  13. uint16_T iscn_pct_cellSoc2[cmnc_num_cellUNumMax];
  14. int16_T iscn_Q_deltAh[cmnc_num_cellUNumMax];
  15. uint16_T iscn_Q_cellAh[cmnc_num_cellUNumMax];
  16. static uint16_T iscn_Q_cellAh0[cmnc_num_cellUNumMax];
  17. static boolean_T iscd_flg_timedWakeUpFlt;
  18. static boolean_T iscd_flg_disChrgFlt;
  19. static uint16_T TimeCtn;
  20. static uint16_T RunCtn;
  21. static uint16_T iscn_num_fltNr[cmnc_num_cellUNumMax];
  22. static boolean_T iscd_flg_fulStat;
  23. //初值
  24. if (iscd_flg_firstRun)
  25. {
  26. iscd_flg_timedWakeUpFlt = false;
  27. iscd_flg_disChrgFlt = false;
  28. memset(iscn_Q_cellAh0, 0, sizeof(iscn_Q_cellAh0));
  29. memset(iscn_pct_cellSoc1, 0, sizeof(iscn_pct_cellSoc1));
  30. memset(iscn_pct_cellSoc2, 0, sizeof(iscn_pct_cellSoc2));
  31. memset(iscn_Q_cellAh, 0, sizeof(iscn_Q_cellAh));
  32. memset(iscn_Q_deltAh, 0, sizeof(iscn_Q_deltAh));
  33. memset(iscn_num_fltNr, 0, sizeof(iscn_num_fltNr));
  34. TimeCtn = 0;
  35. RunCtn = 0;
  36. }
  37. //=====================================================================
  38. //================高端SOC点诊断=================================== 0.1A
  39. //=====================================================================
  40. RunCtn = (RunCtn + 1) > 60000 ? 60000 : (RunCtn + 1);
  41. if (iscd_flg_firstRun)
  42. {
  43. //
  44. if (ArrMax(iscv_Q_remainCpEi, cmnc_num_cellUNum) > cmnc_Q_ratedCp)
  45. {
  46. memset(iscv_Q_remainCpEE, 0, sizeof(iscv_Q_remainCpEi));
  47. iscd_tm_totalEE = 0;
  48. }
  49. else
  50. {
  51. memcpy(iscv_Q_remainCpEE, iscv_Q_remainCpEi, sizeof(iscv_Q_remainCpEi));
  52. iscd_tm_totalEE = iscd_tm_totalEi;
  53. }
  54. //
  55. if ((iscd_tm_totalEE + ihd_tm_parkTime >= 20 * 3600 || iscd_tm_totalEE == 0) && ihd_tm_parkTime >= cmnc_tm_parkTime && socd_pct_battSoc > 900 && sfmd_I_curr > -10 && sfmd_I_curr < 10)
  56. {
  57. for (i = 0; i < cmnc_num_cellUNum; i++)
  58. {
  59. iscn_pct_cellSoc1[i] = look1_u16tu16(sfmv_V_cellU[i], cmnm_V_ocv, cmnm_pct_soc, 13);
  60. iscn_Q_cellAh[i] = (uint16_T)((uint16_T)((uint32_T)iscn_pct_cellSoc1[i] * sohv_Q_cellCap[i] / 2000U) << 1);
  61. iscn_Q_deltAh[i] = (int16_T)(iscn_Q_cellAh[i] - iscv_Q_remainCpEE[i]);
  62. }
  63. for (i = 0; i < cmnc_num_cellUNum; i++)
  64. {
  65. if ((real_T)(ArrMean(iscn_Q_deltAh, cmnc_num_cellUNum) - iscn_Q_deltAh[i]) * 0.1 / (iscd_tm_totalEE + ihd_tm_parkTime) * 3600 > 0.1)
  66. {
  67. iscd_flg_fulStat = true && iscd_tm_totalEE != 0;
  68. }
  69. }
  70. memcpy(iscv_Q_remainCpEo, iscn_Q_cellAh, sizeof(iscn_Q_cellAh));
  71. iscd_tm_totalEE = 0;
  72. }
  73. else
  74. {
  75. memcpy(iscv_Q_remainCpEo, iscv_Q_remainCpEi, sizeof(iscv_Q_remainCpEi));
  76. iscd_tm_totalEE = iscd_tm_totalEE + ihd_tm_parkTime;
  77. }
  78. }
  79. if (iscv_Q_remainCpEo[0] != 0)
  80. {
  81. iscd_tm_totalEo = iscd_tm_totalEE + RunCtn;
  82. }
  83. //=====================================================================
  84. //================定时唤醒诊断======================================1A
  85. //=====================================================================
  86. if (appd_st_preCyc == 1 && ihd_tm_parkTime >= cmnc_tm_parkTime && sfmd_I_curr < 10 && sfmd_I_curr > -10 && iscd_flg_firstRun)
  87. {
  88. for (i = 0; i < cmnc_num_cellUNum; i++)
  89. {
  90. iscn_pct_cellSoc1[i] = look1_u16tu16(appv_V_cellU[i], cmnm_V_ocv, cmnm_pct_soc, 13);
  91. iscn_pct_cellSoc2[i] = look1_u16tu16(sfmv_V_cellU[i], cmnm_V_ocv, cmnm_pct_soc, 13);
  92. iscn_Q_deltAh[i] = (int16_T)((uint16_T)((uint32_T)iscn_pct_cellSoc2[i] * sohv_Q_cellCap[i] / 2000U) << 1) - (int16_T)((uint16_T)((uint32_T)iscn_pct_cellSoc1[i] * sohv_Q_cellCap[i] / 2000U) << 1);
  93. }
  94. for (i = 0; i < cmnc_num_cellUNum; i++)
  95. {
  96. if (ArrMean(iscn_Q_deltAh, cmnc_num_cellUNum) - iscn_Q_deltAh[i] > 10)
  97. {
  98. iscd_flg_timedWakeUpFlt = false;
  99. }
  100. }
  101. }
  102. //=====================================================================
  103. //================放电过程中诊断=================================== 2A
  104. //=====================================================================
  105. if (!pimd_flg_inval)
  106. {
  107. TimeCtn = TimeCtn + 1;
  108. for (i = 0; i < cmnc_num_cellUNum; i++)
  109. {
  110. iscn_Q_cellAh[i] = (uint16_T)((uint32_T)(pimv_pct_cellSoc[i] * sohv_Q_cellCap[i]) / 1000);
  111. }
  112. if (TimeCtn == 60)
  113. {
  114. memcpy(iscn_Q_cellAh0, iscn_Q_cellAh, sizeof(iscn_Q_cellAh));
  115. }
  116. if (TimeCtn > 60 + 360)
  117. {
  118. for (i = 0; i < cmnc_num_cellUNum; i++)
  119. {
  120. iscn_Q_deltAh[i] = (int16_T)(iscn_Q_cellAh[i] - iscn_Q_cellAh0[i]);
  121. }
  122. for (i = 0; i < cmnc_num_cellUNum; i++)
  123. {
  124. if ((real_T)(ArrMean(iscn_Q_deltAh, cmnc_num_cellUNum) - iscn_Q_deltAh[i]) * 0.1 / (TimeCtn - 60) * 3600 > 2)
  125. {
  126. iscn_num_fltNr[i] = (iscn_num_fltNr[i] + 1) > 60000 ? 60000 : (iscn_num_fltNr[i] + 1);
  127. }
  128. else
  129. {
  130. iscn_num_fltNr[i] = 0;
  131. }
  132. if (iscn_num_fltNr[i] > 600)
  133. {
  134. iscd_flg_disChrgFlt = true;
  135. }
  136. }
  137. }
  138. if (TimeCtn > 3600)
  139. {
  140. TimeCtn = 60;
  141. }
  142. }
  143. else
  144. {
  145. TimeCtn = 0;
  146. }
  147. /////
  148. iscd_flg_flt[0] = iscd_flg_disChrgFlt;
  149. iscd_flg_flt[1] = iscd_flg_timedWakeUpFlt;
  150. iscd_flg_flt[2] = iscd_flg_fulStat;
  151. iscd_flg_firstRun = false;
  152. }