[chbot] Fixing bouncing rotary encoder

Charles Manning cdhmanning at gmail.com
Sun Nov 6 07:22:10 GMT 2016


Yup

I almost always debounce switches by polling in a timer interrupt. For push
switches (eg. keyboards) a slow polling interrupt is sufficient. For an
encoder knob a 1kHz interrupt is generally way fast enough.

Generally, the worst is to use an edge detect interrupt to do switch
detection. A noisy (glitchy) transition can end up causing multiple
interrupts. Worst I've seen was when a switch failed mechanically and ended
up causing a few thousand interrupts a second. That extra interrupt load
caused the CPU to overload and they system failed.

Volker: One neat trick might be to disconnect the encoder then use some
circuit to recondition the signal to pass through to the rest of the
system. eg. run it through a micro or a 555 or a filter + hysteresis (74xx
or op amp)  to deglitch it.

encoder->magic->rest_of_circuit.



On Sun, Nov 6, 2016 at 7:51 PM, Mark Atherton <markaren1 at xtra.co.nz> wrote:

> See if you can take the encoder out and inspect it.
>
> If it's optical, it may be a fluff-problem, or dirty pickup optics; a good
> clean may help,
>
> If its a mechanical encoder, again, disassemble and clean it, it could
> still be a fluff-problem. A squirt of contact cleaner may also be beneficial
>
> -mark
>
>
> On 6/11/2016 5:57 PM, Charles Manning wrote:
>
> A capacitor across the contacts might help.
>
> What is the value of the pull up resistor? How often do you expect to see
> pulses (if it was clean)?
>
> Set the capacitor so that the RxC = about 1/10 of the period of the
> nominal "clean" frequency you want.
>
> Alternatively, if you have a scope handy and can see the glitches, set the
> value to about 5 x the period of the glitches.
>
> That should give you a reasonable starting point.
>
>
> Rotary encoders should be doing quadrature encoding. I've seen that messed
> up in firmware at least 50% of the time.
>
> On Sun, Nov 6, 2016 at 5:44 PM, Volker Kuhlmann <list0570 at paradise.net.nz>
> wrote:
>
>> I have a digital power supply that has developed a bounce problem with
>> its twiddle knob, making it pretty much unusable. Someone at the last
>> meeting mentioned the quick fix is to put in a capacitor, but I don't
>> remember the details. Is the capacitor across the contacts? And what
>> value? 100pF? 100nF? Wouldn't burn 100nF the contacts out?
>>
>> Obviously this tool has s... firmware, but I can't fix that. Plan B is
>> to try and replace the encoder, but if a quick fix works that'll save
>> some headaches with models, sizes, etc.
>>
>> Thanks muchly,
>>
>> Volker
>>
>
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.linuxnut.co.nz
> http://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20161106/f64d362d/attachment-0001.html>


More information about the Chchrobotics mailing list