An idea on a ferry
In August 1927 Harold Black, an engineer at Bell Labs, was crossing the Hudson on the ferry to work, worrying about telephone repeaters. Long-distance calls passed through dozens of vacuum-tube amplifiers in series, and each one's gain drifted with the age of its tubes and its supply voltage and distorted the signal a little; multiplied over a continent, the errors were unacceptable. His idea, sketched on his newspaper, was to build an amplifier with far more gain than needed and then throw most of it away by feeding a fraction of the output back, inverted, to the input. The result would depend almost entirely on the feedback network, a few stable passive parts, and hardly at all on the tubes. His patent took nine years to be granted, partly because the examiners did not believe it would work.
You have already used Black's idea: it is why the op-amp circuits of the previous lesson obey simple rules. This lesson looks at feedback itself: what it buys, what it costs, and how a loop meant to correct can instead overshoot, ring, or break into oscillation. Then it turns that failure into a tool, because every clock, radio and processor needs an oscillator, a circuit that makes a steady wave out of a steady supply.
What negative feedback buys
Definition— Loop gain and closed-loop gain
In the loop of the figure, and . Eliminating , The loop gain is the gain all the way round the loop. When , . In general , and depend on frequency.
The op-amp lesson showed the most famous consequence: the closed-loop gain depends on , a ratio of resistors, rather than on the amplifier. Here are the benefits in general form, each a factor of .
Theorem— Desensitivity
A fractional change in the forward gain produces a fractional change in the closed-loop gain times smaller:
Proof
Differentiate with respect to : . Dividing by gives , so .
∎
- Gain stability. With , a 20% drift in moves by about 0.02%.
- Bandwidth. If has a single pole, , then : the gain falls by and the bandwidth rises by the same factor. Their product, the gain–bandwidth product, is unchanged.
- Linearity. Distortion generated inside the amplifier is a disturbance that the loop sees and corrects; it is reduced by about at each frequency, which is why audio amplifiers use large loop gains.
- Impedances. Sampling the output voltage and feeding it back divides the output resistance by ; feeding back in series with the input multiplies the input resistance by . That is how a follower made from an op-amp reaches milliohms of output resistance.
The costs are equally real. You must build times more gain than you use. Feedback cannot reduce noise or interference that enters at the input, which it cannot tell from the signal. Corrections take time to travel round the loop, and if they arrive late, they make things worse: the subject of the next section.
Poles, phase margin, and why amplifiers ring
Every amplifier has poles, and each pole delays the signal: a single pole adds up to 90° of phase lag, approached well above its frequency. With three poles in the loop, the lag reaches 180° at some frequency . At that frequency the "negative" feedback arrives exactly inverted, which turns it positive. If the loop still has a gain of one or more there, a disturbance at comes round the loop at least as large as it left, and builds up: the amplifier oscillates. If the gain is just below one, the disturbance dies away slowly, and the amplifier rings.
Definition— Gain crossover, phase margin and gain margin
The gain crossover frequency is where (0 dB). The phase margin is how far the loop's phase is from −180° there: . The gain margin is how far is below 1 at , where : dB. For loops like these, which are stable when opened, a positive phase margin and a positive gain margin mean the closed loop is stable.
The general test, the Nyquist criterion of 1932, counts how the plot of encircles the point −1; Laplace and stability and Feedback control develop it. For most amplifiers the margins are enough, and they are easy to compute. Take an amplifier with a DC gain of 1000 and three poles, at 100 kHz, 1 MHz and 10 MHz, and close the loop around it for gains of 1, 10 and 100. Then move its first pole down to 100 Hz, which is what an op-amp's internal compensation capacitor does, and repeat.
import math
def loop_gain(f, a0, poles, beta):
"""T(j 2 pi f) = beta * A0 / product of (1 + j f / f_p)."""
t = beta * a0
for fp in poles:
t /= 1 + 1j * f / fp
return t
def solve_log(func, lo, hi):
"""Bisection on a logarithmic frequency axis for a sign change of func."""
for _ in range(100):
mid = math.sqrt(lo * hi)
if (func(mid) > 0) == (func(lo) > 0):
lo = mid
else:
hi = mid
return mid
def margins(a0, poles, beta):
T = lambda f: loop_gain(f, a0, poles, beta)
phase = lambda f: -sum(math.degrees(math.atan(f / fp)) for fp in poles) # unwrapped
fc = solve_log(lambda f: abs(T(f)) - 1, 1e-3, 1e12) if beta * a0 > 1 else None
f180 = solve_log(lambda f: phase(f) + 180, 1.0, 1e12)
pm = 180 + phase(fc) if fc else float("inf")
gm_db = -20 * math.log10(abs(T(f180)))
return fc, pm, f180, gm_db
A0 = 1000.0
UNCOMP = [100e3, 1e6, 10e6] # an amplifier with three poles of similar size
COMP = [100.0, 1e6, 10e6] # the same with its first pole moved down to 100 Hz
for name, poles in (("uncompensated", UNCOMP), ("compensated", COMP)):
print(f"{name}: A0 = {A0:.0f}, poles at {', '.join(f'{p:g} Hz' for p in poles)}")
print(" 1/beta crossover f_c phase margin gain margin")
for beta in (1.0, 0.1, 0.01):
fc, pm, f180, gm = margins(A0, poles, beta)
verdict = "unstable" if pm < 0 else ""
print(f" {1 / beta:6.0f} {fc / 1e3:10.1f} kHz {pm:9.1f} deg {gm:7.1f} dB {verdict}")The uncompensated amplifier is stable only at high closed-loop gain. At a gain of 100 the phase margin is a healthy 54.9°; at 10 it is 3.5°, barely stable; and as a follower (gain 1) it is negative, an oscillator. The lesson is counter-intuitive: more feedback is harder to stabilise, because a larger raises the whole loop-gain curve, pushing the crossover out to higher frequencies where the poles have piled up more phase lag. Moving the first pole down to 100 Hz makes the loop gain fall at 20 dB per decade, with only 90° of lag, all the way to crossover, and the amplifier is then stable at every gain, with at least 83.8° of margin. This is dominant-pole compensation: it deliberately sacrifices open-loop bandwidth to make the amplifier unity-gain stable. Inside an op-amp it is usually done with a small capacitor around the second stage, whose effect the Miller multiplication of Transistor amplifiers magnifies, splitting the poles further apart.
What does a small margin look like? The program below closes each loop, applies a unit step at the input, and integrates the circuit's differential equations with the fourth-order Runge–Kutta method.
import math
def step_response(a0, poles_hz, beta, t_end, dt=1e-9):
"""Closed-loop unit-step response of y = A(s) e, e = u - beta y, with A(s) built as
three first-order stages (gain a0 in the first). Integrated with fourth-order Runge-Kutta."""
w = [2 * math.pi * p for p in poles_hz]
def deriv(x):
e = 1.0 - beta * x[2]
return [w[0] * (a0 * e - x[0]), w[1] * (x[0] - x[1]), w[2] * (x[1] - x[2])]
x, t, ys = [0.0, 0.0, 0.0], 0.0, []
while t < t_end:
k1 = deriv(x)
k2 = deriv([xi + dt / 2 * ki for xi, ki in zip(x, k1)])
k3 = deriv([xi + dt / 2 * ki for xi, ki in zip(x, k2)])
k4 = deriv([xi + dt * ki for xi, ki in zip(x, k3)])
x = [xi + dt / 6 * (a + 2 * b + 2 * c + d) for xi, a, b, c, d in zip(x, k1, k2, k3, k4)]
t += dt
ys.append((t, x[2]))
return ys
cases = [("uncompensated, gain 10 ", [100e3, 1e6, 10e6], 0.1, 3.5),
("uncompensated, gain 100", [100e3, 1e6, 10e6], 0.01, 54.9),
("compensated, gain 1 ", [100.0, 1e6, 10e6], 1.0, 83.8)]
print("case phase margin overshoot 2% settling time")
for name, poles, beta, pm in cases:
ys = step_response(1000.0, poles, beta, t_end=40e-6)
final = 1000.0 / (1 + 1000.0 * beta)
peak = max(y for _, y in ys)
outside = [t for t, y in ys if abs(y - final) > 0.02 * final]
settle = outside[-1] if outside else 0.0
settle_txt = f"{settle * 1e6:8.2f} us" if settle < 39e-6 else " > 40 us (still ringing)"
print(f"{name} {pm:8.1f} deg {max(0.0, 100 * (peak - final) / final):7.1f} % {settle_txt}")With 3.5° of margin the output overshoots by 88% and rings for over 7 µs; with 54.9° it overshoots by 18% and settles in 1.3 µs; with 83.8° it does not overshoot at all. Designers usually aim for 45° to 60°, accepting a little overshoot for speed.
Positive feedback and the Barkhausen criterion
Feed the output back in phase and the loop reinforces whatever happens. With high gain that drives the output to a rail and holds it there: memory, as in the latch of a flip-flop. A comparator with a little positive feedback becomes a Schmitt trigger: once the output has switched high, a fraction of it raises the threshold the input must cross to switch it back, so a slowly varying or noisy input produces one clean transition instead of a burst. With output levels and a feedback divider (to ground) and (from the output), the thresholds are , and the gap between them is the hysteresis.
To make a steady sine wave we want something gentler: positive feedback at exactly one frequency.
Theorem— Barkhausen criterion
A linear loop sustains a sinusoidal oscillation of constant amplitude at frequency only if the loop gain there is exactly one, with zero phase:
The condition is necessary, not sufficient, and a practical oscillator never sits exactly on it. If were exactly 1 the oscillation would neither start nor stay put: any drift in a component would make it decay or grow. Real oscillators are designed with a little above one at start-up, so that noise grows into an oscillation, and then a nonlinearity reduces the effective gain as the amplitude grows until it settles where the average loop gain is exactly one.
Sine-wave oscillators: Wien bridge and phase shift
The Wien-bridge oscillator uses a non-inverting amplifier with a frequency-selective feedback network: a series R–C from the output to the non-inverting input, and a parallel R–C from that input to ground. At the network's phase shift is zero and it passes exactly one third of the output, so the amplifier must have a gain of exactly 3.
Exactly 3 is impossible to hold with fixed resistors, so the gain is made to depend on amplitude. In 1939 William Hewlett, then a Stanford graduate student, used a small incandescent lamp as : as the oscillation grows, the lamp warms, its resistance rises and the gain falls back to 3. His audio oscillator, with very low distortion for its day, was the first product of the company he founded with David Packard. Modern designs use diodes that progressively shunt , or a field-effect transistor acting as a voltage-controlled resistor in an automatic gain control loop.
The phase-shift oscillator uses an inverting amplifier (180°) and a ladder of three R–C sections, each contributing part of another 180°. With three identical high-pass sections (series C, shunt R) loading each other, the network's phase reaches 180° at , where it attenuates by exactly 29, so the amplifier needs a gain of at least 29.
import cmath
import math
R, C = 10e3, 10e-9 # the same R and C in every network below
def wien(f):
"""Wien network: series R-C from the output, parallel R-C to ground; returns v_back / v_out."""
s = 2j * math.pi * f
zs = R + 1 / (s * C)
zp = 1 / (1 / R + s * C)
return zp / (zs + zp)
def ladder(f, sections=3):
"""Three C-R high-pass sections in cascade (each loading the last), output unloaded."""
s = 2j * math.pi * f
m = [[1, 0], [0, 1]]
for _ in range(sections):
for step in ([[1, 1 / (s * C)], [0, 1]], [[1, 0], [1 / R, 1]]): # series C, then shunt R
m = [[m[0][0] * step[0][0] + m[0][1] * step[1][0], m[0][0] * step[0][1] + m[0][1] * step[1][1]],
[m[1][0] * step[0][0] + m[1][1] * step[1][0], m[1][0] * step[0][1] + m[1][1] * step[1][1]]]
return 1 / m[0][0]
def find_phase(func, target_deg, lo, hi):
"""Frequency where the phase of func crosses target_deg (bisection, log axis)."""
g = lambda f: math.degrees(cmath.phase(func(f) * cmath.exp(-1j * math.radians(target_deg))))
for _ in range(100):
mid = math.sqrt(lo * hi)
if (g(mid) > 0) == (g(lo) > 0):
lo = mid
else:
hi = mid
return mid
f = find_phase(wien, 0, 10, 1e6)
print(f"Wien network: zero phase at {f:.2f} Hz (1/(2 pi RC) = {1 / (2 * math.pi * R * C):.2f} Hz), "
f"|beta| = {abs(wien(f)):.4f} -> the amplifier needs a gain of {1 / abs(wien(f)):.3f}")
f = find_phase(ladder, 180, 10, 1e6)
print(f"RC ladder: 180 degrees at {f:.2f} Hz (1/(2 pi sqrt6 RC) = {1 / (2 * math.pi * math.sqrt(6) * R * C):.2f} Hz), "
f"|beta| = 1/{1 / abs(ladder(f)):.3f}")
# A quartz crystal's equivalent circuit (plausible values for a 10 MHz crystal)
L1, C1, R1, C0 = 12.665e-3, 20e-15, 15.0, 4e-12
fs = 1 / (2 * math.pi * math.sqrt(L1 * C1))
fp = fs * math.sqrt(1 + C1 / C0)
print(f"\ncrystal: series resonance {fs / 1e6:.6f} MHz, parallel resonance {fp / 1e6:.6f} MHz "
f"({(fp - fs) / 1e3:.1f} kHz higher), Q = {2 * math.pi * fs * L1 / R1:,.0f}")
for ppm in (20, 1, 0.01):
print(f" a frequency error of {ppm:g} ppm is {ppm * 1e-6 * 86400:.4g} s per day")Both formulas check out numerically: with 10 kΩ and 10 nF, the Wien network has zero phase at 1591.55 Hz with , and the ladder reaches 180° at 649.75 Hz with . (The last lines of the output are about crystals, below.)
Relaxation oscillators
Not every oscillator makes sine waves. A relaxation oscillator charges a capacitor until a threshold, flips, discharges it to another threshold, and flips back. The simplest uses an op-amp as a Schmitt trigger (positive feedback through a divider with ) whose output also charges a capacitor through a resistor connected to the inverting input. The capacitor voltage swings between , and each half-period is the time for an RC charge to cross from one threshold to the other, giving which is for . The output is a square wave and the capacitor voltage a series of exponential ramps, close to a triangle.
The netlist simulates it with a behavioural op-amp of our own: a gain of 10 000 with its output limited to ±5 V by a tanh function and a 50 ns lag, which keeps the switching realistic. The capacitor starts at −1 V (IC=-1 with uic) to begin the cycle.
* Op-amp relaxation oscillator (astable multivibrator)
* A behavioural op-amp used open loop: high gain, output limited to +-5 V,
* with a 50 ns lag so that the switching is realistic and easy to simulate.
B1 x 0 V = 5 * tanh(2000 * (v(p) - v(n)))
RLAG x out 50
CLAG out 0 1n
* positive feedback: a divider returns half the output to the + input
R1 out p 10k
R2 p 0 10k
* negative feedback through R and C: the timing network
RT out n 10k
CT n 0 10n IC=-1
.control
tran 0.1u 2m uic
meas tran period TRIG v(out) VAL=0 RISE=3 TARG v(out) VAL=0 RISE=4
meas tran vhigh MAX v(out) from=1m to=2m
meas tran vcap MAX v(n) from=1m to=2m
let theory = 2 * 10k * 10n * ln(3)
echo "period $&period s; 2 R C ln 3 = $&theory s"
echo "output swings to $&vhigh V; capacitor peaks at $&vcap V"
.endc
.endThe simulated period is 220.04 µs against the formula's 219.72 µs, 0.14% longer because the model's output takes a little time to switch and does not quite reach 5 V (4.98 V). The capacitor peaks at 2.49 V, half the output swing, as the divider promises.
The same principle runs the 555 timer, designed by Hans Camenzind for Signetics around 1971 and still made by many companies, whose two comparators and a flip-flop switch at one third and two thirds of the supply. And chips measure their own speed with ring oscillators, an odd number of CMOS inverters from the Transistors lesson connected in a loop, whose frequency is set by the gate delay.
Crystal oscillators
Quartz is piezoelectric: squeezing it produces a voltage, and a voltage makes it flex. A thin slab of quartz cut at a chosen angle and plated with electrodes vibrates mechanically at a frequency set by its dimensions, and electrically it behaves like a series RLC circuit (the motional arm, , , ) in parallel with the capacitance of its electrodes, the Butterworth–Van Dyke model. The motional inductance is enormous and the capacitance tiny, so the quality factor is huge. The program above, with plausible values for a 10 MHz crystal ( mH, fF, , pF), finds a series resonance at 10.000058 MHz, a parallel resonance only 25.0 kHz above it, and ; an LC circuit on a board manages perhaps 100.
Between the two resonances the crystal behaves as an inductor whose reactance changes extremely fast with frequency. In the Pierce oscillator, used by almost every microcontroller, an inverter provides the gain and the crystal with two small capacitors provides the 180° of phase shift; the phase condition can be met only within a tiny frequency range, so the frequency is pinned. A watch crystal at 32 768 Hz, which is , is halved fifteen times by a digital counter to tick once per second. Ordinary crystals are accurate to about 10–50 parts per million (ppm); 20 ppm is 1.7 seconds a day. Temperature-compensated (TCXO) and oven-controlled (OCXO) oscillators reach 1 ppm and 0.01 ppm, and MEMS oscillators, tiny silicon resonators, now compete with quartz in many products. Beyond them lie the atomic clocks, kept by national laboratories such as NIST in the United States, PTB in Germany and NPL in the United Kingdom, that define the second.
Phase-locked loops
A crystal gives one precise frequency. A phase-locked loop (PLL) multiplies it to any other, and is itself a feedback system. A voltage-controlled oscillator (VCO) produces the output; a divider divides its frequency by ; a phase detector compares the divided signal with the crystal reference and produces an error proportional to their phase difference; and a loop filter smooths that error into the VCO's control voltage. When the loop is locked, the divided output tracks the reference in phase, so
Change and the output moves in steps of , which is how a radio tunes: a 2.4 GHz Wi-Fi channel can be synthesised from a 40 MHz crystal with (practical synthesisers use fractional dividers for finer steps). PLLs also multiply a processor's 100 MHz reference to its several-gigahertz clock, recover the clock hidden in a serial data stream (Timing and clocking), and demodulate FM (Modulation). Because the VCO integrates frequency into phase, the loop has a built-in integrator, and with its loop filter it is a feedback system with all the stability questions of this lesson: a PLL with too little phase margin rings when it changes channel, and its output wobbles in time, the jitter that limits fast data links.
Common misconceptions
Misconception
"More feedback always makes an amplifier more stable." More feedback makes its gain more stable, but it raises the loop gain, pushes the crossover frequency up into the region where the poles add phase lag, and reduces the phase margin. Followers are the hardest configuration to stabilise.
Misconception
"If the loop gain is greater than one at the frequency where the phase is −180°, the amplifier simply has a lot of gain there." It oscillates. Every disturbance at that frequency returns larger and inverted once more, that is, in phase, so it grows until something saturates.
Misconception
"Satisfying the Barkhausen criterion guarantees a clean oscillation." It is a necessary condition for a steady sine wave, not a sufficient one. Real oscillators need excess gain to start and a nonlinear mechanism to settle the amplitude, and the quality of that mechanism sets the distortion.
Misconception
"Negative feedback removes noise." It suppresses noise and distortion generated inside the loop, after the comparison. Noise that arrives with the input, or is generated by the first stage, is indistinguishable from the signal and is amplified with it.
Exercises
1. Feedback, stability and oscillators
Warm-upHumanAn amplifier with forward gain is placed in a negative feedback loop designed for a closed-loop gain of about 50. What is the loop gain ?
2. Feedback, stability and oscillators
CoreHumanAn amplifier has a single pole: with and the pole at 10 Hz. It is used with . What is the closed-loop bandwidth, in hertz? (Use the exact formula, not the approximation.)
3. Feedback, stability and oscillators
Warm-upHumanAt the frequency where a loop gain's magnitude falls to 1, its phase is −132°. What is the phase margin, in degrees?
4. Feedback, stability and oscillators
CoreHumanA Wien-bridge oscillator uses kΩ and nF in both arms of its network. At what frequency, in hertz to the nearest whole number, does it oscillate?
5. Feedback, stability and oscillators
CoreHumanAn op-amp relaxation oscillator like the lesson's has a feedback divider with , a timing resistor of 47 kΩ and a timing capacitor of 22 nF. What is its period, in microseconds, to the nearest whole number?
6. Feedback, stability and oscillators
Warm-upHumanA phase-locked loop uses a 25 MHz crystal reference and an integer divider. What divider ratio makes it produce 2.45 GHz?
7. Feedback, stability and oscillators
CoreHumanWhich statements about oscillators are true? Select all that apply.
8. Feedback, stability and oscillators
CoreComputationalWrite phase_margin(a0, poles_hz, beta) returning the phase margin, in degrees, of the loop gain
where poles_hz lists the pole frequencies in hertz. Assume . Find the crossover frequency numerically, then add up each pole's phase lag there; do not wrap the phase, so an unstable loop returns a negative margin. The tests use the lesson's amplifiers.
Further reading and resources
- Stabilized feedback amplifiers · Harold S. Black · 1934The negative feedback amplifier, explained by its inventor in the Bell System Technical Journal.
- Regeneration theory · Harry Nyquist · 1932The stability criterion for feedback loops, from the frequency response alone.
- ngspice documentationBehavioural sources and transient analysis with initial conditions, used in the oscillator check.
- National Institute of Standards and Technology, Time and Frequency DivisionHow the world's time and frequency standards are kept, from quartz to atomic clocks.
- MIT OpenCourseWare: Feedback Systems (6.302)Lectures on loop gain, stability margins and compensation in electronic feedback systems.