Go to Post Read it, Loved it, posted it on facebook! - wendymom [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #28   Spotlight this post!  
Unread 01-05-2010, 16:42
jhersh jhersh is offline
National Instruments
AKA: Joe Hershberger
FRC #2468 (Appreciate)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
jhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond reputejhersh has a reputation beyond repute
Lightbulb Re: Unexpected results from Encoder::GetRate()

Quote:
Originally Posted by vamfun View Post
This is along the lines I was thinking. But it seems that we have to capture the complete register array before we start using the results or at least temporarily halt the interrupts while we do multiple register reads.
I.E Wouldn't this be a possible problem?
Code:
*/
INT32 Counter::Chris_Get()

{     
	INT32 cnt = m_counter->readOutput_Value(&status);
	
        bool dir = m_counter->readOutput_Direction(&status); 
//Couldn't the registers be different when we read dir vs the cnt read ??

        if(dir )  // Assume dir = 0 decrements count
     
	{ return value  ; } // if we haven't reversed then update count
        else 
       {  return value +1; } // else keep the count at last value
       
}
Yes... if you did it that way, you would have a small window for the register to change. However, that is why I put both in the same register. Same thing goes for the period, the count, and the stall information. All related; all in the same register.

If instead you did:

Code:
INT32 Counter::Chris_Get()
{
	//Now all the information is read in one register access!
	tCounter::tOutput output = m_counter->readOutput(&status);

	// dir = 0 decrements count
	if (output.Direction)
	{
		// if we haven't reversed then update count
		return output.Value;
	}
	else
	{
		// else keep the count at last value
		return output.Value + 1;
	}
       
}
Cheers!
-Joe
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[BB] An unexpected change in plans yodameister General Forum 22 01-12-2009 21:26
Inconsistent reading from encoder get rate rwood359 National Instruments LabVIEW and Data Acquisition 5 13-01-2009 19:10
Results from Drexel, thanks from 365. archiver 2001 1 24-06-2002 02:44
Results from GLR? archiver 2001 0 24-06-2002 02:44
results from regionals archiver 2000 0 23-06-2002 22:31


All times are GMT -5. The time now is 08:52.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi