I’m having a few problems with my program, and I’ve spent quite a while trying to figure out how to fix them, to no avail.
I am using Kevin Watson’s encoder driver. I did encoder testing on the EDU RC, and everything worked fine. I switched to the FRC RC, and I have hooked up the encoders as stated in the file description. So, DIG IN 1 should cause interupt 2, which will in turn call the Left_Encoder_Int_Handler(). I do not have an encoder hooked up as the right side encoder (dig in 2) The encoder itself is working fine, but it increments the right side variable instead of the left. Also, when I plug the encoder into dig in 2, which should handle the right side encoder, neither right or left gets incremented. I have configured my phase B pins in the correct way, but I dont think this is part of the problem. Does anyone know what may be wrong?
only the first 6 digital I/O pins (pins 1 – 6) can be set to generate interrupts (INT2 – INT7)
The interrupts (INT2 and INT3) on pins 1 and 2 are separate and independently configurable. However, the interrupts (INT4, INT5, INT6 and INT7) on pins 3 – 6 are ganged together.
Both of those quotes are from the Interrupts for Dummies white paper, but I know I’ve seen it in official documentation, too.
I am having the exact same problem. I could swear that the encoders even worked correctly a day or two ago! I have checked the connections several times - the left encoder’s phase A is definitely on pin 1, and its phase B is on pin 6, but turning the left encoder increments the right encoder count and turning the right encoder does nothing at all. However, the left encoder count does change from 0 to -1 when the right encoder count is less than 0. I have gone so far as to simply compile and load the Navigation_FRC demo from kevin.org, but I still experience the problem. I have also switched encoders, encoder cables, and FRCs. Can anyone offer some advice?
This sounds strangely like a problem I just had. It turned out that nothing was wrong with the encoder code (of course), just a printf statement.
Note that Get_Right_Encoder_count() returns a long! So you cannot
just put it into a printf with a %d type. If you have 2 %ds, you will
get 1/2 of the long for each one, the upper part is usually 0.
The thing to do is to use %ld to let printf know to expect a long value.