Most of microcontrollers have ADC input which can sample any analog signal including sound. Even using Arduino you can make many cool projects using audio input. For instance you can make voice controlled device, Audio recorder, voice activated switch and so on. In this post I want to to focus a bit on microphone part – the circuit required between condenser microphone and MCU ADC input. Generally speaking you cannot connect electret microphone directly to ADC and expect it to work. The part needed here is called microphone amplifier.
First of all, electret microphone isn’t only a condenser inside. It already has a preamplifier inside normally made of FET transistor, which is connected in common source configuration:
As you can see first of all microphone needs to be powered through drain pull-up resistor. Its value actually depends on power supply voltage. Rule of thumb is to add 1kΩ per +1V of power supply. Up to 10V 10kΩ resistor will work fine. The FET transistor in microphone actually needs negative voltage on gate to cut-off. So when voltage is applied through resistor, some amount of current (~0.2mA) flows through transistor which have some resistance value. So its voltage divider – thus you get unpredictable DC offset which varies depending on temperature and load resistor selected. So generally speaking microphone is like current source where current varies around some DC level. Capacitor on mics output removes this offset and you get low voltage (10-50 mV)AC signal which needs to be amplified. For microcontroller with 3.3VCC we ideally need VCC/2 DC offset and max VCC/2 amplitude signal
to enter ADC channel. If we aren’t looking for very high quality, simple amplifier circuits will do fine. Lets look at several amplifier circuits and find which is best to use.
Self biased transistor amplifier
This is probably the simplest amplifier circuit that works pretty well. This circuit can be assembled pretty quickly but there are some things you should consider before choosing it.
Despite it’s self stabilizing bias current, practically such amp isn’t that great where ambient temperature changes a lot. You should find more deep theory about self biasing problems and benefits on internet. I like this circuit, because it is simple and pretty robust.
Combination or potential Divider Bias amplifier
This circuit has much better thermal stability. The only drawback is that it needs few more passive components. But couple more of resistors doesn’t mean much. Lets look at this circuit more deeply in order to understand ho it works and ho to calculate its component values. This circuit has R1 and R2 voltage divider which produces fixed voltage to transistor base. And so what we have:
It is recommended that current flow through those resistors mush be 10 times greater than base current. So R2 = Vb/(10*Ib); and R1 = (VCC – Vb)/(10*Ib).
Base-Emitter voltage drop is about 0.6V
Ie = Ib + Ic
Ve = 10%*VCC;
Re = Ve/Ie;
Vb = Ve+0.6;
Having those in mind we can easily calculate Circuit values for amplifier. If we are going to feed signal to 3.3VCC powered microcontroller ADC, then our VCC = 3.3V. Lets use general purpose transistor BC547C which DC current gain is hfe = 520. lets chose collector current Ic = 1mA.
We need output Bias voltage = 3.3V/2 = 1.65V.
Now we can calculate collector resistor Rc = 1.65/1mA = 1650Ω
We select standard value of 1.6KΩ;
Emitter voltage Ve = 10%*3.3V = 0.33V;
As Ic Ic then we calculate
Re = Ve/Ie = 0.33/1mA = 330Ω
Base voltage: Vb = Ve + 0.6V = 0.33+0.6 =0.93V;
Required base current Ib = Ic/hfe = 1mA/420 = 2uA;
Resistor divider values:
R2 = Vb/(10*Ib) = 0.93/20uA = 46.5kΩ
Standard value R2 = 47kΩ;
R1 = (VCC-Vb)/(10*Ib) = (3.3-0.93)/20uA = 118.5kΩ
Standard value R1 = 120kΩ;
Lets build this circuit in LTSpice simulator to see it’s working:
And its output when microphone signal amplitude is 20mV:
As you can see output DC offset is a bit up. You might need to tweak resistor divider values a bit to get it right at the middle of VCC.
But it seems that not discrete element solutions aren’t that popular because there are more advanced circuits that use Operational Amplifiers. They are more stable, generate less noise and are compact. So last circuit we are going to look at is simple OP-amp based microphone amplifier circuit.
Op-amp based microphone preamplifier
For our circuit we are going to use standard low power precision operational amplifier LT1215 IC. From it’s datasheet we can find that it can be powered from 3.3V single supply. Let’s build an inverting amplifier with middle point DC offset output. General circuit looks as follows:
And signal output:
With Operational amplifier calculations become more easy. We make a voltage divider with R1 and R2 to the point of VCC. So both resistors are equal. Then we calculate gain resistors by formula:
Gain = R3/R4. If we select Gain = 100. We select R3 = 100k then R4 is calcualted to be 1k.
Few words about input capacitor
We didn’t mention the importance of input capacitor which stands before amplifier. First of all it is a DC offset filter. So if there is any offset voltage from microphone, it is filtered out only AC signal passes through. Second thing is that it acts as high pass filter together with amplifier input resistance. If you want to capture low frequency sounds, then choose higher value capacitors – 1u, 10, 100u.
LTspice files for simulations: micpream.zip