I'm looking to simply read the generic sound level from an Electret Microphone. I've seen a number of schematics with NPN transistors, that will provide an inverted output (~5V when quiet, ~0V when loud, linear operation in between).

Here's an example:

Simple Audio Preamp

However, I would like non-inverted output (linear operation, super quiet input gives ~0V, super loud input gives ~5V). I realize I could easily correct for this in software, but it just seems backward to me in a way and I cannot find any examples of a non-inverting output with a PNP transistor.

Is there a reason for this beyond being uncommon? If it's possible, could anyone provide a schematic of an electret microphone and PNP transistor that will give ~0V when quiet and ~5V when loud?

Further, is there some reason why this is so uncommon, or undesirable? NPNs seem to be used much more often than PNPs, why is this?

Edit

It seems I was rather confused in what I would get as output from the NPN preamp, which would be 0V for silence, and +/- Vin / 2. Here's what I want instead:

0V when silent, ~2.5V in medium sound levels, ~5V in maximum sound levels. This could be read by the ADC easily into 'sound level' without much work at all. However, I cannot feed voltages < 0V or > 5V to the analog comparator. It looks like I want the above with an envelope detector, however that would only get me from 0V to 2.5V. How do I make it vary the full 0V to 5V, 0V being 'quiet' and 5V being 'loud', with everything in between linear?

  • Unfortunately, this circuit will not generate a DC voltage, if the output is taken on the right side of C2. It will generate an AC voltage. This is because of the capacitors. Capacitors do not allow DC voltages pass through them. – abdullah kahraman Feb 11 '13 at 12:15
  • The Arduino has 6 analog inputs, which read 0-1023 for 0V-5V. AC is what I'd be looking for there, right? Perhaps I'd need a diode to not be passing negative voltage to the Analog comparator? – Ehryk Feb 11 '13 at 12:20
  • Yes, but a diode will drop 0.6V on itself. Maybe you should try to make the supply voltage 5V. The supply voltage is the one labeled "+3 to 9 Volts". Then remove C2. Then, read the analog value on the collector of Q1. Experiment with different sound levels, for example clap, talk, shout, be quiet, whisper, and see the analog reading changing. However, it will be a sine wave added with a DC value. – abdullah kahraman Feb 11 '13 at 12:24
  • Reading your question and comments it appears that your questiojn is not clearly stating what you want. It seems that you want an AC level which diminishes in magnitude as the input voltage increases. If this is the case you need to state it clearly. If this is not the case, can you please explain "I'm not looking for a logic 0-1, the Arduino's analog inputs have a 10-bit ADC that gives 0-1023 for 0V-5V, respectively" in this context. || ... – Russell McMahon Feb 11 '13 at 13:06
  • ... IF you are talking about DC levels the question is still unclear. An AC signal will be centred on the DC bias point. This is relatively fixed with signal strength. Can you very clearly and in simple terms explain EXACTLY what you want the output to do as the input signmal goes from 0VAC to Max Vin AC. – Russell McMahon Feb 11 '13 at 13:07
up vote 8 down vote accepted

As far as I understood, you are trying to make some kind of a sound level detector, which will let you detect if there is a sound with a certain volume or not. You can do this with minor changes to the schematic you have. But before that, you should understand the circuit.

Let's break that circuit down. First of all the part with the microphone.

enter image description here

R1 is for supplying power that is needed by the microphone and this is called biasing the microphone. A microphone generates an AC voltage, which is sometimes negative and sometimes positive and it changes most of the time. Think of a sine wave. But remember, we had some biasing to it which is a DC voltage. We have to take that out and give only the AC voltage to the amplifier. And doing this is easy with a simple, single capacitor. A capacitor does not let the DC to pass, but lets AC pass easily. We have blocked the DC portion of the voltage on the electret microphone.

Now, let's look at the amplifier itself. Imagine that there is nothing else but the below schematic:

enter image description here

In this configuration, the transistor is biased to be in the linear region. It is in the edge of being turned ON or turned OFF, but it is neither of it. If it was fully ON, it would be saturated. If it was fully OFF, it would be not conducting at all. But it is in the middle, which is called the linear region.

When it is configured like that, if you touch (not literally) to the base of it, creating a small change, the output will be changing largely. This is what amplification called. You can beg Google for more detailed information.

What if we combine the two circuits mentioned above. A biased electret microphone with a capacitor will output small changes with respect to sound. The transistor will amplify these small changes so they can be viewed easily:

