View Single Post
  #28   Spotlight this post!  
Unread 11-04-2010, 21:16
Bigcheese Bigcheese is offline
C++0x FTW!
AKA: Michael Spencer
FRC #1771
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2008
Location: GA
Posts: 36
Bigcheese is a jewel in the roughBigcheese is a jewel in the roughBigcheese is a jewel in the roughBigcheese is a jewel in the rough
Re: Unexpected results from Encoder::GetRate()

Ok, I finally have good data. First, I edited Encoder.cpp, here's the diff.

Code:
Index: Encoder.cpp
===================================================================
--- Encoder.cpp	(revision 2130)
+++ Encoder.cpp	(working copy)
@@ -258,7 +258,7 @@
 {
 	if (m_counter)
 	{
-		return m_counter->GetPeriod() * DecodingScaleFactor();
+		return m_counter->GetPeriod() / DecodingScaleFactor();
 	}
 	else
 	{
@@ -275,7 +275,7 @@
 			value = (double)output.Period / (double)output.Count;
 		}
 		wpi_assertCleanStatus(status);
-		return value * 1.0e-6  / (DecodingScaleFactor() * 4.0);
+		return value * 1.0e-6 / DecodingScaleFactor();
 	}
 }
 
@@ -380,7 +380,7 @@
  */
 double Encoder::GetRate()
 {
-	return m_distancePerPulse / GetPeriod() * (GetDirection() ? 1.0 : -1.0);
+	return (m_distancePerPulse / GetPeriod() * (GetDirection() ? 1.0 : -1.0)) / 2;
 }
 
 /**
The following data is in 1x and 2x mode. I didn't do a 4x test.

https://spreadsheets.google.com/ccc?...0JZe UE&hl=en

Looks perfect to me
Reply With Quote