The op-amp's two rules: buffer, gain and a mixer
An op-amp follows two rules: it drives its output until its two inputs are at the same voltage, and no current flows into those inputs. From them come the buffer (gain 1), the non-inverting amp (1 + Rf/Rg: 2 with equal resistors), the inverting amp (−Rf/Rin) and the mixer.
circuit OpAmp setting output: 4 V setting gain: 10k, from 1k to 20k R1 in a 10k U1 a m out opamp Rf out m gain # Rg m gnd 10k Rload out gnd 10kendPress Play to see the wave after the circuit, at out.
What you're hearing
An op-amp has two inputs, one output and two rules. The inputs are marked + and −. Rule 1: as long as the output is joined back to the − input through parts (that's feedback), the op-amp drives its output up or down until its two inputs are at the same voltage. Rule 2: no current flows into either input. Everything below is those two rules and Ohm's law, V = I × R, from the voltage divider page. Here a full-scale note is 1 V at the input.
A buffer copies its input and takes nothing from it. In the first button, the + input sits at a, after R1. Nothing joins m to ground, so by rule 2 no current can flow through Rf: there's nowhere for it to go. No current means no voltage across Rf, so out is the same as m, and by rule 1, m is the same as a. The output copies the input: a gain of 1, 0 dB. And because the + input takes no current, none flows through R1 either, so a is the full 1 V. A buffer is often drawn with the output wired straight back to the − input (U1 a out out opamp); it's the same thing.
A buffer stops loading. On the voltage divider page, a 10 kΩ load pulled a divider's output down from 0.50 V to 0.33 V. Here R1 stands for a weak source: anything with resistance in it, like a pot or the top half of a divider. Press "Load before the buffer" and the 10 kΩ load hangs straight on it. R1 and the load are then a divider: 1 V × 10 kΩ / 20 kΩ = 0.5 V, 6.0 dB down. With the buffer between them, the load hangs from the op-amp's output instead. The op-amp supplies the 100 µA the load draws (1 V / 10 kΩ), none of it through R1, and the load gets the full 1 V. That's the idea behind a buffer pedal: a guitar's pickups and pots are a weak source, and a long cable and the pedals after it are a load.
Add Rg and it amplifies: 1 + Rf/Rg. "Non-inverting gain" adds Rg, 10 kΩ from m to ground. Rule 1 holds m at the input's 1 V, so 1 V / 10 kΩ = 100 µA flows down Rg. By rule 2 that current can't come from the − input, so it comes from the output, through Rf: 100 µA × 10 kΩ = 1 V across Rf. The output is m plus that, 1 V + 1 V = 2 V. In general, Vout = Vin × (1 + Rf/Rg) = 1 V × (1 + 10 kΩ / 10 kΩ) = 2 V, a gain of 2, +6.0 dB. Another way to see it: Rf and Rg are a divider from the output, and the op-amp turns its output up until the divider's share equals the input. "Non-inverting" means the output rises when the input rises.
The gain knob turns Rf. It runs from 1 kΩ to 20 kΩ, with R1 and Rg fixed at 10 kΩ:
| Rf (the knob) | non-inverting, 1 + Rf/Rg | inverting, −Rf/R1 |
|---|---|---|
| 1 kΩ | 1.1 (+0.8 dB) | −0.1 (−20.0 dB) |
| 4.7 kΩ | 1.47 (+3.3 dB) | −0.47 (−6.6 dB) |
| 10 kΩ | 2 (+6.0 dB) | −1 (0.0 dB) |
| 20 kΩ | 3 (+9.5 dB) | −2 (+6.0 dB) |
The non-inverting amp never goes below 1: even with Rf at 1 kΩ it's 1.1. In the buffer, the knob does nothing at all.
The inverting amp turns the wave upside down: −Rf/R1. "Inverting gain" puts the + input on ground and runs R1 from the input to the − input, where it becomes the input resistor (often called Rin). Rule 1 now holds m at 0 V, as if it were joined to ground, though it isn't: a virtual ground. So R1 has the whole 1 V across it, and 1 V / 10 kΩ = 100 µA flows into m. By rule 2 it can't go into the op-amp, so it carries on through Rf to the output. To draw 100 µA through Rf away from 0 V, the output has to sit 100 µA × 10 kΩ = 1 V below m: −1 V. In general, Vout = −Vin × Rf/R1, here −1 (0 dB). Unlike the non-inverting amp, it can turn a sound down: Rf at 1 kΩ gives −0.1, −20 dB. Upside down sounds the same on its own, but mixed equally with the original, the two cancel: 1 V + (−1 V) = 0 V. One catch: the source feeding it sees R1 to a virtual ground, a 10 kΩ load, so an inverting amp loads a weak source. Buffers are non-inverting for that reason.
A mixer is the inverting amp with more inputs. Give the − input a second resistor from another sound, and both currents meet at m and carry on through Rf together: Vout = −Rf × (V1/R1 + V2/R2). With all three resistors at 10 kΩ, 1 V on one input and 0.5 V on the other give 100 µA + 50 µA = 150 µA, so the output is −150 µA × 10 kΩ = −1.5 V. Because m stays at 0 V, the inputs don't push on each other: turning one up doesn't change the other's level. Make R2 20 kΩ and that input comes in at half its level, so each input's resistor sets its share. The sum comes out upside down, so mixers often follow with a second inverting stage, of gain −1, to turn it back.
The op-amp here is ideal. Its output can swing as far as the gain asks; a real one stops near its supply voltages, the subject of rails and headroom. A real one also can't change its output instantly: see slew rate and the real-world op-amp.
Try this
- Press "Load before the buffer", then "Buffer". The sound drops by 6 dB, then comes back. The parts are the same: the load has only moved to the op-amp's output.
- In "Buffer", turn gain: nothing changes, because no current flows through Rf. Press "Non-inverting gain" and turn it again: from 1.1 to 3 times. Then press "Inverting gain" and watch the Scope: the saw's ramp now falls instead of rising. Turn gain down to 1 kΩ for −20 dB, which the non-inverting amp can't reach.
- Open it in SynthMaker to change the parts, and make a mixer. Start from the inverting version, add a second way in with
in band a second input resistor,R2 b m 50k, and wire another oscillator into b. A wire's full level is 5 V on a way in like b, so 50 kΩ brings it in at the same level as the sound through R1's 10 kΩ.
The parts list
circuit OpAmp setting output: 4 V setting gain: 10k, from 1k to 20k R1 in a 10k U1 a m out opamp Rf out m gain # Rg m gnd 10k Rload out gnd 10kendThe # line is Rg: remove the # for the non-inverting amp. setting output: 4 V makes 4 V at the output full volume, so there's room for a gain of 3.
How we checked it
Checked against ngspice, a standard circuit simulator: with resistors and an ideal op-amp, the engine's gains are exact to the digits shown (1.0000, 0.5000, 3.0000, −2.0000), as ngspice's are.
Build it step by step
- The lesson: Random voltages from noise (opens in a new tab). In its "Why the buffers" step, a 1 MΩ load drains a held voltage away, and an op-amp buffer holds it flat. A second buffer on the way in lets a weak source fill the capacitor.
- The video: Turn noise into a burbling synth filter: a sample and hold, built from parts. It loads only when tapped.
- A gain stage in a filter: A screaming synth filter, built from parts (opens in a new tab). Its amplifier is this page's non-inverting amp with Rg 4.7 kΩ and Rf 270 kΩ: 1 + 270 / 4.7, a gain of about 58.
Further reading
- The two rules, called the golden rules there, and the stages built from them: P. Horowitz and W. Hill, The Art of Electronics, third edition, Cambridge University Press, 2015. Book site
- The ideal op-amp and its two rules: Wikipedia: Operational amplifier.
- The buffer, the non-inverting and inverting amps and the summing amp, with their formulas: Wikipedia: Operational amplifier applications.
- Why a buffer stops loading: Wikipedia: Buffer amplifier.
- The − input held at 0 V: Wikipedia: Virtual ground.
- How SynthMaker simulates a circuit with op-amps: M. Holters and U. Zölzer, "A Generalized Method for the Derivation of Non-Linear State-Space Models from Circuit Schematics", EUSIPCO 2015. PDF