資源簡介
通過ADC0809采集電壓信號和電流信號,由51單片機處理后,通過開關控制可在數碼管上顯示瞬時電壓、電流、功率值。內附c語言驅動程序和Proteus仿真及ADC0809資料。

代碼片段和文件信息
?#include
unsigned?char?code?dispbitcode[]={0x3f0x060x5b0x4f0x660x6d0x7d0x070x7f0x6f};
unsigned?char?dispbuf[4];
unsigned?int?i;
unsigned?int?j;
unsigned?char?getdataV;
unsigned?char?getdataI;
unsigned?char?getdataP;
unsigned?int?temp;
sbit?ST=P3^0;
sbit?OE=P3^1;
sbit?EOC=P3^2;
sbit?CLK=P3^3;
sbit?P34=P3^4;
sbit?P35=P3^5;
sbit?P36=P3^6;
sbit?P20=P2^0;
sbit?P21=P2^1;
sbit?P22=P2^2;
sbit?P23=P2^3;
sbit?P17=P1^7;
sbit?K1=P2^6;
sbit?K2=P2^7;
void?TimeInitial();
void?Delay(unsigned?int?i);
void?TimeInitial()
{???TMOD=0x10;
????TH1=(65536-200)/256;
????TL1=(65536-200)%256;
????EA=1;
????ET1=1;
????TR1=1;
?}
void?Delay(unsigned?int?i)
{
?????unsigned?int?j;
?????for(;i>0;i--)
?????for(j=0;j<125;j++);
}
?
void?Display()
{?
????P1=dispbitcode[dispbuf[3]];
????P20=0;
????P21=1;
????P22=1;
????P23=1;
????Delay(5);
????P1=0x00;?
????P1=dispbitcode[dispbuf[2]];
????P17=1;
????P20=1;
????P21=0;
????P22=1;
????P23=1;
????Delay(5);?
????P1=0x00;
????P1=dispbitcode[dispbuf[1]];
????P20=1;
????P21=1;
????P22=0;
????P23=1;
????Delay(5);
????P1=0x00;
????P1=dispbitcode[dispbuf[0]];
????P20=1;
????P21=1;
????P22=1;
????P23=0;
????Delay(5);
????P1=0x00;
}
void?main()
{
????TimeInitial();
?????while(1)
????{
????????if(K1==0&K2==1)
?????????{???OE=0;
?????????????ST=1;
?????????????ST=0;
?????????????P34=0;
?????????????P35=0;
?????????????P36=0;
?????????????while(EOC==0);
?????????????OE=1;
?????????????getdataV=P0;
?????????????OE=0;
?????????????temp=getdataV*1.0/255*1500;
?????????????dispbuf[0]=temp%10;
?????????????dispbuf[1]=temp/10%10;
?????????????dispbuf[2]=temp/100%10;
?????????????dispbuf[3]=temp/1000;
?????????????Display();
?????????}
????????else?if(K2==0&K1==1)
?????????{
?????????????ST=1;
?????????????ST=0;
?????????????P34=1;
?????????????P35=0;
?????????????P36=0;
?????????????while(EOC==0);
?????????????OE=1;
?????????????getdataI=P0;
?????????????OE=0;
?????????????temp=getdataI*1.0/255*50;
?????????????dispbuf[0]=temp%10;
?????????????dispbuf[1]=temp/10%10;
?????????????dispbuf[2]=temp/100%10;
?????????????dispbuf[3]=temp/1000;
?????????????Display();
???????????}
?????????else?if(K1==0&K2==0)
??????????{?
??????????????ST=1;
??????????????ST=0;
??????????????P34=0;
??????????????P35=0;
??????????????P36=0;
??????????????while(EOC==0);
??????????????OE=1;
??????????????getdataV=P0;
??????????????OE=0;
?????????
??????ST=1;
??????ST=0;
??????P34=0;
??????while(EOC==0);
??????OE=1;
??????getdataI=P0;
??????OE=0;
?
??????getdataP=getdataV|getdataI;
??????temp=getdataP*1.0/255*750;
??????dispbuf[0]=temp%10;
??????????????dispbuf[1]=temp/10%10;
??????????????dispbuf[2]=temp/100%10;
??????????????dispbuf[3]=temp/1000;
??????????????Display(); ?
????????????}
????}
}
void?t1(void)?interrupt?3?using?0
?{
?????TH1=(65536-200)/256;
?????TL1=(65536-200)%256;
?????C
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????7829??2010-07-03?12:59??數據采集系統\0809測試\0809測試
?????文件???????3013??2010-07-03?12:59??數據采集系統\0809測試\0809測試.c
?????文件?????????48??2010-07-03?12:59??數據采集系統\0809測試\0809測試.lnp
?????文件???????6288??2010-07-03?12:59??數據采集系統\0809測試\0809測試.LST
?????文件??????10718??2010-07-03?12:59??數據采集系統\0809測試\0809測試.M51
?????文件???????7707??2010-07-03?12:59??數據采集系統\0809測試\0809測試.OBJ
?????文件????????978??2010-07-03?13:03??數據采集系統\0809測試\0809測試.Opt
?????文件???????4419??2010-07-03?13:03??數據采集系統\0809測試\0809測試.plg
?????文件???????2113??2010-07-03?11:05??數據采集系統\0809測試\0809測試.Uv2
?????文件????????978??2010-07-03?11:05??數據采集系統\0809測試\0809測試_Opt.Bak
?????文件??????????0??2010-07-03?09:29??數據采集系統\0809測試\0809測試_Uv2.Bak
?????文件?????270878??2010-06-13?15:55??數據采集系統\ADC0809資料\ADC0809.pdf
?????文件?????144663??2010-07-03?13:23??數據采集系統\數據采集系統仿真\Last?Loaded?數據采集.DBK
?????文件?????144634??2010-07-03?13:25??數據采集系統\數據采集系統仿真\數據采集.DSN
?????文件???????3468??2010-07-03?12:59??數據采集系統\數據采集系統仿真\數據采集.hex
?????文件???????1052??2010-07-03?13:25??數據采集系統\數據采集系統仿真\數據采集.PWI
?????目錄??????????0??2010-07-03?13:24??數據采集系統\0809測試
?????目錄??????????0??2010-07-04?13:57??數據采集系統\ADC0809資料
?????目錄??????????0??2010-07-03?13:25??數據采集系統\數據采集系統仿真
?????目錄??????????0??2010-07-04?13:57??數據采集系統
-----------?---------??----------?-----??----
???????????????608786????????????????????20
- 上一篇:銀行家算法模擬實現C++版
- 下一篇:c++高仿QQ截圖
評論
共有 條評論