Help with OpAmp

Hi there,

after struggling a lot with OpAmps with no satisfactory results I'd rather ask for some help!!!

I've an audio signal (I've tried with several inputs... mic, guitar jack, mp3 player...), the voltage range is around 20mVp-p, I need to amplify it to a more suitable range to do AnalogRead with an Arduino UNO Analog PIN (range 0 to 5Volts) and convert it to digital audio.
So far, whatever circuit I've tried (with OpAmp IC like LM386... with generic OpAmp circuit based on transistors and so on) I didn't manage to reach a gain greater than x10 or so! Such an output voltage is useless for AnalogRead.

To workaround this issue I've recently tried to use a pre-manufactured IC amplifier based on PAM8403 Chips... but apparently the output of this circuit is something that my entry-level digital oscilloscope does not "understand" since it's not represented as an amplyfied waveform as I supposed to see... don't know why. Btw I'm using a sinewave generator android-app to test the input/output from the oscilloscope.

Any hint?

What am I missing?

Thx

For one thing, an LM386 isn't an Op Amp. Try an actual Op Amp, then it might work.

LM386 may not actually be an Operational Amplifier (Low Voltage Audio Power Amplifier), but most experimenters will refer to it as one. So, that was a useless post....

Simox,
According to the datasheet, the default amplification is gain of 20. However, it also states that you can alter the gain factor from 20 up to 200. Read the data sheet. set to a higher gain. and, if necessary, use a different analog reference voltage on the uno.

http://pdf1.alldatasheet.com/datasheet-pdf/view/413781/UTC/LM386.html

Thx 123Splat!

Were you referring to the cap between PIN 1 and 8 that is supposed to increase the gain from 20 to 200?
I have also tried with that... no changes.

As i wrote I did some other attempts with other IC (can't remember if it was the TDA 2822M or the CA 3130E...), same result! Gain never above ~x10, say x15 max. The output Vp-p is around 200mV sometimes 300mV (depending how loud is played the audio input). The supplied DC power I've tried is 4.5 and 9 volts, either with a DC adapter or 9V battery...

I believe I'm underestimating something...

Now I've ordered on Amazon the TL072, that requires dual voltage (+-9Volts), that is the reference IC for the Instructables I'm trying to replicate: http://www.instructables.com/id/Arduino-Audio-Input/

It is not an opamp and the opamp circuits in opamp tutorials will not work as expected
since it already has built-in negative feedback. That is an important caveat to make - the gain
can only by boosted by altering the feedback network via pins 1 and 8.

But yes, consult the datasheet for how to change the gain, plenty of example LM386 circuits there.

If you want an opamp for working at 5V I'd not choose the TL072. You want a rail-to-rail opamp.

I've an audio signal (I've tried with several inputs... mic, guitar jack, mp3 player...)

These are all different...

  • [u]Line Level[/u] (about 1V) is what you get from the RCA jacks on your CD/DVD player, or out of your TV, etc.

  • The headphone output from an MP3 player or computer, etc., is approximately line-level when the volume is turned-up.

  • A guitar can put-out about 1V into a high impedance (typically 1M) when plucked-hard and with the volume turned-up. It doesn't take a lot of gain to convert a guitar signal to a line-level signal, but an op-amp is used if you want a line level signal to drive a lower impedance line-level input (typically 10K).

You don't need a preamp for the above sources, although in some situations a gain of 5 or 10 may be useful.

  • A microphone signal is usually in the range of 10-100mV, but it varies greatly depending on the loudness of the sound and the sensitivity of the mic.

I need to amplify it to a more suitable range to do AnalogRead with an Arduino UNO Analog PIN...

Except for the microphone, you should be getting acceptable levels without a preamp.

The Arduino cannot read the negative half of the AC audio waveform, and it can be damaged by negative voltages (especially from a high-current audio power amplifier). And if the Arduino isn't damaged, the audio signal can be "damaged" (distorted). The simplest solution is to [u]bias[/u] the input at 2.5V with 2 equal-value resistors. (If you are using a guitar, I'd increase the resistors to 1M or more.) With the input biased at 2.5V, the ADC should read about 512 with silence. You can subtract-out the bias in software, or otherwise deal with it in software.

The bias can optionally be built-into the preamp circuit. For example, the SparkFun microphone breakout board has the bias built-in.


The CA 3130E and TL072 are op-amps. That's what you want to make a microphone preamp. An op-amp is a high-gain general-purpose device designed for low power (i.e. to drive a relatively high impedance).

