Closed giraffe81 closed 5 years ago
Not really. Most of the delay comes from reading the ADC. Reading 20 potentiometers takes around 4 ms on each iteration.
What you could do is edit the library to call encoder.read between refreshing each potentiometer.
Alternatively, you could read the ADC asynchronously, but it's quite tricky.
Using interrupt pins is the best solution by far.
I did what you suggested and refreshed the encoder between every other control element and it works great. Doesn't seem to miss any pulses now and also doesn't have a notable affect on the speed of reading the potentinmeters.
Thanks
Description of the problem or question
I have about 20 pots through multiplexers and two encoders. The encoders work ok when turned slowly but when moved quickly they go backwards. I don't have the encoders on interrupt pins which I suspect is my problem but I wondered if there was anything else I could tweak.
I am not doing anything else in my loop and have found removing all the other control elements the encoders work fine so it appears there is too much happening in the refresh on each of the controls. Are there any other sections I can remove to speed things up? I have had my PCB produced already so switching to interrupt pins is not going to be easy.
Thanks
Hardware
Atmega32u4 CD74HC4067 - mux TLC5947 - LED driver
Software versions:
MIDI Controller library: 3.1.0 (Encoder library): 1.4.1 (MIDIUSB library): 1.0.3