临醉的境界 临醉的境界
关注数: 3 粉丝数: 64 发帖数: 1,165 关注贴吧数: 20
ADC0809数字电压表显示出问题了,求解!!! 设计图如下源代码如下: //--------------------------------------- //--------------------------------------- #include "reg51.h" sbit ST_ALE=P3^0;//START and ALE both connect to P3.0 sbit EOC=P3^1;//EOC connect to P3.1 sbit OE=P3^2;//OE conect to P3.2 sbit CLK=P3^3;//CLK connect to P3.3 unsigned char CHANNEL;//AD channel variable unsigned char LED[10]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F}; //common cathode LED code unsigned char CHECK[4]={0xFE,0xFD,0xFB,0xF7}; //choose LED channel void delay(unsigned char time) { unsigned char i,j; for(i=time;i>0;i--) for(j=250;j>0;j--) ; } void display() { unsigned long temp; unsigned char DATA,digit[4]; unsigned int k,l; DATA=P1;//save AD data temp=DATA;//the temporary variable temp=temp*1000/51;//AD formula:D=A*5/255 digit[0]=temp/1000;//the thousands place digit[1]=temp%1000/100; //the hundreds place digit[2]=temp%1000%100/10; //the tens place digit[3]=temp%1000%100%10;//the ones place DATA=P2; //save P2 for(k=0;k<1000;k++) { for(l=0;l<4;l++) { P2=P2|0x0F;//avoid LED residual P0=LED[digit[l]]+0x80*(l==0);//LED code P2=DATA&CHECK[l];//choose LED channel } } P2=DATA;//restore P2 } void main() { ST=0;//START and ALE default OE=0;//OE default TMOD=0x02;//T0 operate in mode 2 EA=1;//all interrupt enable ET0=1;//T0 interrupt enable TR0=1;//T0 run while(1) {ST_ALE=1;//lock the AD channel address ST_ALE=0;//AD run while(EOC==0);//wait until AD over OE=1;//enable to transmit AD data display();//view the AD result and diaplay LED } } void T1_TIME() interrupt 1 using 0 { CLK=~CLK;//CLK 500 kHz } 具体问题就是用proteus模拟显示的时候数码管显示的数值和滑动变阻器上的数值不一致,差距很大,而且,在滑动变阻器上0~5V之间变动的时候,数码管只显示2.25~2.78V,这是怎么回事,大神求解啊!!!急求啊!!!!!!!
1 下一页