TExcelTAD
Home › Signals, Systems & Digital Filters for Engineers › Continuous-Time Convolution and Step Responses

Continuous-Time Convolution and Step Responses

An RC filter in front of an ADC receives a 2 ms2\ \text{ms} pulse from a sensor. How high does the filtered pulse get, and how long until it is gone? In Circuit Theory you would solve the differential equation twice, once for the rising edge and once for the falling edge. The systems view is shorter: find the circuit's impulse response h(t)h(t) once, and the output for any input is the convolution integral. This lesson works with continuous-time convolution the way an engineer uses it: the impulse response of real circuits, the step response you can measure, and numerical convolution and scipy.signal.lsim to check hand results. The mathematics is in The Dirac Delta and Convolution.

The convolution integral

The same argument as in discrete convolution, with the sifting property x(t)=∫x(τ) δ(t−τ) dτx(t) = \int x(\tau)\,\delta(t - \tau)\,d\tau in place of the sum of impulses, gives

y(t)=∫−∞∞x(τ) h(t−τ) dτ=∫−∞∞h(τ) x(t−τ) dτy(t) = \int_{-\infty}^{\infty} x(\tau)\,h(t - \tau)\,d\tau = \int_{-\infty}^{\infty} h(\tau)\,x(t - \tau)\,d\tau

For a causal system and an input that starts at t=0t = 0 the limits shrink to 0…t0 \ldots t. The impulse response has units of "output per input per second": for an RC low-pass, h(t)=1τe−t/τu(t)h(t) = \frac{1}{\tau}e^{-t/\tau}u(t) in s−1\text{s}^{-1}, so that ∫h dt=1\int h\,dt = 1, the DC gain.

Impulse and step responses of everyday systems.

System h(t)h(t) step response s(t)=∫0ths(t) = \int_0^t h
RC low-pass, τ=RC\tau = RC 1τe−t/τu(t)\frac{1}{\tau}e^{-t/\tau}u(t) 1−e−t/τ1 - e^{-t/\tau}
RC high-pass δ(t)−1τe−t/τu(t)\delta(t) - \frac{1}{\tau}e^{-t/\tau}u(t) e−t/τe^{-t/\tau}
ideal delay TT δ(t−T)\delta(t - T) u(t−T)u(t - T)
ideal integrator u(t)u(t) t u(t)t\,u(t) (unbounded)
second-order low-pass, ωn\omega_n, ζ<1\zeta < 1 ωn1−ζ2e−ζωntsin⁡(ωdt) u(t)\frac{\omega_n}{\sqrt{1 - \zeta^2}}e^{-\zeta\omega_n t}\sin(\omega_d t)\,u(t) rings at ωd=ωn1−ζ2\omega_d = \omega_n\sqrt{1 - \zeta^2}

Measuring h(t)h(t). You cannot apply a true Dirac impulse, but you can apply a step (switch a supply, a square wave with a long period) and differentiate: h(t)=dsdth(t) = \frac{ds}{dt}. A short pulse of width TpT_p much shorter than the system's time constants also works: its response is ATp h(t)A T_p\,h(t), the pulse's area times hh. Both are standard ways of identifying a sensor or an amplifier on the bench.

Worked example: a pulse through an RC filter

Given: R=1 kΩR = 1\ \text{k}\Omega, C=1 μFC = 1\ \mu\text{F} (τ=1 ms\tau = 1\ \text{ms}); input a rectangular pulse of 5 V5\ \text{V} from t=0t = 0 to T=2 msT = 2\ \text{ms}.

Find: vout(t)v_\text{out}(t), its peak, and its value at t=3 mst = 3\ \text{ms}.

Solve: write the pulse as 5 [u(t)−u(t−T)]5\,[u(t) - u(t - T)]. By linearity and time invariance the output is the step response minus a delayed step response:

vout(t)=5 (1−e−t/τ) u(t)−5 (1−e−(t−T)/τ) u(t−T)vout(T)=5 (1−e−2)=4.323 Vthe peak, at the end of the pulsevout(3 ms)=4.323 e−1=1.590 V\begin{aligned} v_\text{out}(t) &= 5\,(1 - e^{-t/\tau})\,u(t) - 5\,(1 - e^{-(t - T)/\tau})\,u(t - T) \\ v_\text{out}(T) &= 5\,(1 - e^{-2}) = 4.323\ \text{V} && \text{the peak, at the end of the pulse} \\ v_\text{out}(3\ \text{ms}) &= 4.323\,e^{-1} = 1.590\ \text{V} \end{aligned}

Check: the peak is below 5 V5\ \text{V} because the pulse lasts only 2τ2\tau; it reaches 99 %99\,\% only for pulses longer than about 5τ5\tau. Evaluating the convolution integral directly gives the same result, as the code below shows.

python · try it yourself
import numpy as np
from scipy import signal

