Quote:
|
Originally Posted by gburlison
Can we also connect the 'B' side of the encoder to an interrupt and effectively quadruple the amount of precision by counting the rising and falling edges of both the 'A' & 'B' channel of the encoder?
Would this be any different than multiplying the single channel count by '4'?
|
The quick answer is yes, it's as you describe - more interrupts = more resolution per revolution.
Multiplying the existing count of the rising A interrupt by 4 doesn't tell you the encoder has moved further, it only changes the units it's expressed in. That's like multiplying your salary by 100 - okay, you then know how much you made in pennies, but it doesn't let you buy more stuff than you could before. Each actual interrupt you see tells you the encoder has absolutely, positively moved. Extra interrupts are more like extra dollars in your salary - always a nice thing

.
The complexity of your interrupt hander code goes up to correctly interpret the order of the additional interrupts, so you keep track (state machine style) of whether the encoder is rotating forwards vs backwards and when it jitters or changes direction.
E.g., if the A line rises then falls again before the B line changes (either up or down) then you've reversed direction. Or an A fall followed by a B rise is the opposite of an A fall followed by a B fall. You have to know if you should be adding or subtracting encoder counts.