I'd like to attach at least 6 rotary encoders to a single Arduino Leonardo - among great many other things.
The mechanical rotary encoders are incremental with 24 PPR and with 24 dents. The datasheet can be found here: PEC16-4220F-S0024
The encoders will be operated by humans, as they were volume knobs.
One and only one encoder will used at a time.
I don't want to poll the digital inputs since the main loop is quite computation heavy (~150ms at its worst) and it would potentially miss a lot of step between two reading.
Since the Leonardo has only 5 interruptable pins, I thought I could share two interruptor pins (A, B) among the encoders, see the image:
(White: A, Black: B, Red: C, Orange: shared interruptors)
It's pretty unortodox, also isn't working.
There's a couple of things:
- The C pins of the encoders are wired to the +5VC (using INPUT for all the pins) - it was easier to create the logical OR gate from the diodes this way
- I had to use diodes to prevent an interrupt to travel backward to the other encoders (acting as logical OR)
- Works alright if only one encoder is hooked in
- Doesn't work when two encoders are present (the code getting interrupted but the readings on the A/B pins are incorrect)
Goes without saying: but I'm just a beginner with electronics.
Please, if you have any idea how could I wire multiple encoders using only 2 interruptors, or you know what went wront with my pathetic circuit, let me know.