I think the encoder->service() routine (called at the end of loop()) is called too often, as it is driven by a timer interrupt variable which is set 10 times too fast, compared to ClickEncoder 1ms spec (relied upon for acceleration and stuff). This was fine, before this change from 1000->100.
Timer1.initialize(100); //changed from 1000 to 100 for faster PWM to avoid ripple at CV Out
I started looking into this because I thought the encoder was not reacting as smooth as I was expecting. Changed the interrupt routine to only set the flag every ten times, seems to work fine.
bool encoder_service_flag = false;
byte timer1_interrupt_counter = 0;
// amount of interrupts per millis
// encoder is only written for millis service call
#define INTERRUPTSCALE 10
void timerIsr() {
//encoder->service();//andyB, if this is called at the wrong point in loop there can be a spurious clock from Mex
timer1_interrupt_counter++;
if (timer1_interrupt_counter == INTERRUPTSCALE) {
timer1_interrupt_counter = 0;
encoder_service_flag = true;// so just flag it needs to be done
}
}
I think the encoder->service() routine (called at the end of loop()) is called too often, as it is driven by a timer interrupt variable which is set 10 times too fast, compared to ClickEncoder 1ms spec (relied upon for acceleration and stuff). This was fine, before this change from 1000->100.
Timer1.initialize(100); //changed from 1000 to 100 for faster PWM to avoid ripple at CV Out
I started looking into this because I thought the encoder was not reacting as smooth as I was expecting. Changed the interrupt routine to only set the flag every ten times, seems to work fine.