The LM386, PAM8403, and TDA 2822M are power amplifiers designed to drive a speaker (low impedance). These generally have a gain of around 20 and are designed for line level inputs. These amplifiers can be used for other applications, but it's not ideal.

Microphone signals are way lower than that. Expect 100uV to 10mV to be a more representative
range. Low noise amplification is obviously prefered and SMPS's are usually avoided.

Expect 50+dB gain needed for microphone amp - here for the 7mV rms signal 50dB is also about
right, but 40dB isn't disasterous.

Thanks guys, really!

Ok, I have checked! The last circuit on my breadboard was made with the TDA 2822M... so according to DVDdoug indication, all my attempts were done with a wrong OpAmp (LM386, PAM8403, TDA 2822M) :frowning: .

In the list of my components I've found a few other OpAmps and/or Audio-Amps:

-LM 358
-CA 3130E
-MC 4558CN

-NEC uPC1200N (this last I'm not sure is an OpAmp...)

and, as I said, I was considering buying the TL072.

Which one do you suggest better fits my needs?

Consider that, given the low Vp-p I'm measuring on the input (below 100mV, according to my oscilloscope), I need something that provides a x100gain factor (to be sure I can benefit from the wider Arduino AnalogRead range (0-5Volts)) that and in case I'd rather decrease by means of a trim-pot placed as feedback resistor if the output Vp-p value exceed 5 Volts. Do you think this would work?

Ah, MarkT I'm not sure I got the exact point of this statement:

"It is not an opamp and the opamp circuits in opamp tutorials will not work as expected
since it already has built-in negative feedback. That is an important caveat to make - the gain
can only by boosted by altering the feedback network via pins 1 and 8."

Can you explain how, in case, I can increase the gain of the LM386? Is it the CAP (PIN 1 - PIN 8)?

Thx

In theory, an 'Op-Amp' with open loop feedback (no feedback loop) will have a gain of infinity. A 'Op-Amp' with a zero ohm closed loop feedback will have unity gain (gain of 1),,, so, yeah, technically, this is NOT an Op-Amp. It has an internal feedback loop, designed to yield a gain of 20. As stated, the gain figure can be altered by paralleling series resistor, cap, or resistor/cap, between pins 1 and 8.

I stand chastised and humbeled,,, but will still (albeit in error) be caught referring to it as an Op-Amp. Old habits, especially bad ones, are hard to break.

Simox:
...
Which one do you suggest better fits my needs?
...

For experimenting with op-amps, start out with a general purpose 'rail-to-rail' device. Since I like easy to use through hole components, the choices are limited. This one does a pretty good job for low current applications.

Rail-to-rail means that the output voltage goes all the way from the negative voltage to the positive voltage.

op+amp+guitar+preamp+schematic

I've an audio signal

This is WAY TOO VAQUE. How about explaining WHERE the "audio signal" is coming from and HOW you happen to KNOW that the amplitude is 20 mV or so ?

The op amp Chris recommended is a good choice. I use LT1215.

123Splat:
In theory, an 'Op-Amp' with open loop feedback (no feedback loop) will have a gain of infinity. A 'Op-Amp' with a zero ohm closed loop feedback will have unity gain (gain of 1),,, so, yeah, technically, this is NOT an Op-Amp. It has an internal feedback loop, designed to yield a gain of 20. As stated, the gain figure can be altered by paralleling series resistor, cap, or resistor/cap, between pins 1 and 8.

I stand chastised and humbeled,,, but will still (albeit in error) be caught referring to it as an Op-Amp. Old habits, especially bad ones, are hard to break.

Yes 123Splat, you may be right.
I may be not so precise in defining the LM386 an OpAmp... forgive my poor tech language, but it's a loooong loooong time since I last deal with circuitry when I was a Student at University. That's also the reason why I'm actually not so accustomed in reading a datasheet and catch every technical detail that may be relevant for the behavior of the IC.

Anyway, what am I wondering is IF I can eventually increase the gain of a LM386 ABOVE the x200, since the internal feedback loop is in fact built in; my guess is that the close loop classical OpAmp configuration does not apply any more... and "infinity" is way beyond the possibilities of a real life circuit. :slight_smile:

thx

ChrisTenone:
For experimenting with op-amps, start out with a general purpose 'rail-to-rail' device. Since I like easy to use through hole components, the choices are limited. This one does a pretty good job for low current applications.

Rail-to-rail means that the output voltage goes all the way from the negative voltage to the positive voltage.

Ok, thx.

Question: none of the ones of my list is a valid alternative?

-LM 358
-CA 3130E
-MC 4558CN
-NEC uPC1200N (??? OpAmp???)

raschemmel:
op+amp+guitar+preamp+schematic

This is WAY TOO VAQUE. How about explaining WHERE the "audio signal" is coming from and HOW you happen to KNOW that the amplitude is 20 mV or so ?

The op amp Chris recommended is a good choice. I use LT1215.

:slight_smile: I've tried with several "audio signals": mic (old fixline-telephone), mp3 player, guitar jack, android-app sinewave generator... in some cases the signal is above 20mV, ok (measured with an entry level 50$ digital oscilloscope); but as soon as I couldn't succeed in amplify above x10 factor the output is rubbish for AnalogRead of an Arduino UNO.

Could you post the exact circuit you are using? These devices work, you are likely to have
something wrong and we cannot guess what without seeing what you've done in detail.

I've tried with several "audio signals": mic (old fixline-telephone), mp3 player, guitar jack, android-app sinewave generator... in some cases the signal is above 20mV, ok (measured with an entry level 50$ digital oscilloscope); but as soon as I couldn't succeed in amplify above x10 factor the output is rubbish for AnalogRead of an Arduino UNO.

There's several ways we can go about this.

1- You can tell us you have never done this before and have no idea what you are doing and they we can tell you the correct way and you can tell us all the reasons you didn't do it that way. (time consuming , basically non-productive, and some OP's are very defensive and overreact when told they don't have a clue)

FYI, how do we know you have never done this before ?

So far, whatever circuit I've tried (with OpAmp IC like LM386... with generic OpAmp circuit based on transistors and so on) I didn't manage to reach a gain greater than x10 or so! Such an output voltage is useless for AnalogRead.

As already pointed out, you are trying to use a saw as a hammer. The LM386 is an audio amplifier. It is not designed to amplify a signal for data acquisition. It is designed to amplify a signal for the human ear.
Secondly, it isn't even an op amp.

after struggling a lot with OpAmps with no satisfactory results

So we actually would have been quite surprised if you had succeeded using that chip.

2- You can post a schematic of ONE of the circuits you tried for ONE of the many different inputs , all of which require their own unique input circuit (there is no ONE SIZE FITS ALL low level input amp-That kind of amp requires two adjustable gain pots, one called COARSE, the other called FINE) and then we can systematically explain why THAT particular circuit won't work. (since you listed many different inputs, each of which would (SHOULD) have a DIFFERENT design, this won't help you much because you won't know why the OTHER circuits you tried didn't work.

3- You can pick ONE of the various inputs you listed and we can show you the proper design for THAT particular type of input. This involves discussing some of the more common mistakes made by people trying to do this with no electronics background.

a- An AC signal needs to be coupled with a capacitor
b- On the output of the cap, the signal needs to be biased at the midpoint to use the upper analog
range for the positive transition and the lower half of the range for the negative transistion of the
audio signal. A voltage divider of two resistors greater than 10k and less than 50k will work for
this. (10k is typical)
c- A low level signal, whether ac or dc cannot be amplified more than 50 times by a single stage.
I have used a Differential Amp to amplify a 20 mV signal to 1V using a single stage. (A =50)
Look at the Single Supply Instrumentation Amp on the first page of this datasheet.
(Look at the frequency response graph. Gain is 20 for Diff input. [(1+1020/113)+(1+1020/113)]

You would need probably two more stages to get the signal to +/- 2.2V (4.4 Vtotal)

You choose: 1, 2, or 3 ?

Ok, thanks guys for the several hints.
Let me do one or two more tries with a circuit different than the LM386 one and I'll post screenshots of the audio input and output of the oscilloscope display, and pictures of the breadboard.
So that it would be easier (at list for you :slight_smile: ) to understand what am I mistaking.
Anyway although I have a very rusty electronics background I was aware of coupling/decoupling of Ac-Dc and biasing techniques and applied them to my previuos circuits, probably in a wrong way.
On the other hand I was not aware of the physical limit of amp stages and don't actually know how to serialize (if possible) several OpAmp to increase the e2e gain.
Thx

The general rule is no stage should eceed a gain of 20.
Try the Differential Amp schemaic I referenced on the datasheet with the cap in series on the input ( of the op amp ) and the bias divider on the output ( of the op amp) where it connects to analog pin.
You may need a series cap on op amp output as well. (1uF to 3.3 uF)
Do you know how to connect the op amp subtractor ? (Instrumentation Amp)

Vin + => signal
Vin - => Signal GND