Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Sound localization approach.

Status
Not open for further replies.
Ok.. I get it now. The goal is to only find the direction of the sound, not the location.
 
Mosaic

In the past, that site quite was hard to navigate; now even more, because the the "old" is somewhat buried inside. I spent LOT of time making sure I read all. Awfully organized.

This specific content could give you some ideas. I did an excersise of correlation in Excel and was fascinated by the concept behind it.

In my long list of projects.
 
Some of their tests were made with the ADC inside of a PIC and that's what I would do as well.

Correlation from what I understood did not care about zero crossing per se but of sequences of values taken for each channel.

There are some PICs, most probably, recent ones, that could take samples of at least wo signals at the same time. Cannot recall which ones in the 18F family.

Anyway, even if you sample the signals, one after the other, your software could cater for the difference I guess. Maybe, that difference could not meand too much, I guess again.
 
I will attempt the simple OPA 'amplitude' approach but I suspect that a loss of directionality at sub 500Hz will take place.

The second approach:
On the matter of cross correlation, I have done a simplification to side step some of the math for the 16F1826 (32Mhz) processor. Tell me what you think please.

Consider under 3000Hz the domain of interest.
Every 12mS an ADC 8 bit capture for all 3 mics is performed.
6 mS of wave form is captured at a 8Khz rate= 48 samples per mic. At a mic spacing of around 12cm the propagation delay is under 0.5mS. Thus a maximum correlated 'waveform' window of 5mS is obtained across the 3 mics.
The middle 32 samples (4mS window) of data for mic#1 is summed to become the ref. 'energy' window value of the wave.
This this value is correlated to match the equivalent 32 data samples for mics #2 and #3 using brute force summation/comparisons. Thus the relative positional TD value of the correlated wave is determined based on the correlated samples' alignment windows and the known sample rate.
Some software time correction may have to be done for the small sequential delay in Mic sampling.
Based on this the rough direction of the sound (continuous) is assessed. I am only aiming at 45 deg. quadrants for now.
 
Unfortunately, they are not sharing the cross correlation done in the 16F628.:(
Do you have any resources on doing that with integer calcs?

It wodn't be difficult to do it in integers and make it very efficient.

The problems you're facing with correlations are:

1. You need a correlation for every lag. If you analyze 50 possible lags, you need 50 calculations. Each includes one multiplication and one addition at every step, plus comparisons. Even if you fit it into 10 cycles, you'll need 500 cycles per sample or 1500 cycles if you have 3 pairs of microphones. Assuming 200ns/cycle, it'll give you 300us worth of calculations. It's enough time for the sound to travel 10 cm. You need much better CPU. For comparison, you don't need any significant computing power to analyze zero-crossings.

2. Sampling rate. You need to sample 3 channels (one for each microphone). To get 1mm resolution, you need a sample from each channel every 3us, which requires sampling rate at 1MHz, which you probably can't do. With zero crossings you get 0.07mm (assumong 5MIPS CPU)resolution without any sweat.

3. You need to scale your input so that your signal covers substantially all of your ADC range. With zero crossings you don't, because the crossings are right in the middle.

Therefore, calculating correlations is not a good approach to detect phase shift compared to zero crossings. However, I still think that regardless of how you do it, the phase shift detection is inferior to amplitude based approaches (as with this robot, for example).
 
I think there is much guessing going on.
I think there are two different questions.
1) Can a little PIC gather information.
2) Can any machine get direction from 3/4 mics.

As to question 2. I have a 16 channel digital audio recorder. Put the mics in a triangle/square. Walk around making noise. Then using the power of the PC look at the data (not in real time). Use the audio recording software to visually see the phase shift. Use MATlab or Excel to try different formulas. Look for a simple approach that a PIC could do. With Excel you could see what happens with zero crossing verses peak, or volume or phase or........

I also have a 2 channel digital recorder. OK....use a sound card on you PC. Only two channels. less information. faster math. Look to see if you can tell left/center/right.

As to question 1. What can be easy-answered when we know question 1. And maybe the answer is, a PIC can't.
 
Hola mosaic and NG,

I did just a simulation test in Excel with this concept of SAD algorithm in mind. (Pity I could not find the .xls file where I did it).

At instant t0, start taking, say, 300 samples of right and left chanels if possible at the same time or one immediately after the other.

Then, choose a "window" of 10 consecutive samples from de right chanel (starting somewhere in the middle of the period at instant tref) which are pogressively compared to 290 "windows" of 10 samples each from the left channel.

The "comparison" consists of finding the absolute difference between the corresponding samples in both windows.

Once you get the 10 absolute differences, sum them up, save them and move to the next (left) window. Once completed, you should have 290 SADs (sum of absolute differences).

From them, the lowest SAD, with a window starting at instant tx will materialize the difference of TOA= tref - tx

As you see, zero crossing is nothing to worry about using SAD.
 
As you see, zero crossing is nothing to worry about using SAD.

During these 300 samples there could be 2-3 zero crossings on each microphone. So, you would get 4 hardware-recorded numbers which you simply subtract one from another and get the same result as with SADs except with much better accuracy. And you do not need to worry about your sound level exceeding your ADC range.

As you see, SAD is nothing to worry about with zero crossings :)
 
Well, we have (1) the simple to implement amplitude approach with opamps, (2) the uC zero crossing and then (3) the cross correlation that might need a fair amount of MIPS.

1) might work but I've seen papers that claim sub 500Hz confuses amplitude based approaches, plus distant sounds tend to have little amplitude differentiation.
2) seems straightforward enough, I do have concerns about phase reversals being hard to distinguish with 2 mics, although NG thinks otherwise. He just knows more than I do about it, so I'll need some hand holding at that point.
3) requires a fair amount of calcs to correlate the window samples. My plan was to use about 4 ms of 'dead time' with no sampling to analyze each batch of samples. Then do a statistical mode every 50ms or so (5 assessments) to issue a direction.
3) also needs some signal massaging to handle a reasonable range of amplitudes.
 
Just in case I will be posting again when I collect valid hands-on experience. Sorry if I got carried away.
 
1) might work but I've seen papers that claim sub 500Hz confuses amplitude based approaches, plus distant sounds tend to have little amplitude differentiation.

You can build mechanical structures mimicing "ears" to improve performance.
 
You can build mechanical structures mimicing "ears" to improve performance.

**broken link removed**

Today everybody wants to do things cheap and easy.. Back then they did whatever it took to get to the goal. War.. most powerful catalysis in engineering.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top