Encoders aren't working?

We are using the EVO Shifter with [. We’ve wired them to DIO 0-3 on the RIO. The power, ground, and A channel are wired to port 0 / 2 and the B channel is wired to port 1 / 3.

In our code, we are using them like this:


//RobotMap.java init()
rightDriveEncoder = new Encoder( 0, 1 );


//DriveWithJoystick.java execute()
SmartDashboard.putString("DB/String 0", "" + RobotMap.rightDriveEncoder.getRate() );

However, the dashboard always shows 0.0, no matter what we do. We have verified that the encoder is turning. If we change this to display DigitalInput for port 0, it always displays true.

Have we wired it incorrectly or is there something we should be doing in the code?](“http://www.andymark.com/E4T-OEM-Miniature-Optical-Encoder-Kit-p/am-3132.htm”)

Sorry, link didn’t work out. It should be linked here.

Can you please post or PM me your entire robot program?

The encoder initialization in RobotMap is commented out right now (probably intentional, but just in case). Other than that, I would guess it’s a wiring issue, because your code seems correct.

Side note: you probably want to check the bandwidth your camera stream uses. A 640x480 stream at 30 fps (I think that’s what you have it at) is quite likely to consume too much bandwidth.

Got to revisit the problem last night, started debugging things with a multimeter… turns out the person who wired the encoders had broken the encoder wire in several places by zip tying it in a bundle. I now have a good story to bring up whenever something’s blamed on the programming :wink: