[sdiy] Rotary encoders: is there a clever way to handle many?

john slee indigoid at oldcorollas.org
Tue Aug 11 03:18:59 CEST 2015


On 10 August 2015 at 21:45, Rick Jansen <rick.jansen at xs4all.nl> wrote:

> It works quite well, but at the same time I wonder how other machines
> work, that track 8 or 16 rotary encoders.. An Arduino Mega has many more
> interrupt pins than the measly Arduino Uno, but still. Is there a clever
> trick to track many rotary encoders that I am missing?


Note that while the ATmega328 has two interrupt pins, it ALSO has a
pin-change interrupt (PCINT) mechanism wherein you set a mask for the pins
you want to monitor, and then it generates a PCINT interrupt when any of
those pins change.

So you could add all your encoder GPIO pins to the mask and then whenever
it fires, read all of them.

If you assign their GPIO pins sensibly you can then read 8 pins (one
byte/four encoders) in one instruction.

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20150811/a82ee347/attachment.htm>


More information about the Synth-diy mailing list