温度采集.doc_第1页
温度采集.doc_第2页
温度采集.doc_第3页
温度采集.doc_第4页
温度采集.doc_第5页
免费预览已结束,剩余12页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

目录:1.技术要求.12.整体方案调研.13.整体方案论证设计.14.系统设计的器件选择.25主程序和设计总图76参考文献.17一技术要求1.基本要求(1)测温范围0-100;(2) 测温精度2;(3)LED数码管显示,显示方式为点测与巡测(多点测);(4)5v,15v外部电源供电;2.发挥要求(1)设计报警电路,当温度高于一定的温度时就报警;(2)测温点与控制显示部分拉长距离,即无线测温。遥测距离100m二整体方案调研方案一:基于SPCE061单片机数字多路温度采集系统。方案二:基于DSP的多路温度控制系统设计方案三:确定系统功能与性能本系统的功能主要有数据采集、数据处理、输出控制。能对01000 c范围内的各种电加热炉的温度进行精密测量,同时,四位LED显示器直接跟踪显示被控对象的温度值,准确度高,显示清晰,稳定可靠,使用方便(在具体设计编程、调试过程中,为了调试方便,编程把温度范围设在0100 c)。三整体方案论证设计方案一:中SPCE061有采样速度快、信号失真性小、功耗低、成本低等优点。方案二:以dsp作为温度采集和控制的核心,选用“一线总线”式的数字温度传感器ds18b20实现了多路温度采集,简化了电路,结合dsp软件设计,同时启动各路温度传感器进行转换,然后逐一读取温度数据,相比较起传统的采用公用放大电路和A、D转换器逐一转换,这种方式具有采集多路温度信号所用时间少的优点,并且通道越多,省时效应越明显。综上上面的设计方法,我以AT89C51为主要芯片进行设计.方案三:数据采集部分能完成对被测信号的采样,显示分辨率0.1c,测量精度0.1c,控制精度0.1c,可以实现采集信号的放大及A/D转换,并自动进行零漂校正,同时按设定值、所测温度值、温度变化速率,自动进行FID参数自整定和运算,并输出010mA控制电流,配以主回路实现温度的控制。数据处理分为预处理、功能性处理、抗干扰等子功能。输出控制部分主要是数码管显示控制。 确定系统基本结构及硬件设计本单片机应用系统结构是以单片机为核心外部扩展相关电路的形式。确定了系统中的单片机、存储器分配及输入/输出方式就可大体确定出单片机应用系统的基本组成。 四系统设计的器件和各模块选择、单片机最小系统图中晶振插座中可根据应用系统需要插入不同振荡频率的晶振。单片机管脚通过J3、J4和J5引出。、温度检测电路 DS-18B20 数字温度传感器 、数码管显示LED数码管以发光二极管作为发光单元,颜色有单红,黄,蓝,绿,白,七彩效果。单色,分段全彩管可用大楼,道路,河堤轮廓亮化,LED数码管可均匀排布形成大面积显示区域,可显示图案及文字,并可播放不同格式的视频文件。通过电脑下flash、动画、文字等文件,或使用动画设计软件设计个性化动画,播放各种动感变色的图文效果;、液晶显示1602AT89C51是一种带4K字节闪存可编程可擦除只图存储器(FPEROMFlash Programmable and Erasable Read Only Memory)的低电压、高性能CMOS 8位微处理器,俗称单片机。AT89C2051是一种带2K字节闪存可编程可擦除只读存储器的单片机。单片机的可擦除只读存储器可以反复擦除1000次。该器件采用ATMEL高密度非易失存储器制造技术制造,与工业标准的MCS-51指令集和输出管脚相兼容。由于将多功能8位CPU和闪烁存储器组合在单个芯片中,ATMEL的AT89C51是一种高效微控制器,AT89C2051是它的一种精简版本。AT89C单片机为很多嵌入式控制系统提供了一种灵活性高且价廉的方案。外形及引脚排列如图所示主要特性:与MCS-51 兼容 4K字节可编程闪烁存储器 寿命:1000写/擦循环 数据保留时间:10年 全静态工作:0Hz-24MHz 三级程序存储器锁定 1288位内部RAM 32可编程I/O线 两个16位定时器/计数器 5个中断源 可编程串行通道 低功耗的闲置和掉电模式 片内振荡器和时钟电DS18B20基本 DS18B20数字温度计是DALLAS公司生产的1Wire,即单总线器件,具有线路简单,体积小的特点。因此用它来组成一个测温系统,具有线路简单,在一根通信线,可以挂很多这样的数字温度计,十分方便。DS18B20产品的特点(1).只要求一个端口即可实现通信。(2).在DS18B20中的每个器件上都有独一无二的序列号。(3).实际应用中不需要外部任何元器件即可实现测温。(4).测量温度范围在55。C到125。C之间。(5).数字温度计的分辨率用户可以从9位到12位选择。(6).内部有温度上、下限告警设置。DS18B20的使用方法由于DS18B20采用的是1Wire总线协议方式,即在一根数据线实现数据的双向传输,而对AT89S51单片机来说,硬件上并不支持单总线协议,因此,我们必须采用软件的方法来模拟单总线的协议时序来完成对DS18B20芯片的访问。由于DS18B20是在一根I/O线上读写数据,因此,对读写的数据位有着严格的时序要求。DS18B20有严格的通信协议来保证各位数据传输的正确性和完整性。该协议定义了几种信号的时序:初始化时序、读时序、写时序。所有时序都是将主机作为主设备,单总线器件作为从设备。而每一次命令和数据的传输都是从主机主动启动写时序开始,如果要求单总线器件回送数据,在进行写命令后,主机需启动读时序完成数据接收。数据和命令的传输都是低位在先。显示模块:温度采集模块:主程序流程图:五主程序和总电路图16#include#includelcd1602.h#includeds18b20.h#includeds18b20_2.h#includeds18b20_3.h#includeds18b20_4.h#define uchar unsigned char #define uint unsigned int#define TIMER0_COUNT 0xEE11sbit SPK=P35;sbit LED1=P36;sbit LED2=P37;bit flag; uint wendu; uint wendu1; uint wendu2; uint wendu3;uchar count,timer0_tick,count=0;static void timer0_initialize(void) EA=0; timer0_tick=0; TR0=0; TMOD=0X01; TL0=(TIMER0_COUNT & 0X00FF); TH0=(TIMER0_COUNT 8); PT1=1; ET0=1; TR0=1; EA=1; void display_temp() uchar A1,A2; uchar A3,A4; uchar A5,A6; uchar A7,A8; tmpchange(); wendu=tmp(); A1=wendu/10; A2=wendu%10; gotoxy(1,1); display_data(A1); display_string(.); write_date(int_to_charA2); tmpchange2(); wendu1=tmp2(); A3=wendu1/10; A4=wendu1%10; gotoxy(2,1); display_data(A3); display_string(.); write_date(int_to_charA4); tmpchange3(); wendu2=tmp3(); A5=wendu2/10; A6=wendu2%10; gotoxy(1,7); display_data(A5); display_string(.); write_date(int_to_charA6); tmpchange4(); wendu3=tmp4(); A7=wendu3/10; A8=wendu3%10; gotoxy(2,7); display_data(A7); display_string(.); write_date(int_to_charA8); void timer0(void) interrupt 1 TR0=0; TL0=(TIMER0_COUNT & 0X00FF);/设置Timer0低八位数值 TH0=(TIMER0_COUNT 8);/设置Timer0高八位数值 TR0=1;count+; if(count=10) display_temp(); void main()init_lcd(); timer0_initialize(); gotoxy(1,1); display_string(00.0C); gotoxy(2,1); display_string(00.0C);while(1) if(wendu500) | (wendu1500) | (wendu2500) | (wendu3500) SPK=SPK; LED1=LED1; delay(30); else if (wendu100) | (wendu1100) | (wendu2100) | (wendu30;a-)for(b=10;b0;b-); /*void write_com(uchar com)/写命令P0=com;rs=0;lcden=0;delay(10);lcden=1;delay(10);lcden=0;/*void write_date(uchar date)/写数据P0=date;rs=1;lcden=0;delay(10);lcden=1;delay(10);lcden=0;/*void init_lcd(void) /初始化lcd1602 delay(15);write_com(lcd_mode);delay(20);write_com(undisplay_cursor);delay(20);write_com(0x06); /let cursor movedelay(20);write_com(0x01); /clear lcddelay(20);/*void display_string(char *p) /写字符串while(*p)write_date(*p);delay(20);p+; /*void gotoxy(uchar x,uchar y) if(x=1) write_com(0x80+y);else write_com(0xc0+y); /*void display_data(char number) uchar x,y; x=number/10; y=number%10;/y=number-10*x; write_date(int_to_charx); write_date(int_to_chary); #include #include #define uchar unsigned char#define uint unsigned intuint temp; / variable of temperaturesbit DS=P10; /define interfacevoid delay1(uchar count) while(count0) count-;void reset(void) /send reset and initialization command DS=0; delay1(100); DS=1; delay1(4); delay1(200);bit read_bit(void) /read a bit bit temp; DS=0; _nop_(); DS=1; _nop_(); temp=DS; delay1(200); return temp; uchar read_byte(void) /read a byte date uchar i,byte=0; bit j; for(i=0;i8;i+) byte=_cror_(byte ,1); j=read_bit(); if(j=0) byte=byte|0x00; else byte=byte|0x80; return byte;void write_byte(uchar command) /write a byte to ds18b20 uchar i; for(i=0;i8;i+) if(command & 0x01)=0) DS=0; delay1(8); DS=1; _nop_(); else DS=0; _nop_(); DS=1; delay1(8); command=_cror_(command,1); void tmpchange(void) /DS18B20 begin change reset(); write_byte(0xcc); /直接向18b20发送温度变换命令 write_byte(0x44); /启动18b20进行温度转换 uint tmp() /get the temperature float tt; uchar a,b; reset(); write_byte(0xcc); /直接向18b20发送温度变换命令 write_byte(0xbe); /读取温度寄存器的温度值 a=read_byte();/读低八位 b=read_byte();/读高八位 temp=b; temp=8; /two byte compose a int variable temp=temp|a; tt=temp*0.0625; temp=tt*10+0.5; return temp; #include #include #define uchar unsigned char#define uint unsigned int uint temp2; / variable of temperaturesbit DS2=P11; /define interfacevoid delay2(uchar count) while(count0) count-;void reset2(void) /send reset and initialization command DS2=0; delay2(100); DS2=1; delay2(4); delay2(200);bit read_bit2(void) /read a bit bit temp; DS2=0; _nop_(); DS2=1; _nop_(); temp=DS2; delay2(200); return temp; uchar read_byte2(void) /read a byte date uchar i,byte=0; bit j; for(i=0;i8;i+) byte=_cror_(byte ,1); j=read_bit2(); if(j=0) byte=byte|0x00; else byte=byte|0x80; return byte;void write_byte2(uchar command) /write a byte to ds18b20 uchar i; for(i=0;i8;i+) if(command & 0x01)=0) DS2=0; delay2(8); DS2=1; _nop_(); else DS2=0; _nop_(); DS2=1; delay2(8); command=_cror_(command,1); void tmpchange2(void) /DS18B20 begin change reset2(); write_byte2(0xcc); /直接向18b20发送温度变换命令 write_byte2(0x44); /启动18b20进行温度转换 uint tmp2() /get the temperature float tt; uchar a,b; reset2(); write_byte2(0xcc); /直接向18b20发送温度变换命令 write_byte2(0xbe); /读取温度寄存器的温度值 a=read_byte2();/读低八位 b=read_byte2();/读高八位 temp2=b; temp2=8; /two byte compose a int variable temp2=temp2|a; tt=temp2*0.0625; temp2=tt*10+0.5; return temp2 ; #include #include #define uchar unsigned char#define uint unsigned int uint temp3; / variable of temperaturesbit DS3=P12; /define interfacevoid delay3(uchar count) while(count0) count-;void reset3(void) /send reset and initialization command DS3=0; delay3(100); DS3=1; delay3(4); delay3(200);bit read_bit3(void) /read a bit bit temp; DS3=0; _nop_(); DS3=1; _nop_(); temp=DS3; delay3(200); return temp; uchar read_byte3(void) /read a byte date uchar i,byte=0; bit j; for(i=0;i8;i+) byte=_cror_(byte ,1); j=read_bit3(); if(j=0) byte=byte|0x00; else byte=byte|0x80; return byte;void write_byte3(uchar command) /write a byte to ds18b20 uchar i; for(i=0;i8;i+) if(command & 0x01)=0) DS3=0; delay3(8); DS3=1; _nop_(); else DS3=0; _nop_(); DS3=1; delay3(8); command=_cror_(command,1); void tmpchange3(void) /DS18B20 begin change reset3(); write_byte3(0xcc); /直接向18b20发送温度变换命令 write_byte3(0x44); /启动18b20进行温度转换 uint tmp3() /get the temperature float tt; uchar a,b; reset3(); write_byte3(0xcc); /直接向18b20发送温度变换命令 write_byte3(0xbe); /读取温度寄存器的温度值 a=read_byte3();/读低八位 b=read_byte3();/读高八位 temp3=b; temp3=8; /two byte compose a int variable temp3=temp3|a; tt=temp3*0.0625; temp3=tt*10+0.5; return temp3 ; #include #include #define uchar unsigned char#define uint unsigned int uint temp4; / variable of temperaturesbit DS4=P13; /define interfacevoid delay4(uchar count) while(count0) count-;void reset4(void) /send reset and initialization command DS4=0; delay4(100); DS4=1; delay4(4); delay4(200);bit read_bit4(void) /read a bit bit temp; DS4=0; _nop_(); DS4=1; _nop_(); temp=DS4; delay4(200); return temp; uchar read_byte4(void) /read a byte date uchar i,byte=0; bit

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论