基于51单片机的数字温度计课程设计毕业论文 .docx
- 格式:docx
- 大小:575.78 KB
- 文档页数:20
基于MCS-51系列单片机的数字温度计设计基于MCS-51系列单片机的数字温度计设计摘要本文提出了基于MCS-51系列单片机的数字温度计的制作电路和编程思想。
该数字温度计以宏晶公司的STC89C52 单片机为主控,配以达拉斯公司的DS18B20数字温度传感器,采用1602双行英文字符液晶作显示。
实现了对温度的测量,显示,和报警等功能。
关键词:STC89C52单片机;数字传感器DS18B20;显示器LCD;目录摘要 (I)ABSTRACT ........................... 错误!未定义书签。
1 绪论 (4)1.1 选题的背景 (4)1.2 数字温度计简介 (4)1.2.1 数字温度计的特征 (4)1.2.2 设计实现的目标 (5)2 数字温度计的方案设计 (6)2.1 设计方案论证与比较 (6)2.1.1 显示电路方案 (6)2.1.2 测温电路方案 (6)2.2 系统总体方案 (6)3 数字温度计的硬件电路设计 (8)3.1 控制电路 (8)3.1.1 MCU简介 (8)3.2.2 最小系统模块 (9)3.3 温度传感器设计 (10)3.3.1 DS18B20简介 (10)3.3.2 温度传感器与单片机的连接 (12)3.3.3 复位信号及外部复位电路 (13)3.4 单片机与报警电路 (13)3.5 显示电路 (13)4 软件设计 (15)4.1 DS18b20的读操作 (15)4.2 DS18b20的温度数据处理 (16)4.3 1602显示部分 (17)5 数据测试 (20)参考文献 (22)附录1 程序源代码................ 错误!未定义书签。
1 绪论1.1 选题的背景随着现代信息技术的飞速发展和传统工业改造的逐步实现.能够独立工作的温度检测和显示系统应用于诸多领域。
传统的温度检测以热敏电阻为温度敏感元件。
热敏电阻的成本低,但需后续信号处理电路,而且可靠性相对较差,测温准确度低,检测系统也有一定的误差。
安徽广播电视大学毕业设计(论文)分校名称教学点名称年级名称专业名称机电一体化(本科)课题名称基于ms51单片机的数字温度计设计学生姓名指导教师2016年5月摘要随着时代的进步和发展,单片机技术已经普及到我们生活,工作的方方面面,能够独立工作的温度检测和显示系统已经应用于诸多领域。
传统的温度检测以热敏电阻为温度敏感元件,热敏电阻成本低,但需要接信号处理电路,而且热敏电阻的可靠性较差,测量温度的准确度低,检测系统的精度差。
而今电子技术和微型计算机的迅速发展,采用单片机进行温度检测、数值显示和数据的传送,具有效率高、性能稳定等优点,还可以实现实时实地控制等技术要求,在工业生产中应用越来越广泛。
单片机已经走进了我们的生活,并有了不可替代的地位。
而在工业五大基本参数中,温度的测量尤其广泛,可见精确的温度对于工业发展来看有多大的作用。
本文将介绍一种基于单片机的简单数字温度计,本温度计可以精确地测量并显示温度,并实现上下限的报警功能。
关键词:单片机、数字温度计、DS18B20、AT89S51ABSTRACTWith the progress and development of the times, SCM technology has spread to our lives, work in all aspects, to work independently of the temperature detection and display system has been applied in many fields. The traditional temperature measurement with a thermistor as a temperature sensitive element, the cost of the thermistor is low, but the need is connected with a signal processing circuit and poor reliability of thermistor, temperature measurement accuracy is low, the detection system of precision. Now the rapid development of electronic technology and microcomputer, the use of single-chip temperature detection, data display and data transmission, with the advantages of high efficiency and stable performance, but also can realize the requirement of real-time field control technology, in industrial production is applied more and more widely. SCM has come into our lives, and has an irreplaceable position. In the five basic parameters of the industry, the temperature measurement is particularly wide, and the precise temperature can be seen for industrial development. This paper introduces a simple digital thermometer based on single chip microcomputer, the thermometer can accurately measure and display the temperature, and realize the upper and lower alarm function.KEY WORDS:AT89S51,DS18B20,Singlechip,Digital thermometer目录1、绪论 (1)1.1课题背景 (1)1.2温度计的介绍 (1)1.3课题研究的目的和意义 (3)1.4国内外研究现状 (4)2、系统方案的设计与论证 (6)2.1系统的控制特点与性能要求 (6)2.2系统的实现原理 (6)2.3系统的实现方案分析 (7)2.4方案的分析比较 (8)3、系统硬件及其电路的选择 (10)3.1系统硬件的选择 (10)3.2主电路搭建 (12)3.3显示电路 (13)3.4外围电路建立 (14)4、系统的软件设计 (16)4.1软件K EIL介绍 (16)4.2程序介绍 (17)5、总结 (21)6、致谢 (22)附录:参考文献 (23)附录:程序代码 (24)1、绪论1.1 课题背景工农业生产中经常需要测量温度。
摘要:温度和湿度是两个最基本的环境参数,人们生活与温湿度息息相关。
在日常生活、工业、医学、环境保护、化工、石油等领域,经常需要对环境温度和湿度进行测量和控制。
准确测量温湿度在生物制药、食品加工、造纸等行业更是至关重要。
因此研究温湿度的测量方法和装置具有重要的意义。
随着科技的不断发展,单片机技术已经普及到我们生活、工作、科研等各个领域,已经成为一种比较成熟的技术。
由于单片机集成度高、功能强、可靠性高、体积小、功耗低、使用方便、价格低廉等一系列有点,目前已经渗入到人们工作和生活的方方面面。
本论文介绍了一种以单片机AT89C51为主要控制器件,以DHT11为数字温湿度传感器的新型数字温湿度计。
本设计主要包括硬件电路的设计和系统软件的设计、硬件电路主要包括主控制器,测量温湿度控制电路和显示电路等。
关键词:温湿度传感器;LCD1602;protel;keil 软件Digital Thermometer and humidity Based onSingle Chip MicrocomputerAbstract :Temperature and humidity are the two most basic environmental parameters, which are closely related to people's lives and the temperature and humidity. Temperature and humidity measurement and control are often needed to ambient in the field of daily life, industry, medicine, environmental protection, chemical, petroleum, etc.,. Accurate measurement of temperature and humidity in the pharmaceutical, food processing, paper industry is essential. Therefore, studying the temperature and humidity measurement methods and devices is of great significance.This paper describes a microcontroller AT89S52 control devices, digital temperature and humidity sensors to DHT11 new digital hygrometer. The design includes the design of hardware circuits and system software design, hardware circuit includes a master controller, the measurement of temperature and humidity control circuit and display circuit. DHT11 is a composite Sensor contains a calibrated digital signal output of the temperature and humidity. Application of a dedicated digital modules collection technology and the temperature and humidity sensing technology, to ensure that the product has a Song high reliability and excellent long-term stability. Display circuit LCD1602 LCD display, 8-bit microprocessor interface, mapped by the internal 80 ×8-bit DDRAM 2 line x 16 character display, convenient and intuitive. The software part includes the main program, the measured temperature and humidity subroutine to display subroutine. The digital hygrometer with DHT11 with AT89S52 not only has the simple external circuit, but also facilitate debugging and simulation.Keywords:Temperature and humidity sensor; the LCD1602; protell; keil software目录1 绪论 (1)1.1 选题意义 (1)1.2 国内外发展趋势 (1)2 温湿度计的发展 (3)2.1 温度计的发展史 (3)2.2 湿度测量方法 (3)3 开发工具keil和protel (5)3.1 Keil C51 (5)3.1.1 keil 软件简介 (5)3.1.2 建立一个C项目 (5)3.1.3 如何生成.HEX文件 (10)3.2 protel软件 (12)3.2.1 软件简介 (12)3.2.2 功能特点 (12)3.2.3 设计环境 (13)3.2.4 电路原理图设计流程 (14)3.2.5 protel基本操作 (14)3.3 本章小结 (18)4 系统方案设计 (19)4.1 系统设计 (19)4.2 方案论证 (19)4.2.1 主控制器芯片 (19)4.2.2 温湿度采集模块 (22)4.2.3 显示模块 (28)4.3 本章小结 (30)5 硬件电路设计 (31)5.1 复位电路设计 (31)5.2 时钟电路设计 (31)5.3 显示模块电路设计 (32)5.4 温湿度采集模块设计 (33)5.5 电源选择 (33)5.6 本章小结 (34)6 软件设计及联合调试 (35)6.1 设计思路与流程图 (35)6.1.1 主程序设计 (35)6.1.2 LCD1602液晶驱动流程图 (36)6.2 程序的设计 (36)6.3 联合调试 (42)6.4 本章小结 (42)结论 (43)参考文献 (44)致谢 (45)1 绪论1.1 选题意义随着科技的不断发展,现代社会对各种信息参数的准确度和精确度的要求都有了几何级的增长,而如何准确而迅速的获得这些参数就需要受制于现代信息基础的发展水平、在三大信息采集、信息传输和信息处理中,传感器属于信息技术的前沿尖端产品,尤其是温湿度传感器技术,在我国各领域已经引用的非常广泛,可以说是渗透到社会的每一个领域。
基于单片机的数字温度计的设计与实现摘要采用单片机来对他们控制不仅具有控制方便,简单和灵活性大等优点,而且可以大幅度提高被控温度的技术指标,从而能够大大的提高产品的质量和数量。
在生产过程中,为了高效地进行生产,必须对它的主要参数,如温度、压力、流量等进行有效的控制。
传统的测温元件有热电偶和二电阻。
而热电偶和热电阻测出的一般都是电压,再转换成对应的温度,这些方法相对比较复杂,需要比较多的外部硬件支持。
我们用一种相对比较简单的方式来测量。
温度范围为-55~125 ºC,最高分辨率可达0.0625 ºC。
DS18B20可以直接读出温度值,而且采用三线制与单片机相连,减少了外部的硬件电路,具有低成本和易使用的特点。
本文介绍一种基于AT89C51单片机的一种温度测量及报警电路,该电路采用DS18B20作为温度监测元件,测量范围0℃-~+100℃,使用七级数码管LED模块显示,能设置温度报警上下限。
正文着重给出了软硬件系统的各部分电路,介绍了集成温度传感器DS18B20的原理,AT89C51单片机功能和应用,该电路设计新颖、功能强大、结构简单。
关键词:温度测量;DS18B20 ; AT89C51Design of Digital Thermomer Based on SCMABSTRACTControlled by single-chip microcomputer to control not only to them, advantages of simplicity and flexibility, and can significantly increase the temperature specifications, which can significantly increase the quality and quantity of the products. In the process of production, in order to efficiently produce, it must be the main parameters, such as temperature, pressure, flow, and other effective control. Traditional temperature measuring component thermocouple and resistance. Are generally voltage of thermocouple and thermal resistance measured, then converted to the corresponding temperature, these methods are relatively complex and requires more external hardware support. We are in a relatively simple way to measure.-55~125 ºc temperature range, maximum resolution up to 0.0625 ºc. DS18B20 can read temperature value, and wire connected to the microcontroller, reduced external hardware circuits, low cost and ease of use features.The introduction of a cost-based AT89C51 MCU a temperatur measurement circuits, the circuits used DS18B20 high-precision temperatur sensor, measuring scope 0℃-~+100℃,can set the warning limitation, the use of Seven digital tube seven segments LED that can be display the current temperature. The paper focuses on providing a software and hardware system components circuit, introduced the theory of DS18B20, the founctions and applications of AT89C51 .This circuit design innovative, powerful, can be expansionary strong.Keywords:Temperature measurement ;DS18B20 ;AT89C51目录摘要 (I)ABSTRACT (II)第一章绪论 (1)1.1 引言 (1)1.1.1 国内外现状 (1)1.1.2 课题背景及研究意义 (2)1.2 设计内容及性能指标 (2)1.3 系统概述 (3)1.3.1 系统方案论证与比较 (3)1.3.2 系统设计原理与组成 (5)第二章开发工具Proteus与Keil (6)2.1 Proteus软件 (6)2.1.1 Proteus简介 (6)2.1.2 4大功能模块 (6)2.1.3 Proteus简单应用 (8)2.2 Keil软件 (8)2.2.1 Keil软件简介 (8)2.2.2 Keil软件调试功能 (9)第三章系统硬件设计 (10)3.1 单片机的选择 (10)3.1.1 AT89C51单片机的介绍 (10)3.1.2 AT89C51单片机主要特性 (11)3.2 温度传感器的选择 (13)3.3 硬件电路设计 (17)第四章系统软件设计 (20)4.1 各模块的程序设计 (20)4.2 Protues测温仿真 (25)4.3 系统调试 (28)4.4 结果分析 (30)结论 (31)致谢 (32)参考文献 (33)附录1 全部程序清单 (34)附录2 系统总体设计图 (41)第一章绪论1.1引言1.1.1 国内外现状温度控制系统在国内各行各业的应用虽然已经十分广泛,但从国内生产的温度控制器来讲,总体发展水平仍然不高,同日本、美国、德国等先进国家相比,仍然有着较大的差距。
基于51单片机的数字温度计设计Abstract:With the development of technology, the measurement and analysis of temperature data have become increasingly important. In this paper, we present the design and development of a digital thermometer based on 51 single-chip microcomputer, which can accurately measure and display the temperature. The thermometer uses a thermistor as the temperature sensing element, and adopts the method of hardware compensation to improve the accuracy of temperature measurement. The microcontroller is responsible for signal processing, arithmetic operations, and display control. Through debugging and testing, the thermometer meets the design requirements and has good stability and accuracy. This design has broad application prospects in many fields.Keywords: digital thermometer, 51 single-chip microcomputer, thermistor, hardware compensation, temperature measurement, signal processing, display control.Introduction:Temperature measurement is one of the important basic technologies in many fields such as industry, agriculture, medicine, and environmental protection. In recent years, with the rapid development of microelectronics technology, digital temperature measurement technology has become increasingly mature and widely used. A digital thermometer can accurately measure and display the temperature, and has the advantages of small size, low power consumption, and high accuracy. Therefore, it has become an important research topic in thefield of temperature measurement.In this paper, we present the design and development of a digital thermometer based on 51 single-chip microcomputer. The thermometer uses a thermistor as the temperature sensing element, and adopts the method of hardware compensation to improve the accuracy of temperature measurement. The microcontroller is responsible for signal processing, arithmetic operations, and display control. Through debugging and testing, the thermometer meets the design requirements and has good stability and accuracy. This design has broad application prospects in many fields.System Design:The system architecture of the digital thermometer is shown in Figure 1. The thermometer consists of a temperature sensing module, a signal conditioning module, a microcontroller module, and a display module. The temperature sensing module uses a thermistor as the sensing element, and converts the temperature into a voltage signal. The signal conditioning module amplifies and filters the voltage signal, and sends it to the microcontroller module. The microcontroller module is responsible for signal processing, arithmetic operations, and display control. The display module displays the temperature value in real-time.The thermistor is a temperature-sensitive resistor. Its resistance changes with temperature. The relationship between resistance and temperature is non-linear. The temperature sensing module uses a voltage divider circuit to convert the resistance change of the thermistor into a voltage signal. The voltage signal is amplified by an operational amplifier, and filtered by a low-pass filter. The signal conditioning module outputs a stable and accurate voltage signal to themicrocontroller module.The microcontroller module uses a 51 single-chip microcomputer as the core. The program is written in C language, and compiled by Keil C51 development software. The microcontroller module is responsible for A/D conversion, signal processing, arithmetic operations, display control, and temperature compensation. The display module uses a 7-segment LED digital tube to display the temperature value in real-time.The thermometer uses the method of hardware compensation to improve the accuracy of temperature measurement. The compensation algorithm is embedded in the program of the microcontroller module. When the temperature changes, the microcontroller module can automatically adjust the compensation parameters, and improve the accuracy of temperature measurement.Figure 1. System architecture of the digital thermometer.Experimental Results:The digital thermometer was implemented on a prototype board. The temperature measurement range is from -50℃ to 120℃, and the resolution is 0.1℃. The thermometer has the function of temperature conversion between Celsius and Fahrenheit. The thermometer has a high accuracy, with anerror of ±0.5℃. The thermometer has good stability and fast response time.Figure 2. Prototype of the digital thermometer.Conclusion:In this paper, we presented the design and developmentof a digital thermometer based on 51 single-chip microcomputer. The thermometer uses a thermistor as the temperature sensing element, and adopts the method ofhardware compensation to improve the accuracy of temperature measurement. The microcontroller module is responsible for signal processing, arithmetic operations, and display control. Through debugging and testing, the thermometer meets the design requirements and has good stability and accuracy. This design has broad application prospects in many fields such as industry, agriculture, and environmental protection. Further research can be done to improve the functionality and expand the application range of the thermometer.。
毕业论文声明本人郑重声明:1.此毕业论文是本人在指导教师指导下独立进行研究取得的成果。
除了特别加以标注地方外,本文不包含他人或其它机构已经发表或撰写过的研究成果。
对本文研究做出重要贡献的个人与集体均已在文中作了明确标明。
本人完全意识到本声明的法律结果由本人承担。
2.本人完全了解学校、学院有关保留、使用学位论文的规定,同意学校与学院保留并向国家有关部门或机构送交此论文的复印件和电子版,允许此文被查阅和借阅。
本人授权大学学院可以将此文的全部或部分内容编入有关数据库进行检索,可以采用影印、缩印或扫描等复制手段保存和汇编本文。
3.若在大学学院毕业论文审查小组复审中,发现本文有抄袭,一切后果均由本人承担,与毕业论文指导老师无关。
4.本人所呈交的毕业论文,是在指导老师的指导下独立进行研究所取得的成果。
论文中凡引用他人已经发布或未发表的成果、数据、观点等,均已明确注明出处。
论文中已经注明引用的内容外,不包含任何其他个人或集体已经发表或撰写过的研究成果。
对本文的研究成果做出重要贡献的个人和集体,均已在论文中已明确的方式标明。
学位论文作者(签名):年月关于毕业论文使用授权的声明本人在指导老师的指导下所完成的论文及相关的资料(包括图纸、实验记录、原始数据、实物照片、图片、录音带、设计手稿等),知识产权归属华北电力大学。
本人完全了解大学有关保存,使用毕业论文的规定。
同意学校保存或向国家有关部门或机构送交论文的纸质版或电子版,允许论文被查阅或借阅。
本人授权大学可以将本毕业论文的全部或部分内容编入有关数据库进行检索,可以采用任何复制手段保存或编汇本毕业论文。
如果发表相关成果,一定征得指导教师同意,且第一署名单位为大学。
本人毕业后使用毕业论文或与该论文直接相关的学术论文或成果时,第一署名单位仍然为大学。
本人完全了解大学关于收集、保存、使用学位论文的规定,同意如下各项内容:按照学校要求提交学位论文的印刷本和电子版本;学校有权保存学位论文的印刷本和电子版,并采用影印、缩印、扫描、数字化或其它手段保存或汇编本学位论文;学校有权提供目录检索以及提供本学位论文全文或者部分的阅览服务;学校有权按有关规定向国家有关部门或者机构送交论文的复印件和电子版,允许论文被查阅和借阅。
(完整)基于51单片机的数字温度计设计编辑整理:尊敬的读者朋友们:这里是精品文档编辑中心,本文档内容是由我和我的同事精心编辑整理后发布的,发布之前我们对文中内容进行仔细校对,但是难免会有疏漏的地方,但是任然希望((完整)基于51单片机的数字温度计设计)的内容能够给您的工作和学习带来便利。
同时也真诚的希望收到您的建议和反馈,这将是我们进步的源泉,前进的动力。
本文可编辑可修改,如果觉得对您有帮助请收藏以便随时查阅,最后祝您生活愉快业绩进步,以下为(完整)基于51单片机的数字温度计设计的全部内容。
基于51单片机的数字温度计设计一.课题选择随着时代的发展,控制智能化,仪器小型化,功耗微量化得到广泛关注。
单片机控制系统无疑在这方面起到了举足轻重的作用。
单片机的应用系统设计业已成为新的技术热点,其中数字温度计就是一个典型的例子,它可广泛应用与生产生活的各个方面,具有巨大的市场前景。
二.设计目的1.理解掌握51单片机的功能和实际应用。
2.掌握仿真开发软件的使用。
3.掌握数字式温度计电路的设计、组装与调试方法。
三.实验要求1.以51系列单片机为核心器件,组成一个数字式温度计.2.采用数字式温度传感器为检测器件,进行单点温度检测。
3.温度显示采用4位LED数码管显示,三位整数,一位小数。
四.设计思路1.根据设计要求,选择STC89C51RC单片机为核心器件。
2.温度检测采用DS18B20数字式温度传感器。
与单片机的接口为P3。
6引脚.3.采用usb数据线连接充电宝供电,接电后由按钮开关控制电路供电。
硬件电路设计总体框图为图1:五.系统的硬件构成及功能1.主控制器单片机STC89C51RC具有低电压供电和体积小等特点,有40个引脚,其仿真图像如下图所示:2.显示电路显示电路采用4位共阳LED数码管,从P3口RXD,TXD串口输出段码。
LED数码管在仿真软件中如下图所示:3.温度传感器DS18B20是美国DALLAS半导体公司最新推出的一种改进型智能温度传感器,与传统的热敏电阻等测温元件相比,它能直接读出被测温度,并且可根据实际要求通过简单的编程实现9~12位的数字值读数方式。
安徽农业大学课程设计报告基于单片机的DS18B20数字温度计设计学生姓名杜恒院系名称物理与电子工程学院专业名称电子信息工程班级2008 级 6 班学号指导教师汪文蝶完成时间2011年 5 月 20 日基于单片机的DS18B20数字温度计设计学生姓名:杜恒指导老师:汪文蝶内容摘要:随着现代信息化技术的飞速发展和传统工业改造的逐步实现,能独立工作的温度检测系统已广泛应用于各种不同的领域。
本文介绍了一个基于STC89C52单片机和数字温度传感器DS18B20的测温系统,并用LED数码管显示温度值,易于读数。
系统电路简单、操作简便,能任意设定报警温度并可查询最近的10个温度值,系统具有可靠性高、成本低、功耗小等优点。
关键词:单片机数字温度传感器温度计1 引言 (4)2 设计要求 (4)2.1 基本要求 (4)2.2 扩展功能 (4)3 总体方案设计 (4)3.1 方案论证 (4)3.1.1 方案一 (4)3.1.2 方案二 (5)3.2 总体设计框图 (5)4 硬件设计 (5)4.1 单片机系统 (5)4.2 数字温度传感器模块 (6)4.2.1 DS18B20性能 (6)4.2.2 DS18B20外形及引脚说明 (7)4.2.3 DS18B20接线原理图 (7)4.2.4 DS18B20时序图 (7)4.2.5 数据处理 (9)4.3 显示电路 (10)4.4 声光报警电路 (10)4.5 键盘输入电路 (11)5 软件设计 (11)5.1 主程序模块 (11)5.2 读温度值模块 (12)5.3 中断模块 (14)5.4 温度查询模块 (15)5.5 温度设定、报警模块 (16)5.6 数码管驱动模块 (18)6 源程序 (19)7 总结 (26)参考文献: (28)1 引言随着人们生活水平的不断提高,单片机控制无疑是人们追求的目标之一,它所给人带来的方便是不可否定的,各种数字系统的应用也使人们的生活更加舒适。
图2.1AT89S51引脚图
的引脚及基本性能:
是美国ATMEL公司生产的低电压、高性能CMOS8位单片机
字节的可反复擦写的只读程序存储器(PEROM)和128字节的随机存取数据存储器AMTEL公司的高密度、非易失性存储技术生产,兼容标准片内置通用2位中央处理器(CPU)和Flash存储单元,功能强大的
单片机可为您提供许多高性价比的应用场合,可灵活应用于各种控制领域。
功能特性概
2.5 AD590基本应用电路图
℃而言,输出值为时,不可分出任何电流,否则测量值不准。
图2.8 TLC431内部等效图
图2.10 TLC549引脚图
2.11 显示电路图
2.12按钮电路连接图2.13报警电路图
图2.14 +5v直流稳压电源设计图。
数字测温计设计摘要:随着时代的进步和发展,单片机技术已经普及到我们生活、工作、科研、各个领域,已经成为一种比较成熟的技术。
在工业生产中温度是常用的被控参数,而采用单片机来对这些被控参数进行控制已成为当今的主流。
本文介绍了基于AT89S51单片机的测温系统,描述了利用DS18B20开发测温系统的过程,对传感器在单片机下的硬件连接,软件编程以及各模块系统流程进行了详实的分析,对各部分的电路也逐一进行了介绍,该系统灵活的实现了温度采集和显示,且可设定上下限报警温度,使用起来十分方便,适合于我们日常生活和生产中的温度测量,该系统结构相对简单,抗干扰能力较强,适合于不同环境下温度测量,有着广阔的应用前景。
关键词:AT89S51单片机DS18B20 温度测量Abstract:With the progress and development of era,microcontroller technology has become popular in our life,in the work,the scientific research and various fields,has become a relatively mature technology.The temperature measurement method and device of the highlights is very important.Posed by the single chip temperature sensor and temperature measurement system can be widely applied in many fields.目录第1章绪论 (1)1.2 选题的目的和意义 (1)1.2.1选题的目的 (1)1.2.2选题的意义 (1)第2章数字温度计的设计方案 (4)2.1 设计方案的确立及论证 (4)2.1.1 温度传感器DS18B20的选择 (4)2.1.2 显示器的选择 (5)2.1.3 单片机STC89C52的选择 (5)第3章系统硬件电路的设计 (4)3.1 主控制器 (4)3.1.1 AT89S51的介绍 (4)3.1.2 DS18B20的介绍 (9)3.1.3 DS18B20使用的注意事项 ......................................... 错误!未定义书签。
摘要温度的检测与控制是工业生产过程中比较典型的应用。
本设计以AT89C52 单片机为核心,采用DS18B20温度传感器检测温度,由温度采集、温度显示,温度报警等功能模块组成。
基于题口基木要求,本系统对温度采集和温度显示系统行了重点设计。
木系统大部分功能能由软件实现,吸收了硬件软件化的思想。
实际操作时,各功能在开发板上也能完美实现。
本系统实现了要求的基本功能,其余发挥部分也能实现。
关键字:AT89C52单片机、DS18B20温度传感器、数码管显示、温度采集目录绪论 ................................................ 二•设计目的.............................................三.设计要求.............................................四.设计思路.............................................五.系统的硬件构成及功能.................................5.1主控制器...........................................5.2显示电路...........................................5.3温度传感器.........................................六.系统整体硬件电路.....................................七.系统程序设计.........................................八.测量及其结果分析.....................................九.设计心得体会.........................................十.参考文献.............................................. 附录1源程序附录2元件清单及PCB图一. 绪论随着时代的发展,控制智能化,仪器小型化,功耗微量化得到广泛关注。
单片机控制系统无疑在这些忙面起到了举足轻重的作用。
单片机的应用系统 设计业已成为新的技术热点,其中数字温度计就是一个典型的例子。
人民的生活与环境的温度息息相关,在工业生产过程中需要实时测量温 度,在农业生产中也离不开温度的测量,因此研究温度的测量方法和装置具 有重要的意义。
测量温度的关键是温度传感器,温度传感器的发展经历了三个发展阶段: ① 传统的分立式温度传感器 ② 模拟集成温度传感器 ③ 智能集成温度传感器。
目前的智能温度传感器(亦称数字温度传感器)是在20世纪90年代中期 问世的,它是微电子技术、计算机技术和自动测试技术(ATE)的结晶,特点 是能输出温度数据及相关的温度控制量,适配各种微控制器(MCU)O 社会的 发展使人们对传感器的要求也越来越高,现在的温度传感器正在基于单片机 的基础上从模拟式向数字式,从集成化向智能化、网络化的方向飞速发展, 并朝着高精度、多功能、总线标准化、高可靠性及安全性、开发虚拟传感器 和网络传感器、研制单片测温系统等高科技的方向迅速发展,与传统的温度 计相比,其具有读数方便,测温范围广,测温准确,输出温度采用数字显示, 主要用于对测温要求比较准确的场所,或科研实验室使用。
该设计控制器使 用ATMEL 公司的AT89C52单片机,测温传感器使用DALLAS 公司 DS18B20,用数码管来实现温度显示。
二. 设计目的1. 理解掌握MCS-51系列单片机的功能和实际应用。
2. 掌握仿真开发软件的使用。
3•掌握数字式温度计电路的设计、组装与调试方法。
三. 设计要求1. 以MCS-51系列单片机为核心器件,组成一个数字式温度计。
2•采用数字式温度传感器为检测器件,进行单点温度检测,检测精度为±0.5 °C 3•温度显示采用4位LED 数码管显示,三位整数,一位小数。
4.具有键盘输入上下限功能,超过上下限温度时,进行声音报警。
1・根据设计要求,选择AT89C52单片机为核心器件。
设计思路2•温度检测器件采用DS18B20数字式温度传感器。
与单片机的接口为 P3.6引脚。
3•键盘采用独立式按键,由三个按键组成,分别是:设置键(SET ), 加一建(+1),确认键(RET ) oSET 键(上下限温度设置键):当该键按下时,进入上下限温度设置功 能。
通过P3.1引脚接入。
+ 1键(加一调整键):在输入上下限温度时,该键按下一次,被调整 位加一。
通过P3.2引脚接入。
RET 键(确认键):当该键按下时,指向下一个要调整的位。
通过P3.3 引脚接入。
4.声音报警蜂鸣器通过P1.7引脚接入。
硬件电路设计总体框图为图4.1:图4.1五、系统的硬件构成及功能1.主控制器单片机AT89S52具有低电压供电和体积小等特点,四个端口只需要两个口就 能满足电路系统的设计需要,使用Atmel 公司高密度非易失性存储器技术制 造,与工业80C51产品指令和引脚完全兼容。
片上Flash 允许程序存储器 在系统可编程,亦适于常规编程器。
很适合便携手持式产品的设计使用。
AT89S52在仿真软件中的图像为图5. 1时钟电路复 位电路LED 显示器驱动—\3 位 LED 电路显示器温度检测按键输入电 路单片机蜂鸣器电路19图5. 12. 显示电路显示电路采用四位共阳LED 数码管,从P3 口 RXD, TXD 串口输岀段码。
LED 数码管在仿真软件中如图5. 2图5.23. 温度传感器DS18B20是美国DALLAS 半导体公司最新推出的一种改进型智能温度传 感器,与传统的热敏电阻等测温元件相比,它能直接读出被测温度,并且可根据 实际要求通过简单的编程实现9〜1 2位的数字值读数方式。
DS18B20的性能 特点如下:•独特的单线接口仅需一个端口引脚进行通讯►XTAL118XTAL2RSTPO.O/ADO P0.1/AD1 P0.2/AD2 P0.3/AD3 P0.4/AD4 P0.5/AD5 P0.6/AD6 P0.7/AD7 29 30 3?1 2 3 4 5 6 7PSEN ALE EAP2.0/A8 P2.1/A9 P2.2/A10 P2.3/A11 P2.4/A12 P2.5/A13 P2.6/A14 P2.7/A15 P1.0/T2 P1.1fT2EX P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 P3.0/RXD P3.1/TXD P3.2/INT0 P3.3/^ITTP3.4/T0 P3.5E P3.6/WR P3.7/RDAT89C52393837363534 33322122 23 24 25 26 2728101112 13141517•简单的多点分布应用 •无需外部器件 •可通过数据线供电 •零待机功耗•测温范围-55〜+125°C,以0.5°C 递增。
华氏器件-67〜+2570F,以0.90F 递增 •温度以9位数字量读出•温度数字量转换时间200ms (典型值) •用户可定义的罪易失性温度报警设置•报警搜索命令识别并标志超过程序限定温度(温度报警条件)的器件。
DS18B20内部结构主要由四部分组成:64位光刻ROM 、温度传感器、非挥发的 温度报警触发器TI1和TL 、配置寄存器。
DS18B20的管脚排列、各种封装形式如图3. 3.1所示,DQ 为数据输入/输出引脚。
开漏单总线接口引脚。
当被用着在寄生 电源下,也可以向器件提供电源;GND 为地信号;VDD 为可选择的VDD 引脚。
当工 作于寄生电源时,此引脚必须接地。
其电路图如图5. 3.1所示・。
图5.3.1外部封装形式在仿真软件中如图5. 3. 2所示DS18B20的测温原理如图5. 3. 3所示,图中低温度系数晶振的振荡频率受温度的影响很小用于产生固定频率的脉冲信号送给减法计数器1,高温度系数晶振 随温度变化其震荡频率明显改变,所产生的信号作为减法计数器2的脉冲输入, 图中还隐含着计数1 8127136145PACKAGENCNCV DODQNCNC NCGNDS18B20Z8-PIN SOIC (150-MIL)DS18B20P TSOCZJN ZJN ZZINBOTTOM VIEWDALLASDS1820DS18B20 TO-92GND 匚 1 DQEz] 2V DD图5. 3.2门,当计数门打开时,DS18B20就对低温度系数振荡器产生的时钟脉冲后进行计数,进而完成温度测量•计数门的开启时间由高温度系数振荡器来决定,每次测量前,首先将-55 °C所对应的基数分别置入减法计数器1和温度寄存器中,减法计数器1和温度寄存器被预置在-55 *所对应的一个基数值。
减法计数器1对低温度系数晶振产生的脉冲信号进行减法计数,当减法计数器1的预置值减到0时温度寄存器的值将加1,减法计数器1的预置将重新被装入,减法计数器1重新开始对低温度系数晶振产生的脉冲信号进行计数,如此循环直到减法计数器2计数到0时,停止温度寄存器值的累加,此时温度寄存器中的数值即为所测温图5.3.3中的斜率累加器用于补偿和修正测温过程中的非线性其输出用,于修正减法计数器的预置值,只要计数门仍未关闭就重复上述过程, 直至温度寄存器值达到被测温度值,这就是DS18B20的测温原理。
另外,由于DS18B20单线通信功能是分时完成的,有严格的时隙概念,因此读写时序很重要。
系统对DS18B20的各种操作必须按协议进行。
操作协议为:初始化DS18B20C发复位脉冲)一发ROM功能命令一发存储器操作命令一处理数据。
图 5. 3. 3在正常测温情况下,DS1820的测温分辨力为0. 5°C,可采用下述方法获得高分辨率的温度测量结果:首先用DS1820提供的读暂存器指令(BEH)读出以0. 5°C 为分辨率的温度测量结果,然后切去测量结果中的最低有效位(LSB),得到所测实际温度的整数部分Tz,然后再用BEH指令取计数器1的计数剩余值Cs和每度计数值CD。
考虑到DS1820测量温度的整数部分以0・25°C、0. 75°C为进位界限的关系,实际温度Ts可用下式计算:心=(及一O・25°C) + (CD・Cs) /CD表1 •部分温度值对应的二进制温度数据。
六.系统整体硬件电路根据设计要求与设计思路,硬件电路设计框图如图6.1所示,在仿真软件Proteus上完成。
其中LED数码管以动态扫描法实现温度显示,由四个PNP型晶体管Q2, Q3, Q4, Q5和八个电阻组成,基极与单片机的P1.0, P1丄P1.2连接。