sensor sr05 cảm biến siêu âm, tài liệu sử dujnh tiếng việt giúp các bạn nào cần làm báo cáo tiếng anh, trong tài liệu trình bày rõ ràng cấu tạo, tác dụng và cách giao tiếp giữa vi điều khiển với cảm biến siêu âm rf05
Trang 12014
Application of Distance Sensor
in Parking Car
Phạm Duy Khanh Đinh Tiến Đạt
Lê Thanh Tùng CTT Cơ Điện Tử K55
Trang 2Table of Contents
A Abstract 2
B Introduction and Overview 3
C Approach 4
I Structure of our system 4
II Hardware 4
1 Distance sensor 4
2 Microcontroller 10
3 Display device 11
4 Actuator and Status devices 12
III Software 13
1 Programer and complier software 13
2 Simulation platform 15
3 PCB design platform 15
D Design System 16
I Hardware 16
1 Power Supply Block (LM7805) 16
2 Main Block 17
3 Actuator Block 20
II Software 22
1 Distance sensor (HC SR04) code 23
2 Display device (LCD 16x2) code 26
3 Actuator (DC motor) code 29
E Results of our system 32
F Conclusion 32
Trang 3List of fingures
Figure 1: Structure of System 4
Figure 2: Operation of Optical Sensor 5
Figure 3: Sharp GP2Y0A02YK0F analog distance sensor 20-150 cm 5
Figure 4: Operation of Ultrasonic Sensor 6
Figure 5: HC SR04 Ultrasonic sensor 7
Figure 6: Operation of Microwave Sensor 8
Figure 7: HB-100 Microwave Sensor 8
Figure 8: Some types of lcd panel 11
Figure 9: LCD text 16x2 12
Figure 10: DC Motor 13
Figure 11: AVR Studio 6 14
Figure 12: User Interface of AVR Studio 6 14
Figure 13: Proteus 7.8 15
Figure 14: User Interface of Proteus 7.8 15
Figure 15: Altium Designer 14 15
Figure 16: PCB Design of Product 16
Figure 17: IC LM7805 16
Figure 18: Schematic of Power Block 17
Figure 19: Block Diagram of Main Block 17
Figure 20: Schematic of Main Block 18
Figure 21: Real Product 19
Figure 22: IC LM298 20
Figure 23: Schematic of L298 Module 21
Figure 24: Real of L298 Module 21
Figure 25: Flow Chart of Main Program 22
Figure 26: Timing Diagram of HC SR04 23
Figure 27: Flow Chart of Get Width Pulse on HC SR04 24
Figure 28: Flow Chart of LCD in 4bit mode 26
Figure 29: PWM Waveform 30
Figure 30: A Simlifed H Bridge 30
Figure 31: Timing Diagram of fast PWM on Timer 2 in Atmega8 31
Trang 4A Abstract
An increasing number of new vehicles are being equipped with ultrasonic sensors These sensors detect the presence and proximity of objects in the pathway of the reversing vehicle and warn the driver through an audible signal This report
investigates the performance capabilities and potential safety effectiveness of these
systems in reducing the risks to small children and other pedestrians from
reversing vehicles These sensor systems are primarily designed and marketed as parking aids However, some are being promoted as safety systems with the
potential to reduce or prevent collisions with pedestrians, especially small children
In terms of detection area performance, parking aid systems sacrificed detection distance and height in order to suppress false or nuisance alarms The durability and reaction time results revealed there were no substantial performance
differences between the systems The safety benefits of these devices were then estimated based on these test results
B Introduction and Overview
There are many pedestrians struck and injured by reversing vehicles each year in Viet Nam However, this is likely an underestimate as this figure only represents those pedestrians struck in traffic situations It does not account for pedestrians injured or killed in private driveways or parking lots for example Therefore, the exact number of pedestrians injured or killed in Viet Nam is not known but studies
in other jurisdictions have highlighed this problem The study also found that most
of these non-traffic collisions involved toddlers Among the recommendations was
to investigate the potential of rear proximity sensors in detecting the presence of nearby children This paper reports on the performance of ultrasonic sensor systems The purpose was not to set out performance criterea but rather to investigate the capabilities of commercially available systems and to asses their potential effectiveness in reducing pedestrian collisions
Trang 5C Approach of Product
I Structure of System
In our system, we have monitor to display infomation of status and distances recieved from distances sensor If the car is in dangerours regions, the red light is turned on and the buzzer is notified and speed of motor also reduced to zero to the car not cross to object
Figure 1: Structure of System
II Hardware
1 Distance sensor
a Introduce types of distance sensor
Measuring the level, position, distance and displacement of physical objects is
essential for many applications: process feedback control, performance evaluation, transport, traffic control, robotics, security systems, to name just a few
In our problem, we need a sensor that can mearsure extractly distances from source (car) to unknown body (unknown about shape, material, movement,etc)
Hence, we will consider 3 types of distance sensors: optical sensor, microwave sensor and ultrasonic sensor
Optical Distance Sensor:
A light wave is transmitted by the sensor, reflected by the measuring object and
received by the detector The simplest way to calculate distances with optical sensors
is based on the determination of the elapsed time interval between emission and
reception of a pulse (signal burst) or series of pulses
Trang 6Figure 2: Operation of Optical Sensor
Ultrasonnic Distance Sensor:
Ultrasonic waves are mechanical oscillations at a frequency which is beyond the
audibility of humans (more than 20 kHz) By a mutual interference of ultrasonic
waves from the individual sensors, the high density of emitted energy in a certain direction can be reached Using the proper phasing of the transducers configured in a matrix, the concentration of energy in a small area is feasible The same phasing
principle can be implemented on the matrix of receivers for a reflected wave By the computer control of phases of transducers operating in a transmitting or receiving mode
Travel time principle
The pulses containing a definite number of periodic waves propagate with sound
1 http://www.pololu.com/product/1137
Trang 7velocity towards a measured object The pulses are then reflected from the measured object and picked up by the receiver (Figure 7.29) with a lag time equal to the
elapsed time between the emission and reception of pulses The received pulses of ultrasonic waves are transformed to the electrical signal by means of the
piezoelectric effect the scanning regime of operation is feasible (e.g in ultrasonic tomography)
Doppler effect
The Doppler effect, (discovered by C Doppler in 1843) is the change in
frequency undergone by radiation (be it mechanical or electromagnetic) when it is reflected by an object that is moving with respect to the radiation transmitter If the reflector moves with velocity v the shift of frequency is approximately given by
Trang 8Resolution: mm
Examples:
Figure 5: HC SR04 Ultrasonic sensor
US $3.61 2
Microwave Distance Sensor (radar)
Microwaves are electromagnetic waves with high frequency (GHz range)
The procedures used in microwave sensors for distance and position measurement are analogical to those of ultrasonic sensors
The measurements are based on:
– The travel time measurement
– Doppler effect
– Frequency Modulated Continuous Wave (FMCW):
The FMCW-based sensor continuously sends signals with a periodical frequency modulated carrier wave The frequency difference is proportional to the distance
which can be calculated from the following equation:
Where fm is the frequency of the triangular modulating signal and fh s the frequency sweep
The precision of a FMCW radar system depends mainly on the linearity of the
triangular waveform of the frequency modulating signal
2 http://www.robotshop.com/en/hc-sr04-ultrasonic-range-finder.html
Trang 9Travel time measurement is the original procedure used in radar systems for a
Trang 10In Vietnam, we cannot buy HB100 or Sharp GP2Y0A02YK0F, so we
decide choose HC SR04 Ultrasonic Sensor to use in our problem
b Introduce features and characteristics of HC SR04
Ultrasonic ranging module HC-SR04 provides 2cm - 400cm non-contact measurement function, the ranging accuracy can reach to 3mm The modules includes ultrasonic transmitters,receiver and control circuit
The basic principle of work
Using IO trigger for at least 10us high level signal
The Module automatically sends eight 40 kHz and detect whether there is a pulse signal back
If the signal back, through high level,time of high output IO duration is the time from sending ultrasonic to returning Test distance=(high level
timexvelocity of sound (340M/S) /2
Wire connecting direct as following:
1 5V Supply
2 Trigger Pulse Input
3 Echo Pulse Output
4 GND
If you are sourcing a ultrasonic ranging module , the HC-SR04 is good choose Its stable performance and high ranging accuracy make it a popular module in electronic market
Compared to the Shape IR ranging module , HC-SR04 is more inexpensive than it But it has the same ranging accuracy and longer ranging distance
More details:
Power supply :5V DC
Quiescent current : 2mA
Trang 11 Effectual angle: 15 degree
Ranging distance : 2cm - 500 cm
Resolution : 0.3 cm
There are 4 pins out of the module : VCC , Trig, Echo, GND So it's a very easy
interface for controller to use it ranging The all process is : pull the Trig pin to high level for more than 10us impulse , the module start ranging ; finish ranging , If you find an object in front , Echo pin will be high level , and based on the different
distance, it will take the different duration of high level So we can calculated the distance easily :
Distance = ((Duration of high level)(Sonic :340m/s))/2 Finally,look at the back of the module All of the chip in the module have been
burnish, maybe the author want to prevent the designed from plagiarism But
ultrasonic ranging module is nearly the same principle,so it's not hard to speculated that the role of the chip - I'm sure at least one 74series chip on it) It is not a difficult task to crack it, but it's at so low a price, even cheaper than your copy
2 Microcontroller
a Overview of microcontroller
A microcontroller (sometimes abbreviated µC, uC or MCU) is a small computer on a single integrated circuit containing a processor core, memory, and
programmable input/output peripherals Program memory in the form of NOR
flash or OTP ROM is also often included on chip, as well as a typically small amount
of RAM Microcontrollers are designed for embedded applications, in contrast to themicroprocessors used in personal computers or other general purpose applications Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, implantable medical devices, remote controls, office machines, appliances, power tools, toys and other embedded systems By
reducing the size and cost compared to a design that uses a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control even more devices and processes Mixed signal microcontrollers are common, integrating analog components needed to control non-digital electronic systems
b Why choose Atmega8?
With ease-of-use, low power consumption, and high level of integration in mind, microprocessors to deliver a unique combination of performance, power efficiency and design flexibility Optimized to speed time-to-market, they are based on the
industry's most code-efficient architecture for C and assembly programming
No other atmega 8 deliver more computing performance with better power efficiency Industry-leading development tools and design support let you get to market faster
Trang 12Once there, the large AVR family lets you reuse your knowledge when improving your products and expanding to new markets—easily and cost-effectively
c Introducce features and characteristics of Atmega8
The low-power Atmel 8-bit AVR RISC-based microcontroller combines 8KB of
programmable flash memory, 1KB of SRAM, 512K EEPROM, and a 6 or 8 channel 10-bit A/D converter The device supports throughput of 16 MIPS at 16 MHz and operates between 2.7-5.5 volts
3 Display device
A liquid-crystal display (LCD) is a flat panel display, electronic visual display, or video
display that uses the light modulating properties of liquid crystals Liquid crystals do not emit light directly
LCDs are available to display arbitrary images (as in a general-purpose computer display) or fixed images which can be displayed or hidden, such as preset words, digits, and 7-segment displays as in a digital clock They use the same basic technology, except that arbitrary
images are made up of a large number of small pixels, while other displays have larger
elements
LCDs are used in a wide range of applications including computer monitors, televisions, instrument panels, aircraft cockpit displays, and signage They are common in consumer devices such as video players, gaming devices, clocks, watches, calculators, and telephones,
Figure 8: Some types of lcd panel
Why choose LCD 16x2?
1.Easy to control
2.Enough space to display the information that user need to know about
module : distance , warning level
3.Friendly to users
Trang 13Introduce features and characteristic of LCD 16x2
Figure 9: LCD text 16x2
FEATURES
• 5 x 8 dots with cursor
• Built-in controller (KS 0066 or Equivalent)
• + 5V power supply (Also available for + 3V)
• 1/16 duty cycle
• B/L to be driven by pin 1, pin 2 or pin 15, pin 16 or A.K (LED)
• N.V optional for + 3V power supply
4 Actuator and Status devices
In Fact , the systems contains the motion part and notification part There is car’s engine and notion light, speaker To simulate the real systems , we use a motor is such as car’s engine 3 leds and a chip speaker is used to be warning system
Trang 14
Why choose DC motor to simulate?
Figure 10: DC Motor
In this project , we only use motor to simulate the motion of car We need a motor
that easy to control, cheap So DC motor is best solution
DC (Direct Current) Motors are two wire (power & ground), continuous rotation motors When you supply power, a DC motor will start spinning until that power is removed Most
DC motors run at a high RPM (revolutions per minute), examples being computer cooling fans, or radio controlled car wheels!
III Software
1 Programer and complier software
We use AVR Studio v6.2 to write code and complier programs
Trang 15Figure 11: AVR Studio 6
Atmel® Studio 6 is the integrated development platform (IDP) for developing and debugging Atmel ARM® Cortex®-M and Atmel AVR® microcontroller (MCU) based applications The Atmel Studio 6 IDP gives you a seamless and easy-to-use environment to write, build and debug your applications written in C/C++ or assembly code
Atmel Studio 6 is free of charge and is integrated with the Atmel Software Framework (ASF)—a large library of free source code with 1,600 ARM and AVR project
examples ASF strengthens the IDP by providing, in the same environment, access to ready-to-use code that minimizes much of the low-level design required for projects Use the IDP for our wide variety of AVR and ARM Cortex-M processor-based
MCUs, including our broadened portfolio of Atmel SAM3 ARM Cortex-M3 and M4 Flash devices
Figure 12: User Interface of AVR Studio 6
Trang 162 Simulation platform
Figure 13: Proteus 7.8
We use Proteus 7.8 software to dimulate our product before make real product
Figure 14: User Interface of Proteus 7.8
3 PCB design platform
Figure 15: Altium Designer 14
Altium Designer combines Schematic, ECAD Libraries, Rules & Constraints, BoM, Supply Chain Management, ECO Processes and World-Class PCB Design tools in one easy to use, Native 3D enhanced, Unified Environment, increasing