Sub topic 11
The Difference Amplifier
The difference amplifier is an op amp circuit that amplifies the difference between two voltages and rejects what they have in common. This chapter assumes you can use the virtual short and zero input current constraints with KCL. It also assumes you know the inverting and non-inverting amplifier gains and how a voltage divider works. You will derive the output equation, find the condition that makes the circuit a true difference amplifier, and see how resistor mismatch limits it.
Why this circuit exists
Many sensors produce a small signal riding on a larger voltage that is shared between both wires. A bridge sensor, for example, may output 10 mV of signal on top of 2.5 V. The difference amplifier subtracts the two wires and keeps only the signal. It builds on the two configurations you already know. The signal on one input is inverted, and the signal on the other input is non-inverted but attenuated by a divider.
The circuit
The circuit uses one op amp and four resistors:
- R1 connects input V1 to the inverting terminal.
- Rf connects the output to the inverting terminal (the feedback path).
- R2 connects input V2 to the non-inverting terminal.
- R3 connects the non-inverting terminal to ground.
Derivation with the virtual short
Negative feedback through Rf holds the op amp in its linear range, so the virtual short applies: V- = V+. The input currents are zero, so no current enters either input terminal.
- Non-inverting node. No current flows into the terminal, so R2 and R3 form an unloaded divider:
V+ = V2 * R3 / (R2 + R3)
- Inverting node. The current through R1 must all flow through Rf, because the terminal draws none:
(V1 - V-) / R1 = (V- - Vout) / Rf
- Solve for Vout. Multiply by Rf and rearrange:
Vout = V- (1 + Rf/R1) - V1 (Rf/R1)
- Apply the virtual short. Replace V- with V+ from step 1:
Vout = V2 [R3 / (R2 + R3)] (1 + Rf/R1) - V1 * (Rf/R1)
This is the general result for any four resistor values. It has the form Vout = a2V2 + a1V1. The V1 gain is a1 = -Rf/R1, exactly the inverting amplifier gain. The V2 gain is a2 = [R3/(R2+R3)] * (1 + Rf/R1), which is the non-inverting gain multiplied by the divider ratio.
The matching condition
The circuit subtracts only when a2 = -a1. Set the two equal:
[R3 / (R2 + R3)] * (1 + Rf/R1) = Rf/R1
Let k = Rf/R1. The condition becomes R3/(R2 + R3) = k/(1 + k). Cross-multiplying gives R3 = k*R2, so:
Rf / R1 = R3 / R2
When this holds, the divider factor cancels the "1 +" term, and:
Vout = (Rf / R1) * (V2 - V1)
The most common design takes R2 = R1 and R3 = Rf. This choice gives a simple gain of Rf/R1 and equal resistance seen from each input.
Superposition check
You can confirm the result without solving KCL again. Set V2 = 0. The non-inverting terminal is grounded, so the circuit is an inverting amplifier with gain -Rf/R1 for V1. Set V1 = 0. The input V2 drives a non-inverting amplifier through the divider R2, R3, giving [R3/(R2+R3)] * (1 + Rf/R1). Adding the two contributions reproduces step 4. The ideal op amp is linear, so superposition is valid as long as the output stays within the supply rails.
Differential and common-mode signals
Split the inputs into two parts:
- The differential voltage Vd = V2 - V1.
- The common-mode voltage Vc = (V1 + V2) / 2.
Then V2 = Vc + Vd/2 and V1 = Vc - Vd/2. Substituting into Vout = a2V2 + a1V1 gives:
Vout = (a2 + a1) Vc + [(a2 - a1) / 2] Vd
So the differential gain is Ad = (a2 - a1)/2, and the common-mode gain is Acm = a2 + a1. A perfectly matched circuit has Acm = 0. The common-mode rejection ratio (CMRR) is |Ad / Acm|, often quoted in decibels as 20*log10(|Ad / Acm|).
Effect of resistor mismatch
Real resistors have tolerances, so the ratios never match exactly. Take R1 = R2 = 10 kΩ, R3 = 100 kΩ, and Rf = 101 kΩ (1% high):
- a1 = -101/10 = -10.1
- a2 = (100/110) * 11.1 = 10.0909
- Acm = 10.0909 - 10.1 = -0.0091
- Ad = (10.0909 + 10.1)/2 = 10.0955
The CMRR is 10.0955 / 0.0091, about 1110, or roughly 61 dB. A 1% error in one resistor already limits rejection to about 61 dB. A shared 2.5 V common-mode level then produces an unwanted output of 2.5 * (-0.0091) = -23 mV. That error is larger than the 10 mV signal in the sensor example above. Tolerances matter much more here than in a plain inverting amplifier.
The following code computes these quantities for any resistor set.
import math
def diff_amp_gains(r1, rf, r2, r3):
"""Return (a1, a2, ad, acm) for the difference amplifier.
Vout = a1*V1 + a2*V2, with ad the differential gain
and acm the common-mode gain.
"""
a1 = -rf / r1
a2 = (r3 / (r2 + r3)) * (1 + rf / r1)
ad = (a2 - a1) / 2
acm = a2 + a1
return a1, a2, ad, acm
def diff_amp_output(v1, v2, r1, rf, r2, r3):
a1, a2, _, _ = diff_amp_gains(r1, rf, r2, r3)
return a1 * v1 + a2 * v2
# Matched ratios: Rf/R1 = R3/R2 = 10
print(diff_amp_output(2.500, 2.510, 10e3, 100e3, 10e3, 100e3)) # about 0.1
# Rf is 1% high
_, _, ad, acm = diff_amp_gains(10e3, 101e3, 10e3, 100e3)
cmrr = abs(ad / acm)
print(round(ad, 4), round(acm, 4)) # 10.0955 -0.0091
print(round(cmrr), round(20 * math.log10(cmrr), 1)) # 1110 60.9Input resistance
The two inputs do not see the same resistance, which matters when the sources have their own output resistance.
- V1 input. The inverting node sits at V-, which equals V+. This is not ground, but the current into R1 is (V1 - V-)/R1, and the current-to-voltage relationship depends on V+. For the matched case with V2 = 0, V- = 0 and the input resistance seen by V1 is R1.
- V2 input. No current enters the op amp terminal, so V2 sees R2 + R3 to ground. This does not depend on V1.
With R2 = R1 and R3 = Rf, the V1 input resistance is R1 and the V2 input resistance is R1 + Rf, which is much larger. A source resistance Rs in series with either input effectively adds to R1 or R2. That changes one ratio and breaks the matching condition. If your sources are not low-impedance, buffer each input with a voltage follower first.
Output limits and common-mode range
The linear analysis holds only while the output stays between the supply rails. With a gain of 10 and supplies of ±15 V, the output saturates when |V2 - V1| exceeds about 1.5 V (a little less for a real op amp that cannot reach the rails). Also check the node voltages. V+ = V2 * R3/(R2+R3) must remain inside the op amp's input common-mode range. A large common-mode voltage can push the inputs out of range even when the differential signal is small.
Common mistakes
- Swapping the grounded resistor. R3 goes from the non-inverting node to ground, not to the output. If R3 went to the output, the feedback would be positive.
- Forgetting the divider. Applying the plain non-inverting gain 1 + Rf/R1 to V2 gives a gain error of (R2 + R3)/R3.
- Matching values, not ratios. The condition is Rf/R1 = R3/R2. Equal values are only one way to satisfy it.
- Ignoring tolerance. Use matched resistor networks or trimmed parts when high CMRR is required.
Exercise
A difference amplifier has R1 = R2 = 5 kΩ and Rf = R3 = 50 kΩ. Find Vout when V1 = 3.00 V and V2 = 3.04 V, and state the input resistance seen by V2.
Show answer
The ratios match (Rf/R1 = R3/R2 = 10), so Vout = 10 (V2 - V1) = 10 0.04 V = 0.4 V. The common-mode level of about 3 V is rejected. The V2 input sees R2 + R3 = 55 kΩ, because no current enters the non-inverting terminal.
Exercise
With R1 = R2 = 10 kΩ and Rf = 100 kΩ, the resistor R3 is 99 kΩ instead of 100 kΩ. Compute a1, a2, and the common-mode gain Acm.
Show answer
a1 = -100/10 = -10. The divider is 99/(10 + 99) = 0.90826, and 1 + Rf/R1 = 11, so a2 = 0.90826 * 11 = 9.9908. Acm = a2 + a1 = 9.9908 - 10 = -0.0092. The differential gain is (9.9908 + 10)/2, about 9.995, so the CMRR is about 1090, or roughly 61 dB.