Is this a suitable opamp for an electret mic?

I have an electret microhone, which I want to use just to set brightness levels on some LEDs, so I don't need any frequency analysis etc., just peak levels.

All of the example circuits I've found for electret mics seem to favour LM386 or LM358 to amplify the signal and, although I could easily buy one of these and copy a circuit, I already have a couple of CA3140's that I recycled from some donated circuit boards (no idea what the original boards came from), but I don't have the necessary knowledge or experience to understand if this is a practical alternative.

Looking at the datasheets (attached), it's not quite clear to me whether I can use a CA3140 to get a suitable signal to read via ADC in a Uno, and if it is, what additional external components I might need. I can compare the numbers (mostly), but where they differ I'm struggling to figure out what that might mean.

Can anyone give me some guidance?

Thanks in advance,
Roger

CA3140.pdf (1.46 MB)

MD9745APZ-F-Datasheet.PDF (122 KB)

An electret microphone has built-in amplification which means that you do not need to be too concerned of the noise performance of the amplifiers you use.

LM386s are primarily intended to provide the (modest) power to drive loudspeakers, but could be suitable in your application. I have on previous occasions favoured their use as cheap op-amps suited to amplifying ground-referenced signals but their gain is quite modest. Whether an LM358 or CA3140 is useful in your application would depend largely on whether the required supply voltage(s) is (are) available according to its specification, whether the quiescent current is suitable and whether you require one or two op-amps - which you may because you want to firstly amplify and then rectify the signal.

If you're just lighting up some LEDs then almost any opamp will do.

The only thing you really need to worry about is the supply voltage. The CA3140 needs +/-12V so it's going to be difficult to use.

The LM358 will work with a 5V supply.

...and if has to respond to very loud sounds (loud music) then you probably don't even need an opamp.

fungus:
...and if has to respond to very loud sounds (loud music) then you probably don't even need an opamp.

Thanks - I'm more thinking about a reaction to speech and/or "normal" music.

However, from what you've both been saying it sounds like I can't use the CA3140 without adding a 12V supply.

From what @Paul__B said about the possible need for two opamps, I also have some robbed OP400's (datasheet attached) - can I use one of those? If so, can I take advantage of the fact that it's a quad and pump the output of one channel into another? (Sorry if that's a stupid question - I'm still not up to speed on a lot of stuff) ....

OP400.pdf (334 KB)

Directly Replaces Industry Type 741 in Most Applications

Page 6 of the datasheet indicates the CA3140 will run down to 5V, single supply.

http://www.ee.ryerson.ca/~jkoch/courses/ele504/datasheets/CA3140.pdf

In fact, you can push it down to 4V:

Low Voltage Operation
Operation at total supply voltages as low as 4V is possible
with the CA3140. A current regulator based upon the PMOS
threshold voltage maintains reasonable constant operating
current and hence consistent performance down to these
lower voltages.
The low voltage limitation occurs when the upper extreme of
the input common mode voltage range extends down to the
voltage at Terminal 4. This limit is reached at a total supply
voltage just below 4V. The output voltage range also begins to
extend down to the negative supply rail, but is slightly higher
than that of the input. Figure 8 shows these characteristics and
shows that with 2V dual supplies, the lower extreme of the input
common mode voltage range is below ground potential.

So yes, you can use it.

BTW, the output of an electret microphone isn't incredibly strong, but if the sound is -really- loud, it may work as-is. Better, IMHO, to go ahead and amplify it a bit.

Something like this:

Keep in mind that the output of the CA3140 cannot go below about 0.4V, or above Vcc-2V. So that output, on 5V single supply, will clip at 0.4V and 3V. Since you are interested in the peaks, you might want to change the bias point to halfway between those two points, or even put it at 1V.

How are you intending on reading the voltage peaks? A precision rectifier using another CA3140? Look on page 17 of the PDF.

polymorph:
How are you intending on reading the voltage peaks? A precision rectifier using another CA3140? Look on page 17 of the PDF.

Well, maybe I'm misguided on this, but I thought I could just take the opamp output into ADC, sample for a few milliseconds (50-100?) and calculate the difference between the minimum and maximum values over that period to give me a rough idea of the peak.

Now two replies have mentioned the need to rectify to get the peak - have I missed a trick?

