Encoders Programming

Here are some other things to consider:

Are both encoders giving you identical output? It might be easier to look at the output using System.out.println() rather than SmartDashboard. The output goes to the console in NetBeans, and from my experience is more useful for debugging.

Are you calling Encoder#start() more than once for the encoders? You should only need to call it once at the beginning of the program, unless you stop counting with Encoder#stop(). I don’t know if this would cause the encoder count to reset though.

Have you checked for hardware defects? Ensure that there is nothing wrong with your digital sidecar and cables. As Joe Ross mentioned earlier, the problem you described is often because only one channel of the encoder is being read.

Does your team have any other encoders, such as the US Digital E4P? You could try swapping one out temporarily to see if it behaves any differently. This would help identify it as a hardware or a software issue.

You may want to consider setting up a couple of DigitalInputs in code and read/println the two encoder inputs while slowly spinning the shaft by hand: you should be able to see the inputs toggle. That would tell you if it’s wiring (or wrong/bad input) or problems setting up the Counter class…

Hi David. You haven’t posted in 10 days. Did you ever get your problem solved? Please tell us about it.

I still haven’t figured out the encoder resetting problem sadly. I had about 2 months of just thinking about it while I worked on the Safety Animation but the program I came up with inevitably failed. I might just end up going through and yanking everything because the only thing I can think of is it’s a wiring problem.