View Single Post
  #13   Spotlight this post!  
Unread 16-02-2011, 18:34
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: LabVIEW Encoder not reliably returning Rate

This was our fix for exactly the same problem. We created our own encoder class and put in this PIDGet method:

double RhsEncoder:IDGet()
{
double dfNewRate;
double dfNewCount = pQuadrature->GetDistance();
double dfNewTime = GetClock();

if (pQuadrature->GetStopped())
{
dfNewRate = 0.0;
}
else
{
// calc the rate

if((dfNewTime - dfLastTime) == 0.0)
{
dfNewRate = 0.0;
}
else
{
dfNewRate = (dfNewCount - dfLastCount)/(dfNewTime -
dfLastTime);
}
}

dfLastTime = dfNewTime;
dfLastCount = dfNewCount;
return(dfNewRate);
}


HTH
Reply With Quote