Audio Preamp Circuit for a Microcontroller

Thread Starter

Engineer9001

Joined Dec 13, 2019
22
You can get as much gain as you want with ANY supply voltage. But the circuit has only a single transistor so if the gain is high then the distortion will also be high.
You need a higher supply voltage so that loud voices or music will play loudly without distortion.

You never said what "sounds" you are sensing. Maybe nearby gun shots?? Then distortion does not matter.
I see. So the large supply voltage allows for higher gains without the distortion. Thanks for the help!
 

Thread Starter

Engineer9001

Joined Dec 13, 2019
22
I downloaded LTSpice and now my simulations look correct. I also changed some of the values.

Waveform 001.png

I also noticed that resistor R13 (from the Altium schematic) was fitted onto the actual circuit board when it should have been Not Fitted and now I'm getting the correct output voltage on the collector.

The problem now is that there seems to be a power supply pulse every 100ms that gets amplified through the circuit. What's the best way of filtering this out?

Here is the output at the collector:
20200406_211847 Vc Output.jpg

Here is the voltage at the base:
20200406_211927 Vb.jpg

Here's the 3.3V power supply:
20200406_211806 3.3V.jpg

I tried putting a 1000uF Poly cap on the 3.3V power supply and I could have sworn it filtered out the pulses. I also tried using a 100uF poly cap, and a 1uF poly cap and it filtered out the pulses, so I proceeded to solder in the 1uF poly cap. After actually soldering the cap and turning on the circuit, the pulses were still there. I put the 1000uF back onto the 3.3V power supply and it no longer filtered the pulses.

*This circuit board also has the ESP8266 wifi module connected to it. Maybe that's what's causes these pulses? If so, how can I filter them out and prevent these pulses from being amplified?
 

DickCappels

Joined Aug 21, 2008
10,152
You probably need to insert some resistance or reactance (read that: inductor) or both between the voltage source and your very large capacitor to make an "L" filter.
 

Audioguru again

Joined Oct 21, 2019
6,673
Your last circuit has high gain and a low supply voltage. With a conversation level into an electret mic about 10cm away from your lips its distortion is about 5% to 10% but any higher level will produce severe clipping distortion.

An electret mic is designed for a DC voltage across it of 2V or more. Its current is about 0.4mA. With a 10k resistor feeding it 3.3V then its actual current is only 3.3V - (0.4mA x 10k)= less than zero (but it will probably draw a little amount of current). Therefore the 10k must be reduced to about 3.3k allowing the mic to barely work if the sound level is never high.
 

Thread Starter

Engineer9001

Joined Dec 13, 2019
22
You probably need to insert some resistance or reactance (read that: inductor) or both between the voltage source and your very large capacitor to make an "L" filter.
What value of RLC do I need in order to filter out that pulse?


Your last circuit has high gain and a low supply voltage. With a conversation level into an electret mic about 10cm away from your lips its distortion is about 5% to 10% but any higher level will produce severe clipping distortion.

An electret mic is designed for a DC voltage across it of 2V or more. Its current is about 0.4mA. With a 10k resistor feeding it 3.3V then its actual current is only 3.3V - (0.4mA x 10k)= less than zero (but it will probably draw a little amount of current). Therefore the 10k must be reduced to about 3.3k allowing the mic to barely work if the sound level is never high.
What equation do I use in order to determine how much distortion there is for my circuit?

I swapped out the 10k resistor for the electret mic to a 3k. It seems to work fine, but now the power supply noise/pulse seems to be the issue.
 

Audioguru again

Joined Oct 21, 2019
6,673
What value of RLC do I need in order to filter out that pulse?
You can filter the pulse but not eliminate it because your supply voltage is too low.

What equation do I use in order to determine how much distortion there is for my circuit?
A single transistor without any negative feedback causes distortion. Your supply voltage is too low causing severe distortion when mic sounds are a little louder than normal. Before audio opamps were used, mic preamps used two transistors that had plenty of negative feedback and a fairly high supply voltage for low distortion.

