Replies: 3 comments 2 replies
-
Hi, i has same problem too, when connect to mega encoder and multiplexor in result encoder worked not correct, if disconnect multiplexer, encoder work fine. |
Beta Was this translation helpful? Give feedback.
-
An encoder requires frequent polling to work correctly. If you turn it too quickly, so that the time between pulses becomes shorter than your polling rate, you will miss pulses, and it no longer works. Reading the analog values of 24 potentiometers takes an eternity, relatively speaking. The Mega simply cannot do this fast enough, and it cannot poll the encoders while reading the potentiometers at the same time. There are multiple possible workarounds:
Option 3 is definitely the best one, but the Mega may not provide enough external and pin change interrupts for this to work. Control Surface enables external interrupts automatically for its default encoder classes, but only for pins that support it (see this table). Option 1 requires changing the whole program, and is not always feasible, especially in a framework like Control Surface, which relies on cooperative multitasking. I have considered some ideas to improve the performance of multiplexers and analogRead in general, but implementing them would complicate things for all users, even for the 99% that don't need such features. That leaves option 2. You can find code polling 20 encoders using an Arduino Mega in this forum post: https://forum.arduino.cc/t/control-surface-library-encoder-the-full-adventure-with-presonus-studio-one/869572/58 |
Beta Was this translation helpful? Give feedback.
-
hello pieter,
so i have around 64 buttons, 24 potentiometers and 13 rotary encoders, 11 of them are ky040 modules and 2 are 360ppr ones, so when i put the code of the rotary encoders alone they work fine, but when i combine the code of the encoders with the other modules, the encoders giver weird results, and they are not working as intended, keep in mine i cannot have access to an MCP multiplexer, because i live in the middle east, the project is using an arduino mega, and the code is written below, how can i make the readings of the encoders more stable?
Beta Was this translation helpful? Give feedback.
All reactions