




已阅读5页,还剩61页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第 1 页 共 66 页目录设计总说明:. .3ABSTRACT:.5第一章:超声波测距原理论述 .71.1 超声波介绍 .71.2 超声波测距系统概述 .91.3 超声波测距的基本原理 .111.4 本课题的内容和任务 .12第二章 AVR 单片机介绍 .132.1 ATmega16 结构框图 .162.2 AVR CPU 内核 .192.3 AVR ATmega16 存储器。 .192.4 AVR ATmega16 系统时钟 .192.5 系统控制和复位 .202.6 看门狗定时器 .202.7 ATmega16 的中断向量(外部中断) .202.8 具有 PWM 功能的 8 位定时器/ 计时器 .212.9 比较输出模式和波形产生 .222.10 T/C0 与 T/C1 的预分频器 .242.11 串行外设接口 SPI .242.12 串行外设接口USART .252.13 模数转换器 .252.14 JTAG 接口和片上调试系统 .26第三章 硬件电路的设计 .263.1 电源电路设计 .263.2 复位电路设计 .273.3 时钟电路设计 .273.4 数码管显示电路 .283.5 报警电路设计 .30第 2 页 共 66 页3.6 温度补偿电路 .313.6.1 温度计算 .333.6.2 DSl820 工作过程命令 .333.6.3 时 序 .333.6.4 写时间隙 .343.6.5 读时间隙 .343.6.6 多路测量 .343.7 在线通信电路设计 .35第四章,超声波发射电路及接收电路的设计 .364.1 超声波发射电 路 .364.1.1 压电陶瓷超声波传感器介绍 .364.1.2 发射电路原理图分析 .384.2 超声波接收电路 .394.2.1 LC 震荡选频电路设计: .394.2.2 比较电路的设计 .404.2.3 接收电路原理图分析 .40第五章软件设计 .435.1 主程序流程图 .435.2 发射子程序设计 .445.3 温度测量子程序 .445.4 测量子程序 .465.5 计算子程序 .465.6 显示驱动子程序 .475.7 报警子程序 .47第六章 设计心得 .49致 谢 .50参考 文献 .51附录 .52第 3 页 共 66 页基于单片机的超声波测距电路的研究设计总说明:超声波因其指向性强,能量消耗缓慢,在介质中传播距离远等特点,而经常用于进行各种测量. 如利用超声波在水中的发射,利用超声波在固体中的传播,可以用作金属探伤、医用 A 超、B 超等. 利用超声波测距,使用单片机系统,设计合理,计算处理也较方便,测量精度能达到各种场合使用的要求.这篇应用性设计报告描述了一种基于 AVR ATMEGA16 低功耗单片机的超声波测距系统,本系统发射器对着一个物体发射一定频率的超声波同时接收同频率的超声波,单片机通过计算从超声波发射时刻到接收返回的超声波时刻从而确定超声波通过的时间,根据房间的温度来确定超声波在空气中的速度大概是 340m/s , AVR 单片机计算二者的距离同时用 3 个 LED 驱动电路驱动的 LED 来显示,显示距离误差大概是1cm,最小能测量时 1cm 同时局限于发射器的传感器的设定时间,最大能测量 4m,超声波测距发射距离决定与发射物的材质和形状,例如超声波可能被地毯吸收,这样测量的距离就大大的降低,假如反射波接收的频率太低就可能不被系统处理,这样显示就会出现错误。1 设计理论:本设计应用基于声波的反射。声波在其传播的介质中被定义为纵波。当声波受到尺寸大于其波长的目标物阻挡时就会发生反射;反射波称为回声。如果声波在介质中传播的速度是已知的,而且测量到声波从声源到达目标然后返回声源的时间,从声源到目标的距离就可以精确地计算出来。这就是本应用的测量原理。这里声波传播的介质就是空气,采用不可见的超声波。 假设室内超声波的速度是 340m/s 则可以通过计算超声波通过时间来计算距离,但是实际温度对超声波影响很大,通过可以研究,速度和温度(T 为绝对温度)存在一下关系 :01/27Tvms340/omsv由于超声波通过的距离是 2 倍的实际距离,则实际距离是 d/2,所以 t/2dv第 4 页 共 66 页2 电路描述:本设计用来发射和接收超声波的设备是 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.本文在了解超声波测距原理的基础上,完成了基于时差测距原理的一种超声波测距系统的硬件设计,其中为了进一步提高系统测量精度和系统稳定性,在硬件上增加了温度传感器测温电路,采取声速预置和媒质温度测量相结合的办法对声速进行修正,降低了温度变化对测距精度的影响。针对噪声环境中超声波测距的情况,本文讨论了一种基于时延的估计方法,可有效地降低噪声对测距的干扰,有利于提高超声波测距系统的测量精度。第 5 页 共 66 页关键词:超声波测距 AVR atmega16 DS18B20 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 transmitters 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 message1 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 第 6 页 共 66 页for the sound waves to travel the distance from the source to the subject and back to the source is seconds,as we know:01/273Tvms340/omsvThe distance d is computed by the formula Since the sound waves travel twice t/2dthe distance between the source and the subject, the actual distance between the source and the subject will be d/2.2 Circuit DescriptionThe devices used to transmit and receive the ultrasonic sound waves in this application are 40-kHz ceramic ultrasonic transducers. AVR ATMEGA16 drives the transmitter transducer with 40-kHz square-wave signal derived from the crystal oscillator, and the receiver transducer receives the echo. The Timer1in the AVR is configured to count the 40-kHz crystal frequency such that the time measurement resolution is 25 s, which is more than adequate for this application. The measurement time base is very stable as it is derived from a quartz-crystal oscillator. The echo received by the receiver transducer is amplified by an operational amplifier and the amplified output is fed to the Comparator_A input. The Comparator_A senses the presence of the echo signal at its input and triggers a capture of Timer_A count value to capture compare register timer1. The capture is done exactly at the instant the echo arrives at the system. The captured count is the measure of the time taken for the ultrasonic burst to travel the distance from the system to the subject and back to the system. The distance in inches from the system to the subject is computed by the AVR ATMEGA16 using this measured time and displayed on a two-digit static LED. Immediately after updating the display, the AVR goes to sleep mode to save power. The circuit schematic diagram of this application. The output drive circuit for the transducer is powered directly from the 9-V battery and provides drive to the ultrasonic transmitter. The is achieved by a bridge configuration with hex inverter gates CD4049. One inverter gate is used to provide a 180-degrees phase-shifted signal to one arm of the driver. The other arm is driven by the in-phase signal. This configuration doubles the voltage swing at the output and provides the required to the transmitter transducer. Two gates are connected in parallel so that each arm can provide 第 7 页 共 66 页adequate current drive to the transducer. Capacitors block the dc to the transducer. Since the CD4049 operates on 9-V and the AVR ATMEGA16 operates on a VCC of 5 V, there is a logic level mismatch between the AVR ATMEGA16 and the output driver circuit. Bipolar transistor acts as a logic-level shifter between these two logic levels.Operational amplifier NPN is made of by Circuit ,This amplifier has a high-gain bandwidth and provides sufficiently high gain at 40 kHz. The amplified ultrasonic signal swings above and below this virtual midrail. provides selectivity and rejection of unwanted frequencies other than 40kHz. The output of the operational amplifier is connected to the ComparatorLM393 input of the ATMEGA16 via port pin INT0. The Comparator LM393 reference is internally selected to be 0.5VCC. When no ultrasonic echo is received, the voltage level at CA0 is slightly lower than the reference at LM393. When an echo is received, the voltage level increases above the reference and toggles the Comparator LM393 can be fine-tuned for the required sensitivity and the measurable range can be optimized and give the single to the ATMEGA16.Based on the comprehension of measuring distance principle by ultrasonic, the paper completes an hardware design which based on time difference measuring distance theory , In order to improve the measurement accuracy and system stability further, we add a temperature sensor in the hardware design and adopt the improved method which combines sound velocity presetting with medium temperature measurement to mend the sound velocity. By this means, the influence of temperature variation on distance measurement is decreased.Keywords: distance-measuring system based on ultrasonic AVR atmega16 DS18B20第一章:超声波测距原理论述1.1 超声波介绍超声波是指振动频率大于 20KHz 以上的,人在自然环境下无法听到和感受到的声波。超声波因其可在气体、液体、固体、固熔体等介质中有效传播,可传递很强的能量,产生反射、干涉、叠加和共振现象。在液体介质中传播时,可在界面上产生强烈第 8 页 共 66 页的冲击和空化现象。由于超声波与介质的相互作用,使介质发生物理的和化学的变化,从而产生一系列力学的、热学的、电磁学的和化学的超声效应,包括以下 4 种效应: 机械效应。超声波的机械作用可促成液体的乳化、凝胶的液化和固体的分散。当超声波流体介质中形成驻波时 ,悬浮在流体中的微小颗粒因受机械力的作用而凝聚在波节处,在空间形成周期性的堆积。超声波在压电材料和磁致伸缩材料中传播时,由于超声波的机械作用而引起的感生电极化和感生磁化(见电介质物理学和磁致伸缩)。 空化作用。超声波作用于液体时可产生大量小气泡 。一个原因是液体内局部出现拉应力而形成负压,压强的降低使原来溶于液体的气体过饱和,而从液体逸出,成为小气泡。另一原因是强大的拉应力把液体“撕开”成一空洞,称为空化。空洞内为液体蒸气或溶于液体的另一种气体,甚至可能是真空。因空化作用形成的小气泡会随周围介质的振动而不断运动、长大或突然破灭。破灭时周围液体突然冲入气泡而产生高温、高压,同时产生激波。与空化作用相伴随的内摩擦可形成电荷,并在气泡内因放电而产生发光现象。在液体中进行超声处理的技术大多与空化作用有关。 热效应。由于超声波频率高,能量大,被介质吸收时能产生显著的热效应。 化学效应。超声波的作用可促使发生或加速某些化学反应。例如纯的蒸馏水经超声处理后产生过氧化氢;溶有氮气的水经超声处理后产生亚硝酸;染料的水溶液经超声处理后会变色或退色。这些现象的发生总与空化作用相伴随。超声波还可加速许多化学物质的水解、分解和聚合过程。超声波对光化学和电化学过程也有明显影响。各种氨基酸和其他有机物质的水溶液经超声处理后,特征吸收光谱带消失而呈均匀的一般吸收,这表明空化作用使分子结构发生了改变 。 超声应用 超声效应已广泛用于实际,主要有如下几方面: 超声检验。超声波的波长比一般声波要短,具有较好的方向性,而且能透过不透明物质,这一特性已被广泛用于超声波探伤、测厚、测距、遥控和超声成像技术。超声成像是利用超声波呈现不透明物内部形象的技术 。把从换能器发出的超声波经声透镜聚焦在不透明试样上,从试样透出的超声波携带了被照部位的信息(如对声波的反射、吸收和散射的能力),经声透镜汇聚在压电接收器上,所得电信号输入放大器,第 9 页 共 66 页利用扫描系统可把不透明试样的形象显示在荧光屏上。上述装置称为超声显微镜。超声成像技术已在医疗检查方面获得普遍应用,在微电子器件制造业中用来对大规模集成电路进行检查,在材料科学中用来显示合金中不同组分的区域和晶粒间界等。声全息术是利用超声波的干涉原理记录和重现不透明物的立体图像的声成像技术,其原理与光波的全息术基本相同,只是记录手段不同而已(见全息术)。用同一超声信号源激励两个放置在液体中的换能器,它们分别发射两束相干的超声波:一束透过被研究的物体后成为物波,另一束作为参考波。物波和参考波在液面上相干叠加形成声全息图,用激光束照射声全息图,利用激光在声全息图上反射时产生的衍射效应而获得物的重显像,通常用摄像机和电视机作实时观察。 超声处理。利用超声的机械作用、空化作用、热效应和化学效应,可进行超声焊接、钻孔、固体的粉碎、乳化 、脱气、除尘、去锅垢、清洗、灭菌、促进化学反应和进行生物学研究等,在工矿业、农业、医疗等各个部门获得了广泛应用。 基础研究。超声波作用于介质后,在介质中产生声弛豫过程,声弛豫过程伴随着能量在分子各自电度间的输运过程,并在宏观上表现出对声波的吸收(见声波)。通过物质对超声的吸收规律可探索物质的特性和结构,这方面的研究构成了分子声学这一声学分支。普通声波的波长远大于固体中的原子间距,在此条件下固体可当作连续介质 。但对频率在 1012 赫兹以上的特超声波 ,波长可与固体中的原子间距相比拟,此时必须把固体当作是具有空间周期性的点阵结构。点阵振动的能量是量子化的 ,称为声子(见固体物理学)。特超声对固体的作用可归结为特超声与热声子、电子、光子和各种准粒子的相互作用。对固体中特超声的产生、检测和传播规律的研究,以及量子液体液态氦中声现象的研究构成了近代声学的新领域。人类直到第一次世界大战才学会利用超声波,这就是利用“声呐”的原理来探测水中目标及其状态,如
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- lng装车区管理制度
- 临时用电合同管理制度
- nicu库房管理制度
- 事业安全保卫管理制度
- 仓库设备权限管理制度
- 仓储安全防范管理制度
- 仓储公司设备管理制度
- 个体餐饮安全管理制度
- 班杜拉社会认知论的核心
- 中医行业AI技术的伦理规范与质量控制框架
- 医院检验科实验室生物安全程序文件SOP
- 行业标准:GB∕T 9254.2-2021 信息技术设备、多媒体设备和接收机 电磁兼容 第2部分:抗扰度要求
- 公文格式及公文处理(讲稿)ppt课件
- 合伙公司管理制度规定办法
- 环境工程原理课程设计清水吸收二氧化硫过程填料吸收塔设计
- 混凝土护栏技术交底
- 发动机装调工:高级发动机装调工试题及答案
- 药物临床试验的伦理审查课件
- EHS目标与指标管理一览表
- L等级考试LTE无线网络优化L3
- 河北省工伤职工停工留薪期分类目录
评论
0/150
提交评论