HOME

PROJECTS

TUTORIALS

C FUNCTIONS

PROGRAMS

PRODUCTS

VIDEOS

FORUM

COMPANY

SPANISH

                   

 Distance measurement using the ultrasonic HC-SR04 sensor and Bolt 18F2550 system

 

Watch HD video:

 

Background:

Modern ultrasonic sensors for the measurement of distances, are inexpensive and allow their connection to microcontroller systems. These sensors have a small speaker and a receiver microphone of the ultrasonic signal bounced by the object from which you want to measure the distance.

The principle of operation is as follows: through the speaker, trains of ultrasound pulses are sent at a frequency of 40 Khz. This signal bounces off the object, and returns to the sensor, being detected by the microphone (Figure 1). Once the delay is measured between the signal emitted and received, based on the constant speed of propagation of sound (340 meters per second) and using an arithmetic formula (Figure 5) the distance to the object can be calculated.

The HC-SR04 sensor, capable of measuring distances between 2 cm and 4 meters, was used in the project described below.

 

General description:

 

The HC-SR04 sensor handles 2 control signals connected to the microcontroller, in this case, the Bolt 18F2550 system. The first signal is 'Trig', which is a pulse with 10 us of duration that triggers 8 pulses of ultrasound emission via the speaker, as shown in the image. The second signal, called 'Echo', generates a pulse whose duration is equal to the response time of the ultrasonic signal bounced off the object to be measured.

 

Figure 1: Testing equipment for the ultrasonic sensor HC-SR04

 

Figure 2: Connection diagram between HC-SR04 sensor and Bolt 18F2550 board

 

Figure 3: Bolt 18F2550 system with HC-SR04 sensor displaying the distance on its LCD

 

Figure 4: for checking the accuracy of the sensor, tests were made with a scale ruler, moving the object and noting the distance shown by system Bolt 18F2550 on its LCD, and comparing with the mark on the scale ruler. The precision is approximately 3 mm measuring distances from 3 cm up to 50 cms.

 

Figure 5: Calculus of distance given the time elapsed by the ultrasonic signal (outbound and return).

 

Firmware BOLT_HC-SR04.zip

HC-SR04_Ultrasonic_Module_User_Guide.pdf

HC-SR04Users_Manual.pdf