Why are op amps used in sound circuits?

I was loking at the wave shield because I was thinking of adding sound to my project and I noticed they have an op amp:
http://www.ladyada.net/make/waveshield/parts.html

Wikipedia says op amps can multiply a voltage difference millions of times. But other than that it's not very helpful. And that doesn't seem to make a lot of sense to me either. Is it saying my 9v input will be multiplied by millions of times? I kinda doubt the wave shield has 9 million volts running through it. Or even 5 million. So what does an op amp really do?

Also, why use an op amp? Why not a transistor? Can transistors not vary output voltage with input voltage? Or do they just do a crummy job of doing it smoothly or quickly that it doesn't work well for sound generation?

"Audio levels are typically less than 1 volt."

Even if the input to the op amp is from a dac in my circuit, which is being supplied with the same 5v logic as the rest of the circuit?

I stil don't understand why you need to multiply the voltage. I mean I guess if you did have 1v input to it you might want to raise that to say 5v or maybe even 12v, but would you really run a speaker in your circuit on 1000 volts? I've never heard of such a thing being done.

My question here pertains to how the wave shield is using it. So what is it doing in that circuit?

All the page on it says is this:
"The analog signal then goes into a high-output, rail-to-rail opamp. This op-amp can provide up to 100mA per channel. The two channels are hooked up in parallel for up to 200mA output (at 5V). This means it can provide 1/8 W into an 8ohm speaker (or 1/4 W into 4ohm speaker). This isn't enough for a boom-box but its good for headphones and small speakers."

So it sounds like the Op Amp is putting out only 5v. So is the DAC putting out 5v, or 1v? And if all it is doing is increasing the current, again, why can't a simple transistor do that? A transistor does work in an analog manner doesn't it? Wikipedia seems to indicate as much. If the problem here is that the dac can't put out enough current to drive the speaker why isn't a transistor the solution?

I know you said an op amp has many transistors, but that doesn't tell me why you even need more than one to do this.

You might want to read this article - particularly the part about "Class-B" and "Class-AB" push-pull amplifiers:

Basically, with only a few parts, you can make a passable amplifier using only a couple of transistors (NPN and PNP), plus some other passives (and ultimately, a matching transformer for the speaker, usually), that will give "decent" sound. I've got an old AM radio kit assembled "classic-breadboard" style (nails in styrofoam, parts soldered to the nails) that was a part of my tech-school education; it uses such a simple amplifier.

Lemme see...

Damn - this thing is dusty - but yeah, a couple of matching transformers on the input side and output side, plus the NPN/PNP combo in between, and some simple passives (caps and resistors, mainly).

Most transistor AM (and probably cheap FM) radios use a similar arrangement of parts.

Nowadays, you'd probably be daft to do it, unless you had the parts available (the matching transformers would be a size killer) and were being cheap. Instead, go for an LM386 or something similar (there's probably something out there better than the LM386 that can deliver more power and use fewer parts)...

:slight_smile:

  1. Op amps can be tailored to have any gain you wish by simple resistor selection. And no, you aren't going to get 1000 volts out of it. You on the other hand can put in microvolts and get a 1V peak to peak output signal. Tailor the gain to 1000 and you can put in 1 millivolt and get out one volt. Try doing that with transistors, you will need a few stages, many times the size of an opamp footprint, and you have to muck around with getting the signal centered in a reasonably flat area of the linear curve and interstage coupling so that the signal doesn't have any distortion.

  2. Op amps are highly versatile, they don't just amplify. You can do differentiation, integration, smoothing, summing, filtering, comparison, all by using capacitors, resistors, diodes to vary feedback. Once again, the circuits tend to be rather simple, with repeatable results from known configurations.

  3. Op amps can be used as impedance matches between stages. High current op amps can be used as power amplifiers to convert higher voltage swings with little current to lower voltage swings with higher current output to drive, for example, earphones.

The 5Vpp voltage coming off the DAC has to be smoothed and filtered, and is a high impedance circuit with little current capability. It's load is a 10k ohm volume control potentiometer after all. Your earphones are low impedance devices at probably 32 ohms. They expect current, not voltage to do the work of moving the diaphragms. So, the op amp serves as a 5Vpp 200mA power amplifier and impedance match from 10k ohms and minuscule current to 32 ohms and enough current to produce sound.

