Hi, I have problem with my 2 encoders connected to arduino micro (32u4). One encoder - for controlling volume, second for controlling analog input selector.
Vol control is in count0
Sel control is in count1, so first I need to go to count1, then I can control up or down channels
Encoders works ok, they are full step, 20-24pulses. But if I will rotate a little volume encoder, I have "1" on controller , and encoder freezes in this position, then if I rotate second encoder (selector), controller think that it is in count 0 (volume control), and if I rotate selector encoder, then controller are jumping between count0 and count1. When I again rotate a little, then I heard "click" from encoder - full step, encoder hangs up and then all is working ok.
Same situation if I will rotate a little selector encoder , "half step", without hearing click, again controller see "1" from encoeder selector, again rotating volume encoder make changes for selector input.
I have no problem with reading value, it works perfect until encoder go to halfstep / freeze state (move between 0 state and full step, before "click" sound)
I have opened serial monitor and here what I see:
Rotate to down, freeze state
rSelL 1
rSelR 1
Rotate to up, freeze state
rSelL 0
rSelR 1
Selector down
rSelL 1
rSelR 1
Selector up
rSelL 1
rSelR 0
rotate to down, freeze state
rVolL 1
rVolR 0
rotate to up, freeze state
rVolL 1
rVolR 1
Vol down:
rVolL 1
rVolR 1
Vol up:
rVoLL 1
rVolR 0
#define rotaryVolL 13
#define rotaryVolR MISO //(PCINT3)
#define rotarySelL 8 //(PCINT4) (pcint disabled)
#define rotarySelR SS //(PCINT0)
boolean rVolL;
boolean rVolR;
boolean rSelL;
boolean rSelR;
ISR(PCINT0_vect) {
rVolL = digitalRead(rotaryVolL);
rVolR = digitalRead(rotaryVolR);
rSelL = digitalRead(rotarySelL);
rSelR = digitalRead(rotarySelR);
//volume encoder
if (rVolL) {
if (!rVolR) {
switch (count) {
case 0:
vol = vol - 1;
break;
}
} else {
switch (count) {
case 0:
vol = vol + 1;
break;
}
}
}
}
//selector encoder
if (rSelL) {
if (!rSelR) {
switch (count) {
case 0:
count = 1;
break;
case 1:
Analog++;
break;
}
}
else {
switch (count) {
case 0:
count = 1;
break;
case 1:
Analog--;
break;
}
void setup() {
pinMode(rotaryVolL, INPUT_PULLUP);
pinMode(rotaryVolR, INPUT_PULLUP);
pinMode(rotarySelL, INPUT_PULLUP);
pinMode(rotarySelR, INPUT_PULLUP);
PCICR = 1;
PCMSK0 |= (1 << PCINT0) //SS
PCMSK0 |= (1 << PCINT3) //MISO
}
If I understand well, I need function which detect if pulses/interrupts are from encoder volume or encoder selector. Then "freezes state" (half step from encoder which occurs "1" on controller) will not disturb work of second encoder?