用AD590和ADC0809做的温度采集系统
用AD590进行温度采集,但是总感觉并没有采到温度信号,用数码管显示温度,一直是0。求大神指点到底错在哪里了,程序写的乱,还请见谅……电路图中那个圆是AD590,不会画表示了一下,另外旁边的电阻和滑动变阻换成了1K。电压时0.29V。谢谢了!
#include<reg52.h>
#include"intrins.h"
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={
0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,
0x90,0x7f,0x9c,0xc6
};
void DELAY(uint);
void display(uchar,uchar,uchar,uchar,uchar);
void fenli(uchar);
void init();
sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC=P3^2;
sbit CLK=P3^7;
sbit ALE=P3^6;
int t;
uchar wendu,shi,ge,xiaoshu,wen,du;
void main()
{
init();
while(1)
{
ST=0;
DELAY(1);
ALE=1;
ST=1;
DELAY(1);
ALE=0;
ST=0;
while(EOC==0);
OE=1;
wendu=P1;
fenli(wendu);
display(shi,ge,xiaoshu,wen,du);
}
}
void T1_time()interrupt 3
{
TH1=(65536-10)/256;
TH0=(65536-10)%256;
t++;
if(t==1)
{
t=0;
CLK=~CLK;
}
}
void DELAY(uint xms)
{uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void display(uchar shi,uchar ge,uchar xiaoshu,uchar wen,uchar du)
{
P0=table[shi];
P2=0xfe;
DELAY(5);
P0=table[ge];
P2=0xfd;
DELAY(1);
P0=table[10];
P2=0xfb;
DELAY(1);
P0=table[xiaoshu];
P2=0xf7;
DELAY(1);
P0=table[wen];
P2=0xef;
DELAY(1);
P0=table[du];
P2=0xdf;
DELAY(1);
}
void fenli(uchar shu)
{
uchar shi,ge,xiaoshu;
shu=(double)shu;
shu=shu*0.262;
shi=shu/10;
shu=shu%10;
ge=shu;
shu=shu%10;
xiaoshu=shu;
}
void init()
{
EOC=1;
CLK=0;
TMOD=0x10;
TH1=(65536-10)/256;
TH0=(65536-10)%256;
EA=1;
ET1=1;
TR1=1;
}