AT89S52温度变送器实验.docVIP

  • 7
  • 0
  • 约1.85千字
  • 约 7页
  • 2016-09-19 发布于重庆
  • 举报
AT89S52温度变送器实验

AT89S52温度变送器实验 单片机技术使用越来越广泛,在各种仪器仪表生产制造、石油、化工、纺织、机械制造等行业中都得到了广泛运用。 现用AT89S52单片机设计了一款温带度显示的变送器,所需材料如下: 序号 名称 型号 数量(只) 1 单片机 AT89S52 1 2 电容 22pF 2 3 电容 16V10uF 1 4 晶振 12M 1 5 电阻 970欧姆 1 6 电阻 100欧姆 3 7 滑动电阻 510欧姆 1 8 AD转换芯片 LTC1860 1 9 DA转换芯片 LTC1655 1 10 锁存器 74HC573 2 11 数码管显示 6位共阴极 1 仿真电路如下: 温度变送器程序如下: #includereg52.h #includemath.h #includeDAC.c sbit SDO=P1^2; sbit SCK=P1^3; sbit CON=P1^4; #includeLTC1860.c sbit duan=P1^1; sbit wei=P1^0; sbit DIN=P1^5; sbit CLK=P1^6; sbit CS=P1^7; #define A 3367.8 #define B 131.2856 #define C 758.0757 char m; char duantable[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; char weitable[6]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf}; void display(long int dat,int dp) { long int temp,DATE[6],i=0,num=0; temp=dat; m=dp; do { temp=temp/10; num++; } while(temp!=0); if(num=m)num=m+1; temp=dat; for(i=0;inum;i++) { DATE[i]=temp%10; temp=temp/10; P2=weitable[i]; wei=1; wei=0; if(i==m) { P2=duantable[DATE[i]]|0x80; } else P2=duantable[DATE[i]]; duan=1; duan=0; } } void LTC1655(long int dat) { long int temp,i,ch[16]; temp=dat; for(i=0;i16;i++) { if((temp0x8000)==0x8000)ch[i]=1; else ch[i]=0; temp=temp1; } CS=0; CLK=0; for(i=0;i16;i++) { DIN=ch[i]; CLK=1; CLK=0; } i=0; CS=1; } float LTC1860() { long int i=0,ch[12]; float dat,t; CON=0; for(i=0;i12;i++) { SCK=0; if(SDO==0)ch[i]=0; else ch[i]=1; SCK=1; } CON=1; dat=(ch[0]*2048)+(ch[1]*1024)+(ch[2]*512)+(ch[3]*256)+(ch[4]*128)+(ch[5]*64)+(ch[6]*32)+(ch[7]*16)+(ch[8]*8)+(ch[9]*4)+(ch[10]*2)+ch[11]; t=(100*(A-B*sqrt(C-(500000/(2500-(dat*5000/4096))-100)))-18)*0.999361017; return t; } void main() { float t,m; while(1) { t=LTC1860(); m=65535*(t/65027); LTC1655(m); display(t,2); } } 采用本方案设计的温度变送器测量精度可达0.2级,分辨率为0.25℃,测量范围为:0~650℃. 设计:康联和 电话QQ:672260307 个人网站:cqkangli32j7km.web1.cq118.cn 2011年8月31日

文档评论(0)

1亿VIP精品文档

相关文档