Help with TDOA Arduino

Hi! I need help with a project, i have done extensive research, but I still cannot seem to find out what is wrong. I'm trying to localize sound using TDOA(Time Difference Of Arrival). Which in theory is pretty straight forward. However, the results are very unstable. I'm using the 5V "peak allert" on these: Recommendations For You - DealeXtreme. Which in turns uses an LM386 Audio Amplifier. On roughly the same sound and roughly the same position can vary from 30 to 1900 clock pulses, and i believe they are actually in some way dependent on the volume of the sound.
Does anyone know how i can fix this? I'm planning on writing an instructable for this project.

For more details:
The digital input is used because the analog input of Arduino uses 100us to record pluss some overflow, so it ,would not be sufficiently accurate.
After that i tried using the digital inputs, but it was extremely unstable, so therefore i made the circuit with a 12-bit binary counter and some other HC circuitry, running on 30MHz, but the inconsistent timings continued. I then looked at the outputs from the microphone circuits and it seems this is the point where it is unstable. Wiring diagrams, kode, pictures and other informations is going to be published in the instructable, but if you need them to help me I'll gladly post them.

Thanks in advance for any help!

What sort of sound are you talking about, and how do you define the "arrival time" of that sound?

For a sharp bang or click, this is not necessarily problematic, but for anything else, it most certainly is.

Hi! Thank you for your reply and I forgot to put this in the description.

The sound to be recognized is something as simple as a clap. And in theory this should be a very simple task. However, the data suggests not. Is there any reason to believe that using the "gate" function on this: SparkFun Sound Detector - SEN-12642 - SparkFun Electronics would help?

As for the arrival time, I am referring to the difference in time for the sound to reach the two microphones (placed 15cm appart). Given at a true 90 degrees, it would be zero, and at 0 or 180 degrees it would be about 440 us. Using this and a little trigonometry will give me the information i need to calculate it.

The problem is that the data I'm getting from the sound sensors is very inconsistent and must be wrong. Therefore the question is, and i can understand that it was too hidden int the last enty;

How should i get this information into a digital signal that can be read by arduino and my digital logic?

As for the arrival time, I am referring to the difference in time for the sound to reach the two microphones.

You have an oversimplified view of a "sound". All sound is a continuously oscillating set of pressure variations, with discrete sounds having an envelope with a rise and a fall time, generally with lots of amplitude oscillations between start and finish. See this summary: Nine Components of Sound

If you define a certain positive going amplitude as the threshold for the "start" of a sound, then by definition the volume of the sound, which is related to the peak amplitude of the pressure wave, will determine whether that sound is detected.

The task you have chosen is actually quite difficult, so you might want to hold off a bit on that Instructable.

Indeed it is a very difficult project dispite sounding easy.

Have you examined the sound on an oscilloscope? You will find that the signal from each channel looks quite different. For a start have you checked the phase from the two signals are the same.

Rather than a simple trigger you need to take a seriese of samples from both sources and apply a sliding correlation between the two to find the actual delay. I am not sure if the arduino is up to that due to the A/D speed you need.

The ADC on the arduino is definetely too slow, even if i tamper with the microcontroller. That is the reason i left this method and started using a "trigger".

The idea behind the trigger is that if it is set at a certain level then it should - in theory - trigger at the same wave on both of the microphones(Given that it is a clear cut sound like a sharp bang or a clap). And that I should use this in combination with a high frequency counter circuit and the Arduino to measure the TDOA.

My question being; would the circuit i linked to, set at a certain gate, be a better choice than the one I already have? And would it be possible with this circuit? (Given that analog analysis is out of the question as far as arduino is concerned)

Not too sure of your circuit but I would try and have the sound modules trigger an RS flip flop and then time the interval between these flip flops being set. This removes any problem with the trigger signal rapidly turning on and off due to successive peaks of sound.
However if you think about the rise time of the sound waveform, this is going to be in the same order of magnitude as different time of arrival. It is this that makes it difficult.
Yes it will also depend on the gain / sensitivity of each audio channel.

For those of you wondering how the program has turned out, it is actually finished with an OK result. I will definatly perfect it over time. But it is now able to direct itself to sounds in all directions. If you are interested I can post a video of it? For now I'll post a picture: