[sdiy] Digital filtering of pot input
rsdio at audiobanshee.com
rsdio at audiobanshee.com
Sat Dec 3 09:47:03 CET 2016
On Dec 2, 2016, at 10:55 AM, Ben Bradley <ben.pi.bradley at gmail.com> wrote:
> 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.
Pots and faders for through-hole or surface mount typically have a metal shield all the way around them. With a proper ground plane on the PCB, this can completely shield the pot from most noise. Adding a single-pole RC filter to the wiper is indeed a good measure.
It's also important to follow the manufacturer's layout instructions for their ADC peripheral. Many chips have a dedicated analog ground, a dedicated analog reference voltage, and other ways to isolate the ADC inputs. It can be tricky, because you can't exactly maintain two separate grounds successfully, but if you manage the current paths then you can reduce a great deal of the noise that it typical for on-CPU ADC units.
But, no matter how perfect your PCB layout, there will still be *some* noise from the digital clocks within the chip. But I believe that you can get rid of a lot.
> 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
The deadband can be really annoying for pots that set pan or balance, especially when the user is trying to dial in the "center" position and the deadband catches 1 code off from center. As Richie suggested, having way more bits on the ADC than you need for your parameter is great, because then the deadband is much smaller than 1 code away from the desired value.
> 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:
Since a leaky integrator is equivalent to a 1st-order low-pass, it's much easier to tell synth folk that it's a low-pass.
My calculations were off before. The cutoff would be about 5 kHz @ 44.1 kHz sample rate, or about 11 Hz @ 100 Hz sample rate.
More information about the Synth-diy