19 Comments
User's avatar
lcamtuf's avatar

By the way, the demo song is "All The Magic" by Karliene: https://karliene.com/track/2083873/all-the-magic

Expand full comment
Napoleon's avatar

Hi, thank you for sharing this great article!

I tried replicating your microphone amplifier circuit, using almost exactly the same components. However, when I connect the microphone output to my computer for playback, I notice significant background noise — it sounds like strong current or electrical noise. I'm not entirely sure if this is coming from the microphone itself or environmental factors.

My goal is to use this microphone for detecting very weak photoacoustic signals (modulated sound signals around 30 Hz or 300 Hz) and analyze them after FFT processing. However, with the current noise level, it's hard to get usable results.

Do you have any suggestions for improving the noise performance for such sensitive applications, especially for a beginner like me?

Thanks again for your amazing work and any advice you can offer!

Expand full comment
lcamtuf's avatar

What's your power supply? If you're using an AC adapter, it might be contributing ripple that is getting amplified. You can eliminate that with ferrite beads / chokes and some more decoupling caps, but the most expedient workaround would be to switch to batteries.

If it's not that, then my other guess would be that you have long leads to the microphone and this is picking up mains hum. The best way to implement this circuit is to put the amplifier right next to the microphone; for long cables, you'd want another design. That said, using a twisted pair or shielded conductors could help.

The final option would be shielding the entire circuit, for example in an Altoids can bonded to circuit ground. I don't think this should be necessary, but if you have some particularly strong source of interference, it could help.

I'm assuming you implemented the second variant with extra capacitos? Oh: if you're using a chip with two or more op-amps in the package, make sure to ground the inputs for the unused second op-amp.

Expand full comment
Napoleon's avatar

I'm sorry for replying to you so late. I am using a 12V lithium battery that has been reduced to 5V through LDO for power supply. The length of the microphone cable may indeed be a factor, so I will try using a shielding cover

Expand full comment
Pranav's avatar

Lovely article, if I need to filter bird noises which sits in the higher frequency range (1khz - 8khz), do I need to change to a lower feedback capacitor value ?

Expand full comment
Willem's avatar

Thanks for the walk through. I got it all working but I wondered why you used a current to voltage amp setup instead of an inverting amp (voltage to voltage)? As the datasheet says it outputs 1V/Pa (instead of A/Pa), doesn't the mic output a voltage not a current?

Also, 100k-1M was too much gain and I got lots of distortion. 1 to 10k seems like a fine range but there is lots of white noise. I'm using an mcp602 and all I can think of is rail to rail limitations. Thoughts?

Expand full comment
lcamtuf's avatar

As for your other question - it's hard to say without knowing the specifics of your circuit or your use case. If you're driving computer or audio equipment microphone in, you need less amplification because there's some extra amplifier on the receiving side. If that's your use case, try lowering input gain and disabling automatic gain control.

For headphones, around 100k should be a reasonable starting point.

But also depends on what you're trying to record - loud sounds need a lot less gain, etc.

Expand full comment
Willem's avatar

Thanks for helping. I am using headphones and using a 1M pot dialing in a reading .5V max and -.5V min (1Vptp i.e. line level) on my oscilllscope when I hum near the mic. The waves don't look very overdriven (no flat tops on the wave peaks) but the sound is incredibly distorted. The only thing I've done different than your schematic of amp with "improved noise immunity" (second one) is that I'm using 1 uF (tantalum) instead of 2.2uF wherever those are placed. What can I look for if the issue isn't too much gain?

Expand full comment
lcamtuf's avatar

I don't think the cap should be causing problems, unless the value is way too low (1 uF should still be fine).

I'd probably start with the microphone side (check polarity, make sure the bias resistor has the correct value or try some others). Then, probably check the output directly at the op-amp pin (before the output capacitor) to see if it's centered at midpoint and looking otherwise healthy. If it's centered at some other value, the problem may be the voltage divider resistors on the other leg of the op-amp.

If you're using a chip with two op-amps in a single package, and only using one of them, make sure the inputs of the other one are tied to some stable voltage and not floating.

Double-check the decoupling cap for the IC, especially if using a PSU.

The last troubleshooting idea I have is to try other headphones. Are you using old-school wired headphones, or anything that's rechargeable / powered?

Expand full comment
Willem's avatar