All I really want to do is to obtain some kind of "relative noise level" so I can use it to adjust the average brightness of a separate NeoPixel animation (actually driven by a PIC but that's not relevant to this bit) .... right now, I'm using the Uno to prototype this part of the circuit and calibrate as necessary to get the levels in a usable range and then I'll reimplement the whole lot into the PIC's ADC.

Still a little way to go I think .... thanks to all for feedback so far and +karma to the lot of you :slight_smile:

Well, that could work. The maximum sample rate, according to this website, is about 10kHz.

Interesting. This page makes a good case for 9600sps exactly, if you are taking multiple samples. I feel better about that number than the above "about 10kHz" from Arduino.cc.

http://www.microsmart.co.za/technical/2014/03/01/advanced-arduino-adc/

Well, maybe I'm misguided on this, but I thought I could just take the opamp output into ADC, sample for a few milliseconds (50-100?) and calculate the difference between the minimum and maximum values over that period to give me a rough idea of the peak.

You don't need the minimum... An audio waveform is AC, so it goes positive & negative and it goes through zero twice per cycle. So you are basically going to get what looks like a bunch of random numbers, but the range is constrained by the loudness and the peaks should correlate to the loudness.

The Arduino can't read the negative half of the waveform and an op-amp with a single-ended supply can't go quite down to zero, so about half of your readings (during the negative half of the waveform) will be whatever the minimum op-amp output is.

....You probably don't want to do this, at least not right now, but I use a [u]Peak Detector[/u] for my sound triggered lighting effects. The circuit will "hold" the peak for a period of time (depending on the values of C1 & RL). That means you can read the peaks more slowly... 10 times per second is fast enough to give you lots of "lighting action". It makes your programming easier because your software can be doing other things instead reading the ADC all of the time to catch the peaks.

I power it with a bi-polar power supply (positive & negative voltages) so it will go all the way down to zero. The diode prevents the output from going negative. (And, putting the diode in the op-amp's feedback loop compensates for the forward voltage drop across the diode.)

In my circuit, I leave-out R1, and R2 is just a wire (zero Ohms).

Peak detector, aka precision rectifier with a capacitor on the output.

I agree with DVDDoug.

DVDdoug:
The Arduino can't read the negative half of the waveform and an op-amp with a single-ended supply can't go quite down to zero, so about half of your readings (during the negative half of the waveform) will be whatever the minimum op-amp output is.

So would it give me anything extra to add a DC offset to the output of the opamp or would that just waste a few components and I'd gain nothing significant?

DVDdoug:
....You probably don't want to do this, at least not right now, .....

Well I didn't, but I do now ..... it does at least seem like an alternative that I can explore to see what works best for my application.

DVDdoug:
I power it with a bi-polar power supply (positive & negative voltages) so it will go all the way down to zero.

So, like I said above, could I power it with a unipolar supply and offset the output? If so, I could then lose the diode?

polymorph:
I agree with DVDDoug.

That's useful - at least you two understand each other, even if I'm still struggling :smiley:

No, you can't lose the diode. The diode is there to change the AC audio into just the envelope of the sound. Or, with the capacitor on the output, a slow resetting peak detector.

Without a negative power supply, you'll just calibrate your software to recognize Vcc/2 as zero sound input. But the CA3140 only goes up to 3V, so that is a narrow window.

So it might be useful for you to add a negative voltage rail of between -2 to -5V. It can be generated by using analogWrite to output a 50/50 duty cycle squarewave, and a voltage doubler/inverter. That can suffice for very low current. Then you can measure from 0V, giving you more headroom for measurements from 0 to 3V.

polymorph:
No, you can't lose the diode. The diode is there to change the AC audio into just the envelope of the sound. Or, with the capacitor on the output, a slow resetting peak detector.

Ah, I see, I'm understanding a bit better now ...

polymorph:
So it might be useful for you to add a negative voltage rail of between -2 to -5V. It can be generated by using analogWrite to output a 50/50 duty cycle squarewave, and a voltage doubler/inverter.

Thanks - this is very helpful - can you explain what you mean by a voltage doubler/inverter? I understand that it will invert and double, so the 50% duty cycle ends up 100% negative (yes?), but is that a single component or another bit of circuitry? I'm really feeling a huge lack of knowledge now, which is what you get for starting a "new" hobby too late in life :frowning:

At this point I think you need to find out about the MSGEQ7.

It does what you want.

fungus:
At this point I think you need to find out about the MSGEQ7.

It does what you want.

Thanks fungus, I've seen that and I agree that it does what I want (in fact more than I want), and it may end up simpler (and cheaper) to just use that rather than contrive a more complex solution. Even so, there's more scope for playing and learning by trying to use up the components I have to hand .... difficult call at the moment.... I'm torn between learning and getting something finished :slight_smile:

Run a square wave into this:

Wired as a simple voltage doubler, you'd get -(2Vcc - 1.4V), but as a voltage inverter, it is -(Vcc - 1.4V). But the output of an Arduino pin won't go all the way to 5V if you draw any current, so call it 4.5V.

-(4.5V - 1.4V) = -3V

Add a 100 ohm resistor between the Arduino pin and C1 so you don't draw too much current.