Sub topic 11
Ideal inverting integrator
This chapter assumes you know Ohm's law, Kirchhoff's laws, the capacitor relation i = C dv/dt, and the virtual short from the earlier chapters. It also assumes you can read a simple integral as "area under a curve". The goal is to derive the output of an inverting integrator and predict its response to step and square-wave inputs.
What the circuit is
An inverting integrator is an inverting amplifier with the feedback resistor replaced by a capacitor. The input resistor R connects the source to the inverting input. The capacitor C connects the output back to that same input. The non-inverting input is grounded.
The op amp works to keep its inverting input at the same voltage as the grounded non-inverting input. The inverting node is therefore a virtual ground. The input current is set only by Vin and R, and the capacitor must absorb all of that current.
Derivation
Use the ideal op amp assumptions: no current enters either input, and negative feedback forces V− = V+ = 0.
- The resistor current is iR = (Vin − 0) / R = Vin / R, flowing toward the inverting node.
- No current enters the op amp input, so the same current flows through the capacitor toward the output: iC = iR.
- The capacitor's left plate is at 0 V and its right plate is at Vout. The voltage across it, in the direction of the current, is vC = 0 − Vout = −Vout.
- The capacitor law gives iC = C dvC/dt = −C dVout/dt.
- Set the currents equal: Vin / R = −C dVout/dt.
- Rearrange: dVout/dt = −Vin / (RC).
- Integrate from 0 to t:
Vout(t) = −(1/RC) ∫₀ᵗ Vin(τ) dτ + Vout(0)
The output is the running area under the input curve, scaled by −1/RC, plus the starting voltage on the capacitor. The product RC has units of seconds, so 1/RC is a rate in 1/s. For example, R = 10 kΩ and C = 100 nF give RC = 1 ms, so each volt of input moves the output at 1000 V/s.
Reading the equation
Three habits make the result easy to use.
- Sign. A positive input makes the output ramp down. A negative input makes it ramp up.
- Slope. The output slope is −Vin/(RC). Doubling R, doubling C, or halving Vin halves the slope.
- Memory. The output depends on the whole history of the input. If Vin returns to 0 V, the output stops changing and holds its present value. It does not return to zero.
| Input | Output |
|---|---|
| Vin = 0 | Constant at Vout(0) |
| Constant V₀ | Straight ramp, slope −V₀/(RC) |
| Positive then negative pulses of equal area | Ramps down, then ramps back to the starting value |
| Sine, A sin(ωt) | Cosine, amplitude A/(ωRC), shifted from the inverted input by 90° |
For the sine case, ∫ A sin(ωt) dt = −(A/ω) cos(ωt), so Vout = (A/(ωRC)) cos(ωt) − A/(ωRC) + Vout(0). The constant term appears because the integral starts at t = 0. The ideal circuit keeps that offset forever, which matters later.
Worked example: a step input
Take R = 10 kΩ, C = 100 nF, Vout(0) = 0, and a constant 1 V input applied at t = 0.
Vout(t) = −(1/(10 kΩ × 100 nF)) × 1 V × t = −1000 t
At t = 5 ms, Vout = −5 V. The ramp is linear and keeps going until the op amp runs out of output range. That limit is covered in the saturation chapters.
The following Python code integrates the differential equation in small time steps and checks the result.
R = 10e3 # ohms
C = 100e-9 # farads, so RC = 1 ms
vin = 1.0 # constant 1 V input
dt = 1e-5 # 10 microsecond time step
v = 0.0 # initial capacitor voltage, Vout(0) = 0
for _ in range(500): # 500 steps = 5 ms
v -= vin / (R * C) * dt # Vout changes by -(1/RC) * Vin * dt
print(round(v, 3)) # -5.0Worked example: a square-wave input
A square wave alternates between +1 V and −1 V at 1 kHz, with the same R and C. The period is 1 ms, so each half period lasts 0.5 ms.
- During the +1 V half, the output falls at 1000 V/s. Over 0.5 ms it falls by 0.5 V.
- During the −1 V half, the output rises at 1000 V/s. Over 0.5 ms it rises by 0.5 V.
The output is a triangle wave with 0.5 V peak-to-peak. This is the standard way to turn a square wave into a triangle wave. The amplitude of the triangle scales with the half period, so lowering the frequency to 100 Hz raises the peak-to-peak value to 5 V. If the same circuit is driven below about 100 Hz, a few volts of triangle may already approach the limits of a typical supply.
The code below simulates two periods and reports the extremes of the output.
R = 10e3
C = 100e-9
dt = 1e-6 # 1 microsecond step
steps_per_half = 500 # 0.5 ms per half period
v = 0.0
lowest = v
highest = v
for k in range(2000): # 2 ms = two periods
vin = 1.0 if (k % 1000) < steps_per_half else -1.0
v -= vin / (R * C) * dt
lowest = min(lowest, v)
highest = max(highest, v)
print(round(lowest, 3), round(highest, 3)) # -0.5 0.0The output swings between −0.5 V and 0 V. It is not centered on zero. The triangle sits wherever its starting value and the area of the input put it. For an input that is symmetric about zero, the average of the triangle equals its starting offset, which here is the extra −0.25 V shift from beginning at 0 V.
Checking with a simulation
The same circuit in SPICE uses a high-gain voltage-controlled voltage source in place of the op amp. The transient run uses the uic option so that the capacitor starts at 0 V.
* Ideal inverting integrator, op amp modeled as a high-gain VCVS
V1 in 0 PULSE(0 1 0 1n 1n 1 2)
R1 in inv 10k
C1 inv out 100n
E1 out 0 0 inv 100k
.tran 10u 5m uic
.endThe source steps from 0 V to 1 V almost immediately and stays there. The plotted V(out) should fall roughly linearly to about −5 V at 5 ms. It will be slightly off from the ideal answer because the VCVS gain is finite.
Edge cases and common mistakes
- Forgetting the sign. The minus sign comes from the capacitor being measured from the virtual ground to the output. A positive input gives a falling output.
- Mixing units. Use ohms and farads, not kΩ and nF, inside the formula, or convert carefully. 10 kΩ × 100 nF is 1 ms, not 1 s.
- Ignoring Vout(0). The formula needs the initial voltage. In a lab circuit the capacitor may hold leftover charge, and the output will start there.
- Integrating over the wrong span. For piecewise inputs, integrate segment by segment and carry the end value of one segment into the next as its starting value.
- Assuming the output tracks the input. The output tracks the area of the input. A short, large pulse and a long, small pulse with the same area give the same final change.
- Treating the ideal result as the whole story. A real op amp has small input offsets and bias currents. With no resistor across the capacitor, any tiny DC error integrates without limit. The ideal equation gives no warning of this. Later chapters in this tutorial handle it.
Summary of the model
Under the ideal assumptions, the inverting integrator is described by one relation: the output is minus the time integral of the input divided by RC, plus the initial capacitor voltage. Step inputs give ramps, square waves give triangles, and the starting voltage sets the offset of the result.
Exercise
An ideal inverting integrator has R = 20 kΩ and C = 50 nF, with Vout(0) = 2 V. The input is +0.5 V for the first 4 ms, then −1 V for the next 2 ms. What is Vout at t = 6 ms?
Show answer
RC = 20 kΩ × 50 nF = 1 ms, so 1/RC = 1000 per second. The first segment changes the output by −1000 × 0.5 × 0.004 = −2 V, taking it from 2 V to 0 V. The second segment changes it by −1000 × (−1) × 0.002 = +2 V, taking it from 0 V to 2 V. Vout(6 ms) = 2 V.
Exercise
You drive the integrator from the earlier examples (R = 10 kΩ, C = 100 nF) with a symmetric ±2 V square wave at 500 Hz. What is the peak-to-peak amplitude of the triangle wave at the output?
Show answer
The half period is 1 ms. The slope magnitude is 2 V / (1 ms) = 2000 V/s, so the output changes by 2000 × 0.001 = 2 V in each half period. The triangle wave is 2 V peak-to-peak.