Accurate trigger from a microphone

Hi,

I have a mic, Spark Fun mic and amp, module connected to an Arduino Uno. I have a programme with an interrupt timer checking every milli second if the sound has gone over the trigger threshold.

I have a wav file with sound blips, 40 msecs of high frequency tone, every 1 second. This was created in a proffesional audio studio by me and I know they are definitely 40 msecs long and exactly 1 second apart.

When I play this to my Arduino project through a speaker I get timings between blips of 970 msecs to 1038 msecs, and just occasionally 1000 msecs.

I have the same set up with a "light to voltage" sensor and 40 msecs white flashes repeated every 1 second. This is accurate to within 2 msecs.

Is there a better way to measure sound than a mic? Do sound and voltage equate to the same thing? HAve i made some terrible assumptions?

Keepersgain

Are you taking one sample every 1 millisecond? What is the frequency of your tone? Its hard to know where in the tone waveform that the sample is taken. The time to get the sample is the time that the hold circuit is "open" and that is a very short time (microseconds?). Increase your sample rate and see if the accuracy increases. This is sort of an example of aliasing. You need to sample several times per cycle to hope to catch the peak. The light to voltage signal changes much more slowly than a tone so a slower sample rate will pick up peaks easier. By peaks I mean over your threshold.

Hi,

OK that's what I thought. It's good to hear it from someone else. I'l grab number of samples and when they happened and try that.

Thanks