View Single Post
  #76   Spotlight this post!  
Unread 01-05-2010, 14:54
vamfun vamfun is offline
Mentor :Contol System Engineer
AKA: Chris
FRC #0599 (Robodox)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 2003
Location: Van Nuys, California
Posts: 182
vamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of lightvamfun is a glorious beacon of light
Send a message via AIM to vamfun
Re: Unexpected results from Encoder::GetRate()

Quote:
Originally Posted by jhersh View Post
BTW, you can get the same results that you get with your algorithm by simply adding 1 to the distance if direction is false with the built-in counter and you don't need any of that fancy stuff.

-Joe
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 value ;

	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
       
}
Quote:
But it will be worse! ;
Beauty is in the eye of the beholder. I'm pretty happy with the money I'm saving with my hysteresis thermostat even thought the temperature varies a little. All I have to do is figure out a way to connect an encoder to a bi-metalic coil and then hook it to my heater control

Last edited by vamfun : 01-05-2010 at 16:39.
Reply With Quote