Reading encoder values?

I’m having trouble reading values from the coders. When it goes forward I get increasing values for the .get() function (for the encoder). But when I reverse the motor everything the values stay the same, and when I go forward again they continue rising, and they all stay at 0 (I’m printing the get(), getRaw(), getDistance(), and getRate() values).

I don’t know if it’s wiring or coding, but my code only calls reset on the initialization of the subsystem (we’re using java command based programming), so I don’t know why it would be resetting.

For the wiring, I only have power going from one digital input, but I’m using 2 DIO ports for the signals.

Any ideas on how to reduce the get() when going in reverse?

Definitely sounds like a wiring issue. Double check the signal wires for the encoder and the connection to the encoder itself.

Troubleshooting tip: switch the channels of the encoder. Does the encoder reading flip? If so, you may have a bad encoder. If it stays the same after switching the channels, you may have a bad DIO on the RoboRIO.

We had a (homemade) encoder disk our rookie year which would only rotate one way; something caught it when going the other way.

If we use DIO ports 0 and 1 it works fine, but DIO ports 2 and 3 don’t seem to work as well.