基于单片机的超声波测距仪设计毕业论文

 2021-04-19 10:04

摘 要

随着科学的不断进步,人们生活和生产水平不断提高,此时需要对原有的技术进行不断改进来跟上时代的需求。一般的测距技术受到了许多限制,而具有无接触测量、损耗低、精度高等优点的超声波测距技术受到了人们的广泛关注,越来越多的学者就如何提高超声波测距的精度进行了大量研究。

本设计主要介绍了如何用单片机控制超声波的发射和接收并通过计算显示距离,设计完成后对影响测距精度的主要因素进行了研究。该测距仪的系统功能是控制STC89C51单片机的定时器产生超声波脉冲并计时,计算超声波自发射至接收的往返时间,采用温度补偿根据当前环境温度对超声波传播速度进行校正,从而得到实测距离。通过按键控制在四位LED数码管切换显示距离、报警值和温度,还可以根据需要设定报警值,距离低于报警值后蜂鸣器响起。

硬件部分采用STC89C51单片机作为控制器,主要由超声波发射电路、超声波接收电路、温度检测电路、LED显示电路和报警电路构成。软件部分采用KEIL4编程软件使用C语言根据各个模块的功能进行编程。相关部分附有硬件电路图、程序流程图,给出了系统构成、电路原理及程序设计。此系统具有易控制、工作可靠、可读性强和流程清晰等优点。由于加入了温度补偿条件,该测距仪适合不同温度下的距离测量。

实验部分就影响超声波测距精度的主要因素温度进行了测试,对比有无温度补偿条件下超声波测距仪的测量距离与实际距离之间误差来验证温度对超声波传播速度的影响。

【关键词】

超声波测距;单片机;温度补偿;模拟报警器

Ultrasonic range finder based on single chip microcomputer

【Abstract】

With the continuous progress of science, people's life and production levels continue to improve, at this time need to continue to improve the original technology to keep pace with the times. General ranging technology by many restrictions, and has the advantages of no contact measurement, low loss, high precision ultrasonic ranging technology by people's attention, more and more scholars on how to improve the precision of ultrasonic ranging has been studied.

This design mainly introduces how to control the ultrasonic wave transmission and receive with the single chip microcomputer and calculate the distance. The main factors that affect the accuracy of the measurement are studied.. The range finder system function is to control STC89C51 MCU timer generated ultrasonic pulse and time, the calculation of ultrasonic since launch and receive round-trip time and the temperature compensation according to the environment temperature on ultrasonic velocity correction, thus obtains the measured distance. Through the key control in the four LED digital tube switch show distance, alarm and temperature, but also according to the need to set the alarm, the distance below the alarm buzzer sounded.

The hardware is made of STC89C51 microcontroller as the controller, which mainly consists of ultrasonic transmitting circuit, ultrasonic receiving circuit, temperature detection circuit, LED display circuit and alarm circuit.. The software uses the KEIL4 programming software to use the C language according to each module function to carry on the programming. The hardware circuit diagram and the program flow chart are attached to the related part, and the constitution of the system, the circuit principle and the program design are given.. This system is easy to control, reliable, readable and clear, etc.. Due to the temperature compensation, the distance measurement is suitable for different temperatures..

The influence precision of ultrasonic ranging factors, such as temperature were tested, compared with or without temperature compensation conditions under ultrasonic range finder for the measurement of distance with the actual distance between error to verify the effect of temperature on ultrasonic velocity.

【Key Words】

ultrasonic ranging; Single chip microcomputer; temperature compensation; analog alarm;

目 录

1绪 论 - 1 -

1.1研究的目的及意义 - 1 -

1.2国内外研究现状 - 1 -

1.3研究内容及计划 - 2 -

1.4章节安排 - 2 -

2超声波测距模块 - 4 -

2.1超声波测距原理 - 4 -

2.2HC-SR04超声波测距模块 - 5 -

3超声波测距仪硬件系统设计 - 7 -

3.1系统总体架构 - 7 -

3.2单片机最小系统 - 7 -

3.3超声波传感器电路 - 9 -

3.4温度传感器电路 - 10 -

- 10 -

3.5按键电路 - 11 -

3.6显示电路 - 12 -

3.7报警电路 - 13 -

4超声波测距仪软件系统设计 - 15 -

4.1程序总体流程图 - 15 -

4.2按键子程序 - 16 -

4.3温度采集转换子程序 - 18 -

4.4距离计算及显示计算子程序 - 19 -

4.5显示子程序  - 20 -

4.6报警子程序  - 21 -

5实验 - 22 -

5.1测距范围 - 22 -

5.2测距精度(有无温度补偿分别得到的精度) - 22 -

6总结与展望 - 23 -

6.1 总结 - 23 -

6.2展望 - 23 -

致 谢 - 24 -

参考文献 - 25 -

附 录(A)(单片机原理图) - 26 -

附 录(B)(单片机实物测距图) - 27 -

附 录(C)(单片机C源程序清单) - 29 -

1绪 论

1.1研究的目的及意义

目前人们可以利用的测距技术还十分有限,因此,超声波测距是一个正在蓬勃发展而又有无限前景的技术及产业领域。超声波测距仪区别于其它测距仪的最大优点是非接触式测量,因此适用于各个领域,例如医学上的探伤检测、工业上的器件检测、汽车的倒车雷达技术以及各种复杂危险地形的测量等。

现有超声波测距仪大多是基于单片机设计的。这可归结为两个原因:一是单片机的成本低廉并具有低功耗的特点,市场上单片机的的零器件产量高价格便宜易获取,因此方便单片机的制作和节约成本,而且当器件出现问题时方便维修,大大提高了社会资源的合理分配;二是单片机系统方便快捷,现在所使用的单片机系统,大部分都能实现程序的修改从而适用于不同的条件,因此单片机的使用使测距系统更能体现其灵活性,也使设计出的单片机系统能在各个领域都广泛适用。

1.2国内外研究现状

超声波检测技术是国内外重点发展和普及的新技术,它区别于一般的检测技术具有无接触式测量、损耗低、环保等优点。主要用于工业测量、材料测量、医学检测和生物科学等领域。现在,国内外对超声波技术的研究主要是如何提高超声波测距的精度。提高超声波测距精度[2]主要集中在两个最有效的方面:一是提高超声波传播时间的精度;二是根据环境因素修正超声波的传播速度。

您需要先支付 80元 才能查看全部内容!立即支付

课题毕业论文、开题报告、任务书、外文翻译、程序设计、图纸设计等资料可联系客服协助查找,优先添加企业微信。