Yep, you could bang together some transistors and components to do this. Two stages of voltage amplifier for impedance match feeding into a complimentary pair of transistors and all the resistor dividers to get the bias correct along with proper feedback, interstage coupling capacitors and power decoupling capacitors. --> Or simply an op amp and a 100uF output capacitor as was done here http://www.ladyada.net/images/wavshield/v11/wave11schem.png.

(there's probably something out there better than the LM386 that can deliver more power and use fewer parts)...

Sweet pentawatt case device, 5 legs and 18 Watts, mmm, deliciously good!

Many response posted so far here to get you to appreciate op-amps, they really are wonderful useful devices that did for the analog electronic field what the early RTL/DTL/TTL logic gates did for the digital field. A given op-amp my have a open loop gain of 1 million but almost never used that way, instead using feedback resistors a op-amp's gain can be set to exactly what your circuit requires. In fact many op-amp circuits run at a gain of one (no amplifications at all) but at the same time peforming functions like summing inputs, or low/high/bandpass filtering, etc.

So if you have any need or interest in the field of analog electronics you MUST learn about op-amps and the many functions they can perform. They really aren't that hard to understand once you get the concept and understanding of the summing junction.

Thanks for all the info!

So if I understand you all correctly, the op amp not only can increase the voltage level if it's very low, but it also increases the current, and the current is what drives the speaker.

Before one can understand op-amps, transistor circuits, etc, one first must master a true understanding of Ohm's law. There you will find that one can't talk of just current, voltage or resistance as single items but rather interrelated properties of all DC circuits. With that knowledge then you will be better prepared to move on to learn about more advance active components like transistors and op-amps.

Lefty

I'm aware of how current, voltage, and resistance are related to one another. I used an ohms law calculator I found online quite a bit when designing my last circuit.

The reason I was confused about how the op amp was driving the speaker was because the device was mysterious to me, and Wikipedia made no mention of it being a device which allows one to boost current. It only spoke of voltage and multiplying it millions of times, and I couldn't see why one would need to multiply a 5v input millions of times, and why you couldn't just use a transistor if all you needed to to was increase the current.

wikipedia is great for the basic ideas and a nice list of buzzwords to google, it is a decent starting point for most questions

wikipedia is great for the basic ideas and a nice list of buzzwords to google, it is a decent starting point for most questions

Agreed. If there's a general idea I don't understand (like at one point I was looking for a schematic to multiply an Op-Amp voltage by a constant), Wikipedia usually provides (in this case, an AWESOME article called "Operational Amplifier Applications").

What a pitty RC has already said all the things I wanted to say :stuck_out_tongue:

@TchnclFl

What a score! The technical links at the bottom of the page give you every op amp circuit variant you could possibly want. The first one from TI is over 400 pages and if you're into math...

Thanks! [smiley=thumbsup.gif]

An op-amp is a nearly ideal (for practical purposes) "device" with properties that allow one to build any number of useful circuits, including audio amplifiers with whatever level of gain you want.

Don't get hung up on specifications like a gain of "several million"; those end up being measures of the ways that that particular op-amp is NOT "ideal" in the true sense. What they mean in a circuit designed to have a much smaller gain at audio frequencies is that you won't even notice the imperfections.

(BTW, the same thing holds true for simpler transistor circuit. A transistor with a gain of 100 is hardly ever used in a way that results in an actual signal gain of 100. Instead, the circuit is manipulated so that the exact gain of the transistor becomes irrelevant. This prevents you from having to carefully match transistors, for example.)

Why do people use logic ICs like Arduino when you could do the same thing with several thousand logic gates?

That's not what I was asking though.

What I was asking was: Why use an op amp when you can use a single transistor?

The answer to why use a logic IC when you could do the same thing with several thousand logic gates is obvious. But if all I need is to limit current to an LED, you wouldn't tell me to use a resistor ladder because resistor ladders can do much more than a single resistor can.

And my understanding of transistors, though severely limited, is that they can act like a digital switch, or they can vary voltage in an analog manner. And in both cases, the portion of the circuit they control can potentially have a lot more current flowing through it than the portion of the circuit that controls the transistor.

And that sounds like exactly the sort of thing I need to drive a speaker.

But then of course, there is the op-amp. Completely mysterious to me, yet people seem to use them all the time in audio circuits to perform a task, which to my understanding, could be done by a single transistor. But why use a (relatively) expensive chip when a single transistor costing pennies seems like it would do the job just fine? That was my question.

And folks here have tried to answer that, though I'm still not 100% convinced an op-amp is needed here.

I'm not doing high-fidelity sound playback. And I don't think I need to ability to tailor the gain in voltage with two resistors, because I'm guessing if I put in 5v, the DAC will output 5v. And I don't need something which is versatile and can do "differentiation, integration, smoothing, summing, filtering, comparison".

But I understand this:

Yep, you could bang together some transistors and components to do this. Two stages of voltage amplifier for impedance match feeding into a complimentary pair of transistors and all the resistor dividers to get the bias correct along with proper feedback, interstage coupling capacitors and power decoupling capacitors. --> Or simply an op amp and a 100uF output capacitor as was done here http://www.ladyada.net/images/wavshield/v11/wave11schem.png.

Even if I don't know enough about transistors to know why I'd need two of them, or interstage coupling capacitors, or power decoupling capacitors. In fact, I'd assume I wouldn't need a decoupling capacitor on a couple transitors, but I've been told to use one on every IC, so I'd think one would be needed for the op-amp.

So I guess you could say that the reason for my initial question was that I didn't know so mny components would be needed to perform a seemingly basic function like taking the low current variable voltage output from my dac and converting it to a high current variable voltage output. I thought I could just stick a transistor on there and maybe a diode or a resistor or two and be done with it.

I mean take a look at this example:
http://itp.nyu.edu/physcomp/Tutorials/HighCurrentLoads

One diode, one transistor and it drives a motor. How is driving a speaker all that different from driving a motor?

I dunno!

That's why I asked. :slight_smile:

Hooray - so there is a second chance for me!

(a) First you must understand that transistors can work in two modes: digitally as switches (on/off), and as a kind of amplifier. This is where the problems start. It not really started with this, but the first popular transistors were "bipolar" (whatever that would mean), they were current amplifiers. You inject a small current into the "base", you get a significantly higher current drawn-in at the "collector". This was absolutly weird - no one really wanted to have such a thing. Vacuum tubes were so much more useful!! But it came much worse!

The amplification factor was not a reliable constant, but changed over the voltage applied to the collector, from device to device, and also depended on the temperature.

But people can learn Vietnamese, so they also can learn how to work with transistors. The main pressure came from the market: Transistors were the only way to build portable devices and huge things like (mainframe) computers.

That does not change anything to the fact that no-one really liked bipolar transistors. In a university course a long time ago, my professor once said: "And now I shall tell you a secret: No one really understands why transistors work...."

(b) Enters the FET. This is also called a transistor for reasons unknown, maybe because many of them also have three leads, and they are also used to switch and to amplify.... They are very similar to vacuum tubes in that they are controlled by voltage, which however is also only part of the truth as the gate - especially the early gates - had a considerable capacity which is not at all good for someone who is short of current.... And they had other issues.
But designers now had the option to jump from the frying pan into the fire.

(c) Now for something completely different: Engineers had been working with analog computers for some time to solve (mainly) differential equations. For this they had to add, multiply, and integrate values, and they found out that electrical voltage and current was able to help. E.g. take an (ideal) capacitor: It can collect charge (integration). What they also needed was an (ideal) buffer which would keep the charge at the input and did not keep back anything at the output. It turned out that this could also be described as infinite amplification but that was just by the way. The idea behind this was not to amplify things much, but to have no bad influence. So the factual amplification factor was a measure for quality, like buying a 200 kW car. Asking "How fast can it drive?" is not the point. You just cannot avoid it could drive fast...

But back to electronics. Those devices were called instrumentation amplifier and were as expensive as other lab equipment. You intend to buy one or two in your lifetime, or so....

(d) However.... Instrumentation amplifiers were the holy grale of designers as a Porsche 911.. They were ideal, one even could pre-compute the behavior of a circuit (which one could not with a circuit that contained - say - 5 transistors of whatever kind).

The first affordable - now called - operation amplifiers were a disappointment, they were still expensive, they needed "calibration", a negative supply voltage, and were hardly usefull for anything else but what they had been invented for: near DC signals.

But this changed rapidly. Opamps are nowadays used all over the analog world because you - everyone! - can design reliable and predictable circuits. The rule for an opamp is as simple as this:
It adjusts its output voltage in such a way that there is no voltage difference between its inputs.
This has revolutionized a whole industrie...
Of course a set of transistors can in many cases do the same, but no one is willing to pay an expert to develop such a circuit. On the other hand we have very, very good simulation software at the moment. Well, may be the situation might change....

(e) Back to transistors. You remember the "switch" thing? Transistors are very good switches, and very popular because many of their idiosyncrasies are acceptable in this mode. So you will find transistors all over the place in the digital business. Sometimes they are hidden in a black housing called e.g. ULN2801 or something. You would not have guessed that this "8 channel driver" contained nothing but 8 transistors ?(Well, in fact 16 but that would be hair-splitting.) Transistors as switches are well understood and there is hardly any reason they could vanish for this application, except - of cause that they might be packed differently to satisfy requests for "16 at a stretch".

Hope you enjoyed my little story :-)

