1. Introduction
This section describes how to measure distance to objects with the SRF04 sonic modul from Devantech. In this sample we use two sonic modules. MAM128 (Mini Application Modul) is used as controller unit.
2. Physical bases
Ultrasonic waves are sound vibrations outside of the human hearing area. The frequenzy is above 20kHz. Sound waves can only spread when they are in a suitable medium. In a vacuum no suitable medium is available, so it is impossible to hear something in the universe. The sound velocity is depending on it medium. Although the sound velocity is relatively small, it was measured first in the seventeenth century. Within the following centuries the people recognized that the sound velocity didn't depend on the frequency of the wave, but of his medium and the temperature. Sound waves are also reflected differently or even absorbed by objects.
Medium | Velocity in m/s | |
Carbon dioxide | 268 | |
Air 0°C | 331.6 | |
Air 20°C | 344 | |
Air 30°C | 349.6 | |
Hydrogen | 1310 | |
Water | 1483 | |
Glycerin | 1923 | |
Brass | 3420 | |
Glas | 5000 | |
Iron | 5200 |
Sound waves go into all directions circularly, as far as they aren't absorbed or reflected limitedly by objects. The sound energy spreads out proportionally to the radius on an area getting bigger and bigger. The energy of a sound wave and the volume decreases with the distance to the acoustic source. Further the energy depends on the amplitude and frequency of the sound wave. By doubling of the frequency the speed of the air molecules also doubles. If a police car passes fast with siren, you can take acoustically truly, that the tone suddenly gets considerably lower. This fact is called Doppler effect. The dicoverer was the Austrian physicist Christian Doppler who made the first theoretically and practical tests. In the picture below you can recognized how this effect come about. The stationary acoustic source is represented on the left. The wavelengths are equally big in all directions. On the rigth side the acoustic source is moving from left to rigth side. At point A a lower note can be heard because the wavelength was stretched. At point B a higher note than the original one can therefore be heard because the wavelength was compressed. If the start frequency is known, the speed of the object can be calculated.
3. SRF04 Sonic module
The ultrasound module is consisting of transmitter, receiver, control and analyze logic. The modul is working with TTL level. A defined trigger signal starts the measureing. The measurement result is distributed over the echo line. The signal length of the echo line reflect the distance of the object in the recording area. The distance can be calculated with the following formular:
Distance[µs*cm] = Time[µs] / Velocity of sound[µs/cm]3.1 SRF04 Timing
3.2 SRF04 DC Electrical Charateristicts
Voltage | 5V | |
Current | 30mA Typ. 50mA Max. | |
Frequency | 40kHz | |
Max Range | 3 m | |
Min Range | 3 cm | |
Sensitivity | Detect 3cm diameter broom handle at > 2 m | |
Input Trigger | 10uS Min. TTL level pulse | |
Echo Pulse | Positive TTL level signal, width proportional to range. | |
PCB Size | 43mm x 20mm x 17mm height |
4. Hardware Diagram
The MAM (Mini-Application-Mudul is discribed.
5. Software
The software is written in Ansi-C and is optimized for the AVR-GCC cross compiler.