Filters: RC, Noise, and Bandwidth
Noise is not a bug in your measurement. It is a part of it you have not filtered yet.
🎯 By the end you'll understand
The first-order RC filter from both ends: its cutoff frequency and −20 dB/decade slope in the frequency domain, its time constant and settling time in the time domain, and why those are the same fact. Where noise actually comes from on a board (thermal, switching, coupled) and which remedy fits which source. Why an ADC needs a filter in front of it, what aliasing does to a signal you did not remove, and why a first-order filter is weaker than it looks. The two costs of filtering — latency and settling — and how they decide when Beacon may read its own battery.
KEY INSIGHTA filter is a decision about which frequencies you believe
Every measurement is the signal you wanted plus everything else that got in. A filter does not remove "noise"; it removes frequencies. If the thing you wanted lives at the same frequency as the thing you did not, no capacitor will separate them.
Two bench scenarios, opposite mistakes. First: a thermistor reading wobbled by ±3 °C, so a learner put a 100 kΩ resistor and a 10 µF capacitor in front of the ADC. The wobble is gone. So is the response: the reading now takes five seconds to follow a real temperature change, and the "stable" value they log during a 45 ms wake is whatever the capacitor had been drifting toward while the device slept. Second: a battery-voltage reading that jumps around by 40 mV between samples with no visible pattern. The board's buck regulator switches at about 1.8 MHz; the ADC samples at 1 kHz; the 1.8 MHz ripple that nobody filtered is being folded down to a few hundred hertz, where it looks exactly like a slowly wandering battery. Same lesson from both directions: the corner frequency is a choice, and it is a choice about time as much as about noise.
A first-order RC low-pass has one number, the corner fc = 1/(2πRC), and it buys you exactly three things: attenuation that grows by 10× for every 10× above fc, a time constant τ = RC that sets how long the output takes to follow a change, and a phase lag. You cannot have the attenuation without the delay. Choosing R and C is choosing where on that trade you want to stand — and the sampling rate of the ADC behind it decides whether you chose well.
CORE CONCEPTThe RC filter, seen from both ends
A resistor in series with the signal and a capacitor from the output to ground. That is the whole circuit. The capacitor cannot change its voltage instantly — it needs charge, and charge arrives through the resistor at a rate set by the voltage across it. Fast wiggles at the input do not have time to move the capacitor; slow changes do. That is a low-pass filter, and both of its descriptions come from the same equation.
The output-to-input ratio at frequency f is |H(f)| = 1 / √(1 + (f/fc)²) with fc = 1/(2πRC). At fc the output is 1/√2 = 0.707 of the input (−3 dB) and lags by 45°. Well above fc, |H| ≈ fc/f: ten times higher in frequency is ten times smaller in amplitude, which is −20 dB per decade. Below fc the filter is transparent.
A step at the input produces Vout(t) = Vstep·(1 − e−t/τ) with τ = RC. After one τ the output has reached 63 %; after 3τ, 95 %; after 4.6τ, 99 %; after 6.9τ, 99.9 %. To settle within one LSB of a 12-bit ADC (1 part in 4096) takes ln(4096) ≈ 8.3τ. The two descriptions are one fact: fc = 1/(2πτ). A filter with a 3.2 Hz corner has a 50 ms time constant, and there is no way to have one without the other.
The high-pass is the same circuit with the parts swapped: capacitor in series, resistor to ground. Now the capacitor blocks the slow stuff and passes the fast. Same fc, same τ, mirror-image behaviour: |H| = (f/fc) / √(1 + (f/fc)²), transparent above fc, −20 dB/decade below. You use it to remove a DC offset from a signal you only care about the changes in — an audio coupling capacitor, or the LIS2DH12's built-in high-pass that removes the constant 1 g of gravity so its motion threshold only sees acceleration that changed. That filter is inside the sensor and configured over I2C, but it is exactly this circuit's arithmetic.
One R and one C give one "pole" and 20 dB per decade. To get 40 dB of rejection at a given frequency you need the corner 100× below it; to get 60 dB, 1000× below. Cascading two RC stages doubles the slope (with some interaction between the stages unless a buffer separates them), and a proper second-order filter (Sallen-Key around an op-amp from Lesson 2.2) gives 40 dB/decade with a sharper knee. Most embedded front-ends get away with first-order because the noise is far above the signal and the ADC oversamples; when it is not, one capacitor will not save you.
HOW IT WORKSNoise: three sources, three remedies
"Noise" is a bucket word. Before you reach for a capacitor, ask which of these three you are looking at, because the fixes do not interchange.
| Source | What it looks like | Frequency content | Remedy that actually works |
|---|---|---|---|
| Thermal (Johnson) noise | A faint, perfectly random hiss from every resistor, set by physics | Flat across all frequencies ("white") | Lower resistance, lower bandwidth, or averaging: it shrinks by √N with N samples |
| Switching noise | Ripple and sharp spikes at the regulator's switching frequency and its harmonics, plus the edges of every digital signal on the board | Narrow lines at fsw, 2fsw, …, from ~100 kHz to tens of MHz; the spikes extend far higher | A low-pass with its corner far below fsw; ferrite bead + capacitor on the supply; layout (Lesson 2.5) |
| Coupled noise | Mains hum, a nearby motor, a phone's transmit bursts, crosstalk from the trace beside yours | 50/60 Hz and harmonics; broadband bursts; whatever the aggressor does | Short leads, twisted pairs, shielding, distance; a low-pass only if the signal is slower than the aggressor; averaging over whole mains cycles |
Thermal noise, quantified once so you stop worrying about it in the wrong places: the rms voltage across a resistor is Vn = √(4·k·T·R·B), with k = 1.38 × 10−23 J/K, T in kelvin, R in ohms, B the bandwidth in hertz. Beacon's battery divider has a Thevenin resistance of 500 kΩ. At 300 K in the 3.2 Hz bandwidth its 100 nF capacitor allows: √(4 × 1.38 × 10−23 × 300 × 5 × 105 × 3.2) ≈ 0.16 µV rms. Against an ADC LSB of 0.61 mV that is nothing. Even with no capacitor and a megahertz of input bandwidth it is only 91 µV. Thermal noise matters for microvolt sensors behind high gain (Lesson 2.2's thermocouple case); it does not matter for a battery divider, and knowing that saves you a design hour.
Switching noise is the one that gets you, because it is large (tens of millivolts of ripple on a rail is normal), because it is at a frequency you did not think about, and because — as the next section shows — a sampling ADC does not ignore it; it relocates it. The single most effective step is to know the switching frequency of every regulator on the board and write it down next to every ADC input.
Coupled noise is a geometry problem, and the filter is the last resort, not the first. A 50 Hz hum on a slow temperature reading can be filtered (corner at 1 Hz, fine). A 50 Hz hum on a 1 kHz signal cannot — they overlap — and the only fixes are to stop it getting in (shorter wires, a ground plane under the trace, distance from the transformer) or to average each reading over exactly one mains period so the hum cancels. Firmware averaging is a filter too; it just runs on samples instead of charge.
DEFINITIONSampling and aliasing: the ADC does not ignore what you left in
An ADC takes snapshots at a rate fs. The Nyquist theorem says those snapshots faithfully represent any content below fs/2 — and it says something much nastier about content above it. A component at frequency f, sampled at fs, is indistinguishable from a component at |f − k·fs| for the integer k that brings it into 0…fs/2. It aliases: it reappears at a new, lower frequency, at full amplitude, as if it had always been there.
A buck regulator's nominal 1.8 MHz is never exact; call it 1.8374 MHz on this particular unit (the last digits are illustrative — and, as you are about to see, they are the whole story). Sampled at fs = 1 kHz: 1 837 400 mod 1000 = 400, so the ripple aliases to 400 Hz — a wobble on every reading, 2.5 samples per cycle, that looks like a noisy battery. Sampled at 100 Hz: 1 837 400 mod 100 = 0, so it aliases to DC — a fixed offset whose size depends on the phase at which each sample happens to land. Warm the regulator, its frequency drifts a few hundred hertz, and the alias moves. You would spend a week looking for the "battery drift" in the battery.
So the job of an anti-aliasing filter is to reduce everything above fs/2 to below the ADC's resolution before sampling. Here the first-order filter's weakness becomes concrete. To push 40 mV of 1.8 MHz ripple below one LSB (0.61 mV) needs about 36 dB of attenuation, which a first-order filter provides only at 66× its corner: fc ≤ 28 kHz. That is easy for a 1 kHz sample rate and a slow signal — but if the signal you want is itself at 20 kHz, a 28 kHz corner is not "far below the noise", it is on top of your signal. Then you need a steeper filter, a higher sample rate (oversampling moves fs/2 up and makes the filter's job easier), or a different regulator frequency. The relationship to remember:
For noise at fn and sample rate fs: let r = fn mod fs; the alias appears at min(r, fs − r). It is never above fs/2 and it is unpredictable in practice, because fn is never known to the hertz. Any noise you have not attenuated below one LSB before the ADC will show up somewhere in your data, at a frequency you cannot control, with an amplitude you did not reduce.
SEE ITThe RC filter lab: corner, settling, and what the ADC sees
The input is a 1.0 V step at t = 0 (a divider being switched on, or a sensor waking) with 100 mV-peak switching noise riding on it. Choose R and C, the noise frequency, and the ADC's sample rate. The plot shows the filtered voltage, a band for the residual noise, and the actual samples the ADC would take — including the aliased pattern. The dashed line at 45 ms is Beacon's active window: if the reading has not settled by then, the firmware reads the wrong number.
Start from Beacon's own numbers — 500 kΩ, 100 nF — and notice the filter is superb against the buck and hopeless against the window: 3.2 Hz corner, τ = 50 ms, 59 % settled at 45 ms. Drop to 10 nF: τ = 5 ms, settled by 23 ms, and the 1.8 MHz noise is still crushed. Drop to 1 nF with 1 kΩ: the corner is 159 kHz, the buck ripple gets through at about a tenth of its amplitude — still 14 LSB, and the samples show a 400 Hz alias that is 14 LSBs peak. Now switch the noise to 50 Hz mains and watch every one of those filters give up, because the corner would need to be below 1 Hz — at which point the settling time is seconds. Some noise you filter; some you keep out.
IN PRACTICEWhat filtering costs: latency, settling, and the decoupling capacitor
The frequency-domain view makes filters look free. The time-domain view sends the invoice.
Latency. A signal at fc/10 passes with almost no attenuation (−0.04 dB) but lags by about 5.7°, which at that frequency is a fixed delay of τ. A first-order low-pass delays everything below its corner by roughly one time constant. For a temperature reading, τ = 1 s is invisible; for a control loop that closes at 100 Hz, τ = 10 ms is a phase shift that can make the loop oscillate. If you filter inside a feedback loop, the filter is part of the plant.
Settling. Whenever the input jumps — a switched divider turning on, a multiplexer changing channel, a sensor waking — the output takes 4.6τ to get within 1 % and 8.3τ to get within one 12-bit LSB. This is a hard timing requirement on the firmware, and it is the one that catches battery-powered designs, because they switch things on and off constantly to save power. A filter designed while thinking only about noise will be read before it has settled.
A moving average of N samples is a low-pass with a delay of N/2 samples; an exponential average (y += (x − y)/k) is a first-order filter with τ = k samples. Both have the same settling cost as the RC — a 64-sample moving average of a 1 kHz stream needs 64 ms after any step before it tells the truth. Firmware filtering trades a capacitor for CPU time and awake time, and on Beacon awake time is measured in microamps.
The decoupling capacitor is a filter too. A 100 nF capacitor from a chip's supply pin to ground, with the few tens of milliohms of the supply trace and the regulator's output impedance in front of it, forms a low-pass on the supply rail. Its corner is far below the megahertz noise of the chip's own switching, so from the chip's point of view the rail looks clean and stiff. And the capacitor forms an even more important filter with the trace's inductance — a resonant one, which is why placement is not optional. Lesson 2.5 takes that up; here the point is that the same arithmetic applies: a supply filter has a bandwidth, and a chip that suddenly demands current at a frequency above it will see its supply sag.
A bead looks like a few tens of milliohms at DC and a hundred ohms or more at 100 MHz. Put one in series with a sensor's supply, add a capacitor after it, and you have a low-pass for the high-frequency trash while losing almost no DC. Beads saturate at their rated current and their impedance curve is in the datasheet as a graph, not a number; pick one by looking at the graph at the frequency you want to kill.
BEACONBeacon's filters: one capacitor, one timing rule, two inside the sensors
Beacon's schematic v0 has exactly one analog filter that you can see: the 100 nF capacitor across the lower resistor of the 2 × 1 MΩ battery divider. Its Thevenin source is 500 kΩ, so fc = 1/(2π × 500 kΩ × 100 nF) = 3.2 Hz and τ = 50 ms. Against the TPS62840 buck's switching ripple around 1.8 MHz, that is 1.8 × 106 / 3.2 ≈ 5.7 × 105× above the corner — well over 100 dB of attenuation; even the harmonics and the sharper switching spikes have no chance. Against 50 Hz coupled from a nearby mains lead, the corner is 16× below and the attenuation is about 24 dB; enough for a battery reading that only needs to be right to a few tens of millivolts.
The capacitor is on the schematic for a different reason first (Lesson 2.4: it supplies the charge the ADC's sample capacitor gulps), and it filters as a side effect. But the side effect has a cost, and the cost is now a rule on the sheet: after the divider is switched on, the firmware must wait at least 5τ ≈ 250 ms before reading it (4.6τ for 1 %, and a little more because the divider's PMOS switch has its own turn-on). A read at 45 ms would report 59 % of the true half-battery voltage — a 3.7 V cell would appear as 2.2 V and the device would declare itself dead. Whether that wait is scheduled by holding the divider on across a longer wake, or by refreshing the battery reading less often than once per minute, is a Stage 3 decision; the schematic's job is to state the constraint where the firmware author will find it. (The canon's active window of 45 ms at 40 mA is the sensor-and-radio burst; the battery read has to be arranged around it, not inside it.)
Inside the LIS2DH12: a configurable high-pass on the interrupt path removes the 1 g of gravity so the motion threshold reacts to changes, not to orientation. Set its cutoff too high and a slow push of the equipment is missed (R3's motion wake); too low and tilting the tag on a shelf fires it. That is this lesson's arithmetic applied through a register. Inside the SHT40: the measurement is digitally integrated over its conversion time (up to 8.2 ms in high-precision mode), which is a low-pass of its own — and a settling requirement of its own that the driver in Lesson 3.6 must honour. On the supply of each sensor: a 100 nF decoupling capacitor, which is a filter on the rail as much as a charge reservoir. Schematic v0 gets a note beside the divider — "τ = 50 ms; read ≥ 250 ms after enable" — and beside the LIS2DH12 — "HP filter on INT path; cutoff chosen in 3.6."
WEAKNESSWhere this bites
The thermistor with τ = 1 s looks beautifully stable on a plot. It is stable because it is not measuring the present; it is reporting a weighted average of the last several seconds, and every real change arrives late and smeared. On a sleeping device the failure is sharper: the capacitor drifts toward whatever the input was during the sleep, and the wake-time read captures a value from the wrong moment. Before you accept a smooth trace, put a known step on the input and time how long the output takes to follow. If that time is longer than the interval between the thing changing and you needing to know, the filter has replaced noise with lies.
Filtering by feel — "add a 1 µF, see if it helps" — puts corners wherever the parts drawer decides. A 10 kΩ source with 1 µF is a 16 Hz corner; if your signal is a 50 Hz vibration, you have just attenuated it by 10 dB and shifted its phase by 72°, and then concluded the sensor is insensitive. Always compute fc before soldering, and always compare it to the highest frequency in the signal you need, not only to the noise you want gone. If the two overlap, no first-order filter is the answer.
The R in RC is the total resistance the capacitor charges through, and the biggest part of it is often not a resistor you drew. A 1 MΩ divider has 500 kΩ of Thevenin resistance; a sensor with a 10 kΩ output impedance contributes 10 kΩ; a multiplexer adds its on-resistance. Put a "small" 100 nF after a 1 MΩ divider thinking of it as a supply-style decoupling capacitor and you have built a 3 Hz filter with a 50 ms settling time. Compute the Thevenin resistance of whatever feeds the capacitor (Lesson 1.3), then compute fc.
KEY INSIGHTHow this connects
- Passive Components for Real: Resistors, Capacitors, Inductors (1.4) — the C in every RC here is a real capacitor with DC-bias derating and a dielectric. A 100 nF X7R stays 100 nF at 2 V; a 1 µF 0402 X5R at 3.3 V may be 0.4 µF, and your corner frequency is 2.5× higher than you calculated.
- Op-Amps and Amplification (2.2) — the amplifier's gain-bandwidth limit was a first-order low-pass you did not choose; this lesson's corner is one you do. Combine them and the corners multiply.
- ADCs and DACs: Sampling the Real World (2.4) — next: the ADC that has been sitting at the end of every diagram here gets opened up — its sample capacitor, its reference, its bits — and Beacon's battery path is worked end to end with this lesson's settling rule in it.
The alias arithmetic returns in Stage 4 as a radio problem (any periodic sampling of any periodic disturbance folds), and the settling arithmetic returns in Stage 3 as driver timing (every wake, every power switch, every multiplexer change is a step that must settle before a read). And in Stage 5 the decoupling capacitor becomes a placement problem, because the R and L that make it a filter are made of copper.
GLOSSARYKey terms introduced
- Cutoff (corner) frequency fc
- For a first-order RC filter, 1/(2πRC): the frequency at which the output falls to 1/√2 (−3 dB) of the input and lags by 45°.
- Time constant τ
- RC, in seconds. The time for a step response to reach 63 % of its final value; 4.6τ reaches 99 %, 8.3τ settles within one 12-bit LSB. Equal to 1/(2πfc).
- −20 dB per decade
- The slope of a first-order filter above its corner: ten times the frequency, one tenth the amplitude. Steeper slopes need higher-order filters.
- Thermal (Johnson) noise
- The random voltage every resistor generates, Vn = √(4kTRB). White; reduced by lower R, lower bandwidth, or averaging.
- Nyquist limit
- Half the sampling rate. Content below it is represented faithfully; content above it aliases.
- Aliasing
- The reappearance of a frequency above fs/2 at a lower frequency, min(r, fs − r) where r = f mod fs, at full amplitude, after sampling. Prevented only by attenuation before the ADC.
- Anti-aliasing filter
- A low-pass placed before an ADC to reduce everything above fs/2 below the converter's resolution. Its corner is a trade against the signal's own bandwidth and the filter's settling time.
- Settling time
- The time after a step for a filtered signal to come within a stated error of its final value; a hard firmware requirement whenever an input is switched, multiplexed, or woken.
ACTIVE RECALLCheck your understanding
Answer in your own words first, then reveal.
1A sensor with a 10 kΩ output impedance feeds an ADC through a 1 µF capacitor to ground. What is the corner frequency, and how long after the sensor is powered on may the firmware read it to 1 %?›
The R is the sensor's own 10 kΩ. fc = 1/(2π × 10 kΩ × 1 µF) = 15.9 Hz; τ = 10 ms; 1 % settling = 4.6τ = 46 ms after the sensor's output itself is valid (add the sensor's own start-up time from its datasheet). If the firmware reads at 10 ms it gets 63 % of the true value. If the sensor signal has content above ~16 Hz — say a vibration — this capacitor also attenuates it, so check both the noise you want gone and the signal you need before calling 1 µF "just decoupling".
2A rail carries 40 mV of ripple at 1.8 MHz. The ADC has a 0.61 mV LSB and samples at 2 kHz. How much attenuation is needed, and where must a first-order corner be? Where would the unfiltered ripple appear in the samples?›
Needed: 40 mV → under 0.61 mV is a factor of 66, i.e. about 36 dB. A first-order filter gives |H| ≈ fc/f well above its corner, so fc ≤ 1.8 MHz / 66 ≈ 27 kHz — trivially easy for a slow signal; any corner in the hundreds of hertz gives far more margin. Unfiltered, the ripple aliases: 1 800 000 mod 2000 = 0, so it lands at DC as a phase-dependent offset of up to ±40 mV (±66 LSB); if the true frequency is 1.8003 MHz it lands at 300 Hz instead as a visible wobble. Either way the samples carry a component whose frequency depends on the regulator's temperature and whose amplitude was never reduced.
3Why does Beacon's 100 nF divider capacitor create a 250 ms rule for the firmware, and what are two ways to live with that rule without changing the hardware?›
The divider is switched off in sleep, so at each enable the capacitor charges from near zero through the divider's 500 kΩ Thevenin resistance: τ = 50 ms, and 1 % settling takes 4.6τ ≈ 230 ms, rounded up to 250 ms for the switch's own turn-on. A read at 45 ms would return about 59 % of the true value. Two firmware-side options: (1) enable the divider first and hold it on across a longer, low-current wake, reading it last; (2) refresh the battery reading on a schedule slower than the once-a-minute report — the report carries the last good value — so the long settling wake happens rarely and costs little averaged over time. A hardware option exists too (a smaller capacitor, e.g. 10 nF for τ = 5 ms) but it changes the sample-charge margin worked in Lesson 2.4; the point of writing the constraint on the schematic is that the trade is made deliberately, once.
4A colleague says "the reading is noisy, add a bigger capacitor." Give the three questions you ask before agreeing, and the answer that means the capacitor will not help.›
(1) What frequency is the noise? Look at it with a scope on the unfiltered node; a bigger capacitor only helps if the noise is above the new corner. (2) What is the highest frequency in the signal you need? The corner must sit above it, or you attenuate the measurement along with the noise. (3) When is the node read after a step, and how long may it settle? A bigger C raises τ and may push the settling past the read. The answer that kills the capacitor: the noise and the signal overlap in frequency (50 Hz hum on a 50 Hz signal, or broadband coupling across the signal's band). Then the fix is geometry — shorter leads, a return plane, distance from the source — or synchronous averaging, not a low-pass.