Range/Obstacle Detection with Ultrasonic Sensor Projects

Get Started with Altium Upverter, Sign Up Now

Upverter Expert - Range_Obstacle Detection with Ultrasonic Sensor Projects

The choice of sensor is a challenging and crucial part of any project. The performance, cost, and size of your project depends greatly on the sensor you choose. Range, obstacle, and level detection are very common tasks in many applications, and many sensors are available on the market for range detection or obstacle detection. Compared to other sensors, ultrasonic sensors are cheap, easy to use, and robust. This makes them a favorite entry-level sensor for hobbyists and professionals.

HC-SR04 module for ultrasonic sensor projects

The HC-SR04 module for ultrasonic sensor projects

How Ultrasonic Sensors Work

Compared to an optical sensor, and ultrasonic sensor’s output and sensitivity is independent of ambient light, color, texture, and transparency of the target. Because these sensors operate beyond the range of human hearing and vocal spectrum, the sensitivity is also independent of most ambient noise sources.

All ultrasonic sensors determine the distance to an object by measuring the time required for ultrasonic waves to reflect from a target. This is similar to SONAR, but off-the-shelf ultrasonic sensors can be used in any environment. These sensors produce high frequency sound waves which reflect off an object or obstacle in their path. The ultrasound receiver captures the reflected waves, and you can then calculate the total distance to the obstacle based on the speed of sound in that medium. This requires specifying the speed of sound in your calculation (approximately 331 m/s at atmospheric pressure and ambient temperature).

shutterstock_205582693
Ultrasonic sensor measurement principle

First, the total travel time (T) between transmission and reception of the signal is measured with the system, and the distance (D) between the sensor and the target can be estimated using the following relation:

ultrasonic_eq

where Cs is the speed of ultrasonic waves in the medium. The factor of ½ is due to the fact that the wave travels double the distance between the transmitter and receiver.

Getting Started with Ultrasonic Sensor Projects

If you’re thinking of including range detection capabilities to your board, the prepackaged module shown above will interface directly with an Arduino board or other microcontroller board. As most transducers emits at 40 kHz and above, you only need to supply a low frequency analog signal or a stream of digital pulses to trigger the transducer. Given the low frequencies used in these systems, you can easily implement an ultrasonic sensor in your board without worrying about EMI or other signal integrity problems.

Advantages of Ultrasonic Sensors

Linearity is one of the important performance parameters for any sensor, and ultrasonic sensors have linear output response over a broad range of input power. Ultrasonic sensors can be reliably used for range detection indoors or outdoors. The performance doesn’t fluctuate with variations in the ambient lighting. They are also robust and can be moved quite often, hence they are suitable for mobile applications, such as collision avoidance for robots moving at low speed.

Mist, smoke, or dust also do not affect the performance of these sensors. The color and texture of the target doesn’t matter either as long as the target has a hard surface, which means ultrasonic sensors can even be used for mash structures. Soft structures will have reduce the intensity of the reflected wave, making them more difficult to detect at longer range. The response of the sensor has a small dependence on temperature, but these sensors are still more stable against temperature changes than infrared sensors.

Challenges in Using Ultrasound Sensors

The primary challenge involving the use of ultrasonic sensors for range detection occurs when the target surface is of low density. In such cases, sound waves get absorbed by the surface and reflections are too small to be reliably sensed by the receiver. Another concern with ultrasonic sensors is their minimum sensing distance.

After transmitting the signal, the sensor needs some time to recover before it is ready to receive the reflected wave. If the range is too small, the receiver will receive a reflected wave before the trigger signal ends, resulting in an erroneous measurement. The datasheets for your particular sensor will usually specify the minimum range that can be reliably detected.

Range Detection in Your Ultrasonic Sensor Projects

One common sensor used for range detection with a development board is the HC-SR04 (see above), which provides high accuracy and stable readings in a compact package. It has four pins: supply, ground, trigger, and echo. Transmission is initiated by sending a 10 μs pulse to the trigger pin. This causes the ultrasound sensor to send out 8 pulses of 40 kHz each and raise the echo pin to high value. The echo pin stays high until the reflected signal is received, at which point it turns low. The length of time the echo pin remains high is proportional to the distance travelled (see the above equation).

timing_sensorTiming diagram for the HC-SR04 ultrasonic sensor

The typical usable range for this particular sensor is 2 to 400 cm, although working at more than 10 cm ranges gives better results with 3 mm accuracy. These modules typically require a 5 V power supply, and the operating current can reach 15 mA (3 mA standby current). The sensor assembly can be easily plugged into a breadboard for testing purposes.

For a simple range testing, you can plug the HC-SR04 sensor into an Arduino board, as shown in this tutorial. Ultrasonic sensors are excellent devices to use for liquid level measurements with a microcontroller board. This can be used for something as simple as creating an automated plant watering system, flashing an alarm LED, or for triggering a relay to turn a valve in a large water tank.

Another interesting project is to use an ultrasonic sensor in robotics for obstacle avoidance. This is simple enough to implement on an Arduino board, although you might consider going with Raspberry Pi or an equivalent if you need much more processing power. For the clean freaks, you can find a touchless automatic motion-sense trash can in this tutorial. The applications for the ultrasonic sensors are limitless and quite affordable.

More Advanced Ultrasonic Sensor Projects

You can also use an ultrasonic sensor for more complicated speed measurements. If the relative speed between the sensor and the object is rather large, a Doppler shift will occur once the wave is reflected from the target, and the shifted frequency can be detected with an ultrasonic sensor. The magnitude of the Doppler shift can be used to calculate speed, but not heading; at least two sensors with defined angle between them must be used to measure heading as well as speed.

If you want to implement this feature, you need a separate analog ultrasonic transducer. You then need to mix the detected signal with the reference signal, producing an AM analog signal. The frequency of the AM signal can then be extracted using an envelope circuit and then measured. You can then determine the relative speed between the sensor and the target using the standard Doppler shift equation. Note that the actual speed and any heading measurement will depend on the resolution of the ADCs in your system.

Small module for ultrasonic sensor projectsSmall module for ultrasonic sensor projects

Once you have decided on the type of system that you want to build and collected all the required components it’s time to test the system. The easiest way to implement a test system would be using Arduino, Raspberry Pi, or similar platform.

You can sign up for free and get access to the best browser-based PCB editor, schematic editor, and component database. Visit Upverter today to learn more.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s