enter image description here

Notice that I have changed C1 to 1uF. You can use values up to 100uF. You will probably need electrolytic capacitors. Also, notice that there is no more an output capacitor. This means that you will have an output voltage somewhere between 0 and 5 V, depending on the sound level. If you have an oscilloscope, view the waveform on the output. If you do not, try lighting an LED if the analog read is higher than, for example, 750. Experiment with different values than 750, then report me the results.

  • I understand most of that, thank you. Now because it is using an NPN transistor, the output will be about ~5V when quiet/input amplitude is low, and ~0V when loud/input amplitude high. This seems backward. Is there a way to modify it so that it behaves exactly as above, in the linear region, with ~0V meaning 'quiet' and ~5V meaning 'loud'? – Ehryk Feb 11 '13 at 14:12
  • @Ehryk Nope, the output will be somewhere between 0 and 5V. If you take a car siren and put it near the electret microphone, it will be a sine wave from with a peak to peak amplitude of 5Vpp with a frequency of about 300Hz. 5Vpp means it will go to 5V and come back to 0V with a sinusoidal shape. Have a look at this. When there is a whisper, the peak to peak amplitude will be about 1Vpp with changing frequency because of the speech. That means it will go to 1V and come back to 0V. – abdullah kahraman Feb 11 '13 at 14:22
  • However, my comment above ignores the DC offset. – abdullah kahraman Feb 11 '13 at 14:25
  • Is there a way I can make it ~0V for quiet, ~5V for loud? Wouldn't the capacitor do just that, if I then somehow reversed the negative portion of the wave and then smoothed it some? With perhaps a bridge rectifier / diode bridge? (en.wikipedia.org/wiki/Diode_bridge) – Ehryk Feb 11 '13 at 14:28
  • @Ehryk Yes, you can add an output capacitor and an envelope detector. With the right component values, you will be able to have an analog voltage level depending on the sound amplitude. However, I am not sure of this. You should experiment. After getting results, just make an if-else condition in the software depending on the ADC value that you read. – abdullah kahraman Feb 11 '13 at 14:36

The common emitter class A amplifier is always inverting even if you use a PNP, the only difference is you invert the power supply polarity. If you use an audio transformer instead of a capacitor you could change the signal phase as you please. But it will probably cost more than use two BJT. In order to solve your final question anyway, you have to rectify ( even with a single diode ) the output and apply the result to a load ( a resistor would be fine ) and feed this to the arduino analog input. There is no reason to invert the signal at all.

  • Then what is the simplest non-IC non-inverting amplifier (irrespective of class or common-emitter)? – Ehryk Feb 11 '13 at 12:21
  • The common collector, but I think is not correct to use in this case, since you need a voltage gain – Felice Pollano Feb 11 '13 at 12:23
  • The common-base, if you need voltage gain (but its current gain = 1). Note that you could add a second inversion in this instance by simply interchanging R1 and the microphone. No PNP necessary. However inverting or not will NOT solve the stated problem - generating a logic 1 or 0 depending on the loudness. – Brian Drummond Feb 11 '13 at 12:38
  • I'm not looking for a logic 0-1, the Arduino's analog inputs have a 10-bit ADC that gives 0-1023 for 0V-5V, respectively. Can you give circuit diagram for this? – Ehryk Feb 11 '13 at 12:50

This amplifier inverts the signal, but you shouldn't care for an audio signal. What you'll have at the output is AC, a capacitor blocks DC. So, you cannot say ~0V for quiet noise and ~5V for loud. If what you want is a sound level sensor, one easy way is to add, after the output cap a circuit called "demodulator" or "peak detector", easily implemented around a diode and a few passive components.

  • Can you add a diagram of this? Also, wouldn't the peak detector vary between -2.5V and 2.5V? I would want ~0V to be quiet, and ~5V to be the loudest, how would this be accomplished? – Ehryk Feb 12 '13 at 2:28

Simply invert the output a second time, using a 2 stage amplifier. (See this page for more info on two stage, and non-inverting transistor amplification. Very insightful)

enter image description here

The same value resistors and capacitors, the same 2n3094 transistor, added to the output of your existing schematic, would provide a second inversion.

But someone correct me if I am wrong, but your schematic shows a simple biased amplifier, so you would really have 2.5v as the quiet range, and the waveform gets larger with more sound? You will have a ±2.5v peak to peak. You would have 1v/3v as a middle loudness.

protected by clabacchio Apr 7 '13 at 11:59

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.