In this guide
Your sensor works, but the signal is a mess — the temperature reading jumps with every motor pulse, the microphone picks up mains hum, the photodiode output is buried in high-frequency hash. You don't need a better sensor. You need a filter: a circuit that keeps the frequencies you want and attenuates the ones you don't. And the op-amp is the component that turns a two-resistor RC filter from a compromise into a proper design.
This guide explains low-pass and high-pass filters from the ground up: the RC fundamentals, the cutoff-frequency math, what the op-amp adds (and the classic Sallen-Key topology), single-supply practicalities, and how to pick the right filter for your actual problem.
Start with the passive RC filter
Everything builds on two humble circuits. A low-pass filter passes low frequencies and attenuates high ones — resistor in series, capacitor to ground:
R
in ---/\/\/\---+--- out
|
C
|
GND
A high-pass filter does the opposite — capacitor in series, resistor to ground:
C
in ---||---+--- out
|
R
|
GND
The cutoff frequency (fc) — where the signal is attenuated by 3dB (about 71% of the input amplitude) — is the same formula for both:
fc = 1 / (2πRC)
Worked example: R = 1.6kΩ, C = 100nF → fc = 1 / (2π × 1600 × 100×10⁻⁹) ≈ 995Hz, effectively a 1kHz filter. Memorize the shape of this formula: doubling R or C halves the cutoff.
A single RC stage rolls off at 20dB per decade — at 10× the cutoff, the signal is attenuated 10× (a first-order filter). That's gentle. If you need interference at 10kHz suppressed 100× while keeping a 1kHz signal, one stage isn't enough — you need higher order.
The passive filter's weakness: it loads whatever drives it and gets loaded by whatever follows it. The cutoff shifts when impedances change, and you can't get voltage gain. That's what the op-amp fixes.
What the op-amp adds
An op-amp configured as a voltage follower (unity-gain buffer) between stages solves the loading problem: its input draws essentially no current, its output drives the next stage effortlessly. Suddenly each RC stage behaves as designed, and you can cascade stages for steeper rolloff — two first-order stages give 40dB/decade (second-order), three give 60dB/decade.
Better still, the op-amp lets you build the Sallen-Key topology — the workhorse active filter. A second-order Sallen-Key low-pass uses one op-amp, two resistors, and two capacitors:
R1 R2
in ---/\/\/\---+---/\/\/\---+--- out
| |
C2 +\ (op-amp, unity gain
| -/ wiring: out to -in)
GND |
+--- feedback to +in
via divider (unity)
(Conceptually: the RC network sits in the forward path, and the op-amp buffers the output back to the filter node, sharpening the response.) With equal R values and equal C values, the cutoff is still fc = 1/(2πRC), but the rolloff is now 40dB/decade from a single op-amp — and with the right component ratios you can tune the response shape (Butterworth for flat passband, Bessel for clean step response).
If you haven't used op-amps before, start with Op-Amp Basics with the LM358 — it covers the follower, gain, and single-supply biasing this guide builds on.
Note: You don't need exotic filter theory for student projects. A Sallen-Key stage or two, designed with an online calculator and verified on the bench, handles 95% of sensor-filtering needs. Understand cutoff, order, and loading — the rest is refinement.
Low-pass vs high-pass: which problem do you have?
| Your symptom | Filter | Example design |
|---|---|---|
| Sensor reading jumps with high-frequency noise | Low-pass at ~10× your signal bandwidth | Temperature sampled at 10Hz → fc ≈ 100Hz |
| PWM switching noise on an analog line | Low-pass below the PWM frequency | 25kHz PWM → fc ≈ 2–5kHz |
| Mains hum (50Hz) on a slow DC measurement | Low-pass well below 50Hz | DC pressure sensor → fc ≈ 5–10Hz |
| DC offset / drift swamping a small AC signal | High-pass above the drift, below the signal | Heartbeat (~1Hz) with baseline wander → fc ≈ 0.1–0.5Hz |
| Microphone needs voice band only | High-pass ~80Hz + low-pass ~8kHz (band-pass) | Voice projects, sound detection |
| Ultrasonic receiver swamped by audible noise | High-pass near 20kHz | 40kHz ultrasonic → fc ≈ 25kHz |
Design procedure:
- Identify the highest frequency you must keep (your signal bandwidth) and the lowest frequency you must kill (the interference). The cutoff goes between them — ideally with at least a 3–5× gap.
- Choose the order from the required attenuation: need 40dB of suppression one decade above cutoff? That's second-order (40dB/dec). One decade isn't available? Go higher order or accept less suppression.
- Pick C first, then compute R. Capacitors come in fewer standard values — choose C (10nF–1µF for audio-rate filters), then R = 1/(2πfc·C), then round R to the nearest standard value and re-check fc.
- Verify on the bench. Feed a function generator sweep (or your actual noisy signal) and confirm the attenuation with a scope. The oscilloscope guide covers frequency-response measurement.
Single-supply practicalities
Student boards usually have only a positive supply (5V or 3.3V), but filter math assumes signals swing around ground. The fix is a virtual ground: bias the op-amp's non-inverting input at half the supply (Vcc/2) with a resistor divider, AC-couple the input signal through a capacitor, and the filter now processes AC signals riding on a 2.5V (or 1.65V) DC level.
Rules for single-supply filter design:
- Use rail-to-rail input/output op-amps (MCP6002, TLV2372) when the signal approaches the supply rails. The classic LM358's output can't swing closer than ~1.5V to the positive rail — fine for a 5V design with headroom, a problem on 3.3V.
- The bias divider needs its own decoupling capacitor to ground — otherwise supply noise injects directly into your filter.
- Keep the virtual ground impedance low relative to the filter resistors, or buffer it with a spare op-amp section.
- Check the op-amp's gain-bandwidth product (GBW): the op-amp must have gain to spare at your highest frequency of interest. Rule of thumb: GBW ≥ 50–100× the filter's cutoff for accurate response. An LM358 (1MHz GBW) is comfortable to ~10–20kHz cutoffs; beyond that, pick a faster part.
Common mistakes
- Filter cutoff inside the signal band. A 1kHz low-pass on a signal with 2kHz content doesn't "clean" it — it destroys it. Always place fc above your highest signal frequency with margin.
- Forgetting the anti-alias filter before the ADC. Sampling at 1kHz with 5kHz noise present folds the noise down into your measurement band — no digital filter can remove it afterward. Filter in analog before sampling. (More in the ADC resolution vs accuracy guide.)
- Cascading passive RC stages without buffering. The second stage loads the first, shifting both cutoffs. Buffer between stages.
- Electrolytic capacitors in the signal path. Their tolerance (±20%) and leakage make cutoff frequencies sloppy. Use film or C0G/NP0 ceramic for filter capacitors.
- Ignoring op-amp output swing limits. A filter that computes beautifully but clips because the LM358 can't reach the rail gives you distortion, not filtering.
- No input protection. A sensor fault driving the op-amp input beyond the rails can latch or damage the part — a series resistor and clamp diodes cost almost nothing.
Quick design checklist
- Signal bandwidth and interference frequencies identified; fc placed between them
- Filter order chosen from required attenuation (20dB/dec per stage)
- C chosen from standard values; R computed and rounded
- Op-amp GBW ≥ 50× fc; rail-to-rail if on 3.3V single supply
- Virtual ground biased and decoupled (single-supply designs)
- Response verified with a frequency sweep on the scope
Where to go from here
- Op-Amp Basics with the LM358 — followers, gain stages, and comparators.
- ADC Resolution vs Accuracy — why filtering before sampling beats extra bits.
- How to Use an Oscilloscope for Debugging — measure your filter's real frequency response.
- EMI/EMC Basics for Student PCBs — layout practices that keep filtered signals clean.
- More electronics fundamentals in the Electronics / E&TC branch hub.