Encoder not Reading back .Rate()

Hello from team 806.

Our programmer is being beaten by a simple encoder.
We’ve been using them for years and have never had problems with them before.

We ordered a CimCoder from andymark to give us a RPM readout for our launcher wheels but we’re having trouble.
We can call our encoder .getRaw() and .getDistance() and we’re getting reasonable numbers, so we know it’s hooked up correctly. But when we call .getRate or .getPeriod(which i know is no longer used, but we were debugging) we get just blank back while the motor is running, and 0 while the motor is stopped. It returns no numbers, just blank. .getPeriod() is similar but instead of 0 we get infinite.

Here are the relevant pieces of my code.


//declaration
Encoder LauncherEnc;

//this is in robotInit
LauncherEnc = new Encoder(0, 1, true, EncodingType.k2X);

LauncherEnc.setMaxPeriod(.5);
LauncherEnc.setMinRate(10);
LauncherEnc.setDistancePerPulse(20);
LauncherEnc.setReverseDirection(true);
LauncherEnc.setSamplesToAverage(6);

//this is in the teleoploop
SmartDashboard.putString("DB/String 0", "Launch Encoder = " + LauncherEnc.getRate();	)



Thanks for any help, this problem has been killing us.

I think this may be an issue with the dashboard rather than your code. I believe (though i’m not entirely sure) that if your value contains more digits than fit in the display window, the box is left blank. Try using System.out.println() and the Riolog instead…

+1 Coopertition to you my guy.
Worked perfectly once i rounded to 2 decimal places. Thank you.