專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計(jì)實(shí)例 >> 瀏覽文章

八通道adc0808數(shù)據(jù)采集

作者:佚名   來(lái)源:互聯(lián)網(wǎng)   點(diǎn)擊數(shù):  更新時(shí)間:2014年09月17日   【字體:

#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit EN=P0^4;
sbit EOC=P0^6;
sbit STA=P0^7;
sbit ADA=P0^0;
sbit ADB=P0^1;
sbit ADC=P0^2;
sbit ALE=P0^5;
uchar code tab[11]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xD8,0x80,0x90,0xff};
uchar code wela[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar data shu[8]={0,0,0,0,0,0,0,0};
uint ada=1222,adb=0;
uchar alley=0;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=4;y>0;y--);
}
void display()
{

uchar i,hp;

for(i=0;i<8;i++)
{
if(i==1)hp=0x80;else hp=0;
P3=wela[i];
P2=tab[shu[i]]+hp;
delay(10);
P3=0X00;
}
}
void disan()
{
ada=ada*100/51;
shu[4]=alley/1000;
shu[5]=alley%1000/100;
shu[6]=alley%100/10;
shu[7]=alley%10;
shu[0]=ada/1000;
shu[1]=ada%1000/100;
shu[2]=ada%100/10;
shu[3]=ada%10;
}
void adc()
{

ADA=alley&0x01;
ADB=alley&0x02;
ADC=alley&0x04;
STA=0;
delay(30);
STA=1;
delay(30);
STA=0;
while(!EOC)delay(1);
EN=1;
delay(2);
ada=P1;
EN=0;
}
void main()
{
uchar a=100;
while(1)
{
a=1000;
alley++;
if(alley>7)alley=0;
adc();
disan();
while(a--)
{

display();
}
}
}

 

 

 

關(guān)閉窗口

相關(guān)文章