electret mic conversion to dc - Page 1
Forum section: electronics / beginners

author: blewisjr
author_rank: Frequent Contributor
timestamp: October 06, 2013, 02:47:17 pm
content: Hello everyoneI understand an electret mix emitts an analog signal which is in the low millivolt range.I need to hook up the mix to a uC analog input pin to trigger an interrupt when sound comes in.the issue is see is that I need toa) amplify the signalb) filter out the neg voltagesc) filter further to remove signals below a threshold.I am new to this stuff and I have no clue where to even begin.My first thought was to use a voltage doubler to amplify which should remove the neg voltages. I have no clue where to move from there. Any thoughts?

author: Thor-Arne
author_rank: Unknown
timestamp: October 06, 2013, 03:45:37 pm
content: This pageshows how to hook up a electret microphone to a PIC microcontroller.There's no negative voltage if the mic is connected like this, so it only needs to be amplified.A diode and small RC network could provide some peak-hold (seeEEVblog #490), if you need that.The rest of the "filtering" can be done in software, just ignore the readings below a certain reading.

author: blewisjr
author_rank: Frequent Contributor
timestamp: October 06, 2013, 03:56:53 pm
content: From what I see from that it is already amplified. So if I am thinking right I can just run the signal through a single opamp bandpass filter and be good?

author: Thor-Arne
author_rank: Unknown
timestamp: October 06, 2013, 04:04:59 pm
content: Yes, you can use a bandpass filter between that amp and the microcontroller.

author: blewisjr
author_rank: Frequent Contributor
timestamp: October 06, 2013, 04:36:15 pm
content: Ok thanks I will experiment with that on a simple example before I go all out on my project thanks again.

author: blewisjr
author_rank: Frequent Contributor
timestamp: October 08, 2013, 12:43:38 am
content: Ok I ran some tests and ran into nothing but issues haha. The uC code works fine no issues there as it is technically possible for me to manually trigger the interrupt which switches the LED on.From what I can see it seems as if the microphone is either...a) not enough oomph (hard to get a reading with my multimeter seems really low)b) not working at all (not something I can really test I can read voltage on the other side of it)Basically what I am doing here is feeding the mic power (uses the same pin for both input voltage and output voltage)The output of the microphone is going through a single opamp (LM741) band-pass filter and then out to the micro input pin.Not sure what is going on if I tap R1 with a multimeter just right I can get the interrupt to actually fire off.I will attach the schematic for you guys to look at. Keep in mind this is built out on a breadboard.Hopefully someone can pin point what is wrong probably my circuit or something because the code is fine it is just not getting the voltage it needs for the uC to recognize the pin change.

author: Hideki
author_rank: Frequent Contributor
timestamp: October 08, 2013, 01:07:00 am
content: You have connected the microphone right across the power rail, and the signal you send to the opamp is the 5V power, directly.Now, that 5V is unlikely to change much even if you scream into the microphone. Let's hope the capsule survived the shock (it may be dead now).What you need to do is to have a resistor from 5V to the mic. Ideally of a value that biases the output somewhere the middle (2.5V). It is then usually coupled into the next section through a capacitor, just like you see in Thor-Arne's link or herehttp://en.wikipedia.org/wiki/Electret_microphone.

author: blewisjr
author_rank: Frequent Contributor
timestamp: October 08, 2013, 02:23:39 am
content: still not having any luck with this.The mic should be fine as it is rated to take a hit up to 10V max according to the data sheet. However I still have the issue. Right now with the way it is set up the output from the opamp is sitting around 2.8v and no sound at all even loud music will get the voltage to change going into the opamp. I have it hooked up similar to what you see in Thors link except the resistor goes right to the rail instead of a controller pin. Maybe I should try powering it via the controller instead?

author: Skaface
author_rank: Contributor
timestamp: October 08, 2013, 02:48:16 am
content: maybe you should listen to what hideki said

author: blewisjr
author_rank: Frequent Contributor
timestamp: October 08, 2013, 03:03:29 am
content: yes I did that. The drop to the mic bias' around 2.4 volts actually then goes through a capacitor into the amplifier which comes out of the opamp again at 2.5 volt's ish. When you tap, clap, or even play loud music there is no change at all anywhere so the interrupt never gets triggered but yet you can trigger it by tapping a resistor with a multimeter.I apologize if I am not getting the point all this stuff is still new to me and I do not understand a lot of it.

author: Psi
author_rank: Super Contributor
timestamp: October 08, 2013, 03:05:45 am
content: Depending on your application, sound quality required and the MCU you're using you may be able to reduce your component count and remove the preamp by using the MCU's differential ADC channel with programmable gain.Quite a few attiny/mega chips with an ADC also have differential channels and some gain options. 10x, 20x, 100x, 200x etc.With one of the differential inputs connected to half VCC and the other connected to the electret mics output cap you should be able to read the MIC AC waveform from the mcu adc directly.You can then rectify the signal in software if needed. Ignoring sounds below a threshold can also be done in software.

author: blewisjr
author_rank: Frequent Contributor
timestamp: October 08, 2013, 03:13:55 am
content: What I can see all this amp stuff is not working at all. I do not have a adc with this chip I am using however only a analog comparator. So I doubt this method would work. I might be able to cut the voltage going into the mic and feed it into the comparator but I doubt the waveform would have a high enough amplitude to break the reference voltage to trigger the interrupt.Another option may be to use a npn transistor circuit to gate the system to trigger the interrupt but I am not sure if I can get enough current to get the gate to flip either.Sound quality is not what I need. Basically I am trying to simulate what you would call a audio trigger. The Controller senses the signal and then reacts by flipping a bit to turn on the led in this simple case. So for instance as you say clap the led toggles on and off.This is just a experiment to see if I can get the simple case to work before it goes into my sound triggered stopwatch I am planning.All I know is right now I am getting discouraged because nothing is working rightEDIT: I decided what the heck lets lose the band-pass filter and try the gate strategy with the NPN transistor. Figured what the hell everything else did not work. BINGO!!!!! simplifying the preamp to use just a NPN gate did the trick with the digital input pin. Thanks Psi for making me think a bit simpler by mentioning less parts.

author: geraldjhg
author_rank: Regular Contributor
timestamp: October 14, 2013, 07:30:59 pm
content: an electret mic conected to vcc via a resistor with NO capacitor is all positive going andwill generate enough for an adc input via some 10k res for protection, not easy touse as an interrupt sourceonce the idea works see how much you have to shift and or amplify it

author: deth502
author_rank: Frequent Contributor
timestamp: October 14, 2013, 08:00:43 pm
content: im working on something similar and have had similar results. i had it working great with the transistor amplifying it, but wante more sensitivity (gain) and tried it with an op-amp. cant get the op-amp circuit to work for shit. if i have any epiphanies, ill let you know, but most likely ill give up and fall back to the bjt solution.