?? define data struct.bak
字號(hào):
/*
*/
#include <absacc.h>
#include <stdlib.h>
#include <AT89X52.H>
#include <INTRINS.h>
#include "charger.h"
#include "lcdp.h"
//
//-----------------------------
//define data struct
//-----------------------------
//System flag,char of control;
//-----------------------------
static bit bdata boostflag=1;
static unsigned char idata switchchar=0x3f;
/*
//init_system_work_point , counter rate flow
*/
#define BENCHMARK 5
#define AMPLIFICATORY 10//predefine 0.1 proccess, amplificatory 10
#define ADMAX 1024
static unsigned char xdata str[0x1800];
void init_system_work_point(void)
{
unsigned char idata i;
link xdata head;
link xdata new;
link xdata pointer;
for(i=0;i<7;i++)
{
sys[i]=dtab[2][i];//default=2,system is 220V
}
for(i=0;i<5;i++)//i=7
{
sys[i+7]=stab[i][2];
}
sys[12]=0;//tested temperature
init_mempool(str,0x1800);//&XBYTE[0x4000]
head=(link)malloc(sizeof(daydata));
if(head==0){text(0x90,"Head Null");delay(1000);return;}
text(0x80,"malloc is ok!");
head->next=NULL;
head->up=NULL;
delay(1000);
pointer=head;
for(i=0;;i++)
{
new=(link)malloc(sizeof(daydata));
if(new==0)break;
new->next=NULL;
new->up=NULL;
pointer->next=new;
new->up=pointer;
pointer=new;
};
pointer->next=head;
head->up=pointer;
WC_LCD(0x90);
WD_LCD(i);
delay(2000);
//The moving header
today.next=head;
today.up=pointer; //is head->up;
init_rate();
}
static void init_rate(void)
{
unsigned int data i;
crate.temperature=100*BENCHMARK*AMPLIFICATORY/ADMAX;
i=sys[11];
crate.volatage=i*BENCHMARK*AMPLIFICATORY/ADMAX;
i=sys[8];
crate.discharge=i*BENCHMARK*AMPLIFICATORY/ADMAX;
i=sys[9];
crate.charge=i*BENCHMARK*AMPLIFICATORY/ADMAX;
}
/*
//intput data from tlc1543,changed and saved
*/
void getadin(void)
{
unsigned char data i;
for(i=0;i<6;i++)
{
adin[i]=tlc1543(i)*crate.charge;
}
adin[6]=tlc1543(6)*crate.discharge;
adin[7]=tlc1543(8)*crate.temperature;
adin[8]=tlc1543(9)*crate.volatage;//9way
}
/*
//count today working result
*/
void account(void)
{
if(tlong%60==0)
//count Ah, per 10s //count max & min per 10s
{char i;
for(i=0;i<9;i++)
{
if(i<7)
{ //save current integral value
today.work[i*2+1]+=(today.work[i*2+1]+adin[i])/(60*2);
}
else
{//save max & min value
if(adin[i]>today.work[i*2+1])today.work[i*2+1]=adin[i];
else if(adin[i]<today.work[2*i])today.work[i*2]=adin[i];
}
//only save max value
if(adin[i]>today.work[2*i])today.work[i*2]=adin[i];
}
}
}
/*
//output control,switch operation
*/
#define boostvolatage sys[0]
#define booststart sys[1]
#define floatvolatage sys[2]
#define floatrecover sys[3]
#define moterstart sys[4]
#define lowlevel sys[5]
//alarm overload
#define overload sys[6]
#define dischargecurrent 13
//-----------------------------
#pragma DISABLE
static void controlswitch (unsigned char i)
{
P2_7=1;
_nop_();
P0=i;
_nop_();
P2_7=0;
_nop_();
_nop_();
}
//-----------------------------
static void alarm_overload()
{
}
//-----------------------------
void control(void)
{
unsigned int data t,b;
t=today.work[dischargecurrent];
if(t>overload)alarm_overload();
t=adin[8];// volatage of storage battery
b=AMPLIFICATORY*boostvolatage;//boost charge volatage
if(t>b)
{
switchchar=0x0;
controlswitch(switchchar);//all close & wcharge=0
boostflag=0;
}
else
if(boostflag)
{
b=AMPLIFICATORY*booststart;//boost charge start
if(t>b);
else
{
switchchar=0x3f;
controlswitch(switchchar);//6 way start
boostflag=1;
b=AMPLIFICATORY*moterstart;
if(t>b);
else
{
switchchar=0x7f;
controlswitch(switchchar);//6 way start and motor start
b=AMPLIFICATORY*lowlevel;
if(t>b);
else {switchchar=0xff;controlswitch(switchchar);}//not enough volatage alarm,6 way start and motor start
}
}
}
else
{
b=AMPLIFICATORY*floatvolatage;
if(t>b)
{
switchchar &= 0x3f;
switchchar>>=1;
controlswitch(switchchar);
}//close 1 way ,stop motor
else
{
b=AMPLIFICATORY*floatrecover;
if(t>b);
else {switchchar=0x3f;controlswitch(switchchar);}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -