|
Re: Encoder Oscillation Issues
How high of a frequency are you pushing in the input pins of the controller?
I don't see anything obviously wrong with your coding... though it could also be in the actual low priority interrupt handler vector (in user routines fast).
Also, if this is a signed integer type of some kind... the fact that your error starts occuring around 120 to 160 may be significant. Remember, the largest signed value you can store in one byte is 127, so at that point you're number is becoming a two byte integer... which is more complicated for the processor to handle and isn't just a single-instruction operation anymore. This little bit of extra process time may be pushing your ISR to be just a little too long at high frequencies....
Just a hunch... unfortunately I have to run or I'd examine it further. Good Luck!
-q
__________________
Electrical Engineer Illini
1024 | Programmer '06, '07, '08 | Driver '08
|