基于AT89S51的超声波测距系统的.

  • 格式:doc
  • 大小:1.02 MB
  • 文档页数:38

毕业设计

学号: 14082500075

毕业论文

题 目: 基于AT89S51的超声波测距系统的

设计与实现

作 者 向杰 届 别 2012

学 院 物理与电子学院 专 业 电子科学与技术

指导老师 梅孝安 职 称 副教授

完成时间 2012.05

毕业设计

I 摘要

超声波是指频率在20kHz以上的声波,它属于机械波的范畴。随着科技水平的不断提高,超声波测距技术被广泛应用于人们日常工作和生活之中。

本系统采用以AT89s51单片机为核心的低成本、高精度、微型化数字显示超声波测距仪的硬件电路。整个电路采用模块化设计,由信号发射和接收、供电、温度测量、显示等模块组成。超声波经放大后发射出去,单片机的计时器开始计时,当超声波被反射原路返回后,再经过放大、滤波、整形等环节,被单片机接收,计时器停止计时。用时间乘以速度就得到了测量距离。本系统设有DSl8b20数字温度传感器,能测量环境的温度,以此来校正超声波的速度,使测量结果更准确。本系统硬件和软件设计科学合理,实际测量误差小于3%。

关键词:AT89S51;超声波测距 ;DS18b20 温度检测 毕业设计

II

Abstract

Ultrasonic, a sound wave with more than 20 kHz frequency, belongs to the category of

mechanical wave. For the unceasing improvement of science and technology, ultrasonic

ranging technology has been widely applied in people’s daily work and life.

This system uses a low cost, high precision, miniaturization digital display ultrasonic

rangefinder hardware circuit which centralized in single chip AT89S51.The whole circuit uses

modular design and consists of the signal transmission and reception, power supply,

temperature measurement, display module and so

on. The ultrasonic transmits out after

being amplified, and then the microcontroller starts its timers. When ultrasonic reflexly

returns by the original road, it is received by microcomputer after getting through the link of

amplification ,filtration and reshaping,so the counter stops working. Using the time times

speed gets the measured distance. This system ,with DSl8b20 digital temperature sensor, can

measure the temperature of the environment so to adjust the speed of the ultrasonic and make

measuring results more accurate. The system’s practical measuring error is less than 3% with

rational and scientific hardware and software design.

Keywords: AT89S51; Ultrasonic distance measure; DS18b20temperature measurement 毕业设计

III 目录

摘要 ..................................................................... I

ABSTRACT ................................................................ II

第一章 绪论 .............................................................. 1

1.1 研究背景及意义 ................................................................ 1

1.2 超声波测距的原理概述 .......................................................... 1

1.3 研究内容及论文结构 ............................................................ 2

第二章 系统总体设计 ...................................................... 4

2.1方案设计及论证 ................................................................ 4

2.1.1 控制器的选择 ............................................................ 4

2.1.2 超声波传感器选择 ........................................................ 4

2.1.3 测温传感器选择 .......................................................... 5

2.1.4 显示子系统选择 .......................................................... 5

2.2 系统总体设计 .................................................................. 5

第三章 系统硬件设计 ...................................................... 7

3.1 单片机控制电路设计 ............................................................ 7

3.2 超声波发射及接收电路设计 ...................................................... 8

3.2.1 超声波发射电路的设计 ...................................................... 8

3.2.2 超声波接收电路的设计 ..................................................... 10

3.3 温度检测电路设计 ............................................................. 10

3.4 LED数码管显示电路设计 ....................................................... 11

3.5电源电路设计 ................................................................. 12

第四章 系统软件设计 ..................................................... 13

4.1 系统的算法设计 ............................................................... 13

4.2 主程序设计 ................................................................... 13

4.3 定时器T1中断服务子程序设计 .................................................. 14

4.4 外部中断INT0中断服务子程序的设计 ............................................ 16

4.5 DS18B20测温程序设计 ......................................................... 16

4.6显示程序设计 ................................................................. 20

第五章 硬件测试及误差分析 ............................................... 21

第六章 总结 ............................................................. 23

参考文献 ................................................................ 24

致 谢 ................................................................... 25

附录A :硬件电路原理图 ................................................. 26

附录B : PCB图 ......................................................... 26

附录C : 源程序 ........................................................ 27