内容发布更新时间 : 2024/11/15 16:51:30星期一 下面是文章的全部内容请认真阅读。
河南科技学院
2010 届本科毕业设计
设计题目:基于单片机的温度控制系统的设计与实现
学生姓名:
所在院系:
所学专业:
导师姓名:
完成时间: 2011-05-25
摘要
本论文介绍了一种以AT公司的89S52 单片机为主要控制元件,通过DALLAS公司的DS18S20 温度传感器测温的新型数字温度计。主要包括硬件电路的设计和系统程序的设计。硬件电路主要包括主控制器,测温电路和显示电路等,主控制器采用单片机AT89S52,温度传感器采用美国DALLAS 半导体公司生产的DS18S20,显示电路采用4位共阳极LED 数码管以动态扫描法直读显示。系统程序主要包括主程序,读出温度子程序,温度处理子程序,报警子程序,报警温度值设定子程序,LED 显示子程序等。此外,还介绍了系统的测试。
本数字温度计设计采用美国DALLAS 半导体公司推出的一种智能温度传感器DS18S20作为检测元件,测温范围为-55~125℃,最大分辨率可达0.0625℃。 主控制器采用单片机AT89S52,其集成度高,片内资源丰富,接口模块包括SPI、SCI、A/D、PWM 等。显示电路采用4 位共阳极LED 数码管,从P0口输出段码,列扫描用P2口来实现。
由于采用了改进型智能温度传感器DS18S20 作为检测元件,与传统的温度计相比,本数字温度计减少了外部的硬件电路,具有低成本和易使用的特点。DS18S20 温度计还可以在高温报警、远距离多点测温控制等方面进行应用开发,具有很好的发展前景。
关键词 单片机 主控制器 温度传感器 显示电路 数字温度计
Design and Implementation of Temperature Control System Based on Single Chip Microcontroller
Abstract
This thesis introduces a sort of controller bases on the principle of MCU, a new typeof digital thermometer bases on temperature sensor DS18S20. This thesis mainly containshardware circuit design and system program design. Hardware circuit mainly contains mastercontroller, temperature detection circuit and display circuit, etc. master controller usesAT89S52,temperature sensor uses DS18S20, which is produced by DALLASsemiconductor company ,USA. Display circuit uses 4 bit common cathode LED nixietube, it candirectly read the result by dynamic scanning. System program mainly contains main program,read temperature subprogram, temperature treatment subprogram, LED display subprogram, etc.In addition, it also introduces system test. This digital thermometer design uses a sort of intelligent temperature sensor DS18S20,which is produced by DALLAS semiconductor company, USA ,as a detecting element,temperature measuring range is-55℃~125℃,the maximum resolution is 0.0625℃.Master controller usesAT89S52 MCU, it is highly integrated, it’s internal resource isplentiful, it’s interface module contains SPI、SCI 、A/D、 PWM ,etc.Display circuit uses 4 bit common cathode LED nixietube, it’s segment code output fromP0, It’s column scan is realized by P2.
By reason of using second generation intelligent temperature sensor DS18S20 as detectingelement, compared with traditional thermometer, this digital thermometer decreased externalhardware circuit, has the feature of low cost and inaccessible. DS18S20 thermometer can also be used in high temperature alert, distant multipoint temperature detection, etc, and has a bright future development.
Key words: MCU Master controller Temperature sensor Display circuit
Digital thermometer
目 录
1绪论 ........................................................................ 1 1.1 方案一 热敏电阻 ............................................... 1 1.2 方案二控制内核不用单片机 用DSP ................................ 1 1.3 方案三 温度传感器18B20 ........................................ 1 2系统设计 .......................................................... 1 2.1 系统功能 ...................................................... 1 2.2 系统框图 ...................................................... 1 2.3 单片机的介绍 .................................................. 2 2.4 DS18B20的介绍 ................................................. 6 2.4.1 DS18B20的介绍 ............................................ 7 2.4.2 DS18B20温度传感器与单片机的接口电路 ...................... 9 2.4.3 DS18B20的控制方法 ............................................... 10 2.5 LED数码管 .................................................... 12 2.5.1 LED数码管的主要技术参数 ................................. 12 2.5.2 LED数码管的引脚说明 ..................................... 12 2.5.3 LED数码管编码说明 ............................................... 14
3硬件设计 ......................................................... 14 3.1单片机最小系统电路 ........................................... 14 3.2 DS18B20测温电路 ............................................. 15 3.3 报警电路 ..................................................... 16 3.4四位数码管显示电路 ........................................... 16 3.5 报警温度设定按键电路 ......................................... 17 3.6 ISP程序下载接口电路 ......................................... 18 3.7控制电路设计 ................................................. 18 3.8电路原材料清单 ......................................................... 19 3.9使用工具及仪表清单 .................................................... 20
4软件设计 ......................................................... 20 4.1程序流程图 ................................................... 20 4.2开机数码管显示设置 ........................................... 21 4.3 DS18B20采集温度程序 ......................................... 21 4.4读取温度程序 ................................................. 25 4.5显示温度程序 ................................................. 25 5调试过程 ......................................................... 25 5.1 数码管显示乱码 ............................................... 25 5.3 按键处理问题 .......................................................... 25
5.3 DS18B20时序问题 ...................................................... 25 6结论 ............................................................. 25 参考文献........................................................... 26 总结 ........................................................................ 27 谢辞............................................................... 28 附录............................................................... 29 附录一程序源代码 ................................................. 29 附录二电路图 ............................................................... 34