Sensing Sound Wave with microcontroller

Sound wave can be sensed by using sound sensor. If you are designing some kind of robot, sometimes it is useful to enable sensing of sound. Then you can program your robot to follow your voice commands. In some cases sound wave sensors are used as collision sensors. Sound wave sensor is a microphone. Microphone is a device which converts sound pressure in to electric signals.

Lets see how sound wave can be sensed. As we already know, sound is a complex signal which consists of multiple different frequency waves. One sound wave can be represented as sin or cos signal:

sound wave

When many of such waves are summed (s called harmonics), we can represent any analog signal- any shape and any frequency.

X(t)=A*sin(2Ï€t/T)=A*sin(2Ï€ft),

Where A – Amplitude, T – Period, f=1/T – frequency, t- time. This is a function of above sine signal. I am not going too deep in to details of trigonometric functions, you can find them inany math or physics book.

Lets see how square impulses can be made of few different frequency, phase and amplitude sine waves.

sound_wave_harmonics

We can see in illustration that by adding multiple harmonics we can get desired signals. More harmonics we add – more accurate signal we get. Frequency of first harmonic defines the frequency of signal. Mathematic formulas you can find anywhere. I just wanted to show an idea, what signals are made of. Logically thinking if we can combine signal by adding multiple sines or cosines than there is ability to split signal in to separate waves. For this filters are used. If we want to extract first harmonics we can use low frequency filter. The lof frequency filter characteristics is shown in the following illustration:

soundwave_filter

Cut off frequency of filter is in level 0.707. This means that signal is reduced 1.414 times, what is 3dB.

Simple low frequency filter may be Butterwort active filter:

Butterwort_filter

There are many typer of filters, low pass, high pass, band pass, band stop. They can be analog or digital and so on. How they can be used to recognise some voice commands in embedded systems. Of course if you are using general purpose microcontrollers, than it is quite hard to implement digital filter. One solution can be to use analog filter like band pass. If we know, that command is going to be sound wave (1kHz) then you use bandpass filter to select only 1kHz sound wave from environmental noise.

bandpass Filter

Using microcontroller you can detect filtered signal and microcontroller can react with some action. Lets say you want you robot to be able to recognize 3 commands. Then you can use three bandpass filter like 1kHz, 1.5kHz and 2kHz. To send accurate sound waves use whistles with mentioned frequencies. This is simple method. If you want more reliable system, you should use some coding of sound commands and so on.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

To submit your comment, click the image below where it asks you to...