OCCRA
Go to Post Never allow your students to get away with an answer that amounts to "because it's better". Have them prove it to the best of their ability, and when they're wrong, ask them to figure out why they're wrong. - Tom Line [more]
Home
Go Back   Chief Delphi > Technical > Programming > WindRiver C++
CD-Events   CD-Media   CD-Spy   FRC-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-22-2012, 04:34 PM
trilogy2826's Avatar
trilogy2826 trilogy2826 is offline
Mentor - 2826
AKA: Jake Fischer
FRC #2826 (Wave Robotics)
Team Role: Mentor
 
Join Date: Nov 2008
Rookie Year: 2006
Location: Oshkosh, WI
Posts: 104
trilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond repute
Encoder function calls reporting inf

While attempting to improve our autonomous distance driving by employing a velocity based feedback control using the GetRate() function, we noticed that many of our encoder function calls to retrieve data are reporting inconsistent to our expectations.

GetDistance(): Works without flaw. Currently a mainstay in our autonomous code. This is our main reason to assume our encoder is connected properly

GetRate(): Reports 0(zero) no matter the speed of the encoder physically turning

GetPeriod(): Reports inf no matter the speed of the encoder physically turning. This is odd because this function is necessary for GetDistance() to work according to the encoder.c file

We are calibrating the encoder using SetDistancePerPulse()

We have one encoder per side of a WCD style drive, both side reporting the same.

Encoder sampling is not changed from the default 4X

Both A and B channels for both encoders are connected to the Side Car in ports 6,7,9 and 10 Slot 2 in a 4 slot cRio

All data is being viewed using a cout from the WTX console (currently our main method of debugging).

Thanks in advance for any help
Reply With Quote
  #2   Spotlight this post!  
Unread 04-22-2012, 05:28 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 6,039
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: Encoder function calls reporting inf

Quote:
Originally Posted by trilogy2826 View Post
GetPeriod(): Reports inf no matter the speed of the encoder physically turning. This is odd because this function is necessary for GetDistance() to work according to the encoder.c file
GetDistance does not use GetPeriod(). It uses GetRaw()

Code:
/**
 * Get the distance the robot has driven since the last reset.
 * 
 * @return The distance driven since the last reset as scaled by the value from SetDistancePerPulse().
 */
double Encoder::GetDistance()
{
	if (StatusIsFatal()) return 0.0;
	return GetRaw() * DecodingScaleFactor() * m_distancePerPulse;
}
Reply With Quote
  #3   Spotlight this post!  
Unread 04-22-2012, 06:14 PM
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: Encoder function calls reporting inf

Quote:
Originally Posted by trilogy2826 View Post
GetRate(): Reports 0(zero) no matter the speed of the encoder physically turning

GetPeriod(): Reports inf no matter the speed of the encoder physically turning. This is odd because this function is necessary for GetDistance() to work according to the encoder.c file
Slightly backwards here. GetRate() is the one that requires GetPeriod() to work.

Somewhat hard to debug here, since almost all of the implementation for encoders is in the FPGA, and I haven't seen this before. Still, my hunch is that one of the two encoder lines is not connected/assigned properly. GetDistance() probably works because it is counting off the one good line, but since the other line never fires, a full period is never seen. GetPeriod() returns inf whenever the period is over a certain threshold (side note - if anyone knows what that default threshold is, please tell me. I can't find it in any of the comments).

Also, if that is the problem, most likely when you fix it your distances will double.
__________________

"To have no errors would be life without meaning. No strugle, no joy"
"A network is only as strong as it's weakest linksys"

Last edited by Radical Pi : 04-22-2012 at 06:16 PM. Reason: add note at the end
Reply With Quote
  #4   Spotlight this post!  
Unread 04-22-2012, 06:51 PM
trilogy2826's Avatar
trilogy2826 trilogy2826 is offline
Mentor - 2826
AKA: Jake Fischer
FRC #2826 (Wave Robotics)
Team Role: Mentor
 
Join Date: Nov 2008
Rookie Year: 2006
Location: Oshkosh, WI
Posts: 104
trilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond repute
Re: Encoder function calls reporting inf

Quote:
Originally Posted by Radical Pi View Post
GetDistance() probably works because it is counting off the one good line, but since the other line never fires, a full period is never seen.
This makes a lot of sense. The confusing part about this theory is that the same output occurs on both encoders and on both robots (comp and practice) for a total of 4 encoders with identical failures. My next step will be to confirm that my channel assignments are correct. Thanks for pointing me in a sane direction.
Reply With Quote
  #5   Spotlight this post!  
Unread 04-22-2012, 06:57 PM
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 7,848
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Encoder function calls reporting inf

Are you calling SetMinRate ?
Reply With Quote
  #6   Spotlight this post!  
Unread 04-22-2012, 10:32 PM
trilogy2826's Avatar
trilogy2826 trilogy2826 is offline
Mentor - 2826
AKA: Jake Fischer
FRC #2826 (Wave Robotics)
Team Role: Mentor
 
Join Date: Nov 2008
Rookie Year: 2006
Location: Oshkosh, WI
Posts: 104
trilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond reputetrilogy2826 has a reputation beyond repute
Re: Encoder function calls reporting inf

Quote:
Originally Posted by Joe Ross View Post
Are you calling SetMinRate ?
We are not. I tried to find a reference of the default value and could not locate it. I can't even find a reference to the units this expects (I assume milliseconds). Any ideas?

Could any value for MinRate actually cause an inf as reported?
Reply With Quote
  #7   Spotlight this post!  
Unread 04-23-2012, 12:42 AM
Radical Pi Radical Pi is offline
Putting the Jumper in the Bumper
AKA: Ian Thompson
FRC #0639 (Code Red Robotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 655
Radical Pi has a spectacular aura aboutRadical Pi has a spectacular aura aboutRadical Pi has a spectacular aura about
Re: Encoder function calls reporting inf

Quote:
Originally Posted by trilogy2826 View Post
We are not. I tried to find a reference of the default value and could not locate it. I can't even find a reference to the units this expects (I assume milliseconds). Any ideas?

Could any value for MinRate actually cause an inf as reported?
If there's no use of it in the code, it probably isn't the problem. The default value has been fine for me in the past.

Units for it are the same as what come from GetRate(). Basically, if the value that would come out of GetRate falls below MinRate, the cRIO will assume the motor is stopped, set period to infinity, and rate to 0. The default is low enough though that you should be clearing the minimum by just spinning the shaft by hand though.
__________________

"To have no errors would be life without meaning. No strugle, no joy"
"A network is only as strong as it's weakest linksys"
Reply With Quote
Reply


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


All times are GMT -5. The time now is 06:22 AM.

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


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