---
title: Integrators and differentiators
heading: Calculus with a capacitor and an op amp
eyebrow: C6 · Lesson 25 · Integrators and differentiators
xp: 50
---

::: hook
Swap the feedback resistor of an inverting amplifier for a capacitor, and the op amp integrates its input: the input current flows into the capacitor, so the output records the running total. Swap the input resistor for a capacitor instead, and it differentiates. Before digital computers, rooms of these circuits solved the differential equations of flight and ballistics. Today integrators shape waveforms, set filter characteristics and turn currents into voltages in every measurement chip.

::: play
- An inverting integrator: a square wave in, through R, into the capacitor's virtual ground. The large resistor across C keeps the output from drifting. (The scope shows the circuit a second after it was switched on, once its start-up offset has died away.)
- What shape is the output? How steep are its slopes?
- Halve R, or halve C. What happens to the slopes?
:::
:::

```sim circuit
V1 in 0 square -1 1 500 Hz  @ 0,0 down 2
R1 in m 10k                 @ 0,0 right
C1 m out 100n               @ 2,-2 right 3
RP m out 1M                 @ 2,-3 right 3
U1 0 m out                  @ 2,1
slider: R1 2k..50k log
slider: C1 20n..500n log
scope: v(in), v(out)
time: 1..1.006 s
meter: v(out)
```

::: predict
## An integrator with R = 10 kΩ and C = 100 nF has a steady +1 V input. How fast does its output change?

- [ ] +1 V/ms
- [x] −1 V/ms
- [ ] −10 V/ms
- [ ] It stays at 0

::: reveal
−1 V/ms. The input drives $1\text{ V}/10\text{ kΩ} = 0.1$ mA into the virtual ground, and that current charges the capacitor, so the output falls at $I/C = 0.1\text{ mA}/100\text{ nF} = 1$ V/ms. Left alone it would ramp until it hit a supply rail, which is why practical integrators have a resistor across the capacitor or get reset.
:::
:::

::: nameit
## Integrator and differentiator

**Integrator.** Input resistor R, feedback capacitor C. The input current $v_\text{in}/R$ flows into C (rule 1), and the capacitor's voltage is the output's, negated (rule 2):

$$v_\text{out}(t) = -\frac{1}{RC}\int v_\text{in}\,dt$$

In the frequency domain, $H = -\frac{1}{j\omega RC}$: gain $1/(\omega RC)$, falling 20 dB per decade, with +90° of phase (an inversion and a 90° lag).

**Why it drifts.** At DC the capacitor is open, so the op amp has no feedback, and any tiny input offset is integrated without limit. A large resistor across C (here 1 MΩ) gives DC feedback, turning the circuit into a low-pass with a corner at $1/(2\pi R_PC)$ that behaves as an integrator well above it.

**Differentiator.** Input capacitor C, feedback resistor R:

$$v_\text{out} = -RC\frac{dv_\text{in}}{dt} \qquad H = -j\omega RC$$

Its gain grows with frequency without limit, so it amplifies noise and tends to oscillate. Practical differentiators add a small resistor in series with C to cap the gain at high frequencies.

**Uses.** Integrators: triangle-wave and ramp generators, the integrating ADCs in multimeters, PID controllers (D3), and charge amplifiers. Differentiators: edge detectors, rate sensors.
:::


::: example
## An integrator has R = 100 kΩ and C = 10 nF, and its output saturates at −12 V. A steady 1 V is applied. What happens?

::: solution
1. **Ramp rate.**
   $$-\frac{1\ \text{V}}{RC} = -1\ \text{V/ms}$$
2. **Time to saturate.** At that rate it reaches −12 V after 12 ms.
3. **Afterward.** It stays at −12 V until the input changes sign.

**Answer:** the output ramps down at 1 V/ms, saturates at −12 V after 12 ms and stays there until the input changes sign.
:::
:::

