Learn & build · Electronics · Chapter 7

Op-amps

An operational amplifier is a chip with two inputs and one output that amplifies the difference between its inputs about a hundred thousand times. On its own that's almost useless: the tiniest difference slams the output against its supply. Add one resistor from the output back to an input, and it becomes the most obedient part in electronics, doing exactly what two resistors tell it. That trick, negative feedback, is this chapter.

In plain words: an op-amp is a servant that watches its two inputs and moves its output, as hard as it can, until they're equal. Wire its output back to its − input through some resistors, and you decide what "equal" means, and so what the output does.

1. A huge gain, and nowhere to put it

With nothing connected around it ("open loop"), the output is \(A\,(V_+ - V_-)\) with \(A \approx 100{,}000\), clipped at the supply rails (here a ±12 V supply: one rail 12 V above ground and one 12 V below, so the output can swing both ways; it stops about 1.5 V short of each). Move the two inputs, in millivolts.

With a gain of 100,000, how big a difference between the inputs is enough to drive the output to 10 V?

\(10 / 100{,}000 = 0.0001\) V = 0.1 mV. Smaller than the noise on most wires: open loop, the output just bangs between the rails. That's useful for one thing, a comparator (section 5).

2. Feedback: the golden rules

Now connect the output back to the − input through a resistor \(R_f\), and feed the input signal through \(R_{in}\). If the output goes too high, the − input rises, the difference shrinks, the output comes back down. It settles where the two inputs are (almost exactly) equal. That gives two rules that solve nearly every op-amp circuit:

  1. With negative feedback, the output does whatever it takes to make \(V_- = V_+\).
  2. The inputs draw no current.

🎯 Challenge: make the output exactly 10 times bigger than the input (and upside down), then push the input until it clips.

The math, step by step

The + input is at ground, so by rule 1 the − input is at 0 V too (a "virtual ground"). The current through \(R_{in}\) is then \(V_{in}/R_{in}\). By rule 2 none of it enters the op-amp, so all of it continues through \(R_f\), dropping \(R_f \cdot V_{in}/R_{in}\). The − input is at 0, so the output sits that far below it:

\[ V_{out} = -\frac{R_f}{R_{in}}\, V_{in} \]

Notice what's missing: \(A\). The gain is set by two resistors, accurate to their tolerance (chapter 5), and nearly independent of the op-amp itself. The finite \(A\) only adds a tiny error, a factor of about \(1/(1 + (1 + R_f/R_{in})/A)\): for a gain of 10 and \(A = 10^5\), 0.01%.

\(R_{in} = 1\) kΩ, \(R_f = 4.7\) kΩ, input +1 V DC. What's the output?

\(-4.7/1 \times 1 = -4.7\) V.

With negative feedback, an op-amp moves its output until its two inputs are equal, so the resistors around it, not the op-amp, set the gain.

3. Non-inverting, and the buffer

Feed the signal to the + input instead and put the divider in the feedback: the output stays the right way up, and the input draws no current at all. Gain:

\[ V_{out} = \left(1 + \frac{R_f}{R_g}\right) V_{in} \]

With \(R_f = 0\) and no \(R_g\) the gain is exactly 1: the voltage follower, or buffer. It sounds pointless, but remember chapter 1's divider sagging under a load? A buffer copies the voltage without taking any current from the divider, and can feed the load from its own supply.

Non-inverting with \(R_f = 10\) kΩ and \(R_g = 1\) kΩ. What's the gain?

\(1 + 10/1 = 11\). The lab's "Op-amp non-inverting amplifier" template is this exact circuit.

4. Adding signals: the mixer

Put several inputs, each through its own resistor, into the virtual ground of an inverting amplifier. Each pushes its own current \(V_k/R_k\) into the − node, the currents add, and all of them flow through \(R_f\):

\[ V_{out} = -R_f \left( \frac{V_1}{R_1} + \frac{V_2}{R_2} + \cdots \right) \]

Because the − input sits at 0 V, the inputs don't affect each other. That's every audio mixer's channel summing, and, with resistors weighted 1, 2, 4, 8, a simple digital-to-analog converter.

\(R_f = 10\) kΩ; input 1: 1 V through 10 kΩ; input 2: 1 V through 5 kΩ. What's the output?

\(-10\text{k} \times (1/10\text{k} + 1/5\text{k}) = -(1 + 2) = -3\) V.

5. Comparators and hysteresis

Without feedback, an op-amp (or a chip made for the job, a comparator) answers one question: is the input above the reference? Here's a slow, noisy signal, like a light sensor at dusk, compared with 2.5 V. Watch the output chatter as the signal wanders across the line. Then add hysteresis: a little positive feedback that moves the threshold up after the output switches low and down after it switches high, so noise can't flip it back.

🎯 Challenge: with noise at 0.25, find the smallest hysteresis that gives exactly one clean switch each way.

Why does hysteresis need positive feedback (output back to the + input)?

That self-reinforcing snap is a Schmitt trigger. Every button debouncer and many sensor inputs on microcontrollers have one built in.

6. An integrator

Replace \(R_f\) with a capacitor. The input pushes a current \(V_{in}/R\) into the virtual ground; it has nowhere to go but onto the capacitor, which charges steadily: the output is a ramp whose slope follows the input. A square wave in becomes a triangle out.

The math

\[ \frac{V_{in}}{R} = -C\,\frac{dV_{out}}{dt} \quad\Longrightarrow\quad V_{out}(t) = -\frac{1}{RC}\int_0^t V_{in}\, dt \]

For a ±1 V square wave at frequency \(f\), each half period \(1/(2f)\) the output ramps by \(\frac{1}{RC}\cdot\frac{1}{2f}\): with 1 ms and 250 Hz, 2 V peak to peak. Real integrators add a big resistor across the capacitor so tiny DC offsets don't ramp the output into a rail.

7. What real op-amps can't do

Rails. The output can't go beyond its supply, and older parts (like the LM358 or 741) stop 1–2 V short; "rail-to-rail" parts get within millivolts. On a single 3.3 V supply, that difference decides whether a design works.

Gain-bandwidth. The gain of 100,000 only holds for slow signals; it falls as frequency rises, so that gain × frequency stays roughly constant, the gain-bandwidth product (GBW). An op-amp with 1 MHz GBW gives a gain of 100 up to about 10 kHz, a gain of 10 up to 100 kHz.

Slew rate. The output can only move so many volts per microsecond (0.5 V/µs for a 741). A 10 V-peak sine at 20 kHz needs \(2\pi f V = 1.26\) V/µs, so a 741 turns it into a triangle.

An op-amp with a GBW of 1 MHz, set up for a gain of 50. Up to roughly what frequency does it keep that gain?

\(1\text{ MHz} / 50 = 20\) kHz: just enough for audio. Need more gain and more bandwidth? Use two stages, or a faster op-amp.

A microcontroller runs on 3.3 V and you want to amplify a sensor to use the ADC's full 0–3.3 V range. Which op-amp?

Datasheet first (chapter 5): check the supply range, and "output swing" in the electrical characteristics table.

Build the inverting and non-inverting amplifiers in the circuit lab (Insert circuit → op-amp templates) and watch the scope. Next: filters, where op-amps and capacitors shape which frequencies get through.

Previous: The circuit-theory toolkit · All chapters: Learn & build.

Last updated