Motor Encoder Problem

We are trying to implement Mecanum Drive on our FRC robot. We have attached encoders to all 4 mecanum wheels, and have implemented PID systems with all of them. 3 of the motors are working excellently with the PID and encoders, but one of them is not working correctly.

It randomly jumps between positive and negative values, and appears to accelerate on its own when there is an input of 0.

The encoders that we are using are AMT103 encoders. We replaced the encoder on the motor that is not working with a new encoder, as well as adjusting the shaft, yet the problem persists. The code is the same for all 4 motors. The encoder wires connecting to the RoboRIO are made from jumper wires, so we tried to make a new one, but the problem is there. We switched ports on the roboRIO, but that didn’t work either.

What could be the problem?

Does the encoder for the wheel in question appear to be functioning correctly outside of the PID loop? That is, if you put the encoder reading on the smartdashboard and turn the wheel by hand, does the response look correct?

Check to make sure that your encoder’s “forward” direction is the same as the motor’s “forward.” If not, you will have an unstable loop that will run off to max output.

We managed to fix it. Apparently the shaft on this motor was smaller than all the other motors, so it was simply a matter of switching the sleeve size of the encoder.

Thank you!

What motors are you using?