毕业设计-基于AT89S51单片机的温度控制系统的设计.doc_第1页
毕业设计-基于AT89S51单片机的温度控制系统的设计.doc_第2页
毕业设计-基于AT89S51单片机的温度控制系统的设计.doc_第3页
毕业设计-基于AT89S51单片机的温度控制系统的设计.doc_第4页
毕业设计-基于AT89S51单片机的温度控制系统的设计.doc_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

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

文档简介

许昌学院单片机课程设计 本科生课程论文(设计)题目名称 基于单片机的温度控制系统的设计 专 业班 级学 生 姓 名 联 系 方 式 年 月摘 要 本设计以at89s51单片机为核心的温度控制系统的工作原理和设计方法。温度信号由温度芯片ds18b20采集,并以数字信号的方式传送给单片机。文中介绍了该控制系统的硬件部分,包括:温度检测电路、温度控制电路、pc机与单片机串口通讯电路和一些接口电路 。单片机通过对信号进行相应处理,从而实现温度控制的目的。文中还着重介绍了软件设计部分,在这里采用模块化结构,主要模块有:数码管显示程序、键盘扫描及按键处理程序、温度信号处理程序、继电器控制程序、超温报警程序。而采用数字温度传感器ds18b20,因其内部集成了a/d转换器,使得电路结构更加简单,而且减少了温度测量转换时的精度损失,使得测量温度更加精确。数字温度传感器ds18b20只用一个引脚即可与单片机进行通信,大大减少了接线的麻烦,使得单片机更加具有扩展性。由于ds18b20芯片的小型化,更加可以通过单跳数据线就可以和主电路连接,故可以把数字温度传感器ds18b20做成探头,探入到狭小的地方,增加了实用性。更能串接多个数字温度传感器ds18b20进行范围的温度检测。关键词:at89s51单片机 ds18b20温度芯片 温度控制 串口通讯21目录摘要21 设计要求41.1设计要求41.2主要功能模块42工作原理43方案设计53.1 温度测量部分方案53.2 主控制部分方案74 电路的设计84.1总设计及电路图84.2报警电路84.3显示电路95主程序及流程图105.1流程图105.2主程序10结论14参考文献15 1 设计要求 1.1设计要求(1)用单片机控制一个由1kw电炉加热的电烤箱,最高温度不超过120。(2)电烤过程恒温控制,温度可通过系统设置,误差不超过2。(3)实时显示温度和设置温度,显示精确为1。(4)温度超出设置温度5时发超限报警,对升温和降温过程不作要求。1.2主要功能模块 温度控制系统的主要功能模块包括温度测量(温度传感器、放大器、adc转换器)、温度控制(光电隔离、驱动电路、可控硅电路、电炉)、温度给定(按键)、温度显示和报警等几部分。根据具体情况选择合适型号的单片机,温度传感器、adc转换器等硬件设备进行设计。2工作原理温度传感器 ds18b20 从设备环境的不同位置采集温度,单片机 at89s51 获取采集的温度值,经处理后得到当前环境中一个比较稳定的温度值,再根据当前设定的温度上下限值,通过加热和降温对当前温度进行调整。当采集的温度经处理后超过设定温度的上限时,单片机通过三极管驱动继电器开启降温设备 (压缩制冷器) ,当采集的温度经处理后低于设定温度的下时 , 单片机通过三极管驱动继电器开启升温设备 (加热器) 。 当由于环境温度变化太剧烈或由于加热或降温设备出现故障,或者温度传感头出现故障导致在一段时间内不能将环境温度调整到规定的温度限内的时候,单片机通过三极管驱动扬声器发出警笛声。 系统中将通过串口通讯连接pc机存储温度变化时的历史数据,以便观察整个温度的控制过程及监控温度的变化全过程。原理图如下pc机max232电平转换芯片数据显示at89s51 8bit cpu键盘电路ds18b20 温度芯片数据传输超温报警输入电源继电器1压缩制冷器继电器2加热器 图2-1工作原理图3方案设计3.1 温度测量部分方案ds18b20是dallas公司生产的一线式数字温度传感器,它具有微型化、低功耗、高性能抗干扰能力、强易配处理器等优点,特别适合用于构成多点温度测控系统,可直接将温度转化成串行数字信号(按9位二进制数字)给单片机处理,且在同一总线上可以挂接多个传感器芯片,它具有三引脚to-92小体积封装形式,温度测量范围55125,可编程为912位a/d转换精度,测温分辨率可达0.0625,被测温度用符号扩展的16位数字量方式串行输出,其工作电源既可在远端引入,业可采用寄生电源方式产生,多个ds18b20可以并联到三根或者两根线上,cpu只需一根端口线就能与多个ds18b20通信,占用微处理器的端口较少,可节省大量的引线和逻辑电路。从而可以看出ds18b20可以非常方便的被用于远距离多点温度检测系统。综上,在本系统中我采用温度芯片ds18b20测量温度。该芯片的物理化学性很稳定,它能用做工业测温元件,且此元件线形较好。在0100摄氏度时,最大线形偏差小于1摄氏度。该芯片直接向单片机传输数字信号,便于单片机处理及控制。 图3-1 温度传感器引脚图ds18b20的工作过程a初始化:ds18b20所有的数据交换都由一个初始化序列开始。由主机发出的复位脉冲和跟在其后的由ds18b20发出的应答脉冲构成。当ds18b20发出响应主机的应答脉冲时,即向主机表明它已处在总线上并且准备工作。b. rom命令:rom命令通过每个器件64-bit的rom码,使主机指定某一特定器件(如果有多个器件挂在总线上)与之进行通信。ds18b20的rom如表3-6所示,每个rom命令都是8 bit长。c. 功能命令:主机通过功能命令对ds18b20进行读/写scratchpad存储器,或者启动温度转换。 ds18b20的信号方式ds18b20采用严格的单总线通信协议,以保证数据的完整性。该协议定义了几种信号类型:复位脉冲、应答脉冲、写0、写1、读0和读1。除了应答脉冲所有这些信号都由主机发出同步信号。总线上传输的所有数据和命令都是以字节的低位在前。a.初始化序列:复位脉冲和应答脉冲b.读和写时序在写时序期间,主机向ds18b20写入指令;而在读时序期间,主机读入来自ds18b20的指令。在每一个时序,总线只能传输一位数据。读/写时序如图3-4所示。写时序存在两种写时序:“写1”和“写0”。主机在写1时序向ds18b20写入逻辑1,而在写0时序向ds18b20写入逻辑0。所有写时序至少需要60s,且在两次写时序之间至少需要1s的恢复时间。两种写时序均以主机拉低总线开始。读时序ds18b20只能在主机发出读时序时才能向主机传送数据。所以主机在发出读数据命令后,必须马上产生读时序,以便ds18b20能够传送数据。所有读时序至少60s,且在两次独立的读时序之间至少需要1s的恢复时间。3.2 主控制部分方案at89s51 是一个低功耗,高性能cmos 8位单片机,片内含8k bytes isp(in-system programmable)的可反复擦写1000次的flash只读程序存储器,器件采用atmel公司的高密度、非易失性存储技术制造,兼容标准mcs-51指令系统及80c51引脚结构,芯片内集成了通用8位中央处理器和isp flash存储单元,功能强大的微型计算机的at89s51可为许多嵌入式控制应用系统提供高性价比的解决方案。at89s51具有如下特点:40个引脚,4k bytes flash片内程序存储器,128 bytes的随机存取数据存储器(ram),32个外部双向输入/输出(i/o)口,5个中断优先级2层中断嵌套中断,2个16位可编程定时计数器,2个全双工串行通信口,看门狗(wdt)电路,片内时钟振荡器。此外,at89s51设计和配置了振荡频率可为0hz并可通过软件设置省电模式。空闲模式下,cpu暂停工作,而ram定时计数器,串行口,外中断系统可继续工作,掉电模式冻结振荡器而保存ram的数据,停止芯片其它功能直至外中断激活或硬件复位。同时该芯片还具有pdip、tqfp和plcc等三种封装形式,以适应不同产品的需求。 可以看出at89s51提供以下标准功能:4k字节flash闪速存储器,128字节内部ram,32个i/o口线,看门狗(wdt),两个数据指针,两个16位定时器/计数器,一个5向量两级中断结构,一个全双工串行通信口,片内振荡器及时钟。同时, at89s51可降至0hz的静态逻辑操作,并支持两种软件可选的节电工作模式。空闲方式停止cpu的工作,但允许ram,定时/计数器,串行通信口及中断系统继续工作。掉电方式何在ram中的内容,但振荡器停止工作并禁止其它所有部件工作直接到一个硬件复位。 图3-2at89c51引脚图 4 电路的设计 4.1总设计及电路图 图4-1具体电路连接图4.2报警电路 系统中的报警电路是由蜂鸣器,发光二极管和限流电阻组成,并与单片机的p2.3端口连接。当温度超过预设的最高温度或最低温度时,蜂鸣器发出响声。图4-2报警电路4.3显示电路lmo16l液晶模块采用hd44780控制器。hd44780具有简单而功能较强的指令集,可以实现字符移动、闪烁等功能。lmo16l液晶模块采用hd44780控制器。hd44780具有简单而功能较强的指令集,可以实现字符移动、闪烁等功能。lm016l引脚说明管脚号名称电平功能描述1 vss 0v2 vdd 5.0v3 rs h/l h:数据线上为数据信号;l:数据线上为指令信号4 rw h/l h: 读数据模式;l:写数据模式5 e h/l 使能信号端6 db0-db7 h/l 数据线 图4-3显示电路 5主程序及流程图5.1流程图 图5-1程序流程图 5.2主程序#includeuint temp,settemp=30;uchar string1=now_temp: c;uchar string2=set_temp: c;sbit key1=p32;sbit key2=p33; sbit dq=p26;sbit rs=p20;sbit rw=p21;sbit e=p22;sbit rled=p23;/sbit gled=p24;/sbit buzzer=p25;void delayms(uint xms);void delayus(uchar xus);void write_1602lcd(uchar datas,bit x);void init_1602lcd();bit init_ds18b20();uchar read_ds18b20();void write_ds18b20(uchar datas);void get_temp();void showtemp();void dangerous();void showset_temp();void init_inter();void display(uchar string);void main()init_inter();init_1602lcd();while(1)get_temp();showtemp();showset_temp();write_1602lcd(0x80,0);display(string1);write_1602lcd(0xc0,0);display(string2);void init_inter()ie=0x85;/10000101it0=1;it1=1;void delayms(uint xms)uint i,j;for(i=xms;i0;i-)for(j=110;j0;j-);void write_1602lcd(uchar datas,bit x)delayms(20);rs=x;rw=0;e=0;p0=datas;delayms(2);e=1;delayms(5);e=0;void init_1602lcd()write_1602lcd(0x38,0);write_1602lcd(0x0c,0);write_1602lcd(0x06,0);write_1602lcd(0x01,0);void delayus(uchar xus)while(-xus);bit init_ds18b20()bit status_ds18b20;dq=1;dq=0;delayus(250);dq=1;delayus(20);if(dq)status_ds18b20=1;elsestatus_ds18b20=0;delayus(250);dq=1;return(status_ds18b20);uchar read_ds18b20()uchar i,datas=0;for(i=0;i=1;dq=1;if(dq)datas|=0x80;dq=1;delayus(25); return(datas);void write_ds18b20(uchar datas) uchar i=0;for(i=0;i=1;dq=0;dq=cy;delayus(25);dq=1;void get_temp()uchar a=0,b=0;init_ds18b20();write_ds18b20(0xcc);write_ds18b20(0x44);init_ds18b20();write_ds18b20(0xcc);write_ds18b20(0xbe);a=read_ds18b20(); b=read_ds18b20();temp=b;temp8)temp=temp+1;temp_flag=1;*/temp=temp*0.0625;void showtemp()if(temp100)string19= ;elsestring19=temp/100+0x30; if(tempsettemp) dangerous();void showset_temp()if(settemp100)string29= ;elsestring29=settemp/100+0x30; if(settemp10)string210= ;elsestring210=settemp%100/10+0x30;string211=settemp%10+0x30;void dangerous()rled=0;delayms(500);rled=rled;delayms(500);void inter_it0() interrupt 0ea=0;/delayms(13);if(key1=0)settemp+;delayms(250);ea=1;void inter_it1() interrupt 2ea=0;/delayms(13);if(key2=0)settemp-;delayms(250);ea=1;void display(uchar string) uchar i=0;while(stringi!=0)write_1602lcd(stringi+,1); 结论本制作的设计中使用了at89c51单片机作为控制核心,以智能温度传感器ds18b20为温度测量元件,对各点温度进行检测,设置温度上下限,超过其温度值就报警。本设计用c语言进行编程,充分c语言更易于理解和编程。第一次做关于编程的课程设计,对我们来说都很不易,搜集各种关于温控系统的资料,回顾c语言课程,也让我充分认识到团队的力量。在工业生产和日常生活中,对温度控制系统的要求,主要是保证温度在一定温度范围内变化,稳定性好,不振荡,对系统的快速性要求不高。在论文中简单分析了单片机温度控制系统设计过程及实现方法。本系统的测温范围为-1040,温度检测系统根据用户设定的温度范围完成一定范围的温度控制。本次软件是采用模块化编程,就是把程序中的函数,定义等代码进行分类采用模块化编程的好处是,整个工程脉络清晰,代码规划合理。程序模块化,有利于代码的积累,重复使用,快速建立工程;可以将程序模块编译未lib库文件,有利于源代码的保密。 参考文献1王忠飞,胥芳mcs-51 单片机原理及嵌入式系统应用m西安:西安电子科技大学出版社,20072李广弟,朱月秀,冷祖祁.单片机基础第三版m.北京:北京航空航天大学出版社,2007.3赵娜,赵刚,于珍珠等.基于单片机的温度测量系统m. 微计算机信息,2007.裘宗燕 著,从问题到程序科学出版社,北京大学出版社,1999.4刘瑞挺主编,计算机二级教程,南开大学出版社,1996.5陈朔鹰等编著,c语言程序设计基础教程,兵器工业出版社,1994.6姜仲秋等主编,c语言程序设计,南京大学出版社,1998. 7何利民.单片机高级教程m.北京:北京航空航天大学出版社.2000.g an employment tribunal claiemployment tribunals sort out disagreements between employers and employees.you may need to make a claim to an employment tribunal if: you dont agree with the disciplinary action your employer has taken against you your employer dismisses you and you think that you have been dismissed unfairly.for more information about dismissal and unfair dismissal, seedismissal.you can make a claim to an employment tribunal, even if you haventappealedagainst the disciplinary action your employer has taken against you. however, if you win your case, the tribunal may reduce any compensation awarded to you as a result of your failure to appeal.remember that in most cases you must make an application to an employment tribunal within three months of the date when the event you are complaining about happened. if your application is received after this time limit, the tribunal will not usually accept i.if you are worried about how the time limits apply to you, take advice from one of the organisations listed underfurther help.employment tribunals are less formal than some other courts, but it is still a legal process and you will need to give evidence under an oath or affirmation.most people find making a claim to an employment tribunal challenging. if you are thinking about making a claim to an employment tribunal, you should get help straight away from one of the organisations listed underfurther help.if you are being represented by a solicitor at the tribunal, they may ask you to sign an agreement where you pay their fee out of your compensation if you win the case. this is known as adamages-based agreement. in england and wales, your solicitor cant charge you more than 35% of your compensation if you win the case.if you are thinking about signing up for a damages-based agreement, you should make sure youre clear about the terms of the agreement. it might be best to get advice from an experienced adviser, for example, at a citizens advice bureau. to find your nearest cab, including those that give advice by e-mail, click onnearest cab.for more information about making a claim to an employment tribunal, seeemployment tribunals.the (lack of) air up there watch mcayman islands-based webb, the head of fifas anti-racism taskforce, is in london for the football associations 150th anniversary celebrations and will attend citys premier league match at chelsea on sunday.i am going to be at the match tomorrow and i have asked to meet yaya toure, he told bbc sport.for me its about how he felt and i would like to speak to him first to find out what his experience was.uefa hasopened disciplinary proceedings against cskafor the racist behaviour of their fans duringcitys 2-1 win.michel platini, president of european footballs governing body, has also ordered an immediate investigation into the referees actions.cska said they were surprised and disappointed by toures complaint. in a statement the russian side added: we found no racist insults from fans of cska.age has reached the end of the beginning of a word. may be guilty in his seems to passing a lot of different life became the appearance of the same day; may be back in the past, to oneself the paranoid weird belief disillusionment, these days, my mind has been very messy, in my mind constantly. always feel oneself should go to do something, or write something. twenty years of life trajectory deeply shallow, suddenly feel something, do it.一字开头的年龄已经到了尾声。或许是愧疚于自己似乎把转瞬即逝的很多个不同的日子过成了同一天的样子;或许是追溯过去,对自己那些近乎偏执的怪异信念的醒悟,这些天以来,思绪一直很凌乱,在脑海中不断纠缠。总觉得自己自己似乎应该去做点什么,或者写点什么。二十年的人生轨迹深深浅浅,突然就感觉到有些事情,非做不可了。the end of our life, and can meet many things really do?而穷尽我们的一生,又能遇到多少事情是真正地非做不可?during my childhood, think lucky money and new clothes are necessary for new year, but as the advance of the age, will be more and more found that those things are optional; junior high school, thought to have a crush on just means that the real growth, but over the past three years later, his writing of alumni in peace, suddenly found that isnt really grow up, it seems is not so important; then in high school, think dont want to give vent to out your inner voice can be in the high school children of the feelings in a period, but was eventually infarction when graduation party in the throat, later again stood on the pitch he has sweat profusely, looked at his thrown a basketball hoops, suddenly found himself has already cant remember his appearance.童年时,觉得压岁钱和新衣服是过年必备,但是随着年龄的推进,会越来越发现,那些东西根本就可有可无;初中时,以为要有一场暗恋才意味着真正的成长,但三年过去后,自己心平气和的写同学录的时候,突然就发现是不是真正的成长了,好像并没有那么重要了;然后到了高中,觉得非要吐露出自己的心声才能为高中生涯里的懵懂情愫划上一个句点,但毕业晚会的时候最终还是被梗塞在了咽喉,后来再次站在他曾经挥汗如雨的球场,看着他投过篮球的球框时,突然间发现自己已经想不起他的容颜。originally, this world, can produce a chemical reaction to an event, in addition to resolutely, have to do, and time.原来,这个世界上,对某个事件能产生化学反应的,除了非做不可的坚决,还有,时间。a persons time, your ideas are always special to clear. want, want, line is clear, as if nothing could shake his. also once seemed to be determined to do something, but more often is he backed out at last. dislike his cowardice, finally found that there are a lot of love, there are a lot of miss, like shadow really have been doomed. those who do, just green years oneself give oneself an arm injection, or is a self-righteous spiritual.一个人的时候,自己的想法总是特别地清晰。想要的,不想要的,界限明确,好像没有什么可以撼动自己。也曾经好像已经下定了决心去做某件事,但更多的时候是最后又打起了退堂鼓。嫌恶过自己的怯懦,最终却发现有很多缘分,有很多错过,好像冥冥之中真的已经注定。那些曾经所谓的非做不可,只是青葱年华里自己给自己注射的一支强心剂,或者说,是自以为是的精神寄托罢了。at the moment, the sky is dark, the air is fresh factor after just rained. suddenly thought of blue plaid shirt; those were broken into various shapes of stationery; from the corner at the beginning of deep friendship; have declared the end of the encounter that havent start planning. those years, those days of do, finally, like youth, will end in our life.此刻,天空是阴暗的,空气里有着刚下过雨之后的清新因子。突然想到那件蓝格子衬衫;那些被折成各种各样形状的信纸;那段从街角深巷伊始的友谊;还有那场还没有开始就宣告了终结的邂逅计划那些年那些天的非做不可,终于和青春一样,都将在我们的人生中谢幕。baumgartner the disappointing news: mission aborted. r plays an important role in this mission. starting at the ground, conditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud cover. the balloon, with capsule attached, will move through the lower level of the atmosphere (the troposphere) where our day-to-day weather lives. it will climb higher than the tip of mount everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere. as he crosses the boundary layer (called the tropopause),e can expect a lot of turbulence.the supersoni

温馨提示

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

评论

0/150

提交评论