[sdiy] Digital filtering of pot input

Ben Bradley ben.pi.bradley at gmail.com
Fri Dec 2 19:55:03 CET 2016

These are good suggestions, but I always like the hardware idea of
keeping the noise as low as possible at the ADC pin. Fortunately it's
a slowly varying signal. so a 0.01uF or even 0.1uF cap right between
the ADC input pin and nearest analog ground pin should help. Also, run
wires directly from that ground pin and the nearest
(analog/stable/well filtered) Vcc pin to the pot along with the wire
to the wiper, and twist all three wires together. This likely won't
make it perfect, but may reduce the noise so you make your deadband
area smaller and thus less noticeable.

For my contribution on fixing the staircase effect (this is similar to
Vladimir's idea), if you detect movement outside the deadband, start
returning the actual value of the ADC (or possibly the
software-filtered output as you're already doing) but keep checking
for movements outside the deadband. When there's been no movement
outside the deadband for about one second (or whatever time you're
comfortable with), switch the final output back to the deadband

Tim Ressel's "running average" is known by another name, a leaky
integrator - the actual code for this sort of thing is simpler than
the math behind it:

On Fri, Dec 2, 2016 at 7:51 AM, Matthias Puech <matthias.puech at gmail.com> wrote:
> Hi DIYists,
> I have a potentially simple question on filtering. I get my pot reading from a very noisy ADC (on-board STM32F4), but I absolutely need the value to be constant when I'm not touching the pot. It's ok for it to be a bit wobbly while I am turning the pot. Now I'm using hysteresis:
> if (fabs(reading - output) < 0.01)
>   output = reading;
> which gives me a stable value when I'm not turning the pot, but I am annoyed by the staircase effect while I'm turning it. Is there a simple filter that will let signal through when there is consistent movement but hold it when not?
> Thanks in advance,
>         -m
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at synth-diy.org
> http://synth-diy.org/mailman/listinfo/synth-diy

More information about the Synth-diy mailing list