::: example
## The same integrator gets a ±1 V square wave at 500 Hz. What comes out, and what leak resistor across C keeps it from drifting while affecting 500 Hz little?

::: solution
1. **Output.** Each 1 ms half cycle ramps by 1 V, so the output is a 1 V peak-to-peak triangle.
2. **Leak resistor.** A 10 MΩ leak puts the integrating corner at
   $$\begin{aligned} f &= \frac{1}{2\pi \times 10\ \text{M} \times 10\ \text{nF}} \\ &= 1.6\ \text{Hz} \end{aligned}$$
   far below 500 Hz.

**Answer:** a 1 V peak-to-peak triangle comes out, and a 10 MΩ leak resistor keeps it from drifting.
:::
:::

::: example
## A differentiator has C = 10 nF and $R_f$ = 10 kΩ. A 100 Ω resistor is added in series with C. What's its gain at 1 kHz, at 10 kHz, and far above?

::: solution
1. **Corner of the series pair.**
   $$\begin{aligned} f_c &= \frac{1}{2\pi \times 100 \times 10\ \text{nF}} \\ &= 159\ \text{kHz} \end{aligned}$$
2. **Below the corner.** It still differentiates, and the gain is $\omega R_fC$:
   $$\begin{aligned} 1\ \text{kHz:}&\quad 0.628 \\ 10\ \text{kHz:}&\quad 6.28 \end{aligned}$$
3. **Far above.** The capacitor is a short, and the gain levels off at
   $$\frac{R_f}{100\ \Omega} = 100$$
4. **Why the resistor is there.** The bare differentiator's gain would keep rising with frequency, amplifying noise and, combined with the op amp's own pole, ringing or oscillating. The series resistor caps it.

**Answer:** the gain is 0.628 at 1 kHz, 6.28 at 10 kHz, and levels off at 100 far above.
:::
:::

::: check
given: V = 0.5 | 1 | 2; R = 22 | 47 | 220; C = 10 | 47
answer: -V/(R*1e3*C*1e-9)/1000
unit: V/ms
tolerance: 0.5%

## An integrator with R = {R} kΩ and C = {C} nF has a steady {V} V input. How fast does its output change?

::: right
Right. $-V/(RC)$ = {answer}.
:::

::: misses
- [V/(R*1e3*C*1e-9)/1000] An inverting integrator ramps the other way.
- [-V*R*1e3*C*1e-9*1000] Divide by RC.
- [any] Not yet. $dv_o/dt = -v_\text{in}/(RC)$.
:::
:::

::: check
given: R = 10 | 100; C = 10 | 100; f = 100 | 1000
answer: 1/(2*pi*f*R*1e3*C*1e-9)
tolerance: 0.5%

## What's the gain of an integrator (R = {R} kΩ, C = {C} nF) at {f} Hz?

::: right
Right. $1/(2\pi fRC)$ = {answer}.
:::

::: misses
- [2*pi*f*R*1e3*C*1e-9] That's a differentiator's gain.
- [1/(f*R*1e3*C*1e-9)] Include 2π.
- [any] Not yet. $|H| = 1/(\omega RC)$.
:::
:::

::: check
given: Vp = 1 | 2; f = 100 | 500; R = 10 | 22; C = 100 | 220
answer: Vp/(2*f*R*1e3*C*1e-9)
unit: V
tolerance: 0.5%

## A ±{Vp} V square wave at {f} Hz drives an integrator (R = {R} kΩ, C = {C} nF). What's the peak-to-peak swing of the triangle that comes out?

::: right
Right. Each half period of $1/(2f)$ ramps at $V_p/(RC)$: {answer}.
:::

::: misses
- [Vp/(f*R*1e3*C*1e-9)] Each ramp lasts half a period.
- [any] Not yet. Slope × half period.
:::
:::

::: check
given: R = 10 | 100; C = 10 | 100; s = 1 | 10
answer: -R*1e3*C*1e-9*s*1000
unit: V
tolerance: 0.5%