I swapped out the 10k resistor for the electret mic to a 3k. It seems to work fine, but now the power supply noise/pulse seems to be the issue.
Usually the resistor that powers an electret mic is fed from an RC filter that your circuit is missing. But your supply voltage is too low to have an RC
 
Last edited by a moderator:

DickCappels

Joined Aug 21, 2008
10,152
You may need to have the filter on the output of your power source and the analog circuitry. Try different values we can only guess. Generally, the more R,C, and L the better. If the noise source is a switching power supply a good quality ceramic capacitor 0.1 uf to .001 uf such as those used for bypassing logic chips might be needed.
 

Thread Starter

Engineer9001

Joined Dec 13, 2019
22
You can filter the pulse but not eliminate it because your supply voltage is too low.


A single transistor without any negative feedback causes distortion. Your supply voltage is too low causing severe distortion when mic sounds are a little louder than normal. Before audio opamps were used, mic preamps used two transistors that had plenty of negative feedback and a fairly high supply voltage for low distortion.


Usually the resistor that powers an electret mic is fed from an RC filter that your circuit is missing. But your supply voltage is too low to have an RC
I see. Maybe in my next iteration of this preamp I'll increase the power supply, add more RLC filters, and use two transistors with negative feedback.

Is it more beneficial to just buy a pre-packaged preamp chip instead of designing it using passive components?

You may need to have the filter on the output of your power source and the analog circuitry. Try different values we can only guess. Generally, the more R,C, and L the better. If the noise source is a switching power supply a good quality ceramic capacitor 0.1 uf to .001 uf such as those used for bypassing logic chips might be needed.
I have the power coming in through a power board I designed. The noise doesn't seem to be coming from the power board, but instead probably the ESP82666 wifi device I have is drawing current every 100ms which is causing those pulses?
 

Audioguru again

Joined Oct 21, 2019
6,673
Low noise audio opamps have been used as mic preamps for about 45 years. I thought you are using a transistor to be retro.
A linear voltage regulator IC would probably reduce the the noise enough that a simple RC will eliminate it.
Of course the supply voltage should be higher because audio has a wide range of levels.
 

DickCappels

Joined Aug 21, 2008
10,152
I have the power coming in through a power board I designed. The noise doesn't seem to be coming from the power board, but instead probably the ESP82666 wifi device I have is drawing current every 100ms which is causing those pulses?
Probably.

1586423410894.png
If you place this on the power supply line going into the ESP8266 with the power source being the Vin and Vout going to the ESP8266. The idea is to have the capacitor supply most of the current to the ESP8266 during those bursts instead of taking it directly from the power supply -that's why the series resistor is there, so that little of that edge of the burst makes it through to the power supply. Make the capacitor large.

A similar setup for your premap will filter out some fraction of the spikes.

Switching from the discreet transistor open loop preamp to an integrated circuit preamp will probably help a lot since power supply ripple rejection is an important parameter for op amps but ripple rejection degrades as frequencies increase or in this case, as the change in voltage with time increases so you may still need this filter.
 

redrooster01

Joined Jul 15, 2014
93
Your base bias resistor values are Way Too Low. Then they short away a lot of signal from the electret mic and the input coupling capacitor value of only 0.1uF cuts all low audio frequencies.
With your 5k (also a low value) for the collector resistor the collector current is about 1V/5k= 0.2mA. Then the 2N3904 has a typical hFE of about 100 for its low collector-emitter voltage. Then its typical base current is 0.2mA/100= 2uA and the current in the base bias voltage divider should be 2uA x 10= 20uA then their total resistance is 3.3V/20uA= 165k. The total can be as low as about 51k then the input coupling capacitor value of 0.1uF can pass frequencies down to about 100Hz.

