PCB Design
How to filter noise on an ADC input with an RC filter
To keep noise out of an ADC reading, put a resistor in series with the signal and a capacitor from the ADC pin to ground. That's a low-pass filter with its corner at 1 ÷ (2πRC). Set the corner about ten times above the fastest signal you want to measure; everything well above it is divided down against the resistor. And put the capacitor at the pin, not anywhere else.
Signal and noise on one wire
A sensor sends a slow 100 Hz signal down a long wire. On its way it passes a switching regulator and picks up 1 MHz hash. The ADC can't tell them apart: it reads the sum.
Pick the corner
10 kΩ and 10 nF put the corner at 1.6 kHz: sixteen times above the 100 Hz signal, and more than 600 times below the 1 MHz noise.
Worked numbers
The capacitor's reactance, 1 ÷ (2πfC), does the sorting:
| Frequency | 10 nF looks like | Reaches the pin |
|---|---|---|
| 100 Hz, the signal | 160 kΩ | about 99.8 % |
| 1 MHz, the noise | 16 Ω | about 0.16 % |
At 100 Hz the capacitor is nearly open and the signal passes whole. At 1 MHz it's nearly a short, a 16 Ω divider against 10 kΩ. Above the corner a single RC cuts by ten times for every ten times in frequency, 20 dB per decade.
Live experiment
Clean a noisy sensor line
A 100 Hz sensor signal picks up 1 MHz switching noise on its way to an ADC pin through 10 kΩ. Pick the capacitor: 10 pF lets 99 % of the noise through, 10 nF cuts it to 0.16 % and keeps the signal, 1 µF cuts the signal too. Then move it to the sensor's end.
“Quiet the sensor line” is lesson 5 of 6 in Solder Strait, PCB Design World 2. Free with an account. Lessons unlock in order, so you’ll do the 11 before it first.
Not too big
A bigger capacitor is not a better one. With 1 µF the corner drops to 16 Hz, below the signal itself, and the 100 Hz reading arrives at about 16 % of its size. The noise is gone, and so is the measurement. A filter that's too slow also delays the reading, which matters when it feeds a control loop.
Choosing R
The same corner comes from many pairs. A bigger R needs a smaller C, but the ADC draws little bursts of current each time it samples, and too much source resistance means the sample has no time to settle and reads wrong. Microcontroller ADCs like the one on an Arduino Uno are designed for sources of about 10 kΩ or less. The capacitor at the pin helps here too: it holds a store of charge for the converter's sampling capacitor to draw on.
Swap the two parts, capacitor in series and resistor to ground, and you've built a high-pass filter that blocks the slow signal and passes the noise. Resistor in the path, capacitor to ground.
Free lesson
Now build it yourself
Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.
“Quiet the sensor line” is lesson 5 of 6 in Solder Strait, PCB Design World 2. Free with an account. Lessons unlock in order, so you’ll do the 11 before it first.
Or start from the very first lesson, no account neededPractice questions
Three quick questions from the lessons. Pick an answer to check it.
Show the answer
Answer: 0.16 %. A divider of 10 kΩ over 16 Ω: about 16 ÷ 10 000, 0.16 %. The signal at 100 Hz sees 160 kΩ instead and passes whole.
- Why not “50 %”? Half would need the capacitor's reactance to match the resistor. At 1 MHz it's 16 Ω against 10,000.
- Why not “16 %”? That's a hundred times too much. 16 Ω against 10 kΩ divides the noise to about 16 ÷ 10,000, which is 0.16 %.
- Why not “All of it”? At 1 MHz the 10 nF is nearly a short to ground, so almost none of the noise reaches the pin.
Show the answer
Answer: 16 %: the corner has dropped to 16 Hz, below the signal. 1 ÷ (2π × 10 kΩ × 1 µF) is 16 Hz, under the 100 Hz signal, so the signal is divided down too. The noise is gone, and so is the reading.
- Why not “0.16 %”? 0.16 % is what reaches the pin of the 1 MHz noise with 10 nF. The 100 Hz signal with 1 µF keeps about 16 %.
- Why not “Exactly 50 %”? At 100 Hz the signal is six times above the 16 Hz corner, where a single RC passes about a sixth, not half.
- Why not “99 %: bigger is always better”? A bigger capacitor lowers the corner. At 16 Hz it sits below the 100 Hz signal, which is cut along with the noise.
Show the answer
Answer: Reaches the pin: it was picked up after the capacitor. The wire is the antenna. A filter before the antenna filters nothing it picks up. At the pin, it catches everything.
- Why not “Is filtered”? A filter only acts on what passes through it. Noise picked up on the wire after the capacitor never meets it.
- Why not “Disappears”? Nothing removes it: the noise enters after the capacitor and goes straight to the pin.
- Why not “Is doubled”? Moving the capacitor doesn't add noise. It just stops removing the noise the wire picks up.
“Quiet the sensor line” is lesson 5 of 6 in Solder Strait, PCB Design World 2. Free with an account. Lessons unlock in order, so you’ll do the 11 before it first.
Questions people ask
What RC values should I use on an Arduino analog input?
Put the corner about ten times above the fastest signal you care about. Keep the resistor at 10 kΩ or less, since the Uno's ADC is designed for sources of about 10 kΩ or lower, then pick C from f = 1 ÷ (2πRC). For a slow sensor, 10 kΩ and 100 nF gives a corner near 160 Hz.
Why does the filter capacitor go right at the ADC pin?
A filter only cleans what passes through it. Any wire after the capacitor is an antenna that picks up fresh noise. At the pin, the capacitor dumps that noise to ground exactly where the converter would read it, and it also gives the converter's sampling capacitor a charge to draw on.
Is this the same as an anti-aliasing filter?
Yes. Noise above half the sampling rate folds down and looks like a slow signal once it's sampled, and nothing in software can separate it afterwards. The RC removes it before conversion, which is the only place it can be removed.
Related topics
- Low-pass filter explainedA resistor and a capacitor that pass the bass and fade the treble, and where the cutoff sits.
- What is aliasing, and what is the Nyquist rate?Sample too slowly and a fast wheel seems to crawl backwards.
- How Arduino analogRead worksHow analogRead turns 0–5 V into 0–1023, and how to scale it for analogWrite.
- What is a decoupling capacitor?Why every chip has a capacitor beside its power pins, how big, and why it must be close.