R, C = 1e3, 1e-6
tau = R * C
dt = 1e-6                                   # 1 us integration step
t = np.arange(0, 8e-3, dt)
x = np.where(t < 2e-3, 5.0, 0.0)            # 5 V, 2 ms pulse
h = np.exp(-t / tau) / tau                  # impulse response in 1/s

y_conv = np.convolve(x, h)[:len(t)] * dt    # the integral as a Riemann sum
sys = signal.lti([1.0], [tau, 1.0])         # H(s) = 1/(s tau + 1)
_, y_lsim, _ = signal.lsim(sys, x, t)

def exact(tt):
    return 5 * (1 - np.exp(-tt / tau)) - np.where(tt >= 2e-3, 5 * (1 - np.exp(-(tt - 2e-3) / tau)), 0.0)

for tm in (1e-3, 2e-3, 3e-3, 6e-3):
    i = int(round(tm / dt))
    print(f"t = {1e3 * tm:.0f} ms: exact {exact(tm):.4f} V, convolution {y_conv[i]:.4f} V, lsim {y_lsim[i]:.4f} V")
print(f"area of h: {np.sum(h) * dt:.4f} (DC gain)")
t = 1 ms: exact 3.1606 V, convolution 3.1640 V, lsim 3.1606 V
t = 2 ms: exact 4.3233 V, convolution 4.3212 V, lsim 4.3208 V
t = 3 ms: exact 1.5905 V, convolution 1.5897 V, lsim 1.5895 V
t = 6 ms: exact 0.0792 V, convolution 0.0791 V, lsim 0.0791 V
area of h: 1.0002 (DC gain)

Both numerical answers agree with the formula to a few millivolts. The Riemann sum carries the left-sum bias of Signal Classes (of order 5 V×h(0) Δt=5 mV5\ \text{V} \times h(0)\,\Delta t = 5\ \text{mV} near the edges); lsim solves the state equation exactly but assumes the input is linear between samples, so it sees the falling edge as a 1 μs1\ \mu\text{s} ramp and ends 2.5 mV2.5\ \text{mV} low after it. Halve dt and both errors halve.

Simulation. The same circuit in the netlist lab, with the pulse source and the cursor at 3 ms3\ \text{ms}: about 4.32 V4.32\ \text{V} at the end of the pulse and 1.59 V1.59\ \text{V} at 3 ms3\ \text{ms} (the source's 1 μs1\ \mu\text{s} edges and the solver's time step shift the third digit). Drag CC to see the peak fall as τ\tau grows beyond the pulse width.

0240246t (ms)VV(in)V(out)at t = 3.000 msV(in)0 VV(out)1.59 VI(V1)1.59 mAI(R1)-1.59 mAI(C1)-1.59 mA

Step response to impulse response, and second-order ringing

A MEMS accelerometer behaves like a second-order low-pass with fn=100 Hzf_n = 100\ \text{Hz} and ζ=0.2\zeta = 0.2. Its step response overshoots by e−πζ/1−ζ2=52.7 %e^{-\pi\zeta/\sqrt{1 - \zeta^2}} = 52.7\,\% and rings at fd=fn1−ζ2=97.98 Hzf_d = f_n\sqrt{1 - \zeta^2} = 97.98\ \text{Hz}. Below, the impulse response is recovered from a "measured" step response by differentiation:

python · try it yourself
import numpy as np
from scipy import signal

fn, zeta = 100.0, 0.2
wn = 2 * np.pi * fn
sys = signal.lti([wn**2], [1, 2 * zeta * wn, wn**2])
t = np.linspace(0, 0.05, 5001)              # 10 us steps
_, s = sys.step(T=t)
_, h = sys.impulse(T=t)
h_from_s = np.gradient(s, t)                # differentiate the step response

print(f"overshoot {100 * (s.max() - 1):.1f} % at t = {1e3 * t[np.argmax(s)]:.2f} ms (theory {100 * np.exp(-np.pi * zeta / np.sqrt(1 - zeta**2)):.1f} % at {1e3 / (2 * fn * np.sqrt(1 - zeta**2)):.2f} ms)")
print(f"max |h - ds/dt| = {np.max(np.abs(h - h_from_s)):.2f} 1/s out of peak h = {h.max():.1f} 1/s")
print(f"area of h = {np.trapezoid(h, t):.4f} (DC gain 1)")
overshoot 52.7 % at t = 5.10 ms (theory 52.7 % at 5.10 ms)
max |h - ds/dt| = 1.97 1/s out of peak h = 475.1 1/s
area of h = 0.9987 (DC gain 1)

The difference between the true hh and ds/dtds/dt is about 0.4 %0.4\,\% of its peak with a clean step (the central difference is second-order accurate; it is largest where hh curves most). The area falls 0.13 %0.13\,\% short of 1 because the record stops at 50 ms50\ \text{ms}, while the ringing envelope e−ζωnte^{-\zeta\omega_n t} still has e−6.28=0.19 %e^{-6.28} = 0.19\,\% left. On real data the derivative amplifies noise, so smooth the step response or average many steps before differentiating.

