Bench note

Analog filtering when the ADC sees every bounce

The problem arrives as noise

You've wired a potentiometer or a photoresistor to an ADC input, your firmware reads ten samples and averages them, and the reading still jumps around enough to make control feel twitchy. Digital filtering helps, but if the noise rides in on the analog side—mechanical vibration on a pot, mains hum on a long wire, or just breadboard capacitance interacting with your source impedance—you're asking firmware to clean up a mess that a resistor and capacitor could handle before the converter ever sees it.

An RC lowpass filter is two parts: a series resistor and a capacitor to ground. The cutoff frequency is 1 / (2π RC). Pick a cutoff well above your signal bandwidth but below the noise you want to suppress. If your sensor changes at most once per second, a 10 Hz filter is safe. If you're reading a joystick at 100 Hz, keep the cutoff around 50 Hz so you don't introduce lag that feels mushy.

Choosing R without loading your source

The series resistor must be small enough that it doesn't form a significant divider with the ADC's input impedance—typically 10 kΩ to 1 MΩ depending on the microcontroller and sample time. A 1 kΩ series resistor is usually safe. If your sensor has high output impedance (like a 100 kΩ pot at mid-travel), the ADC's input impedance might already load it; check the datasheet's equivalent input circuit and verify your error budget.

Once you've chosen R, solve for C: if you want 10 Hz and R is 1 kΩ, C = 1 / (2π × 1000 × 10) ≈ 16 µF. Standard values near that—15 µF or 22 µF—are fine. Ceramic or film both work; ceramics are compact, but if you're near the voltage rating or need tight tolerance, film is more predictable.

Placement and one grounding caution

Mount the RC filter as close to the ADC pin as the board allows. Long traces between the filter and the pin let noise couple back in. If you're using a shielded cable for the sensor, tie the shield to ground at the board end only, not at both ends, to avoid ground loops. The capacitor's ground return should go to the same ground plane the ADC references—if you've split analog and digital ground, keep the filter on the analog side and join grounds at a single star point.

This is adjacent to the reverse polarity protection you've already installed on the power input; both are insurance you pay for once and collect on every prototype session.

When firmware still needs to help

The RC filter reduces high-frequency noise, but it won't remove offset drift or slow interference. After the filter, a median-of-five or simple moving average in firmware catches outliers and smooths the tail. The analog stage does the heavy lifting; firmware just cleans the last bit.

If you find yourself cranking the cutoff frequency lower and lower to chase noise, stop and check your layout: are ADC traces running parallel to PWM lines? Is your sensor sharing a ground return with a motor driver? Fix the board, then size the filter. Analog filtering is not a substitute for quiet layout, but it's the last line of defense that costs two parts and one equation.

← Full log