📄 control.lst
字号:
209 #define boostvolatage sys[0]
210 #define booststart sys[1]
211 #define floatstop sys[2]
212 #define floatstart sys[3]
213 #define moterstart sys[4]
214 #define lowlevel sys[5]
215 #define dischargecurrent adin[6]
216 #define BatteryVolatage adin[8]
217
218 //-----------------------------
219 //System flag,char of control;
220 //-----------------------------
221 //control state character
222 #define fstopc 0x17
223 #define fstarc 0x12
224 #define bstopc 0x15
225 #define bstarc 0x18
226 #define lowerc 0x2
227 #define overc 0x13
228 #define motorc 0xf
229 #define loadoverswitch P3_3
230
231 bit bdata boostflag;
232
233 #pragma DISABLE
234
235 void control(void)
236 {
237 1 static bit bdata motoropen,exe,ffo;
238 1 static unsigned char idata switchchar=0xff; //all close
239 1
240 1 unsigned int data ofv,cfv;
241 1 unsigned char data fk;
C51 COMPILER V7.20 CONTROL 06/20/2005 16:55:56 PAGE 5
242 1 unsigned int data temp_flr;
243 1 temp_flr=float_revise/10;//100*10=1000
244 1 if(t50ms%40>20)//2s
245 1 {if(exe)return;}
246 1 else {exe=0; return;}
247 1
248 1 exe=1;
249 1 syserror();//check sys rightly
250 1
251 1 //float charge Temperature revise
252 1 if(adin[7]>2980)//25^C
253 1 {
254 2 cfv=floatstop*AMPLIFICATORY-((adin[7]-2980)*temp_flr)/100;// /1000;
255 2 ofv=floatstart*AMPLIFICATORY-((adin[7]-2980)*temp_flr)/100;
256 2 }
257 1 else
258 1 {
259 2 cfv=floatstop*AMPLIFICATORY+((2980-adin[7])*temp_flr)/100;
260 2 ofv=floatstart*AMPLIFICATORY+((2980-adin[7])*temp_flr)/100;
261 2 }
262 1
263 1 if(controlstate==fstopc)fk=0;
264 1
265 1 if(BatteryVolatage > boostvolatage*AMPLIFICATORY)
266 1 {
267 2 boostflag=0; controlstate=bstopc;
268 2 if(switchchar!=0xff)
269 2 {
270 3 fk=1;
271 3 while(switchchar==(switchchar|fk))fk<<=1;
272 3 switchchar|=fk; switchchar|=0xC0;
273 3 }else controlstate=fstopc;
274 2 }
275 1 else
276 1 {
277 2 if(boostflag)
278 2 {
279 3 controlstate=bstarc;//boost charge start
280 3 switchchar|=0xC0;
281 3 if((switchchar&0x3F) !=0x00)
282 3 {
283 4 fk=1;
284 4 while(switchchar==(switchchar&~fk))fk<<=1;
285 4 switchchar&=~fk;
286 4 }
287 3 if(BatteryVolatage< moterstart*AMPLIFICATORY)
288 3 {
289 4 motoropen=1;//and motor start
290 4 if(BatteryVolatage<lowlevel*AMPLIFICATORY)
291 4 {//controlstate=lowerc;
292 5 switchchar&=0x7F;}//not enough volatage alarm,6 way start
293 4 }
294 3 }
295 2 else //float controll
296 2 {
297 3 if(BatteryVolatage >cfv)//float stop
298 3 {
299 4 ffo=0;
300 4 motoropen=0; controlstate=fstopc;
301 4 if(switchchar!=0xff)
302 4 {
303 5 fk=1; controlstate=fstarc;
C51 COMPILER V7.20 CONTROL 06/20/2005 16:55:56 PAGE 6
304 5 while(switchchar==(switchchar|fk))fk<<=1;
305 5 switchchar|=fk; switchchar|=0xC0;
306 5 }
307 4 }//stop motor,close 1 way
308 3 else
309 3 {
310 4 if(switchchar==0xff)controlstate=fstopc;
311 4 else controlstate=fstarc;
312 4 if(ffo)
313 4 if((switchchar&0x3F) !=0x00)
314 4 {
315 5 fk=1;
316 5 while(switchchar==(switchchar&~fk))fk<<=1;
317 5 switchchar&=~fk; switchchar|=0xC0;
318 5 }
319 4 if(BatteryVolatage < ofv)//float start
320 4 {
321 5 ffo=1;
322 5 if(BatteryVolatage < booststart*AMPLIFICATORY)
323 5 {
324 6 boostflag=1; controlstate=bstarc;//boost charge start
325 6 }
326 5 }
327 4 }
328 3 }
329 2 }
330 1
331 1 if(motoropen)
332 1 if(BatteryVolatage <cfv)//float stop,stop motor
333 1 { if(t50ms%15<7)controlstate=motorc; switchchar &=0xBF;}//motor mask
334 1 else {switchchar |=0x40;motoropen=0;}
335 1 //Send control to port
336 1 P8255B=switchchar;
337 1
338 1 RESET_DOG;
339 1 }
340 void overloadctl(void)
341 {
342 1 //OverLoad alarm
343 1 if(dischargecurrent>(overload*AMPLIFICATORY))
344 1 {
345 2 if(loadoverswitch)//P3_3
346 2 {controlstate=overc;loadoverswitch=0;_nop_();_nop_();}
347 2 else loadoverswitch=1;
348 2 }
349 1 //Lower volotage alarm
350 1 if(BatteryVolatage<lowlevel*AMPLIFICATORY)
351 1 {static data unsigned char i;i++;
352 2 if(i&1)return;
353 2 if(loadoverswitch)//P3_3
354 2 {controlstate=lowerc;loadoverswitch=0;_nop_();_nop_();}
355 2 else loadoverswitch=1;
356 2 }
357 1
358 1 if(dischargecurrent<(overload*AMPLIFICATORY)&&(BatteryVolatage>lowlevel*AMPLIFICATORY))
359 1 loadoverswitch=1;
360 1
361 1 _nop_();_nop_();
362 1 }
363 //----------------------------------------
364 ///save tab to xdata at the one day
365 //-----Xsave the first value---------
C51 COMPILER V7.20 CONTROL 06/20/2005 16:55:56 PAGE 7
366 static unsigned char xdata day[3] _at_ 0xD580;
367
368 void save(void)
369 {
370 1 if(today.date[2]==day[2])return;
371 1
372 1 if(day[2]==0||day[2]>31)
373 1 {
374 2 day[2]=today.date[2];
375 2 day[1]=today.date[1];
376 2 day[0]=today.date[0];
377 2 return;
378 2 }
379 1
380 1 {
381 2 unsigned long xdata *Ah;
382 2 unsigned char data i;
383 2 link p;
384 2 p=today.next;
385 2 //save data to dubluelooplinktable
386 2 for(i=0;i<18;i++)//copy today to today.next
387 2 {
388 3 if(i<3)
389 3 {
390 4 p->date[i]=day[i];
391 4 day[i]=today.date[i];
392 4 };
393 3 p->work[i]=today.work[i];
394 3 today.work[i]=0;//clear buffer
395 3 }
396 2
397 2 Ah=tmpAh;
398 2 for(i=0;i<7;i++)*Ah++=0;//clear Ahtmp
399 2
400 2 today.next=p->next;//OR today.next->next
401 2 today.up=p;
402 2 p=today.next;
403 2 p->date[0]=0;
404 2 p->date[1]=0;
405 2 p->date[2]=0;//break looplink
406 2 }
407 1 RESET_DOG;
408 1 }
409
410
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 2566 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 7 32
IDATA SIZE = 1 ----
BIT SIZE = 5 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -