We have encountered a problem where doing this:
Code:
double getRate() {
return 60 / counter.getPeriod();
}
Randomly returns 3,000,000 sometimes. We're using it to determine how accurate our bang-bang is by averaging the difference between the setpoint RPM and the real RPM, and it works well until at seemingly random times it will return strange high numbers. Other than the high numbers, it returns accurate ones. We are using a once-per-rev hall effect sensor and we've gotten (by graphing the data) within 20+- rpm of what we'd like. The random large numbers mess up our data, and we're wondering what would cause this to happen.
This is getPeriod():
Code:
public double getPeriod() {
double period;
if (m_counter.readTimerOutput_Stalled()) {
return Double.POSITIVE_INFINITY;
} else {
period = (double) m_counter.readTimerOutput_Period() / (double) m_counter.readTimerOutput_Count();
}
return period / 1.0e6;
}
How would m_counter.readTimerOutput_Stalled() return true? That's when it is considered "stopped", correct?