Edit:

I just fixed 24 typos...

desilve:
That's all very interesting!

Can you explain this a bit better though?

"It adjusts its output voltage in such a way that there is no voltage difference between its inputs."

I don't understand what you mean by that, and the wikipedia article on them seems to indicate a different behavior:

The amplifier's differential inputs consist of a V+ input and a V- input, and ideally the op-amp amplifies only the difference in voltage between the two, which is called the differential input voltage. The output voltage of the op-amp is given by the equation,

Vout = (V+ - V-) * Aol

where V+ is the voltage at the non-inverting terminal, V- is the voltage at the inverting terminal and Aol is the open-loop gain of the amplifier. (The term "open-loop" refers to the absence of a feedback loop from the output to the input.)

I think the behavior you're describing is what happens when you set up a negative feedback loop?

So if a negative feedback loop is needed to get a linear response to voltage input, and you need two resistors to set that up, why does the wave sheild not use any resistors in this feedback loop, and use two op-amps?

It's not multiplying the input voltage here is it? Isn't the DAC outputting 5v? I thought the op-amp was just being used to supply a variable voltage to the speaker, with a larger current than the dac could handle? How does using two op-amps in series help here?

Well, who am I to say, the wikipedia were uncorrect :-) Fact is, we are both right - in fact the wikipedia is more correct wrt a real opamp and I am more correct wrt to an ideal opamp. But what I said is more helpful....

