Sub topic 12
The Ideal Integrator and Differentiator
This chapter assumes you have read the inverting amplifier chapter. It uses the virtual short (the inverting input sits at the same voltage as the grounded non-inverting input) and zero input current, along with KCL and the capacitor law i = C dv/dt. The goal is to show that replacing resistors with a capacitor turns the inverting amplifier into a circuit that performs calculus on a voltage.
From Inverting Amplifier to Integrator
The inverting amplifier has an input resistor R from the source to the inverting node and a feedback resistor Rf from the output back to that node. Its gain is -Rf/R because both elements obey Ohm's law, so the currents are proportional to voltages.
Replace the feedback resistor with a capacitor C. The capacitor current depends on the rate of change of its voltage, not on the voltage itself. The circuit's behavior changes from "multiply by a constant" to "accumulate over time".
Deriving the Integrator
Follow the analysis procedure: write the constraints, then apply KCL at the inverting node.
- The non-inverting input is grounded, so the virtual short puts the inverting node at 0 V.
- The resistor current, flowing toward the node, is i_R = (Vin - 0)/R = Vin/R.
- The op amp input draws no current, so all of i_R must continue through the capacitor toward the output.
- The capacitor voltage, measured from the inverting node to the output, is v_C = 0 - Vout = -Vout.
- The capacitor current is iC = C dvC/dt = -C dVout/dt.
Setting iR = iC gives
Vin/R = -C dVout/dt
Rearranging and integrating from time 0 to t:
Vout(t) = Vout(0) - (1/RC) ∫ Vin(τ) dτ, with τ running from 0 to t
Three points follow from this result.
- The output is the negative of the running integral of the input, scaled by 1/RC. The product RC has units of seconds, and a larger RC gives a slower ramp.
- Vout(0) is the capacitor's initial voltage. It is an integration constant that you must know to find the output.
- A constant input gives a linear ramp. A square wave gives a triangle wave, and a sine wave gives a cosine of opposite sign.
Worked example
Let R = 10 kΩ and C = 100 nF, so RC = 1 ms. Apply Vin = +1 V starting at t = 0 with the capacitor discharged.
Vout(t) = -(1 V / 1 ms) t = -1000 V/s × t
At t = 5 ms the output is -5 V. With ±15 V supplies the output reaches -15 V at t = 15 ms and cannot go further.
Frequency-Domain View
For a sinusoid, the capacitor impedance is 1/(jωC). The inverting-amplifier gain -Z_f/R becomes
Vout/Vin = -1/(jωRC) = j/(ωRC)
- The magnitude is 1/(ωRC). Gain falls by a factor of 10 for each tenfold increase in frequency.
- The phase is +90°, since -1/j equals j.
- The gain magnitude equals 1 at f = 1/(2πRC). For RC = 1 ms this is about 159 Hz.
- At ω → 0 the ideal gain grows without limit. This is the source of the problems described below.
Simulating the Integrator
The script below integrates the input step by step and clamps the result to the supply rails.
def integrator_output(vin, dt, r, c, v0=0.0, rail=15.0):
"""Ideal inverting integrator, sampled every dt seconds.
The output is clamped to +/- rail, where the linear model no longer holds."""
out = []
v = v0
for x in vin:
v += -(x / (r * c)) * dt
v = max(-rail, min(rail, v))
out.append(v)
return out
dt = 1e-4 # 0.1 ms steps
vin = [1.0] * 200 # 1 V step lasting 20 ms
vout = integrator_output(vin, dt, r=10e3, c=100e-9)
print(round(vout[49], 3)) # -5.0 (t = 5 ms)
print(round(vout[149], 3)) # -15.0 (rail reached at t = 15 ms)
print(round(vout[199], 3)) # -15.0 (stays clamped)Once the output hits the rail, the virtual short fails. The op amp can no longer drive its inverting input to match the non-inverting input, so the equations above stop describing the circuit.
Deriving the Differentiator
Swap the positions of R and C. The capacitor now connects the source to the inverting node, and the resistor is the feedback element.
- The inverting node is again at 0 V by the virtual short.
- The capacitor voltage is Vin - 0, so its current toward the node is i_C = C dVin/dt.
- No current enters the op amp, so i_C flows through R from the node toward the output.
- The resistor current in that direction is (0 - Vout)/R = -Vout/R.
Setting the currents equal:
C dVin/dt = -Vout/R, so Vout = -RC dVin/dt
The output is the negative of the input's rate of change, scaled by RC. In the frequency domain, Vout/Vin = -jωRC. The gain rises 20 dB per decade with frequency, and the phase is -90°.
Worked example
Let R = 10 kΩ and C = 10 nF, so RC = 0.1 ms. The input is a ramp rising at 2 V/ms, which is 2000 V/s.
Vout = -(0.1 ms)(2000 V/s) = -0.2 V
A triangle wave input becomes a square wave output, with each slope producing a constant level.
Comparing the Two Circuits
| Property | Integrator | Differentiator |
|---|---|---|
| Element in series with the input | Resistor R | Capacitor C |
| Element in the feedback path | Capacitor C | Resistor R |
| Time-domain result | Vout = -(1/RC) ∫ Vin dt + Vout(0) | Vout = -RC dVin/dt |
| Frequency-domain gain | -1/(jωRC) | -jωRC |
| Gain trend with frequency | Falls 20 dB per decade | Rises 20 dB per decade |
| Phase | +90° | -90° |
| Main practical problem | DC drift to a rail | Noise amplification and instability |
Where the Ideal Models Break
Both circuits are accurate on paper and troublesome on a bench. The ideal model hides the difficulties because it assumes zero offset, no noise, and infinite gain.
Integrator fixes
- Reset switch. A switch across C discharges it to set Vout(0) to a known value before each integration. This is the standard approach when you need a true integral over a defined window.
- Feedback resistor. A resistor Rf in parallel with C gives the circuit a finite DC gain of -Rf/R. It now behaves as an integrator only for frequencies well above 1/(2πRfC). Below that corner it is an ordinary inverting amplifier, and the drift is bounded. The trade-off is that the integral is no longer exact at low frequencies, so the output slowly decays.
- Input bias current. The input bias current also flows into C, adding to the drift, and a real capacitor leaks. Use a low-leakage capacitor type, such as film, for long integration times.
Differentiator fixes
The differentiator's gain rises with frequency, so it amplifies high-frequency noise as strongly as it amplifies the signal. Combined with the op amp's own falling open-loop gain, the capacitor and the feedback network form a loop with extra phase shift. This often causes ringing or oscillation.
The usual remedy is to add a small resistor Rs in series with C, plus a small capacitor Cf in parallel with R. The series resistor caps the high-frequency gain near R/Rs, and Cf rolls the gain off. The circuit then differentiates only below a chosen frequency, which you pick well under the op amp's gain-bandwidth limit.
Checks to run before trusting a result
- Compute the peak output from the ideal formula and confirm it stays inside the supply rails.
- Confirm the signal frequencies sit in the band where the ideal behavior holds, above 1/(2πRfC) for a lossy integrator and below the added corner for a practical differentiator.
- Confirm the initial capacitor voltage is known. An unknown Vout(0) makes the integrator's absolute output unknown.
Summary of the Method
For either circuit, put the inverting node at 0 V, write the input element's current, and set it equal to the feedback element's current. Express the capacitor current as C dv/dt, then solve for Vout. The result follows directly from the same analysis procedure used for the resistive amplifiers. Only the element law changes.
Exercise
An ideal integrator has R = 100 kΩ and C = 10 nF, and the capacitor starts discharged. The input is +2 V for 2 ms, then 0 V. What is the output at t = 2 ms, and what is it at t = 5 ms? If the same input is applied to a differentiator with R = 10 kΩ and C = 10 nF, what is its output during a ramp of 2 V/ms?
Show answer
For the integrator, RC = 100 kΩ × 10 nF = 1 ms. During the pulse, Vout = -(2 V / 1 ms) t, so at t = 2 ms Vout = -4 V. After the input returns to 0 V the capacitor current is zero, so the output holds at -4 V. At t = 5 ms the output is still -4 V (an ideal integrator with no leakage or offset). For the differentiator, RC = 10 kΩ × 10 nF = 0.1 ms, and the ramp rate is 2 V/ms = 2000 V/s. Vout = -(0.1 ms)(2000 V/s) = -0.2 V.
Exercise
A lossy integrator adds a 1 MΩ resistor in parallel with C. If R = 10 kΩ and C = 100 nF, what is the DC gain, and below roughly what frequency does the circuit stop behaving as an integrator?
Show answer
The DC gain is -Rf/R = -1 MΩ / 10 kΩ = -100. The corner frequency is 1/(2πRfC) = 1/(2π × 1 MΩ × 100 nF) = 1/(2π × 0.1 s) ≈ 1.6 Hz. Below about 1.6 Hz the circuit acts as an inverting amplifier with gain -100, so the integral is no longer accurate there.