[sdiy] Rotary encoders: is there a clever way to handle many?
Rick Jansen
rick.jansen at xs4all.nl
Tue Aug 11 08:00:09 CEST 2015
> On 11 Aug 2015, at 03:18, john slee <indigoid at oldcorollas.org> wrote:
>
>> 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
Great idea! I had forgotten this is possible! It makes it easier to read at least a few encoders. Thanks!
rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20150811/a6f8851e/attachment.htm>
More information about the Synth-diy
mailing list