top of page

Ultrasonic Rangefinder using 8051:

In this project, we have built an Ultrasonic Rangefinder using 8051 Microcontroller and Ultrasonic Sensor. We have different ways to measure the distance. One way is to use Ultra Sonic Sensor or Module for distance measurement. This article explains you how to measure the distance using 8051 microcontroller. This Ultrasonic Range Finder system measures the distance up to 4 meters with an accuracy of 3 mm.

Principle of Ultrasonic Rangefinder:

Generally, the distance can be measured using pulse echo and phase measurement method. Here, the distance can be measured using pulse echo method. The ultrasonic module transmits a signal to the object, then receives echo signal from the object and produces output signal whose time period is proportional to the distance of the object.  The mechanism of the ultra sonic sensor is similar to the RADAR (Radio Detection and Ranging).

radar-concept.jpg

Radar Concept

Steps of Programming

  1. 8051 microcontroller needs to transmit at least 10 us trigger pulse to the HC-SR04 Trig Pin.

  2. After getting trigger pulse, HC-SR04 automatically sends eight 40 kHz sound wave and waits for rising edge output at Echo pin.

  3. When the rising edge capture occurs at Echo pin which is connected to the input of 8051, start Timer of 8051 and again wait for falling edge on Echo pin.

  4. As soon as the falling edge is captured at the Echo pin, microcontroller read the count of the Timer. This time count is used to calculate the distance to an object.

Calculation (distance in cm)

 

 

 

 

Where,

            Sound Velocity = 34300 (in cm per second)

Here, oscillator frequency of AT89S52 (8051) is 11.0592 MHz then timer frequency of 8051 will be 921.6 kHz. So, time required to execute 1 instruction is 1.085 us.

So, timer gets incremented after 1.085 us time elapse.

e.g.

distance.gif
formula.gif

Interfacing Diagram

Ultrasonic module interface with 8051.pn
bottom of page