View Single Post
  #1   Spotlight this post!  
Unread 09-02-2013, 14:16
bhughes bhughes is offline
Registered User
no team
 
Join Date: Jan 2013
Rookie Year: 1999
Location: Michigan
Posts: 24
bhughes is on a distinguished road
60 / getPeriod() returns 3,000,000

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?