Your 8k (not a standard value) and 2.2k voltage divider causes the base to be at 0.71V then the emitter is at 0.11V and the emitter current is 0.11V/500=0.22mA. Then the collector voltage is 3.3V - (0.22mA x 5k)= 2.2V (too high) and can swing up to 3.3V and down to 0.2V for a total p-p output of 3.1V (into an impedance of 20k or higher). Only 2.2V p-p can be symmetrical.

You wrongly said the gain was only 3 but you forgot that the emitter capacitor was a short circuit to AC. My previous simulation shows a distorted gain of about 58 times at 1kHz. A mic output is about 10mV RMS for a conversation level 10cm away from your mouth. Then to have an output of 1V you need a gain of 100 times but more is needed if the person at the mic has a faint voice level.

I think your simulation program has the Covid-19 virus, mine works fine with your 80k and 22k base bias resistors but then the
collector voltage is too high and causes clipping as shown here:
Exactly! I couldn't have said it better myself. lol
 

neonstrobe

Joined May 15, 2009
190
Your sinewave looks good with this very high input level of 50mV peak. The preamp gain is much too low for normal levels.
The low value of the input coupling capacitor reduces 114Hz -3dB and cuts lower frequencies at -6dB per octave.
Not with 470 ohm emitter resistor. That provides a lot of local feedback, or linearisation. Distortion is hard to see, anyway, from a "scope" display.
 

neonstrobe

Joined May 15, 2009
190
Take care with earthing too. Depending where you connect the ground you may actually have power supply interference. You need to find a common earth point for your micro and transistor preamp. A lowish value of resistor for a filter (e.g. 330 ohms) (so as not to drop too many volts - you don't have many to spare) and a large capacitor would be suitable. (1mF is plenty). IF you still have trouble, use two capacitors and resistors e.g. 150-1mF-150-1mF as this gives better attenuation of spikes than a single RC stage.
(Most older amplifier I.C.s don't work at 3.3V although newer ones might. That's why I took it you were using a transistor. HOwever a single device direct from a microphone might not be particularly low noise. You would do better to have a two or three transistor circuit with feedback to control the gain and noise).

And regarding your original circuit, it is not clear why it simulated (apparently) correctly. The resistor values are completely wrong as has been pointed out!
Unlikely to be due to the transistor model. You had low values of bias resistor (compared with what you could have used) but that would have biased even a low gain transistor correctly (if they'd been the right values that is).
 

sparky 1

Joined Nov 3, 2018
756
I ran sim on low distortion sine output circuit. I think that the output impedance has to be declared. Guessing that 2000 ohm output impedance might be accomplished for the awkwardly low 3.3V
 

Thread Starter

Engineer9001

Joined Dec 13, 2019
22
Probably.

View attachment 203900
If you place this on the power supply line going into the ESP8266 with the power source being the Vin and Vout going to the ESP8266. The idea is to have the capacitor supply most of the current to the ESP8266 during those bursts instead of taking it directly from the power supply -that's why the series resistor is there, so that little of that edge of the burst makes it through to the power supply. Make the capacitor large.

A similar setup for your premap will filter out some fraction of the spikes.

Switching from the discreet transistor open loop preamp to an integrated circuit preamp will probably help a lot since power supply ripple rejection is an important parameter for op amps but ripple rejection degrades as frequencies increase or in this case, as the change in voltage with time increases so you may still need this filter.
Thanks! I'll try and rework the PCB to add that series resistor and add a larger capacitor.
 

sparky 1

Joined Nov 3, 2018
756
I found CN034 made by Analog Devices. It is an evaluation board using AD9834 and the AD8014. There is an application note showing the AD8014 circuit. There were several alternative op amps. I think current amplifier the trade off favored low distortion and the noise rejection was low as all the choices had outstanding performance. Before I said it was akward to have only 3.3V for the 2N3904. I think the insertion loss is small enough for adding an op amps and NPN. Getting more people to be happy and use 2N3904 should encourage
experimenting.
 
Last edited:
Top