## A differentiator has R = {R} kΩ and C = {C} nF. Its input rises at {s} V/ms. What's its output?

::: right
Right. $-RC\,dv/dt$ = {answer}.
:::

::: misses
- [R*1e3*C*1e-9*s*1000] It inverts.
- [-s/(R*1e3*C*1e-9)] Multiply by RC.
- [any] Not yet. $v_o = -RC\,dv_\text{in}/dt$.
:::
:::

::: check
given: Rp = 1 | 10; C = 10 | 100
answer: 1/(2*pi*Rp*1e6*C*1e-9)
unit: Hz
tolerance: 0.5%

## An integrator has $R_P$ = {Rp} MΩ across its {C} nF capacitor to stop drift. Below what frequency does it stop acting like an integrator?

::: right
Right. $1/(2\pi R_PC)$ = {answer}.
:::

::: misses
- [1/(Rp*1e6*C*1e-9)] Include 2π.
- [any] Not yet. The corner of $R_P$ and C.
:::
:::

::: check
kind: parts
given: C = 1 | 10 | 47; Rf = 10 | 100; Rs = 47 | 220; f = 0.1 | 1

## A differentiator has C = {C} nF and $R_f$ = {Rf} kΩ, with {Rs} Ω in series with C.

::: part
answer: 2*pi*f*1000*Rf*1000*C*1e-9
tolerance: 1%

### What's its gain at {f} kHz, well below the series corner?

::: misses
- [any] $\omega R_fC$.
:::
:::

::: part
answer: Rf*1000/Rs
tolerance: 0.5%

### Where does its gain level off at high frequency?

::: misses
- [any] $\frac{R_f}{R_s}$.
:::
:::
:::

::: check
kind: derivation
vars: R = 1000..1000000, C = 0.000000001..0.000001, V = 0.01..10, L = 1000000..1000000000

## An integrator has input resistor R and capacitor C, with a leak resistor L across C, and a steady input V.

::: step
answer: V/(R*C)

### How fast does its output ramp at first?
:::

::: step
answer: -V*L/R

### Where does the leak make it settle?
:::

::: step
answer: 1/(2*pi*L*C)

### Below what frequency does it stop integrating?
:::

::: right
Right. The leak trades integration at very low frequencies for a bounded DC output.
:::
:::

::: explain
## Why does an ideal op-amp integrator drift, and how does a resistor across the capacitor stop it?

::: model
At DC a capacitor carries no current, so with only a capacitor in the feedback path there's no DC feedback at all. Any small constant input, such as the op amp's own offset voltage or bias current, drives a constant current into the capacitor, and the output ramps steadily until it hits a supply rail. A large resistor across the capacitor gives DC feedback, limiting the DC gain to $R_P/R$, so small offsets only produce a small, steady output. Above the corner frequency set by that resistor and the capacitor, the capacitor dominates and the circuit still integrates.
:::
:::

::: practice

::: check
given: R = 1 | 10; C = 1 | 10
answer: R*C
unit: ms
tolerance: 0.5%

## RC for {R} kΩ and {C} µF?

::: misses
- [any] kΩ × µF = ms.
:::
:::

::: check
given: I = 1 | 10; C = 1 | 10
answer: I/C
unit: V/ms
tolerance: 0.5%

## {I} µA charges {C} nF. Rate of change, in V/ms?

::: misses
- [any] $I/C$.
:::
:::

::: check
kind: match

## Match each circuit to its frequency response.

- integrator :: gain falls 20 dB per decade
- differentiator :: gain rises 20 dB per decade
- inverting amplifier :: flat gain
- integrator with a resistor across C :: flat, then falling, above a corner

::: right
Right. $1/j\omega RC$ falls, $j\omega RC$ rises, and $R_f/R_\text{in}$ is flat.
:::
:::
:::
