View Single Post
  #58   Spotlight this post!  
Unread 16-02-2011, 23:46
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,055
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: LabVIEW Encoder not reliably returning Rate

Quote:
Originally Posted by wireties View Post

Code:
if((dfNewTime - dfLastTime) == 0.0)
	   {
		   dfNewRate = 0.0;
	   }
When would (dfNewTime - dfLastTime) ever be zero; and if it were, wouldn't you want

Code:
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 = dfLastRate;
//don't reset dfLastCount; let it accumulate
}
else
{
dfNewRate = (dfNewCount - dfLastCount)/(dfNewTime - dfLastTime);
dfLastTime = dfNewTime;
dfLastCount = dfNewCount;
}
}

dfLastRate = dfNewRate;
return(dfNewRate);
}

Reply With Quote