超声波测距-毕业论文设计

2019-04-14 12:50

目录

设计总说明:. ............................................................................................................................................ 3 ABSTRACT:. .............................................................................................................................................. 5 第一章:超声波测距原理论述 ............................................................................................................. 7

1.1 超声波介绍 .................................................................................................................. 7 1.2 超声波测距系统概述 .................................................................................................. 9 1.3 超声波测距的基本原理 ........................................................................................... 11 1.4 本课题的内容和任务 ............................................................................................... 12 第二章 AVR单片机介绍 ........................................................................................................................ 13

2.1 ATmega16结构框图 ................................................................................................ 16 2.2 AVR CPU 内核 ........................................................................................................... 19 2.3 AVR ATmega16存储器。 .......................................................................................... 19 2.4 AVR ATmega16系统时钟 .......................................................................................... 19 2.5 系统控制和复位 ....................................................................................................... 20 2.6 看门狗定时器 ........................................................................................................... 20 2.7 ATmega16 的中断向量(外部中断) ..................................................................... 20 2.8 具有PWM功能的8位定时器/ 计时器 ................................................................... 21 2.9 比较输出模式和波形产生 ....................................................................................... 22 2.10 T/C0 与T/C1 的预分频器 .................................................................................... 24 2.11 串行外设接口- SPI ............................................................................................. 24 2.12 串行外设接口-USART ........................................................................................... 25 2.13 模数转换器 ............................................................................................................. 25 2.14 JTAG 接口和片上调试系统 ................................................................................... 26 第三章 硬件电路的设计 ....................................................................................................................... 26

3.1 电源电路设计 ........................................................................................................... 26 3.2 复位电路设计 ............................................................................................................ 27 3.3 时钟电路设计 ........................................................................................................... 27 3.4 数码管显示电路 ........................................................................................................ 28 3.5 报警电路设计 ............................................................................................................ 30

第 1页 共 64页

3.6 温度补偿电路 ............................................................................................................ 31

3.6.1 温度计算 .......................................................................................................... 33 3.6.2 DSl820工作过程命令 ...................................................................................... 33 3.6.3时 序 ................................................................................................................. 33 3.6.4写时间隙 ........................................................................................................... 34 3.6.5读时间隙 ........................................................................................................... 34 3.6.6多路测量 ........................................................................................................... 34 3.7在线通信电路设计 ..................................................................................................... 35 第四章,超声波发射电路及接收电路的设计 ................................................................................. 36 4.1 超声波发射电路 .............................................................................................................................. 36

4.1.1压电陶瓷超声波传感器介绍 ........................................................................... 36 4.1.2发射电路原理图分析 ....................................................................................... 38 4.2 超声波接收电路 ....................................................................................................... 39

4.2.1 LC震荡选频电路设计: .................................................................................. 39 4.2.2比较电路的设计 ............................................................................................... 40 4.2.3 接收电路原理图分析 ...................................................................................... 41

第五章软件设计 ....................................................................................................................................... 43

5.1主程序流程图 ............................................................................................................. 44 5.2发射子程序设计 ......................................................................................................... 44 5.3温度测量子程序 ......................................................................................................... 44 5.4测量子程序 ................................................................................................................. 46 5.5计算子程序 ................................................................................................................. 46 5.6显示驱动子程序 ......................................................................................................... 47 5.7报警子程序 ................................................................................................................. 47 第六章 设计心得 ..................................................................................................................................... 49 致 谢 ............................................................................................................................................................ 50 参考文献 ..................................................................................................................................................... 51 附录 .............................................................................................................................................................. 52

第 2 页 共 64 页

基于单片机的超声波测距电路的研究

设计总说明:超声波因其指向性强,能量消耗缓慢,在介质中传播距离远等特点,而经常用于进行各种测量. 如利用超声波在水中的发射,利用超声波在固体中的传播,可以用作金属探伤、医用A 超、B 超等. 利用超声波测距,使用单片机系统,设计合理,计算处理也较方便,测量精度能达到各种场合使用的要求.

这篇应用性设计报告描述了一种基于AVR ATMEGA16低功耗单片机的超声波测距系统,本系统发射器对着一个物体发射一定频率的超声波同时接收同频率的超声波,单片机通过计算从超声波发射时刻到接收返回的超声波时刻从而确定超声波通过的时间,根据房间的温度来确定超声波在空气中的速度大概是340m/s , AVR单片机计算二者的距离同时用3个LED驱动电路驱动的LED来显示,显示距离误差大概是±1cm,最小能测量时1cm同时局限于发射器的传感器的设定时间,最大能测量4m,超声波测距发射距离决定与发射物的材质和形状,例如超声波可能被地毯吸收,这样测量的距离就大大的降低,假如反射波接收的频率太低就可能不被系统处理,这样显示就会出现错误。

1设计理论:

