Functional encoder returning 0

We have three US Digital quad encoders on our robot this year. We’ve implemented the fake encoder workaround for GetRate(), and the two encoders that we need to get rate out of are working fine, but the third, which we only need distance out of, never registers any change. The following code contains the contructors for all of our encoders:


fakeEncoderA = new Encoder(6,1,6,2,false, fakeEncoderA->k4X);
leftEncoder = new Encoder(4, LEFTMOTORA, 4, LEFTMOTORB, false, leftEncoder->k4X);
//fakeEncoderB = new Encoder(6,3,6,4,false, fakeEncoderB->k4X);
liftEncoder = new Encoder(4, LIFTMOTORA, 4, LIFTMOTORB, false, liftEncoder->k4X);
rightEncoder = new Encoder(4, RIGHTMOTORA, 4, RIGHTMOTORB, false, rightEncoder->k4X);
//fakeEncoderC = new Encoder(6,5,6,6,false, fakeEncoderC->k4X);
//liftEncoder = new Encoder(4, LIFTMOTORA, 4, LIFTMOTORB, false, liftEncoder->k4X);

The lift encoder is the one that doesn’t register change. We have verified that the encoder works by plugging it into the left encoder’s ports and reading it as the left encoder. We have also verified that the pins that the encoder is plugged into are working by successfully reading the left encoder off of them. The lift encoder still doesn’t read if we comment out all of the other encoders, change the order of the constructors and declarations, or change the encoding type to 2X. Also, if none of the encoder constructors are commented out, the console constantly throws an “Assertion Failed” error from line 217 of Encoder.cpp in WPILib. I assumed that was because the FPGA can’t handle 6 4X encoders, but changing them to 2X or 1X didn’t help. Does anyone know how to solve this problem, or what’s causing it?

Did you run Encoder->Start() before you try to get values? That’s tripped me up before.

Well, that’s embarassing. :stuck_out_tongue: So, the lift encoder is now reading, but is there any insight on why I can’t run more than four 2X encoders?

The wpi library user’s guide talks about how there are only 4 modules in the FPGA on the CRIO that can run more 4x encodings, and they are probbly used to run 2x if you specify that mode.