Sub topic 9
Difference Amplifier
This chapter assumes you know Ohm's law, KCL, voltage dividers, and the virtual short from the earlier chapters. Here you derive the output of the four-resistor difference amplifier and find the condition that makes it a pure difference.
The circuit
The difference amplifier amplifies the difference between two signals and ignores what they have in common. It uses one op amp and four resistors.
- V1 drives the inverting input through R1.
- Rf connects the output back to the inverting input.
- V2 drives the non-inverting input through R2.
- R3 connects the non-inverting input to ground.
Derivation by superposition
The circuit is linear, so you can find the output caused by each source alone and add the results. Set the other source to 0 V each time.
V1 alone (V2 = 0). The non-inverting input sits at 0 V, so the circuit is an inverting amplifier:
Vout1 = -(Rf/R1) V1
V2 alone (V1 = 0). R2 and R3 form a voltage divider, so the non-inverting input voltage is:
V+ = V2 · R3/(R2 + R3)
With V1 grounded, the op amp is a non-inverting amplifier with gain 1 + Rf/R1 applied to V+:
Vout2 = V2 · R3/(R2 + R3) · (1 + Rf/R1)
Total:
Vout = V2 · [R3/(R2 + R3)] · (1 + Rf/R1) − V1 · (Rf/R1)
This is the same expression the Python function below evaluates.
The condition for a pure difference
Suppose the resistor ratios match: Rf/R1 = R3/R2 = k. Then R3/(R2 + R3) = k/(1 + k), and 1 + Rf/R1 = 1 + k. The factors cancel:
Vout2 = V2 · [k/(1 + k)] · (1 + k) = k · V2
So:
Vout = (Rf/R1) · (V2 − V1)
Checking the numbers
The functions below evaluate the formulas. With R1 = R2 = 10 kΩ and Rf = R3 = 20 kΩ, the gain is 2.
def summing_output(vs, rs, rf):
"""Ideal inverting summer: Vout = -Rf * sum(Vi / Ri)."""
return -rf * sum(v / r for v, r in zip(vs, rs))
def difference_output(v1, v2, r1, rf, r2, r3):
"""Four-resistor difference amp.
V1 drives the inverting input through r1, rf is the feedback resistor,
V2 drives the non-inverting input through r2, r3 goes from that input to ground.
"""
return v2 * (r3 / (r2 + r3)) * (1 + rf / r1) - v1 * (rf / r1)
print(summing_output([1.0, 2.0], [10e3, 10e3], 10e3)) # -3.0 (approximately, floating point)
print(difference_output(1.0, 3.0, 10e3, 20e3, 10e3, 20e3)) # about 4.0, which is (20k/10k) * (3 - 1)The second line prints about 4.0, which equals 2 × (3 − 1). The first line is the summing amplifier from the previous chapter.
Common errors
- Swapping the signs. V2 (non-inverting side) gets a positive sign. V1 (inverting side) gets a negative sign.
- Forgetting the divider. The non-inverting input does not see all of V2. R2 and R3 attenuate it, so the gain of V2 is not simply 1 + Rf/R1.
- Matching the wrong pairs. The ratio Rf/R1 must equal R3/R2. Matching Rf to R3 and R1 to R2 works. Matching Rf to R2 does not.
- Ignoring source resistance. If a source has output resistance, it adds to R1 or R2 and breaks the ratio match.
Mismatched ratios
If the ratios differ, the circuit also amplifies the common-mode voltage, which is the part shared by both inputs. A later chapter in this tutorial covers how this limits common-mode rejection. For now, notice that if V1 = V2 = Vc, the output is not zero unless Rf/R1 = R3/R2.
Exercise
A difference amplifier has R1 = 10 kΩ, Rf = 50 kΩ, R2 = 10 kΩ, and R3 = 40 kΩ. Is it a pure difference amplifier? If V1 = V2 = 1 V, what is Vout?
Show answer
No. Rf/R1 = 5, but R3/R2 = 4, so the ratios do not match. Using the full formula: V2 term = 1 · (40/50) · (1 + 5) = 4.8 V. V1 term = 1 · 5 = 5 V. Vout = 4.8 − 5 = −0.2 V. A pure difference amplifier would give 0 V for equal inputs, so the −0.2 V is an error caused by the mismatch.