钦 州 学 院 本科毕业论文(设计)
基于单片机的数字温度计的设计
院 系 物理与电子工程学院 专 业 自动化 学 生 班 级 2010级1班 姓 名 学 号
指导教师单位 物理与电子工程学院 指导教师姓名 指导教师职称 讲师
2014年4月
基于单片机的数字温度计的设计
自动化专业2010级
指导教师
摘 要
随着时代的进步和发展,单片机技术已经普及到生活、工作、科研等各个领域,已经成为一种比较成熟的技术。本文将介绍一种基于单片机控制的多功能数字温度计,该设计主要包括温度模块和时钟模块,温度模块实现了温度的上下限设置报警功能,当温度不在设定范围内时,可以报警;时钟模块可以同步显示时间日历,日期和时间都可通过按键校整。本系统显示部分采用LCD液晶显示屏显示,工作方便,外形美观。
关键词:单片机STC89C52;LCD1602;DS18B20;DS1302
Design of digital thermometer based on single chip
Automation professional 2010
Instructor
Abstract
With the era of progress and development, single-chip technology has spread to live, work, research and other fields, has become a relatively mature technology. This paper will introduce a single-chip microcomputer-based control of multifunctional digital thermometer. This design includes a temperature module and a clock module. Temperature modules can achieve alarm function by setting the upper and lower limits of temperature. When the temperature is not within the set range, it could alarm. And clock modules can simultaneous display the calendar, which date and time can be corrected through the keys. Parts of the system display use LCD liquid crystal display screen, work convenient with beautiful appearance.
Key words: Single Chip STC89C52, LCD1602, DS18B20, DS1302
目录
前言 .......................................................................................................................................................... 1 1 方案论证与系统总体框图 ............................................................................................................. 1
1.1 方案论证 ................................................................................................................................ 1
1.1.1 方案一 ........................................................................................................................ 1 1.1.2 方案二 ........................................................................................................................ 1 1.2 系统设计框图 ....................................................................................................................... 2 2 主要器件功能介绍........................................................................................................................... 2
2.1 STC89C52RC单片机 ......................................................................................................... 2 2.2 LCD1602显示屏 ................................................................................................................. 4 2.3 DS1302时钟芯片 ................................................................................................................ 6
2.3.1 DS1302的寄存器 .................................................................................................... 7 2.3.2 DS1302的读写方式 ............................................................................................... 8 2.4 温度传感器DS18B20 ......................................................................................................... 9
2.4.1 DS18B20接口电路 .............................................................................................. 10 2.4.2 DS18B20工作原理 .............................................................................................. 10 2.4.3 DS18B20工作时序 .............................................................................................. 13
3 硬件电路 .......................................................................................................................................... 16
3.1 单片机主控制模块设计 .................................................................................................. 16 3.2 显示模块设计 .................................................................................................................... 18 3.3 时钟电路模块设计 ........................................................................................................... 18 3.4 温度测量电路模块设计 .................................................................................................. 18 3.5 报警和按键模块设计 ....................................................................................................... 20 3.6 系统总体硬件电路 ........................................................................................................... 20 4 软件设计 .......................................................................................................................................... 21
4.1 系统软件程序设计 ........................................................................................................... 21 4.2 液晶显示程序 .................................................................................................................... 22 4.3 时钟芯片程序 .................................................................................................................... 23 4.4 温度传感器程序 ................................................................................................................ 24
总结 ....................................................................................................................................................... 26 致谢 ....................................................................................................................................................... 27 参考文献 .............................................................................................................................................. 27 附录A ................................................................................................................................................... 29 附录B ................................................................................................................................................... 29 附录C ................................................................................................................................................... 30