Thanks for the solid troubleshooting tips. The issue was that my 5V power from usb battery bank was noisy causing whine and probably over driving the op-amp. This was exacerbated by running my sound recorder off the same battery. Perhaps a ground loop the mic is extra sensitive to.

To fix this I put a 430R resistor in series before the 4.7K resistor and a 4.7uF capacitor to ground after the 430R resistor. I understand there may be some high-pass effect on the mic but these were the lowest values of this RC filter that removed the whine. Hopefully that's helpful to others scrapping it together on a breadboard with crude power (or who want to run off usb bank). Checking and testing different decoupling caps didn't change this issue unfortunately.

I'm happily hyper-listening now, thank you!

Expand full comment
lcamtuf's avatar

There's a bunch of reasons to do it this way. Most importantly, less noise at lower frequencies (because op-amp's internal voltage noise isn't amplified by the same factor as the input signal) and higher bandwidth in high-gain applications (note that the cutoff frequency is inversely proportional to the *square* or Rf, not to Rf as in the case of a voltage-to-voltage circuit). You can also skip one resistor, so fewer parts and fewer additional sources of Johnson-Nyquist noise.

A microphone can be thought of as a voltage- or a current-based signal source, one ultimately depends on the other... but as with photodiodes, current-based circuits are just simpler and perform better.

Expand full comment
Willem's avatar

That's enlightening to my amplifier types knowledge. Also wondering why you chose 5V and 4.7K into into mic when datasheet says max 3V and recommends a 2.2K resistor?

Expand full comment
lcamtuf's avatar

They give an operating range as "1-10 V".

Electret microphones internally have a JFET transistor that admits current that varies with sound pressure. It's not hugely sensitive to the applied voltage, but you want to stay in the vicinity of the spec-suggested current.

The spec for this microphone actually isn't very helpful, but they specify an internal impedance of 2.2 kΩ. At 3 V and with an extra, external 2.2 kΩ series resistor that they suggest, this works out to a current of about 5 V / (2.2 kΩ * 2) = approx. 700 µA.

At 5 V and 4.7 kΩ... you also get ~700 µA. So we're in the same ballpark. In practice, I doubt you'd hear much of a difference with 3.3 kΩ or 6.8 kΩ. Since you're using an op-amp that works down to 2.5 V, you can also try going down to Vdd = 3 V, but this doesn't buy you anything.

Expand full comment
Willem's avatar

In the diagram under "improving the design" I don't see an R1 that you later mention could be 470K. Am I missing something or is the diagram?

Expand full comment
lcamtuf's avatar

Good catch - the text should have read "Rf".

Expand full comment
Brian's avatar

What are your thoughts on pencil lead graphite resistors? I read that audiophiles will upgrade resistors to pencil lead on sound systems to improve quality / reduce noise. Would a pencil lead replacement of the output side 100ohm resistor (in the final diagram) help anything or would the improvement be negligible? Thanks for the great article.

Expand full comment
lcamtuf's avatar

I can't see what would be the point. Based on a Google search, looks like the main claim is that they're "non-inductive". I guess they can have lower inductance than wirewound resistors, but first, the inductance of speaker wires and coils is likely much higher than what you're adding or removing here; and second, you don't need to use wirewound resistors to begin with? Carbon composition resistors should be pretty much the same as pencil leads.

Further, unless you have a really good way to bond copper leads to graphite, I think there's a good chance of the resistor behaving erratically, especially in audio equipment. Vibration and all that...

Expand full comment
Brian's avatar

Thanks for the reply. I read this on the web a while back (about the pencil lead resister), can't remember the source. My initial guess was that it would not work, be practicle, or improve sound in a microphone.. So thanks for the added info. I guess your designed mic might look cool in a clear box with homemade pencil lead resistors and vacume tube transistors, even if not an improvement in sound. Bulky, impractical, time consuming, and more expensive, but cool looking.

Expand full comment
Ant Chris's avatar

Greetings! I wish to kindly ask for your help about some component-codes for the jack connector, that you used on this project, also for the on/off switch, I try to replicate your design , I cannot find a way to hear my voice better, when singing at home, without complicating things for no reason.. And finally - can you please advice, how can I add a volume potentiometer, like - replacing the feedback resistor in the first opamp stage, or directly to the output..? Thank you for your generosity to share this project

Expand full comment