Guided lab: identify an RC filter from its step response

Hand calculation. R=1 kΩR = 1\ \text{k}\Omega, C=1 μFC = 1\ \mu\text{F}: τ=1 ms\tau = 1\ \text{ms}; a 5 V5\ \text{V} step reaches 3.16 V3.16\ \text{V} (63.2 %63.2\,\%) at 1 ms1\ \text{ms}; a 2 ms2\ \text{ms} pulse peaks at 4.32 V4.32\ \text{V}.

Simulation. The netlist lab above; and the lsim program with the pulse width changed to 0.2 ms0.2\ \text{ms} (peak 5(1−e−0.2)=0.906 V5(1 - e^{-0.2}) = 0.906\ \text{V}, nearly ATp/τ=1 VA T_p/\tau = 1\ \text{V} times e−0.1e^{-0.1}: the short-pulse approximation).

What you would measure. Drive the RC from a function generator (square wave, 00 to 5 V5\ \text{V}, 50 Hz50\ \text{Hz} so each half period is 10τ10\tau), scope on the capacitor. Read the time to 63.2 %63.2\,\%: expect 1.0 ms1.0\ \text{ms} within the tolerances of the parts (typically ±5\pm 5 to ±10 %\pm 10\,\% for the capacitor, so 0.90.9 to 1.1 ms1.1\ \text{ms}). Then switch to a pulse of 2 ms2\ \text{ms} and compare the peak with 4.32 V4.32\ \text{V}. A 50 Ω50\ \Omega generator output adds 50 Ω50\ \Omega to RR, i.e. 5 %5\,\% to τ\tau; a 10:110{:}1 probe adds about 1010 to 15 pF15\ \text{pF}, negligible here.

Hazards and safe setup. Generator and battery or USB-powered equipment only, 5 V5\ \text{V} signals; use a non-polarised (film or ceramic) capacitor, since the square wave may swing negative if the offset is wrong.

Pitfalls

  • Forgetting the dtdt factor when approximating the convolution integral with np.convolve: the result is off by the sampling rate.
  • Treating the peak of a filtered pulse as the pulse amplitude: a pulse shorter than about 5τ5\tau never reaches it.
  • Differentiating a noisy measured step response without smoothing.
  • Mixing up the impulse response's units (s−1\text{s}^{-1} for a voltage-to-voltage system) with the step response's (dimensionless).

Practice

  1. What is the response of an RC low-pass (τ=0.5 ms\tau = 0.5\ \text{ms}) to a 3 V3\ \text{V} step, at t=1 mst = 1\ \text{ms}?
  2. A system's step response is s(t)=(1−e−t/2ms)2 u(t)s(t) = (1 - e^{-t/2\text{ms}})^2\,u(t). What is h(t)h(t)?
  3. A 10 μs10\ \mu\text{s} pulse of 10 V10\ \text{V} drives a system with h(t)=1000 e−1000tu(t) s−1h(t) = 1000\,e^{-1000 t}u(t)\ \text{s}^{-1}. Estimate the peak output.
Answer
  1. 3(1−e−2)=2.59 V3(1 - e^{-2}) = 2.59\ \text{V}.
  2. h=ds/dt=2(1−e−t/τ) 1τe−t/τh = ds/dt = 2(1 - e^{-t/\tau})\,\frac{1}{\tau}e^{-t/\tau} with τ=2 ms\tau = 2\ \text{ms}, for t>0t > 0.
  3. The pulse is short compared with τ=1 ms\tau = 1\ \text{ms}, so y≈ATp h(t)y \approx A T_p\,h(t); the peak is 10 V×10 μs×1000 s−1=0.1 V10\ \text{V} \times 10\ \mu\text{s} \times 1000\ \text{s}^{-1} = 0.1\ \text{V} (exactly 10(1−e−0.01)=0.0995 V10(1 - e^{-0.01}) = 0.0995\ \text{V}).

Test yourself

The impulse response of an RC low-pass with time constant τ\tau is

  1. e−t/τu(t)e^{-t/\tau}u(t)
  2. 1τe−t/τu(t)\frac{1}{\tau}e^{-t/\tau}u(t)
  3. 1−e−t/τ1 - e^{-t/\tau}
  4. τe−t/τ\tau e^{-t/\tau}

How can you obtain h(t)h(t) from a bench measurement?

  1. integrate the step response
  2. differentiate the step response
  3. square the step response
  4. it cannot be measured

A 5 V pulse lasting 2τ2\tau drives an RC low-pass. The output peaks at

  1. 5 V
  2. 4.32 V
  3. 3.16 V
  4. 2.5 V

Approximating ∫x(τ)h(t−τ)dτ\int x(\tau)h(t - \tau)d\tau with np.convolve(x, h) needs

  1. nothing else
  2. a factor dtdt
  3. a factor 1/dt1/dt
  4. flipping hh first