All opamps have to be fed-back! An opamp application without feed-back is - well - arcane...

When you thoroughly look at LadyAdas sketch you will see that the output of the opamps is directly (without any resistor) fed-back to the -input. What does this mean? It means the output voltage X will be set by the opamp so it be EXACTLY the voltage X at the +input, so +X -X = 0.
This circuit is very popular, called "voltage follower" and has the voltage(!) amplification 1. Its usage is to "buffer" a signal: The input has a very high impedance (>10 MOhms for all FET opamps), the output (of any opamp) has a very low impedance (<100 Ohms generally) In other words we are amplifying current (there is always more than one way to "explain" an electrical circuitry), but that makes no true sense, as there is hardly any current flowing at the input, so the current amplification would have to be called "infinite", which does not help anyone.... Note is not infinite because the output current (the numerator) is infinite, but because the denominator is zero!

But back to the sketch! The right hand opamp is wired in the same way. If you follow its wires thoroughly you will find however that it is wired IN PARALLEL to the first one, in the same way as you use batteries in parallel, and to the same avail. The output impedance is devided (or - in other words - the output current is doubled). This is done because the opamps are not ideal, but real.

I must admit that such a thing is not really covered by my (the common!) rule for opamp designs...

Voltage followers are used with transistors as well. The typical resistor sits between emitter and ground, and the signal is output at the emitter. There is (generally) no resistor at the collector and also none - surprise, surprise! - at the base. That simple "substitution" however will be an order of magnitude less powerful ( in all electrical aspects!) than the opamp design.

Note the subtle shift of thinking! We consider the opamp design as "primary" and the transistor circuitry as "derived"...

Edit

Hopefully removed all my typos now

So good of you to say the same things as I did ;D