本设计应用基于声波的反射。声波在其传播的介质中被定义为纵波。当声波受到尺寸大于其波长的目标物阻挡时就会发生反射;反射波称为回声。如果声波在介质中传播的速度是已知的,而且测量到声波从声源到达目标然后返回声源的时间,从声源到目标的距离就可以精确地计算出来。这就是本应用的测量原理。这里声波传播的介质就是空气,采用不可见的超声波。 假设室内超声波的速度是340m/s则可以通过计算超声波通过时间来计算距离,但是实际温度对超声波影响很大,通过可以研究,速度和温度(T为绝对温度)存在一下关系 :

v?v01?Tm/s 273vo?340m/s

由于超声波通过的距离是2倍的实际距离,则实际距离是d/2,所以d?v?t/2 2 电路描述:

第 3页 共 64页

本设计用来发射和接收超声波的设备是40hz压电陶瓷超声波传感器,AVR ATMEGA16单片机驱动超声波发射器40hz的方波来源于晶振,波接收器接收回波 由于AVR ATMEGA16单片机的计时器计算40khz的分辨率是25us 是完全胜任我们的设计,我们系统的稳定性来源于晶振的工作。被超声波接收器超声波通过一个运算放大器放大对输入a放大,相对输入a输出超声波的同时触发单片机计时器timer1 ,捕获的回波被精确计算时间来计算距离。计数器从超声波发射开始计时到收到回波停止,时间被精确记录,我们可以通过DS18B20 芯片来确定室温,精确的确定超声波的速度,二者的距离通过 AVR ATMEGA16精确的计算同时在3个数码管上显示出来,一旦显示出来,单片机就进入休眠状态来节省电力能源。这篇设计的主要电路分析。

传感器的输出驱动电路直接由9V 电池供电并提供驱动超声波发射器由一个二进制非门CD4049电路实现的。其中一个非门用来为驱动器的一侧提供180 度的相移信号。另一侧由相内信号驱动。这种结构使输出端的电压提高了一倍,为发射传感器提供了足够的电压。两个门并联连接以便每一侧能够为传感器提供足够的驱动电流。电容耦合阻断了到传感器的直流通路。因为CD4049 工作于9V 而AVR ATMEGA16工作于Vcc=5V。 AVR ATMEGA16和输出驱动器之间的逻辑电平是不匹配的,可以双极性晶体管就作为这两种逻辑电平之间的转换器。

由LC选频放大器对超声波接收器接收的回波在40KHz 时提供充分的高增益。选择并丢弃除了40KHz 之外的频率。运算放大器的输出端连接到比较器LM393的输入端。 比较器LM393 的参考电平内部选择为0V。当接收到回声时电压高于参考电平从而触发比较器的输出。然后触发单片机的INT0.

本文在了解超声波测距原理的基础上,完成了基于时差测距原理的一种超声波测距系统的硬件设计,其中为了进一步提高系统测量精度和系统稳定性,在硬件上增加了温度传感器测温电路,采取声速预置和媒质温度测量相结合的办法对声速进行修正,降低了温度变化对测距精度的影响。针对噪声环境中超声波测距的情况,本文讨论了一种基于时延的估计方法,可有效地降低噪声对测距的干扰,有利于提高超声波测距系统的测量精度。

关键词:超声波测距 AVR atmega16 DS18B20

第 4 页 共 64 页

ABSTRACT: In different occasions , the demands of the precision on ultrasonic distance measuring system are different .Usually , the error of the ultrasonic distance measuring system is large , so they cannot be satisfied with the demands in some occasions. This article takes temper A Ture account into the ult rasonic distance measuring system and makes it have higher precision han before and increases the function of broadcasting the result . It can apply in more occasions and be felt more convenient .

This design application report describes a distance-measuring system based on ultrasonic sound utilizing the AVR atmega16 ultralow-power microcontroller. The system transmits a burst of ultrasonic sound waves towards the subject and then receives the corresponding echo. The time taken for the ultrasonic burst to travel the distance from the system to the subject and back to the system is accurately measured by the AVR atmega16. Assuming the speed of sound in air at room temperature to be 340m/s, the AVR atmega16 computes the distance between the system and the subject and displays it using a three-digit static LED driven by its integrated LED driver. The distance is displayed in inches with an accuracy of ±1 cm. The minimum distance that this system can measure is 1cm and is limited by the transmitter’s transducer settling-time. The maximum distance that can be measured is 4m. The amplitude of the echo depends on the reflecting material, shape, and size. Sound-absorbing targets such as carpets the maximum measurable range is lower for such subjects. If the amplitude of the echo received by the system is so low that it is not detectable by the Comparator the system goes out of range. This is indicated by displaying the error message 1 Theory of Operation

This application is based on the reflection of sound waves. Subjects whose Dimensions are larger than the wavelength of the impinging sound waves reflect them; the reflected waves are called the echo. If the speed of sound in the medium is known and the time taken for the sound waves to travel the distance from the source to the subject and back to the source is measured, the distance from the source to the subject can be computed accurately. This is the measurement principle of this application. Since it is inaudible to humans. Assuming that the speed of sound in air is v=340m/s at room temperature and that the measured time taken for the sound waves to travel the distance from the source to the subject and back to the source is seconds,as we know:

第 5页 共 64页


超声波测距-毕业论文设计.doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:PEP三年级下册英语期末总复习资料句子+单词+练习 - 图文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: