Tuesday, February 19, 2013

Sound frequency detection and new order for parts

Introduction

This is part of my trilateration project.

I have spent a few days working with the electret microphone circuit connected to an Arduino to be able to listen to a specific frequency. In my code I count the number of times the input wave crosses over the zero line. This way I can identify that a specific frequency is played from the robot but there is still a long way from reliable results. With current circuit and code it takes too long to detect. Every millisecond gives a large error in distance.

Other issues is that sound waves are really long if you do not go to high frequencies.
"The wavelengths of sound frequencies audible to the human ear (20 Hz–20 kHz) are thus between approximately 17 m and 17 mm" - http://en.wikipedia.org/wiki/Wavelength
This means if I use 20KHz I can theoretical get a distance precision of one single wave detection of 1.7cm. That also means I have to detect the time of the first wave that hits the microphone. In my experiments really load noises like clapping or whistling close to the microphone gives really large outputs that can be easily detected but the tone of a buzzer a few meters away is way harder to detect.

The sampling frequency I get is around 10Khz. I have seen others get higher frequencies by neat tricks. Another thing to consider is that it looks like the tone library´s limit is around 30Khz .

10KHz sampling rate showing the tone wave from the robot.
The plan is to test a few more software libraries and then move over to hardware devices like the XR-2567 that can handle higher frequencies.

The Goertzel Library

The Goertzel Library is the thing that looks most promising
https://github.com/jacobrosenthal/Goertzel
it is based on the Goertzel algorithm and can detect frequencies.
http://en.wikipedia.org/wiki/Goertzel_algorithm

The XR-2567 dual monolithic tone decoder

The 2567 IC also looks most interesting and is made to detect specific frequencies and outputs an logic output. so I will order myself one of those. This might enable me to go to much higher frequencies than the Arduino can handle by itself. 

The 2567 Datasheet, I hate those bad scans!
http://www.electrokit.com/productFile/download/918

Here is a similar circuit showing a similar IC to get a feel for typical values for the capacitors and resistors.

New Order 

I decided to order some parts from electrokit .
  1. Various Capacitors and Resistors for the audio detection circuits
  2. 10K Trimpot for the audio detection circuits
  3. XR2567CP-DIP 16 Dual tone decoder
  4. ATTiny13V and ATTiny25 just for fun. I have not tried the ATTiny13V before.
  5. A couple of zener diods to be able to do some experiments on voltage regulation
  6. Digital potentiometer 256 steps also for experiments
But tonight I hope to get some coding done...

6 comments:

  1. I tried the Goertzel Library, at first I think it works then I get a lot of false positives...

    ReplyDelete
  2. and the frequency-measurement-library might work but it seems like a circuit Im too tired of connecting tonight...

    ReplyDelete
  3. I know it's trying to solve a different problem but using FFT you can pick which frequency band you want after it's done. See http://coolarduino.wordpress.com/2012/10/01/sound-localization/ for an elegant example. Also http://coolarduino.wordpress.com/2012/10/18/speech-voice-recognition-remix/ Keep up the good work.

    ReplyDelete
    Replies
    1. Thank you! I must take a look at those FFT!

      Delete
    2. And I found a library for it :)

      http://neuroelec.com/2011/03/fft-library-for-arduino/

      Delete
    3. And another one...

      http://wiki.openmusiclabs.com/wiki/ArduinoFFT

      this one looks promising!

      Delete