How to detect sound direction?


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default How to detect sound direction?

    Has anyone used PBP and 2 or more microphones to detect the direction that a loud sound comes from?

    If not, any ideas?

    I'm thinking of starting with 2 microphones connected to ADCs and using that to measure the time difference between a sound over a certain threshold being detected in each microphone.

    But im not sure how accurate the timing will be. I'm thinking I may have to use 2 PICs, because as far as i know, you can only select one ADC channel at once.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default

    And if two different sounds come wih slightly different time, from 2 different locations?

    You have to identify the sounds first. If they are tha same, then try to locate them. But in my opinion this is not so easy. Humans can detect the direction in any of the x-y-z axis because of the ear construction and not only of time difference. It is more complicated than it sounds! Literally!

    Ioannis

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Yeah, I realise that its difficult, and I wouldn't expect anything I come up with to be perfect.

    Thinking about it more, 2 microphones wont do the trick. I think with 3 microphones in a triangle and a bit of creative code it would be possible to make something that could crudely pinpoint the directions of loud noises.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  4. #4
    Join Date
    Sep 2006
    Location
    Indiana, USA
    Posts
    72


    Did you find this post helpful? Yes | No

    Default

    You would need an amp of some sort of course, opamp, whatever. Then feed that into a schmitt trigger to get a nice square wave and then detect which mic triggers first and how long it takes to get the second trigger. that might give you a rough direction, but sound waves move pretty fast and arent always super directional, and there are tons of stuff that can affect them.
    But I did build a lightning detector that used the flash of light to trigger my digital SLR. I used a fast photodiode and an pic with an ADC so i could set a threshold to handle ambient light. So speed may not be that big an issue anyway

  5. #5
    Join Date
    Oct 2008
    Location
    Southern California
    Posts
    17


    Did you find this post helpful? Yes | No

    Cool You're in for a long project

    You can do what you want to do, but don't think this is going to be an easy project for the weekend. You'll need to convert to square waves, use the internal comparator, use as high a clock speed as possible, 2 PICs, comms between the PICs, and OPAMPs externally for a start. Yes, you need 3 mics (or 4 might be easier). Or, just deal with the left-right ambiguity if you can (much simpler if you know which 180 degrees of the originating signal). You're probably not going to be happy with the results in the end. You're trying to accomplish Time Difference of Arrival (TDOA) with a ~40 MHz (10 really) PIC. Get really comfortable with PBP and interrupts. Read up on "zero crossing detection" as well. It isn't because of the speed of sound, but the looong waves and abiguity in the zero crossings that will make this rough. You'll have to get good with the internal counters also.Brush up on your trigonometry too. PBP isn't strong in that area. In the end, you're going to have most of the chip working toward the goal and still not be happy with the result. YOU'RE GOING TO LEARN A TON TRYING!! I don't mean to sound like this is impossible, but you're biting off a REALLY big chunk of work. Great idea, but hard (and advanced) to implement! Even experienced programmers struggle with TDOA and higher power processors than PICs.

    Another possible way to do it if you're not worried about accuracy so much is to set up 8 mics in a wide as possible circle (omni mics pointing up) and external circuits to amplify and convert to square waves at zero crossings, and then use port B (interrupt on change). At least you can tell the basic direction of arrival (45 degrees-ish) instead of all the work of true TDOA. As others said, this is going to be hard to do if you have interfering sounds at all. How would you want to display the information? LEDs in a compass rose? To the LCD? Serial data out?

    Post your code when you're done! Good luck.
    Last edited by rswain; - 11th December 2008 at 00:53.

  6. #6
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    I realise that this isnt a quick and easy project, but since i'm struggling to come up with ideas of what to make next, I figured ill give it a try.

    I have had some experience with the things rswain mentioned including interrupts, counters, comparators and some basic zero-crossing detection. The fun bit is going to be getting all of those things to work together to produce a result.

    I feel pretty confident about the coding side of things (or at least as confident as you can be when trying to tackle a tricky problem). Where my knowledge is going to let me down is the analogue electronics side. As soon as things are digital im fairly comfortable.

    Does anyone have ideas on how best to amplify the mic signals and convert them to square waves? I think this is where I will struggle the most.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  7. #7
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    This is what i'm thinking at the moment, but as I said, analogue electronics isnt my strong point so I could be way off track.

    Opamp and schmitt trigger configured for threshold detection:

    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

  8. #8
    Join Date
    Nov 2006
    Posts
    70


    Did you find this post helpful? Yes | No

    Default

    What if, instead of using time of arrival to determine where a sound comes from, you use directional microphones. Or you use some sort of muffling cone to reduce the sound energy that reaches the mike from behind. Then you could measure sound intensity from all of the mikes and compare loudness to get a direction. Its not as sophisticated as the timing approach, but it might be easier to implement given the simple situation you describe with a single loud noise. Maybe you need decibel meters and not microphones. Sounds cool. Good luck.

Similar Threads

  1. Delayed output 10 secs
    By lilimike in forum mel PIC BASIC Pro
    Replies: 37
    Last Post: - 14th October 2011, 06:28
  2. new to PIC programming could really do with some help
    By karenhornby in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th March 2008, 14:03
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. Sound and sound control with minimal parts
    By bartman in forum General
    Replies: 23
    Last Post: - 18th January 2005, 14:08
  5. Re: quick fix for sound command?
    By Melanie in forum Code Examples
    Replies: 0
    Last Post: - 9th July 2004, 01:44

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts