Quote:
Originally Posted by Mk.32
We've heard that the WIPlib Encoder method getRate() is inconsistent, so we're trying to write out own (better) without any success.
|
It's not entirely clear what you mean by "without
any success". I will assume what you meant is that you are getting a signal, but it is very noisy.
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;
}
In the above code, you are not using the actual elapsed time since the previous sample to compute rate. You are assuming the scheduler's timing jitter can be ignored. Try reading a high-res system clock and dividing the delta_counts by the actual elapsed time.
Also, if you are not sampling the encoder at 1x, you might try that also:
Quote:
Originally Posted by Joe Ross
With 4x encoding, you get more noise in the velocity due to quadrature phase errors in the encoder wheel. I recommend 1x for velocity and 4x for distance.
|