基于51单片机的超声波避障小车设计大学论文 下载本文

内蒙古科技大学

本科生毕业设计说明书(毕业论文)

题 目:基于单片机的超声波避障小车

设计

学生姓名:祝伟泰 学 号:1267112115 专 业:测控技术与仪器 班 级:测控2012-1 指导教师:燕芳 副教授

内蒙古科技大学毕业设计说明书(毕业论文)

基于单片机的超声波避障小车设计

摘要

随着科学技术的飞速发展,人们对智能汽车的研究有增无已,智能车已然成为以后科学技术发展的新思路和新方向。智能车可以按照预先设定的模式在一个环境里自动的运作,不需要人为的操控,可应用于路面检测,科学勘探,智能温度测量等。

本设计中制作的智能小车(又称轮式机器人)是本人在综合应用了本科所学的专业知识后设计出的一台智能小车,它具有超声波测距,自动避障,同步测速等功能。虽然超声波避障小车只是智能车领域中的冰山一角,但是它却也是智能车中一个典型的代表。麻雀虽小五脏俱全,本次设计的超声波避障小车,用STC15单片机作为核心控制器,设计出一种可以自动避障,并能同步实现速度和距离的测量以及显示的智能小车。避障和测距通过超声波测距模块实现,并加入光电码盘测速模块从而实现测速功能,小车驱动由L298N驱动电路完成,数据的显示用LCD1602实现。

关键词:STC15单片机;超声波;避障;测速

I

内蒙古科技大学毕业设计说明书(毕业论文)

Ultrasonic obstacle avoidance car design based

on Micro Computer Unit

Abstract

With the development of science and technology, People have increased the research of

smart car.Smart car has become the new way of thinking and a new direction for after the development of science and technology . Smart cars can be according to the preset mode automatically in an environment of operation, without the need of human control, can be applied to road testing, scientific exploration, intelligent temperature measurement, etc. This paper discusses the intelligent car (also known as wheeled robot) is I after summarized the major undergraduate course design a smart car, it has the ultrasonic distance measurement, automatic obstacle avoidance, synchronous speed, and other functions. Although ultrasonic obstacle avoidance car is just the tip of the iceberg in the field of smart car, but it is also a typical representative in intelligent vehicles. The sparrow is small all-sided, the design of ultrasonic obstacle avoidance car, use STC51 single-chip microcomputer as the core controller, design a kind of can automatic obstacle avoidance, and can realize the speed and distance measurement simultaneously and the smart car show. Obstacle avoidance and the distance by ultrasonic ranging module, and add light code disc speed measuring module and function of speed of the car drive by L298N drive circuit is completed, through LCD1602 display of measured data.

Keywords: STC15;Ultrasonic sensors; avoidance; speed

II

内蒙古科技大学毕业设计说明书(毕业论文)

目录

摘要 ..................................................................... I Abstract ................................................................ II

1.1课题研究背景和意义 ................................................ 1 1.2智能汽车的发展概述 ................................................ 1 1.3 课题研究技术要求与主要内容 ....................................... 2 第二章 总体方案设计 ...................................................... 4

2.1总体方案设计 ...................................................... 4

2.1.1具体设计思路 ................................................. 5 2.2系统各模块的设计方案 .............................................. 6

2.2.1控制核心模块的选择方案论证 ................................... 6 2.2.2主电路板的方案论证 ........................................... 6

2.2.3测距避障传感器的方案论证 ..................................... 7 2.2.4 测速模块的选择方案论证 ...................................... 8

2.2.5电机驱动选择方案论证 ......................................... 9 2.2.6 显示装置的选型方案论证 ...................................... 9

2.3 本章小结 ........................................................ 11 第三章 硬件电路设计 ..................................................... 11

3.1 STC15单片机简介 ................................................. 12

3.1.1 引脚说明 ................................................... 12 3.1.2 特别管脚说明 ............................................... 13 3.1.3 中断说明 ................................................... 13 3.2 时钟电路和复位电路 ............................................... 14 3.3电源电路部分 ..................................................... 14 3.4超声波传感器 ..................................................... 14

3.4.1 超声波测距的物理性质 ....................................... 15 3.4.2 超声波测距的原理 ........................................... 15 3.4.3超声波测距过程分析 .......................................... 16 3.5 电机驱动电路 .................................................... 17

III

内蒙古科技大学毕业设计说明书(毕业论文)

3.5.1 电机驱动电路分析 ........................................... 18 3.5.2 PWMD调速分析 ............................................... 19 3.6 LCD1602显示电路设计 ............................................. 19

3.6.1 LCD1602显示 ................................................ 19 3.6.2 LCD1602引脚功能说明 ........................................ 20 3.6.3 1602LCD的指令说明及时序: .................................. 20 3.7 光电测速模块 ..................................................... 22 3.8 报警电路设计 ..................................................... 23 第四章 软件设计部分 ..................................................... 24

4.1 主程序的设计 ..................................................... 24 4.2 超声波测距程序设计 ............................................... 25 4.3 避障程序设计 ..................................................... 26 4.4 PWM程序设计 ..................................................... 27 4.5 显示子程序设计 ................................................... 28 4.7 报警程序设计 ..................................................... 29 第五章 系统调试 ......................................................... 30

5.1概述 ............................................................. 30 5.2 各模块的调试 ..................................................... 30

5.2.1 LCD的调试 .................................................. 30 5.2.2光电码盘调试 ................................................ 31 5.2.3 蜂鸣器报警调试 ............................................. 31 5.2.4 电机及驱动调试 ............................................. 32 5.2.5 超声波模块调试 ............................................. 32

总结 .................................................................... 33 参考文献 ................................................................ 34 附录A 实物图 ............................................................ 36 附录B 源程序 ............................................................ 37 致谢 .................................................................... 38

IV