Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Encoder not Reading back .Rate() (http://www.chiefdelphi.com/forums/showthread.php?t=155063)

BlacksmithWoods 10-02-2017 18:27

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.

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.

soundfx 10-02-2017 19:08

Re: Encoder not Reading back .Rate()
 
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..

BlacksmithWoods 10-02-2017 21:15

Re: Encoder not Reading back .Rate()
 
+1 Coopertition to you my guy.
Worked perfectly once i rounded to 2 decimal places. Thank you.


All times are GMT -5. The time now is 20:19.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi