Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: airman00 on February 27, 2008, 10:25:56 PM

Title: Take a reading from a microphone
Post by: airman00 on February 27, 2008, 10:25:56 PM
How can you take a reading of a microphone and interface it to a microcontroller? Would it be ADC or something else?

I found this schematic online
(http://www.oldbird.org/mikecir.jpg)

But are all those capacitors necessary , and also what would be the form of that signal( aka how do I interface it to a microcontroller)

Title: Re: Take a reading from a microphone
Post by: hazzer123 on February 28, 2008, 01:39:51 AM
Im guessing the microphone's output is proportional to the pressure of the air at its sensor. So the output would be a sound wavel.

To record sound using a MCU, you would have a loop in which you sample the ADC and store it as an element of an array.

This would record 2 seconds of sound.
Code: [Select]

counter =0;
for(2 seconds) {
     soundRecordArray[counter] = Reading from ADC;
     counter++;
}


Say the human voice has a maximum of 4000 Hz when talking. You would have to sample at aout 4 x4000Hz to ensure each wave can be accurately recorded. If you sample at a lower frequency, you may find your recorder sampling only the peaks of a wave, which would then look like DC.

To play it back you would need a DAC.
Title: Re: Take a reading from a microphone
Post by: airman00 on February 28, 2008, 05:17:56 AM
I see....

I want to compare the inputs of two microphones, to detect where the voice is coming from. So I would ADC on both and compare the readings, correct?
Title: Re: Take a reading from a microphone
Post by: paulstreats on February 28, 2008, 06:22:50 AM
Wouldnt you have to do something else such as convert it to a changeing voltage rather than a changeing amp for the adc to read it properly. Usually microphones emit an wave which is interpreted electronically as a change in the amps, the voltage level remains the same. When you amplify you usually increase the voltage level and the amps wave increases in proportion.
Title: Re: Take a reading from a microphone
Post by: benji on February 28, 2008, 06:41:37 AM
u gorra check mic output voltage levels and turn it to 0 >> 5 volts to get the best of you adc
mics give a very weak signal unless its attached to an amp
Title: Re: Take a reading from a microphone
Post by: Asellith on February 28, 2008, 02:09:08 PM
If you don't care about the sound only the sound level you might be able to feed it into a capacitor and read the overall voltage stored there. I'm doing this on the fly at work so it might sound crazy after I think about it some more  ;D  But the louder the sound into the mic the larger the RMS voltage will be if you filter that with a cap it might give you a rough estimate of the volume. If you sample from 2 different mics you might get a false positive because the second mic will read the voltage at a different time and might get the falling edge of the signal even though it had a larger peak. Ok now back to making wiring adapters for clocks. I can't wait till I grow up to be a real engineer. 5 more months!
Title: Re: Take a reading from a microphone
Post by: Soeren on February 28, 2008, 02:53:38 PM
Hi,

Say the human voice has a maximum of 4000 Hz when talking. You would have to sample at aout 4 x4000Hz to ensure each wave can be accurately recorded. If you sample at a lower frequency, you may find your recorder sampling only the peaks of a wave, which would then look like DC.
The human voice contains formants important for distinguishing certain sounds of up to slightly above 6kHz.

To sample a frequency reliable, you need to sample at least twice that frequency (Nyquists theorem).
Title: Re: Take a reading from a microphone
Post by: hazzer123 on February 28, 2008, 03:57:36 PM
Hmm thats what i got taught - (the Nyquist theorem) - but when i think about it, 2x doesn't seem enough. I might be wrong though ...

Heres why i think it's wrong

(http://i269.photobucket.com/albums/jj80/Hakins90/samplingNyquists.jpg)

This is sampling at 2xf, yet the output is not what the input was.
Title: Re: Take a reading from a microphone
Post by: Soeren on February 28, 2008, 09:52:17 PM
Hi,

Hmm thats what i got taught - (the Nyquist theorem) - but when i think about it, 2x doesn't seem enough. I might be wrong though ...
Either you are. or the entire world of engineers working in some way with sampling digital signals (including me) are  ;D


Heres why i think it's wrong

(http://i269.photobucket.com/albums/jj80/Hakins90/samplingNyquists.jpg)

This is sampling at 2xf, yet the output is not what the input was.
That is what could happen at the Nyquist frequency (highly theoretical though, since no circuit has a frequency deviation of exactly zero.
If your sample speed is a bit too low, you would get false readings (the input would appear to be of a lower frequency), but as long as your sample speed is just a wee bit higher than twice your signal frequency, you're in the green.
CD audio sample speed is 44.1 kHz and the signal can go to 20kHz - does your CD's sound bad? (Not talking music taste here of course :))
Title: Re: Take a reading from a microphone
Post by: Admin on March 01, 2008, 10:40:48 PM
Quote
I want to compare the inputs of two microphones, to detect where the voice is coming from.
http://www.societyofrobots.com/robotforum/index.php?topic=1125.0
Title: Re: Take a reading from a microphone
Post by: airman00 on March 01, 2008, 10:42:42 PM
Quote
I want to compare the inputs of two microphones, to detect where the voice is coming from.
http://www.societyofrobots.com/robotforum/index.php?topic=1125.0

I saw that,  :P

I just wanted to know how to take the actual reading