123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- #include "ISC.h"
- void ISC_Init(void)
- {
- iscd_flg_firstRun = true;
- }
- //-------------------------------------------------------------------------
- void ISC(void)
- {
- uint16_T i;
- static uint32_T iscd_tm_totalEE;
- static uint16_T iscv_Q_remainCpEE[cmnc_num_cellUNumMax];
- uint16_T iscn_pct_cellSoc1[cmnc_num_cellUNumMax];
- uint16_T iscn_pct_cellSoc2[cmnc_num_cellUNumMax];
- int16_T iscn_Q_deltAh[cmnc_num_cellUNumMax];
- uint16_T iscn_Q_cellAh[cmnc_num_cellUNumMax];
- static uint16_T iscn_Q_cellAh0[cmnc_num_cellUNumMax];
- static boolean_T iscd_flg_timedWakeUpFlt;
- static boolean_T iscd_flg_disChrgFlt;
- static uint16_T TimeCtn;
- static uint16_T RunCtn;
- static uint16_T iscn_num_fltNr[cmnc_num_cellUNumMax];
- static boolean_T iscd_flg_fulStat;
- //初值
- if (iscd_flg_firstRun)
- {
- iscd_flg_timedWakeUpFlt = false;
- iscd_flg_disChrgFlt = false;
- memset(iscn_Q_cellAh0, 0, sizeof(iscn_Q_cellAh0));
- memset(iscn_pct_cellSoc1, 0, sizeof(iscn_pct_cellSoc1));
- memset(iscn_pct_cellSoc2, 0, sizeof(iscn_pct_cellSoc2));
- memset(iscn_Q_cellAh, 0, sizeof(iscn_Q_cellAh));
- memset(iscn_Q_deltAh, 0, sizeof(iscn_Q_deltAh));
- memset(iscn_num_fltNr, 0, sizeof(iscn_num_fltNr));
- TimeCtn = 0;
- RunCtn = 0;
- }
- //=====================================================================
- //================高端SOC点诊断=================================== 0.1A
- //=====================================================================
- RunCtn = (RunCtn + 1) > 60000 ? 60000 : (RunCtn + 1);
- if (iscd_flg_firstRun)
- {
- //
- if (ArrMax(iscv_Q_remainCpEi, cmnc_num_cellUNum) > cmnc_Q_ratedCp)
- {
- memset(iscv_Q_remainCpEE, 0, sizeof(iscv_Q_remainCpEi));
- iscd_tm_totalEE = 0;
- }
- else
- {
- memcpy(iscv_Q_remainCpEE, iscv_Q_remainCpEi, sizeof(iscv_Q_remainCpEi));
- iscd_tm_totalEE = iscd_tm_totalEi;
- }
- //
- 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)
- {
- for (i = 0; i < cmnc_num_cellUNum; i++)
- {
- iscn_pct_cellSoc1[i] = look1_u16tu16(sfmv_V_cellU[i], cmnm_V_ocv, cmnm_pct_soc, 13);
- iscn_Q_cellAh[i] = (uint16_T)((uint16_T)((uint32_T)iscn_pct_cellSoc1[i] * sohv_Q_cellCap[i] / 2000U) << 1);
- iscn_Q_deltAh[i] = (int16_T)(iscn_Q_cellAh[i] - iscv_Q_remainCpEE[i]);
- }
- for (i = 0; i < cmnc_num_cellUNum; i++)
- {
- 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)
- {
- iscd_flg_fulStat = true && iscd_tm_totalEE != 0;
- }
- }
- memcpy(iscv_Q_remainCpEo, iscn_Q_cellAh, sizeof(iscn_Q_cellAh));
- iscd_tm_totalEE = 0;
- }
- else
- {
- memcpy(iscv_Q_remainCpEo, iscv_Q_remainCpEi, sizeof(iscv_Q_remainCpEi));
- iscd_tm_totalEE = iscd_tm_totalEE + ihd_tm_parkTime;
- }
- }
- if (iscv_Q_remainCpEo[0] != 0)
- {
- iscd_tm_totalEo = iscd_tm_totalEE + RunCtn;
- }
- //=====================================================================
- //================定时唤醒诊断======================================1A
- //=====================================================================
- if (appd_st_preCyc == 1 && ihd_tm_parkTime >= cmnc_tm_parkTime && sfmd_I_curr < 10 && sfmd_I_curr > -10 && iscd_flg_firstRun)
- {
- for (i = 0; i < cmnc_num_cellUNum; i++)
- {
- iscn_pct_cellSoc1[i] = look1_u16tu16(appv_V_cellU[i], cmnm_V_ocv, cmnm_pct_soc, 13);
- iscn_pct_cellSoc2[i] = look1_u16tu16(sfmv_V_cellU[i], cmnm_V_ocv, cmnm_pct_soc, 13);
- 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);
- }
- for (i = 0; i < cmnc_num_cellUNum; i++)
- {
- if (ArrMean(iscn_Q_deltAh, cmnc_num_cellUNum) - iscn_Q_deltAh[i] > 10)
- {
- iscd_flg_timedWakeUpFlt = false;
- }
- }
- }
- //=====================================================================
- //================放电过程中诊断=================================== 2A
- //=====================================================================
- if (!pimd_flg_inval)
- {
- TimeCtn = TimeCtn + 1;
- for (i = 0; i < cmnc_num_cellUNum; i++)
- {
- iscn_Q_cellAh[i] = (uint16_T)((uint32_T)(pimv_pct_cellSoc[i] * sohv_Q_cellCap[i]) / 1000);
- }
- if (TimeCtn == 60)
- {
- memcpy(iscn_Q_cellAh0, iscn_Q_cellAh, sizeof(iscn_Q_cellAh));
- }
- if (TimeCtn > 60 + 360)
- {
- for (i = 0; i < cmnc_num_cellUNum; i++)
- {
- iscn_Q_deltAh[i] = (int16_T)(iscn_Q_cellAh[i] - iscn_Q_cellAh0[i]);
- }
- for (i = 0; i < cmnc_num_cellUNum; i++)
- {
- if ((real_T)(ArrMean(iscn_Q_deltAh, cmnc_num_cellUNum) - iscn_Q_deltAh[i]) * 0.1 / (TimeCtn - 60) * 3600 > 2)
- {
- iscn_num_fltNr[i] = (iscn_num_fltNr[i] + 1) > 60000 ? 60000 : (iscn_num_fltNr[i] + 1);
- }
- else
- {
- iscn_num_fltNr[i] = 0;
- }
- if (iscn_num_fltNr[i] > 600)
- {
- iscd_flg_disChrgFlt = true;
- }
- }
- }
- if (TimeCtn > 3600)
- {
- TimeCtn = 60;
- }
- }
- else
- {
- TimeCtn = 0;
- }
- /////
- iscd_flg_flt[0] = iscd_flg_disChrgFlt;
- iscd_flg_flt[1] = iscd_flg_timedWakeUpFlt;
- iscd_flg_flt[2] = iscd_flg_fulStat;
- iscd_flg_firstRun = false;
- }
|