|
@@ -1,6 +1,14 @@
|
|
|
+/*
|
|
|
+ * @Author : ChenJie
|
|
|
+ * @Date : 2021-12-06 17:12:12
|
|
|
+ * @Version : V3.0
|
|
|
+ * @LastEditors : ChenJie
|
|
|
+ * @LastEditTime : 2021-12-07 10:31:33
|
|
|
+ * @Description : file content
|
|
|
+ * @FilePath : \PLAT\project\ec616_0h00\apps\qx_app\src\EmbeddedCoder_src\SOR.c
|
|
|
+ */
|
|
|
#include "SOR.h"
|
|
|
|
|
|
-
|
|
|
boolean_T FirstRun_SOR;
|
|
|
|
|
|
void SOR_Init(void)
|
|
@@ -13,54 +21,53 @@ void SOR(void)
|
|
|
static uint16_T sorn_ohm_cellREE[cmnc_num_cellUNumMax];
|
|
|
static uint16_T sorn_ohm_cellREEArr[5][cmnc_num_cellUNumMax];
|
|
|
uint16_T sorn_ohm_cellRSum[cmnc_num_cellUNumMax];
|
|
|
- static uint16_T sorn_V_cellU[cmnc_num_cellUNumMax];
|
|
|
- static uint8_T sorn_num_ctn;
|
|
|
- static int16_T sorn_I_curr;
|
|
|
+ static uint16_T sorn_V_cellU[cmnc_num_cellUNumMax];
|
|
|
+ static uint8_T sorn_num_ctn;
|
|
|
+ static int16_T sorn_I_curr;
|
|
|
uint16_T i;
|
|
|
uint16_T j;
|
|
|
- socd_pct_battSoc = 600;
|
|
|
+ // socd_pct_battSoc = 600;
|
|
|
//
|
|
|
- if(FirstRun_SOR)
|
|
|
+ if (FirstRun_SOR)
|
|
|
{
|
|
|
sorn_num_ctn = 0;
|
|
|
sorn_I_curr = sfmd_I_curr;
|
|
|
- memcpy(sorn_V_cellU,sfmv_V_cellU, sizeof(sfmv_V_cellU));
|
|
|
+ memcpy(sorn_V_cellU, sfmv_V_cellU, sizeof(sfmv_V_cellU));
|
|
|
}
|
|
|
- if(FirstRun_SOR)
|
|
|
+ if (FirstRun_SOR)
|
|
|
{
|
|
|
- if(ArrMax((&(sorv_ohm_cellREi[0])) , cmnc_num_cellUNum) > 65000)
|
|
|
+ if (ArrMax((&(sorv_ohm_cellREi[0])), cmnc_num_cellUNum) > 65000)
|
|
|
{
|
|
|
- memset(sorn_ohm_cellREE,0, sizeof(sorn_ohm_cellREE));
|
|
|
+ memset(sorn_ohm_cellREE, 0, sizeof(sorn_ohm_cellREE));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- memcpy(sorn_ohm_cellREE,sorv_ohm_cellREi, sizeof(sorv_ohm_cellREi));
|
|
|
+ memcpy(sorn_ohm_cellREE, sorv_ohm_cellREi, sizeof(sorv_ohm_cellREi));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if(socd_pct_battSoc >= 550 && socd_pct_battSoc <= 700 && sorn_num_ctn < 5)
|
|
|
+ if (socd_pct_battSoc >= 0 && socd_pct_battSoc <= 1000 && sorn_num_ctn < 5)
|
|
|
{
|
|
|
- if(sfmd_I_curr - sorn_I_curr > 200 || sfmd_I_curr - sorn_I_curr < -200)
|
|
|
+ if (sfmd_I_curr - sorn_I_curr > 200 || sfmd_I_curr - sorn_I_curr < -200)
|
|
|
{
|
|
|
- for(i = 0;i < cmnc_num_cellUNum;i++)
|
|
|
+ for (i = 0; i < cmnc_num_cellUNum; i++)
|
|
|
{
|
|
|
- sorn_ohm_cellREEArr[sorn_num_ctn][i] = (uint16_T)( ((real_T)(sorn_V_cellU[i] - sfmv_V_cellU[i]) * 0.001) / ((real_T)(sorn_I_curr - sfmd_I_curr) * 0.1) * 1000000 );
|
|
|
+ sorn_ohm_cellREEArr[sorn_num_ctn][i] = (uint16_T)(((real_T)(sorn_V_cellU[i] - sfmv_V_cellU[i]) * 0.001) / ((real_T)(sorn_I_curr - sfmd_I_curr) * 0.1) * 1000000);
|
|
|
}
|
|
|
sorn_num_ctn = sorn_num_ctn + 1;
|
|
|
- memset(sorn_ohm_cellRSum,0, sizeof(sorn_ohm_cellRSum));
|
|
|
- for(i = 0;i < cmnc_num_cellUNum;i++)
|
|
|
+ memset(sorn_ohm_cellRSum, 0, sizeof(sorn_ohm_cellRSum));
|
|
|
+ for (i = 0; i < cmnc_num_cellUNum; i++)
|
|
|
{
|
|
|
- for(j = 0;j < sorn_num_ctn;j++)
|
|
|
+ for (j = 0; j < sorn_num_ctn; j++)
|
|
|
{
|
|
|
- sorn_ohm_cellRSum[i] = sorn_ohm_cellRSum[i] + sorn_ohm_cellREEArr[j][i];
|
|
|
+ sorn_ohm_cellRSum[i] = sorn_ohm_cellRSum[i] + sorn_ohm_cellREEArr[j][i];
|
|
|
}
|
|
|
- sorn_ohm_cellREE[i] = sorn_ohm_cellRSum[i]/sorn_num_ctn;
|
|
|
+ sorn_ohm_cellREE[i] = sorn_ohm_cellRSum[i] / sorn_num_ctn;
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
- memcpy(sorv_ohm_cellREo,sorn_ohm_cellREE, sizeof(sorn_ohm_cellREE));
|
|
|
- sorn_I_curr = sfmd_I_curr;
|
|
|
- memcpy(sorn_V_cellU,sfmv_V_cellU, sizeof(sfmv_V_cellU));
|
|
|
+ memcpy(sorv_ohm_cellREo, sorn_ohm_cellREE, sizeof(sorn_ohm_cellREE));
|
|
|
+ sorn_I_curr = sfmd_I_curr;
|
|
|
+ memcpy(sorn_V_cellU, sfmv_V_cellU, sizeof(sfmv_V_cellU));
|
|
|
FirstRun_SOR = false;
|
|
|
}
|