Quadrature Encoder Problems

My encoder keeps giving me very large numbers. I turn less than 180 degrees. At point A it is 0, at point B its -115, then when I go back to point A its suddenly 1000 or something. I already tried multiple encoders. Still same problem. I use robotC. Could it be because of the wires? I plugged both into digital.

How are your wires plugged in? Can you give a precise description? And how have you set up the sensor in ROBOTC?

Have you tried opening the encoder and cleaning the encoder with some canned air? If your encoder is right up against a piece of plastic rubbing all day or if playing in dirty locations where the fields are not clean, dust can be generated and get in the encoder producing bad values.

i got a new encoder and it still had the same problems

Are you using extension pwm cables with the encoder? If you are try to plug the encoder cables straight in the encoder. Or you should just put an axle through your new encoder and manually spin it forward and backwards to see if it gives you better values

The problem is probably in your code then.

Have you tired multiple digital ports with the same issue?

Have you tried just reading the quad encoder into a global variable and watching on the debugger? I’d try that first. And turn the axle slowly to ensure the connection back to the debugger is fast enough to see exactly what is going on. You could have a drop out between the two and it just looks like a big jump when it’s not really.

Can you post your code

Try re-firmware-ing the robot. Sometimes it magically fixes these things.

Wouldn’t you know it, this exact same issue has plagued our team this weekend! Autonomous tried going twice as far messing up the scoring in a few matches. argh

After the competition, I took it off and opened it up - it’s not dirty at all. Plugged it in a few different ports - nope, nothing showing on the debugger either. Just dead.

The wires were tightly placed to fit into the cortex so it’s probably that bit of abuse that killed it I think. Will put extensions on the next one or switch to the motor based encoders next time.

what type of variable are you using? Sometimes sensors mess up like this when you don’t use the right variable type. Make sure to use the variable type “long”