Filtering Noisy Data With An Arduino

One of the first frustrating situations a beginning microcontroller programmer will come across is the issue of debouncing switches. Microcontrollers are faster than switches, and the switch has yet to be built that can change state in zero time like they can on paper. This hurdle is easily overcome, but soon we are all faced with another issue: filtering noise from an analog signal. Luckily [Paul Martinsen] has put together a primer of three different ways to use an Arduino to filter signals.

The first (and fastest, simplest, etc.) way to filter an analog signal is to sample a bunch of times and then average all of the samples together. This will eliminate most outliers and chatter without losing much of the information. From there, the tutorial moves on to programming a running average to help increase the sample time (but consume much more memory). Finally, [Paul] takes a look at exponential filters, which are recursive, use less memory, and can be tweaked to respond to changes in different ways.

[Paul] discusses all of the perks and downsides of each method and provides examples for each as well. It’s worth checking out, whether you’re a seasoned veteran who might glean some nuance or you’re a beginner who hasn’t even encountered this problem yet. And if you’re still working on debouncing a digital input, we have you covered there, too.

King Of Clever Reads 4-Pin Rotary Encoder With One Analog Pin

Rotary encoders are pretty interesting pieces of technology. They’re a solid way to accurately measure rotation including the direction. [David] recently wrote some software to handle these input devices, but unlike everyone else, his application can get by on only one microcontroller pin.

Most people will use three pins to handle a rotary encoder with a microcontroller: one to handle the switch and two to handle the quadrature inputs. With only one pin left available on his project [David] had to look for another solution, and he focused on the principle that the encoder pins behaved in very specific ways when turning the shaft. He designed a circuit that generates an analog voltage based on the state of those pins. He also wrote a program that can recognize the new analog patterns produced by his rotary encoder and his new circuit.

If you’ve been stuck on a project that uses a rotary encoder because you’ve run out of pins, this novel approach may help you get un-stuck. It’s a pretty impressive feat of circuit design to boot. Just think of how many other projects use these types of input devices and could benefit from it!

[via Project Page go give it a Skull!]