![]() |
Custom GetRate not working.
Hi all,
We've heard that the WIPlib Encoder method getRate() is inconsistent, so we're trying to write out our own (better) without any success. Any suggestions? Code: private static double currGet = 0.0; public static double getRate() { double prevGet = currGet; currGet = shooterEncoder.get(); int scalar = 50; double rateDegreePerSec = Math.abs(currGet-prevGet)*scalar; double rpm = rateDegreePerSec/6.0; System.out.println("Rate: " + rpm); return rpm; } |
Re: Custom GetRate not working.
Quote:
Code:
private static double currGet = 0.0;Also, if you are not sampling the encoder at 1x, you might try that also: Quote:
|
Re: Custom GetRate not working.
Sorry for the confusion, we are getting data back however it is very noisy and unstable.
|
Re: Custom GetRate not working.
Quote:
Try using 1x instead of 4x, and try using actual measured elapsed time since last sample instead of a fixed scale factor. If that doesn't work, check to make sure your encoder disk is installed properly. |
Re: Custom GetRate not working.
Here is a quick re-write I did, using all the above comments. Encoder is set to 1x.
Wouldn't get to test till next Wednesday. But comments are welcome. Code:
public static void shooterEncoderStart() { |
Re: Custom GetRate not working.
Quote:
You want to get the encoder count and the time once per iteration, and compare those values to the previous iteration. Pseudocode: Code:
new_counts = get_counts(); |
Re: Custom GetRate not working.
Thank you for the help Ether, I will try it out next meeting!
|
| All times are GMT -5. The time now is 10:05. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi