0% found this document useful (0 votes)
10 views

Esd Lab-7 Working With Ultrsonic Sensor

Uploaded by

Heshwar Lap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Esd Lab-7 Working With Ultrsonic Sensor

Uploaded by

Heshwar Lap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

BECE403E-Embedded System

Design Lab
LAB-7
Working with Ultrasonic
Sensor

LAB - BECE403E-Embedded System 1


INTRODUCTION TO ULTRASONIC
SENSOR
 An ultrasonic sensor is an electronic device that measures the
distance of a target object by emitting ultrasonic sound
waves, and converts the reflected sound into an electrical
signal.
 Ultrasonic sensors have two main components:
 Transmitter (which emits the sound using piezoelectric crystals)
 Receiver (which encounters the sound after it has travelled to and
from the target).
 In order to calculate the distance between the sensor and the
object, the sensor measures the time it takes between the
emission of the sound by the transmitter to its contact with
the receiver.
LAB - BECE403E-Embedded System 2
INTRODUCTION TO ULTRASONIC
SENSOR
 Ultrasonic sensors are used primarily as proximity sensors.
 They can be found in automobile self-parking technology,
anti-collision safety systems, robotic obstacle detection
systems also used as level sensors to detect, monitor, and
regulate liquid levels in closed containers.
 The HC-SR04 ultrasonic sensor offers excellent non-contact
range detection with high accuracy and stable readings from
2 cm to 400 cm.
 It comes complete with ultrasonic transmitter and receiver
module.

LAB - BECE403E-Embedded System 3
INTRODUCTION TO ULTRASONIC
SENSOR
 Steps involved in measuring distance using HC-SR04
Ultrasonic module are,
 Transmit trigger pulse of at least 10 us to the HC-SR04 Trig Pin.

 Then the HC-SR04 automatically sends Eight 40 kHz sound wave and
generate the rising edge at Echo pin.

 When the rising edge capture occurs at Echo pin, start the Timer and
wait for falling edge on Echo pin.

 As soon as the falling edge is captured at the Echo pin, read the
count of the Timer. This time count is the time required by the sensor
to detect an object and return back from an object (to and from).
LAB - BECE403E-Embedded System 4
INTRODUCTION TO ULTRASONIC
SENSOR

LAB - BECE403E-Embedded System 5


INTRODUCTION TO ULTRASONIC
SENSOR
Distance = (Speed x Time)/ 2
Distance = (0.034 cm/µs x 500 µs) / 2
Distance = 8.5 cm

When no obstacles then timeout after 38ms


When obstacle detected pulse width of 50 µS to 25 mS received
LAB - BECE403E-Embedded System 6
INTRODUCTION TO ULTRASONIC
SENSOR
API Required – TIMER

LAB - BECE403E-Embedded System 7


LAB TASK-1
Read the distance value from HC-SR04 and print it on
serial monitor

Write a program to read distance value from HC-SR04 ultrasonic


sensor module in cm and print it on the serial monitor. Implement
and verify this logic on the STM32 Nucleo-64 board using Keil
Studio Cloud IDE.

LAB - BECE403E-Embedded System 8


LAB TASK-1
Program

LAB - BECE403E-Embedded System 9


LAB TASK-2
Reverse parking sensor module (Exercise)
Write a program to design a reverse parking sensor module. This
module consist of HC-SR04 ultrasonic sensor, LCD and buzzer
interfaced with Nucleo. The ultrasonic sensor continuously measure
the distance (in cm) between the car and obstacle, then display it
on the first row of the LCD. Whenever the measured distance is
lesser than 30cm generate warning signal to driver using buzzer
also display a message “Obstacle !!!” on the second row of the LCD
display. Implement and verify this logic on the STM32 Nucleo-64
LAB - BECE403E-Embedded System 10
LAB TASK-2
Program

LAB - BECE403E-Embedded System 11


CHALLENGING TASK
Smart Parking system
Write a program to design smart parking system using HC-SR04 ultrasonic
sensor, servo motor, buzzer, LCD and STM32 Nucleo-64 board.
 The ultrasonic sensor module place near the gate entrance
continuously check for the incoming vehicles. The LCD display “Smart
Parking” on the first row and “Avail. slot: XY” in second row of the
display.
 When a vehicle comes closer to the ultrasonic sensor detection area
and parking slot is available then the system open a gate barrier to 90°
(close after 10 seconds) to allow the vehicle enter into the parking slot
and decrement parking slot by 1.
 If no parking slot available then display a message “No Parking slot” on
LCD (2nd line) and switch on the buzzer (for 5 Seconds). Have a similar
system on the exit and increment the free slot by 1 for every vehicle
leaves the parking slot.
LAB - BECE403E-Embedded System 12
THANK YOU

b y

ka
a

You might also like