Sub topic 11
The difference amplifier
This chapter assumes you can apply the virtual short and zero input current constraints, and that you have derived the inverting and non-inverting gains. It uses node-voltage analysis and voltage dividers.
What the circuit does
A difference amplifier produces an output proportional to the difference between two input voltages. It combines an inverting path and a non-inverting path around one op amp. This is useful when a signal is carried as the difference between two wires and both wires share an unwanted common voltage.
The circuit uses four resistors. V1 connects through R1 to the inverting input, and R2 connects from that input to the output. V2 connects through R3 to the non-inverting input, and R4 connects from that input to ground.
Derivation
Use the analysis procedure: find the non-inverting input voltage, apply the virtual short, then write KCL at the inverting node.
- No current enters the non-inverting input, so R3 and R4 form an unloaded voltage divider: V+ = V2 · R4 / (R3 + R4).
- The virtual short gives V- = V+.
- No current enters the inverting input, so the current through R1 equals the current through R2: (V1 - V-)/R1 = (V- - Vout)/R2.
- Solve for Vout: Vout = V-(1 + R2/R1) - V1 · R2/R1.
- Substitute V- from step 1:
Vout = V2 · R4/(R3 + R4) · (1 + R2/R1) - V1 · R2/R1
This is the general result. It is a superposition of an inverting gain on V1 and a non-inverting gain on V2 that has been scaled down by the divider.
The matched-ratio design
Choose R3 = R1 and R4 = R2. Then R4/(R3 + R4) = R2/(R1 + R2), and (1 + R2/R1) = (R1 + R2)/R1. The product is R2/R1, so:
Vout = (R2/R1)(V2 - V1)
The gain on V2 and the gain on V1 now have equal size and opposite sign. Only the difference V2 - V1 reaches the output.
Common-mode rejection
Write the inputs as a differential part Vd = V2 - V1 and a common-mode part Vc = (V1 + V2)/2. If both inputs rise by the same amount, the output should not move. With matched ratios it does not, because the two gains cancel exactly.
Real resistors have tolerance, so the ratios never match perfectly. The mismatch converts some common-mode voltage into output error. The calculation below shows the effect.
def diff_amp(v1, v2, r1, r2, r3, r4):
"""Ideal-op-amp output of the difference amplifier."""
return v2 * r4 / (r3 + r4) * (1 + r2 / r1) - v1 * r2 / r1
# Matched resistors: a 5 V common-mode signal is rejected completely.
print(diff_amp(5.000, 5.010, 1e3, 10e3, 1e3, 10e3)) # 0.1 (10 mV * 10)
# R4 is 1 percent high: the same inputs now produce a large error.
print(diff_amp(5.000, 5.010, 1e3, 10e3, 1e3, 10.1e3)) # about 0.5The first call returns about 0.1 V, which is the correct amplified difference. The second call returns about 0.5 V. A 1 percent error in one resistor adds roughly 0.4 V of output error from the 5 V common-mode voltage, four times the real signal.
Input resistance
The two inputs do not see the same load. V1 sees R1 into a virtual ground-like node, so its input resistance is R1. V2 sees R3 + R4 in series, because the non-inverting input draws no current. With the matched design this is R1 + R2, which differs from R1. Unequal source resistances unbalance the circuit and spoil the matching, so drive both inputs from low-resistance sources, or buffer them first.
Common errors
- Forgetting that R3 and R4 form a divider and writing the non-inverting gain as 1 + R2/R1 alone.
- Matching R1 = R3 but not R2 = R4. Both ratios must be equal.
- Ignoring source resistance, which adds to R1 or R3 and breaks the ratio.
Exercise
A difference amplifier has R1 = R3 = 2 kΩ and R2 = R4 = 20 kΩ. V1 = 3.00 V and V2 = 3.20 V. What is Vout, and what is the input resistance seen by V2?
Show answer
The gain is R2/R1 = 10, so Vout = 10 × (3.20 - 3.00) = 2.0 V. V2 sees R3 + R4 = 22 kΩ.