ZDBMS/output/GasGauge.lst

309 lines
14 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

C51 COMPILER V9.00 GASGAUGE 03/13/2023 18:09:38 PAGE 1
C51 COMPILER V9.00, COMPILATION OF MODULE GASGAUGE
OBJECT MODULE PLACED IN .\output\GasGauge.obj
COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE code_gasguage\GasGauge.c LARGE OPTIMIZE(7,SIZE) REGFILE(.\output\MCUCore
-_Load.ORC) BROWSE INTVECTOR(0X1000) INCDIR(.\header_app;.\header_drv;.\code_gasguage) DEBUG OBJECTEXTEND PRINT(.\output\
-GasGauge.lst) OBJECT(.\output\GasGauge.obj)
line level source
1 /********************************************************************************
2 Copyright (C), Sinowealth Electronic. Ltd.
3 Author: Sino
4 Version: V0.0
5 Date: 2020/05/30
6 History:
7 V0.0 2020/05/30 Preliminary
8 ********************************************************************************/
9 #include "Main.h"
10 #include "math.h"
11
12
13 //容量统计相关的变量
14 BOOL bDsgEndFlg;
15 BOOL bCHGEndFlg;
16 BOOL bRSOCSlow; //SOC调节速率减慢
17 BOOL bRSOCFast; //SOC调节速率加快
18
19 U16 idata uiRCCharge; //充电容量统计
20 U16 idata uiRCDischarge; //放电容量统计
21 U16 idata uiTempBK; //温度备份
22 U8 idata ucCycleGain; //根据放电次数调整容量百分比
23 U16 xdata uiDfFCC; //滤波前的FCC
24 U16 xdata uiDfRC; //滤波前RC
25 U16 xdata uiDfRSOC; //滤波前RSOC
26 U8 xdata ucDSGEndDelay;
27 U8 xdata ucCHGEndDelay;
28 U8 xdata ucDSGDelay1;
29 U8 xdata ucDSGDelay2;
30 U8 xdata ucRSOCCnt;
31 S32 xdata slCur;
32
33
34 /*************************************************************************************************
35 * 函数名: GasGaugeInit
36 * 参 数: 无
37 * 返回值: 无
38 * 描 述: 第一次上电根据电压初始化容量
39 *************************************************************************************************/
40 void GasGaugeInit(void)
41 {
42 1 U8 i;
43 1 U16 RSOCtemp = 100;
44 1
45 1 //变量初始化
46 1 bDsgEndFlg = 0;
47 1 uiRCCharge = 0;
48 1 uiRCDischarge = 0;
49 1 uiTempBK = 0;
50 1 ucCycleGain = 0;
51 1 uiDfFCC = 0;
52 1 uiDfRC = 0;
53 1 uiDfRSOC = 0;
C51 COMPILER V9.00 GASGAUGE 03/13/2023 18:09:38 PAGE 2
54 1 ucDSGEndDelay = 0;
55 1 ucCHGEndDelay = 0;
56 1 ucDSGDelay1 = 0;
57 1 ucDSGDelay2 = 0;
58 1 bRSOCSlow = 0;
59 1 bRSOCFast = 0;
60 1 //容量初始化
61 1 for(i=0; i<10; i++) //Prejudge capacity according to initial voltage
62 1 {
63 2 if(uiCellVmax < E2uiVOC[i])
64 2 {
65 3 if(i == 0)
66 3 {
67 4 if((uiCellVmax<E2uiDsgEndVol)||bUV)
68 4 {
69 5 RSOCtemp =0;
70 5 }
71 4 else
72 4 {
73 5 RSOCtemp = (U32)(uiCellVmax-E2uiDsgEndVol)*10/(E2uiVOC[0]-E2uiDsgEndVol);
74 5 }
75 4 break;
76 4 }
77 3 else
78 3 {
79 4 RSOCtemp = 10*i + (U32)(uiCellVmax-E2uiVOC[i-1])*10/(E2uiVOC[i]-E2uiVOC[i-1]);
80 4 break;
81 4 }
82 3 }
83 2 }
84 1
85 1 if(uiCellVmax >= E2uiVOC[7]) //防止充满电后再断电上电RSOC会改变
86 1 {
87 2 RSOCtemp = 100;
88 2 }
89 1
90 1 if(RSOCtemp>E2ucSOC)
91 1 {
92 2 RSOCtemp = E2ucSOC;
93 2 }
94 1 else
95 1 {
96 2 if((E2ucSOC-RSOCtemp) > INTSOCDIF)
97 2 {
98 3 E2ucSOC = RSOCtemp;
99 3 }
100 2 else
101 2 {
102 3 RSOCtemp = E2ucSOC;
103 3 }
104 2 }
105 1
106 1 Info.uiRSOC = RSOCtemp;
107 1 Info.ulFCC = E2ulLastFCC;
108 1 Info.ulRC = (U32)Info.ulFCC*Info.uiRSOC/100;
109 1
110 1 uiDfFCC = Info.ulFCC; //uiDfFCC/uiDfRC/uiDfRSOC为滤波前的参数<E695B0>
-跏蓟<E8B78F>辈⒚挥新瞬<E696B0>
111 1 uiDfRC = Info.ulRC;
112 1 uiDfRSOC = Info.uiRSOC *10;
113 1
114 1 if(E2uiCycleCount>CYCLECOUNTC) //根据循环次数调整FCC修调系数
C51 COMPILER V9.00 GASGAUGE 03/13/2023 18:09:38 PAGE 3
115 1 {
116 2 ucCycleGain=75;
117 2 }
118 1 else if(E2uiCycleCount>CYCLECOUNTB)
119 1 {
120 2 ucCycleGain=95 - E2uiCycleCount/5;
121 2 }
122 1 else if(E2uiCycleCount>CYCLECOUNTA)
123 1 {
124 2 ucCycleGain=105 - E2uiCycleCount/10;
125 2 }
126 1 else
127 1 {
128 2 ucCycleGain=100;
129 2 }
130 1
131 1 uiTempBK = 0; //保证放电就计算一次FCC
132 1 ucDSGEndDelay = 0;
133 1 ucDSGDelay1 = 0;
134 1 ucDSGDelay2 = 0;
135 1 bDsgEndFlg = 0;
136 1 ucCHGEndDelay = 0;
137 1 }
138
139
140 /*************************************************************************************************
141 * 函数名: GasGaugeManage
142 * 参 数: 无
143 * 返回值: 无
144 * 描 述: 根据充放电状态统计容量
145 *************************************************************************************************/
146 void GasGaugeManage(void)
147 {
148 1 U16 xdata chgdffcc = 0;
149 1
150 1 slCur=0;
151 1
152 1 if(Info.slCurr > E2siDfilterCur) //充电过程中电量计算
153 1 {
154 2 ucDSGEndDelay = 0;
155 2 ucDSGDelay1 = 0;
156 2 ucDSGDelay2 = 0;
157 2 bDsgEndFlg = 0;
158 2
159 2 chgdffcc = E2ulChgFCC*ucCycleGain/100; //充电过程FCC一直保持不改变
160 2
161 2 if(chgdffcc != uiDfFCC) //满充容量
162 2 {
163 3 uiDfRC = (U16)(chgdffcc*Info.uiRSOC/100);
164 3 IrqUartDis();
165 3 Info.ulRC = uiDfRC;
166 3 IrqUartEn();
167 3 }
168 2 uiDfFCC = chgdffcc;
169 2
170 2 uiRCCharge += slCadcCurAverage; //每1S计算一次电量每次加上电流值即计算每
-1S的电量mAS
171 2 while(uiRCCharge >= mAhVALUE) //当累加电量超过3600mAS即等于1mAh
172 2 {
173 3 uiRCCharge -= mAhVALUE;
174 3 if(uiDfRC < uiDfFCC)
175 3 {
C51 COMPILER V9.00 GASGAUGE 03/13/2023 18:09:38 PAGE 4
176 4 uiDfRC++; //剩余容量增加1mAh
177 4 }
178 3 else
179 3 {
180 4 uiDfRC = uiDfFCC; //当剩余容量等于满充容量,容量不再增加
181 4 uiRCCharge = 0;
182 4 }
183 3 }
184 2
185 2 if(uiDfRC < uiDfFCC)
186 2 {
187 3 uiDfRSOC = (U32)uiDfRC*1000/uiDfFCC;
188 3 }
189 2 else
190 2 {
191 3 uiDfRSOC = 1000;
192 3 }
193 2
194 2 if(slCadcCurAverage < E2siChgEndCurr) //充电截止判断,如果此时的电流小于充电截止
-电流
195 2 {
196 3 if(uiCellVmax>E2uiChgEndVol) //此时的单节最大电压大于充电截止电压
197 3 {
198 4 if(++ucCHGEndDelay>=E2ucChgEndDelay)
199 4 {
200 5 ucCHGEndDelay = E2ucChgEndDelay;
201 5 bCHGEndFlg = 1;
202 5 }
203 4 }
204 3 }
205 2
206 2 CorrectCHGSOC(); //根据EEPROM中的电压点修正充电过程中的SO
-C,同时需要调整uiDfRC
207 2
208 2 }
209 1 else if(Info.slCurr < -E2siDfilterCur) //放电过程中计算电量
210 1 {
211 2 ucCHGEndDelay = 0;
212 2 bCHGEndFlg = 0;
213 2
214 2 slCur = slCadcCurAverage /*+ slAdcCur2*/; //放电过程中同时计算主回路及辅控回路的电量
215 2 if(slCur<0)
216 2 {
217 3 uiRCDischarge -= slCur;
218 3 }
219 2 if(uiRCDischarge >= mAhVALUE)
220 2 {
221 3 while(uiRCDischarge >= mAhVALUE) //累加的放电电量大于3600mAS后同样剩余电量减1mAh
222 3 {
223 4 uiRCDischarge -= mAhVALUE;
224 4 E2ulCycleThresholdCount++; //累计
225 4 if(uiDfRC > 1)
226 4 {
227 5 uiDfRC --;
228 5 }
229 4 }
230 3 if(E2ulCycleThresholdCount >= E2ulCycleThreshold) //cyclecount
231 3 {
232 4 E2ulCycleThresholdCount -= E2ulCycleThreshold;
233 4 E2uiCycleCount++;
234 4 }
235 3 }
C51 COMPILER V9.00 GASGAUGE 03/13/2023 18:09:38 PAGE 5
236 2
237 2 CorrectDSGSOC();
238 2 }
239 1
240 1 if(bOV) //Charge end
241 1 {
242 2 IrqUartDis();
243 2 uiDfRC = uiDfFCC;
244 2 Info.ulRC = uiDfRC;
245 2 Info.ulFCC = Info.ulRC;
246 2 Info.uiRSOC = 100;
247 2 IrqUartEn();
248 2 }
249 1
250 1 if(uiDfRC>uiDfFCC)
251 1 {
252 2 uiDfRC = uiDfFCC;
253 2 }
254 1 else if(uiDfRC <(uiDfFCC*2/100))
255 1 {
256 2 uiDfRC = uiDfFCC*2/100;
257 2 }
258 1 uiDfRSOC=(U32)uiDfRC*1000/uiDfFCC;
259 1
260 1 DataFilter();
261 1
262 1 IrqUartDis();
263 1 E2ucSOC = Info.uiRSOC;
264 1 E2ulLastFCC = Info.ulFCC;
265 1 Info.uiCycleCount = E2uiCycleCount;
266 1 IrqUartEn();
267 1 }
268
269
270
271
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1410 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 15 3
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = 7 ----
BIT SIZE = 4 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)