View Single Post
  #13   Spotlight this post!  
Unread 13-04-2010, 17:00
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 Bigcheese View Post
Here's 4x decoding data with the same changes to Encoder.cpp as listed above.

http://spreadsheets.google.com/ccc?k...E1zX 2c&hl=en

And here's the relevant code for getting the data.



I agree that the problem is with the period returned by the FPGA.
Thanks for the code... both our encoders are broken so may not get to it for a while.

Question: What encoders did you use on left and right and what are the corresponding distances per pulse? The right encoder has a little less noise than the left.

I did a statistical analysis of your data and will post it soon.

If you still have the same set up and a little extra time, I'd love to see the 2x and 4x cases with the get rate averaged over 2 and 4 pulses respectively rather than the default single pulse. Please use the corresponding JAG speeds as in the original data sets. In case you aren't familiar with this:

The 2x is set in the counter.cpp InitCounter() line :
m_counter->writeTimerConfig_AverageSize(1, &status);
by changing to
m_counter->writeTimerConfig_AverageSize(2, &status);

Similarly, the 4x is set in the encoder.cpp InitEncoder() line:
m_encoder->writeTimerConfig_AverageSize(1, &status);
by changing to
m_encoder->writeTimerConfig_AverageSize(4, &status);

This would help mitigate the rate noise if people insist on using 2x and 4x encoder modes. I would like this to be the default configurations. If you run the cases Ill add it to the statistical analysis and post it also. It would be a nice reference for future First teams making this decision.

If you can't do it, I certainly understand. Thanks

By the way, last year Joe H and I had a thread on moving average : http://forums.usfirst.org/showthread...8143#post28143. Our team added a function to the Encoder.cpp that allows you to do this in your robot init code similar to SetDistancePerPulse(). Eventually, I hope the WPI guys incorporate this capability.
Code:
void SetMovingAveragePulseCount(int max_count)
{ //check if 1=<max_count<=127 TODO: should throw an error flag here with message if max_count invalid
if (max_count<1) max_count = 1;
else if (max_count>127) max_count = 127;
if(m_counter)
m_counter->m_counter->writeTimerConfig_AverageSize(max_count, &status); // Counter object within Encoder -> tCounter within Counter
else
m_encoder->writeTimerConfig_AverageSize(max_count, &status);
}

Last edited by vamfun : 13-04-2010 at 17:08.
Reply With Quote