|
@@ -1,6 +1,5 @@
|
|
|
#include "CDM.h"
|
|
|
|
|
|
-
|
|
|
static boolean_T FirstRun_CDM;
|
|
|
|
|
|
void CDM_Init(void)
|
|
@@ -8,7 +7,6 @@ void CDM_Init(void)
|
|
|
FirstRun_CDM = true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
void CDM(void)
|
|
|
{
|
|
|
real_T cmdn_V_cellUDelt[cmnc_num_cellUNumMax];
|
|
@@ -16,107 +14,104 @@ void CDM(void)
|
|
|
static real_T P[4][cmnc_num_cellUNumMax];
|
|
|
static real_T deltaE[cmnc_num_cellUNumMax];
|
|
|
static real_T deltaR[cmnc_num_cellUNumMax];
|
|
|
- static real_T deltaES[cmnc_num_cellUNumMax];
|
|
|
+ static real_T deltaES[cmnc_num_cellUNumMax];
|
|
|
static real_T deltaRS[cmnc_num_cellUNumMax];
|
|
|
static real_T Lambda;
|
|
|
real_T K[2];
|
|
|
real_T arf[cmnc_num_cellUNumMax];
|
|
|
uint16_T i;
|
|
|
static uint8_T ihd_st_workStat_Delay;
|
|
|
- static int16_T sfmd_I_curr_Delay;
|
|
|
- static uint8_T Cnt;
|
|
|
-
|
|
|
+ static int16_T sfmd_I_curr_Delay;
|
|
|
+ static uint8_T Cnt;
|
|
|
+
|
|
|
//
|
|
|
- if(ihd_st_workStat_Delay == 2 && ihd_st_workStat != 2)
|
|
|
+ if (ihd_st_workStat_Delay == 2 && ihd_st_workStat != 2)
|
|
|
{
|
|
|
FirstRun_CDM = true;
|
|
|
}
|
|
|
ihd_st_workStat_Delay = ihd_st_workStat;
|
|
|
- //
|
|
|
+ //
|
|
|
if (FirstRun_CDM)
|
|
|
{
|
|
|
- for (i = 0;i < cmnc_num_cellUNum;i++)
|
|
|
+ for (i = 0; i < cmnc_num_cellUNum; i++)
|
|
|
{
|
|
|
P[0][i] = 10;
|
|
|
P[1][i] = 0;
|
|
|
P[2][i] = 0;
|
|
|
P[3][i] = 10;
|
|
|
Lambda = 0.991;
|
|
|
- deltaE[i] = 0;
|
|
|
- deltaR[i] = 0;
|
|
|
- deltaES[i] = 0;
|
|
|
+ deltaE[i] = 0;
|
|
|
+ deltaR[i] = 0;
|
|
|
+ deltaES[i] = 0;
|
|
|
deltaRS[i] = 0;
|
|
|
- Cnt = 0;
|
|
|
- test_curr =0;
|
|
|
- test_U=5000;
|
|
|
+ Cnt = 0;
|
|
|
+ test_curr = 0;
|
|
|
+ test_U = 5000;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
- if(ihd_st_workStat != 2 && (sfmd_I_curr_Delay - sfmd_I_curr > 10 ||sfmd_I_curr_Delay - sfmd_I_curr < -10 ||sfmd_I_curr_Delay ==0 && sfmd_I_curr == 0))
|
|
|
+ if (ihd_st_workStat != 2 && (sfmd_I_curr_Delay - sfmd_I_curr > 10 || sfmd_I_curr_Delay - sfmd_I_curr < -10 || sfmd_I_curr_Delay == 0 && sfmd_I_curr == 0))
|
|
|
{
|
|
|
- for (i = 0;i < cmnc_num_cellUNum;i++)
|
|
|
+ for (i = 0; i < cmnc_num_cellUNum; i++)
|
|
|
{
|
|
|
- cmdn_V_cellUDelt[i] = (real_T)(sfmv_V_cellU[i] - sfmd_V_cellUAvrg) * 0.001;
|
|
|
+ cmdn_V_cellUDelt[i] = (real_T)(sfmv_V_cellU[i] - sfmd_V_cellUAvrg) * 0.001;
|
|
|
}
|
|
|
- cdmn_I_curr = (real_T) sfmd_I_curr * 0.1;
|
|
|
+ cdmn_I_curr = (real_T)sfmd_I_curr * 0.1;
|
|
|
//
|
|
|
cdmd_flg_deltOCVDisable = false;
|
|
|
- for (i = 0;i < cmnc_num_cellUNum;i++)
|
|
|
+ for (i = 0; i < cmnc_num_cellUNum; i++)
|
|
|
{
|
|
|
- K[0] = (P[0][i] + cdmn_I_curr * P[1][i])/(Lambda + P[0][i] + cdmn_I_curr * P[2][i] + ( P[1][i] + cdmn_I_curr * P[3][i]) * cdmn_I_curr);
|
|
|
- K[1] = (P[2][i] + cdmn_I_curr * P[3][i])/(Lambda + P[0][i] + cdmn_I_curr * P[2][i] + ( P[1][i] + cdmn_I_curr * P[3][i]) * cdmn_I_curr);
|
|
|
+ K[0] = (P[0][i] + cdmn_I_curr * P[1][i]) / (Lambda + P[0][i] + cdmn_I_curr * P[2][i] + (P[1][i] + cdmn_I_curr * P[3][i]) * cdmn_I_curr);
|
|
|
+ K[1] = (P[2][i] + cdmn_I_curr * P[3][i]) / (Lambda + P[0][i] + cdmn_I_curr * P[2][i] + (P[1][i] + cdmn_I_curr * P[3][i]) * cdmn_I_curr);
|
|
|
arf[i] = cmdn_V_cellUDelt[i] - (deltaE[i] + cdmn_I_curr * deltaR[i]);
|
|
|
deltaE[i] = deltaE[i] + K[0] * arf[i];
|
|
|
deltaR[i] = deltaR[i] + K[1] * arf[i];
|
|
|
- P[0][i] = ((1 -K[0])* P[0][i] -P[2][i] * K[0] * cdmn_I_curr) /Lambda;
|
|
|
- P[1][i] = ((1 -K[0])* P[1][i] -P[3][i] * K[0] * cdmn_I_curr) /Lambda;
|
|
|
- P[2][i] = (-K[1] *P[0][i] +P[2][i] * (1 - K[1] * cdmn_I_curr))/Lambda;
|
|
|
- P[3][i] = (-K[1] *P[1][i] +P[3][i] * (1 - K[1] * cdmn_I_curr))/Lambda;
|
|
|
-
|
|
|
- if(arf[i] > 0.04 || arf[i] < -0.04)
|
|
|
+ P[0][i] = ((1 - K[0]) * P[0][i] - P[2][i] * K[0] * cdmn_I_curr) / Lambda;
|
|
|
+ P[1][i] = ((1 - K[0]) * P[1][i] - P[3][i] * K[0] * cdmn_I_curr) / Lambda;
|
|
|
+ P[2][i] = (-K[1] * P[0][i] + P[2][i] * (1 - K[1] * cdmn_I_curr)) / Lambda;
|
|
|
+ P[3][i] = (-K[1] * P[1][i] + P[3][i] * (1 - K[1] * cdmn_I_curr)) / Lambda;
|
|
|
+
|
|
|
+ if (arf[i] > 0.04 || arf[i] < -0.04)
|
|
|
{
|
|
|
- cdmd_flg_deltOCVDisable = true;
|
|
|
+ cdmd_flg_deltOCVDisable = true;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
//
|
|
|
- Cnt = Cnt + 1;
|
|
|
+ Cnt = Cnt + 1;
|
|
|
|
|
|
- for (i = 0;i < cmnc_num_cellUNum;i++)
|
|
|
- {
|
|
|
+ for (i = 0; i < cmnc_num_cellUNum; i++)
|
|
|
+ {
|
|
|
deltaES[i] = deltaES[i] + deltaE[i];
|
|
|
- deltaRS[i] = deltaRS[i] + deltaR[i];
|
|
|
+ deltaRS[i] = deltaRS[i] + deltaR[i];
|
|
|
}
|
|
|
|
|
|
- if (Cnt >= 10)
|
|
|
- {
|
|
|
- for (i = 0;i < cmnc_num_cellUNum;i++)
|
|
|
- {
|
|
|
- cdmv_V_deltOCV[i] = (int16_T) (deltaES[i]/Cnt * 1000);
|
|
|
- cdmv_ohm_deltR[i] = (int16_T) (deltaRS[i]/Cnt * 1000 * 1000);
|
|
|
- deltaES[i] = 0;
|
|
|
- deltaRS[i] = 0;
|
|
|
+ if (Cnt >= 10)
|
|
|
+ {
|
|
|
+ for (i = 0; i < cmnc_num_cellUNum; i++)
|
|
|
+ {
|
|
|
+ cdmv_V_deltOCV[i] = (int16_T)(deltaES[i] / Cnt * 1000);
|
|
|
+ cdmv_ohm_deltR[i] = (int16_T)(deltaRS[i] / Cnt * 1000 * 1000);
|
|
|
+ deltaES[i] = 0;
|
|
|
+ deltaRS[i] = 0;
|
|
|
|
|
|
- if(deltaR[i] > 5000 &&test_U==5000)
|
|
|
- {
|
|
|
+ if (deltaR[i] > 5000 && test_U == 5000)
|
|
|
+ {
|
|
|
test_curr = ihd_I_curr;
|
|
|
- test_U =ihv_V_cellU[i];
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- Cnt = 0;
|
|
|
- }
|
|
|
+ test_U = ihv_V_cellU[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Cnt = 0;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
cdmd_flg_deltOCVDisable = true;
|
|
|
}
|
|
|
- //printf("u_:%f %f %f\n",arf[0],arf[1],arf[2]);
|
|
|
- //printf("E_:%d %d %d\n",cdmv_V_deltOCV[0],cdmv_V_deltOCV[1],cdmv_V_deltOCV[2]);
|
|
|
- //printf("R_:%d %d %d\n",cdmv_ohm_deltR[0],cdmv_ohm_deltR[1],cdmv_ohm_deltR[2]);
|
|
|
- //printf("\n");
|
|
|
- cdmd_flg_deltOCVDisable = true; ////////
|
|
|
- sfmd_I_curr_Delay = sfmd_I_curr;
|
|
|
+ //printf("u_:%f %f %f\n",arf[0],arf[1],arf[2]);
|
|
|
+ //printf("E_:%d %d %d\n",cdmv_V_deltOCV[0],cdmv_V_deltOCV[1],cdmv_V_deltOCV[2]);
|
|
|
+ //printf("R_:%d %d %d\n",cdmv_ohm_deltR[0],cdmv_ohm_deltR[1],cdmv_ohm_deltR[2]);
|
|
|
+ //printf("\n");
|
|
|
+ cdmd_flg_deltOCVDisable = true; ////////
|
|
|
+ sfmd_I_curr_Delay = sfmd_I_curr;
|
|
|
FirstRun_CDM = false;
|
|
|
-
|
|
|
}
|