High Quality Electret Microphone pre-amplifier

There are many microphone pre-amplifiers available for teh Arduino that are based around common purpose op-amps. An Op-Amp especially suited for audio purposes is the MAX 4466. The Datasheet gives the following application:

MAX4466

In Practice the circuit will look like this. The DC bias for the microphone is taken care of by the resistors R4 and R5. The input capacitor C1 is increased in value to get a better low cut off. The output is rail-to-rail so if the sounds gets loud, the output can go up to Vcc

Vcc is 2.4-5VDC. For the best performance, use the “quietest” supply available (on an Arduino, this would be the 3.3V supply).  The output will have a DC bias of Vcc/2 so when its perfectly quiet, the voltage will be a steady Vcc/2 volts (it is DC coupled). If the audio equipment you’re using requires AC coupled audio, place a 100uF capacitor between the output pin and the input of your device. If you’re connecting to an audio amplifier that has differential inputs or includes decoupling capacitors, the 100uF cap is not required.
max4466-microThe gain is depending on R5, P1 and R6. If the current gain is not enough, the value of R6 can be decreased, but in that case the value of C4 needs to be increased in order not to influence the Low pass value.

L1 and L2 are ferrite beads that separate the analogue supply  from other  supply lines

Advertisements

Electret microphone amplifier

zx-sound-self

Amplifier for an electret microphone that can be used to detect sound with an Arduino or other microcontroller. The op-amp used is a TLC272 that is pin compatible with a number of other dual op-amps such as the LM393 the LM358 or the OPA2344 and OPA2345.

IC1a is used as a non-inverting amplifier. It offers a higher impedance as the inverting amplifier. The gain of the non-inverting amplifier is determined by 1+R4/R1 and is 40dB (100x). If desired a trim pot can be used for R4.

In most cases it is possible to DC couple the circuit. However in this case it is necessary to ensure that the non-inverting has a DC path to earth for the very small input current that is needed. This can be achieved by resistor, R2 in the diagram. The value of this may typically be 100 kOhms or more. If this resistor is not inserted the output of the operational amplifier will be driven into one of the voltage rails.

When adding a resistor in this manner the capacitor-resistor combination forms a high pass filter with a cut-off frequency. The cut off point occurs at a frequency where the capacitive reactance is equal to the resistance. This is expressed in the Formula 1/2πRC. For the used combination it is =16Hz.

The output on pin 1 is at best a sinus wave and though microcontrollers do not really like those or any other odd shaped wave, when fed to their ADC input that does not make a difference. However, if  the output of IC1a is fed to an ADC there will be very strong fluctuations in the reading and as such the signal is not really representing the total sound pressure. We do that  with op-amp IC1b that is used as a comparator with a reference voltage on the inverting entrance. When fed with  5Volt, the Voltage on the inverting entrance will be 72mV ((5000/69)*1)
As long as V- < V+, Vo will be low, but when the sound level rises above 72mV, IC1b will make the output go high.
With a gain of 100 in IC1a, a voltage off 720uV from the microphone would be enough.  The Voltage build up over C3 is depending on the number of times the Output goes high and thus is an indication for the sound pressure.

electret-pcb

The PCB is quite simple. The convoluted area above the double op-amp is to either insert a resistor, or an upright trim pot that can be inserted facing, or facing away from the IC.
There are 4 extra components in comparison with the circuit. Those are 2 LED’s and 2 resistors. These give an indication of the Output voltage as well as the supply voltage.  They are optional however:
P1040773e

There are many commercially available electret breakout boards for the Arduino (or other micro controllers). One of them is the Sparkfun breakout board:
electret-sparkfun Sparkfun had a bit of a rocky start in this area with their BOB-08669 and they replaced it with the BOB-09964, the difference between the two being some changes in resistor and capacitor values.

The Sparkfun board is centered around 1 op-amp, the OPA344 that is used as an inverting amplifier. The gain is determined by R5/R4 and is 40dB (100x). The input high pass RC filter cuts off frequencies below 10Hz. The RC network with C3 and R5 cut off above 13 kHz. The original BOB-08669 would cut off too high and it’s impedance was too low (as can be expected from an inverting op amp). The cut-off  for the low pass filter can be calculated from xc=1/2πRC, in which xc being the reactive capacitance. With the given values of 12pF and 1Mhz the low pass is determined at 13.2kHz. The high pass around C1 and R4 gives a cut off of 3.3Hz (so not 10Hz as stated).

R2 and R3 give an off-set adjustment centered around half voltage (2.5 Volts).

Though the new board is an improvement over the old one, still a lot of people experienced problems with it. It did not really change in design, just a few R and C values were adapted.

Dealextreme  offers a board based around a 393. It has an audio out and a digital out for if the signal comes above a certain threshold. It is the KY-037 from Keyes and has a 12 turn potentiometer to set the threshold. It is rumoured to have low sensitivity.

Freetronics board
The Freetronics board is also based upon the TLC272. It offers an audio output and a sound pressure output with visual indication. Here the peak detection on pin 6 of the IC is set to 71 mV and the gain of the first opamp is set to 100
mike_module_freetronics

Using a Single Opamp
electret-741

Using a single op-amp of course is also possible and this time we will use the inverting pin of an LM741. The gain = R4/R3 =1000=60dB.
D1 and D2 form a voltage doubler, rectifier and peak detector.
C3 and R5 form an RC delay for the analog entrance of the Arduino

 

Using the LM386
Although the LM386 is primarily aimed to drive a speaker, it can be used as a microphone pre-amp. results with it however have been less than satisfying.

Using the LM358
The LM358 gives better results than the LM386.

Testing
The following code can be used to easily test the workings of the amplifier in combination with an Arduuino. The code reads the input 10.000 tmes and then prints the min, the max and the spread

/**
 * Measures the voltage on an analog pin over a ~1s period
 * of time and sends the Min, Max and Diff (Spread) values 
 * over Serial.
 *
 * Author: 
 * Dimitar Kovachev, http://lowvoltage.wordpress.com/
 *
 */
const int analogPin = 0;

void setup() {
  Serial.begin(9600); 
}

void loop() {
  int mn = 1024;     // mn only decreases
  int mx = 0;        // mx only increases

  // Perform 10000 reads. Update mn and mx for each one.
  for (int i = 0; i < 10000; ++i) {
    int val = analogRead(analogPin);
    mn = min(mn, val);
    mx = max(mx, val);
  }

  // Send min, max and delta over Serial
  Serial.print("m=");
  Serial.print(mn);  
  Serial.print(" M=");
  Serial.print(mx);  
  Serial.print(" D=");
  Serial.print(mx-mn);  
  Serial.println();  
}