Go to Post Students can learn to drive on whatever they give us. Ramps, carpet, grating, HDPE, lexan, diamond plate, regolith, other robots the driver station wall, referees, stairs, Dean, the bar, goals, the scorer's table, you name it, I've watched robots somehow manage to drive on it - Peter Matteson [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-02-2009, 21:20
Analog's Avatar
Analog Analog is offline
Registered User
AKA: Bob Most
FRC #2619 (The Charge)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Midland, Michigan
Posts: 53
Analog will become famous soon enoughAnalog will become famous soon enough
Two of Five encoders are giving identical values

We've got an encoder on every wheel and one for steering. We noticed that two of the five encoders return the exact same value. It is not a hardware issue, as we have isolated each one by physically unplugging them etc. It seems the software sees them as the same, even though they are declared and started separately.

In addition, we can 'control' which two mimic each other. Its always the first and the last in the code where they are declared. We verified this by rotating the declaration list, and sure enough, they followed each other - which further confirms that it has nothing to do with the hardware.

Any ideas?
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2009, 02:59
TimCraig TimCraig is offline
Registered User
AKA: Tim Craig
no team
 
Join Date: Aug 2004
Rookie Year: 2003
Location: San Jose, CA
Posts: 221
TimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to beholdTimCraig is a splendid one to behold
Re: Two of Five encoders are giving identical values

Quote:
Originally Posted by Analog View Post
Any ideas?
I wasn't able to find exactly why it's happening without really digging, but I'd guess from some of the code in ChipObject\tEncoder.h that there's a limit of 4 encoders built into the system. If you look at the #defines at the bottom of the file, they go from Encoder0 through Encoder4. My guess is that since it's the first and last that you get reading the same value, that when you try to add the 5th encoder to the system, you get a "wrap around" situation and it replaces the first one and the instances of Encoder that you're holding in your code representing the first and fifth end up pointing to the same underlying I/O points. It appears to have something to do with kNumSystems but I can't find where a value is assigned to this. I guess we're not privy to the source for those modules and only have the compiled version in the library and the class in the header is our portal. Makes debugging a bit hard.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-02-2009, 03:54
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 803
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: Two of Five encoders are giving identical values

I was talking with Brad Miller last night, and there is a 4 encoder limit. With the newest version of WPILib though, there is an optional parameter you can pass to the constructor that will let you have more than 4 encoders.

The parameter is "EncodingType encodingType". The documentation in Encoder.cpp is pretty good in this respect and from it you will be able to figure out the side effects of initializing an encoder with the k1X or k2X flags instead of the default k4X flags.
Reply With Quote
  #4   Spotlight this post!  
Unread 06-02-2009, 12:31
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: 8,572
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: Two of Five encoders are giving identical values

From the Programming Guide:

Quote:
There are four QuadratureEncoder modules in the FPGA and 8 Counter modules that can operate as quadrature encoders. One of the differences between the encoder and counter hardware is that encoders can give an oversampled 4X count using all 4 edges of the input signal. Counters can either return a 1X or 2X result based on one of the input signals. If 1X or 2X is chosen in the Encoder constructor a Counter module is used with lower oversampling and if 4X (default) is chosen, then one of the four encoders is used.
The LabVIEW encoder open will return an error if you try to allocate more then 4 encoders (with 4x). In the C++ Encoder::InitEncoder, there is a comment that says
Code:
//TODO: need to check for errors here
Reply With Quote
  #5   Spotlight this post!  
Unread 06-02-2009, 15:25
M.Rehberg's Avatar
M.Rehberg M.Rehberg is offline
Registered User
AKA: Mike Rehberg
FRC #2619 (The Charge)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Michigan
Posts: 11
M.Rehberg is an unknown quantity at this point
Re: Two of Five encoders are giving identical values

Our development systems have update 3, however when we try to use the "k4X", or "k2X". The compiler returns the following error:

Quote:
C:/WindRiver/workspace/Encoders/encoders and gyro.cpp:35: error: `k2X' undeclared (first use this function)
Reply With Quote
  #6   Spotlight this post!  
Unread 06-02-2009, 20:18
M.Rehberg's Avatar
M.Rehberg M.Rehberg is offline
Registered User
AKA: Mike Rehberg
FRC #2619 (The Charge)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Michigan
Posts: 11
M.Rehberg is an unknown quantity at this point
Re: Two of Five encoders are giving identical values

Looking into this further it seems that the WPILib has added this parameter (k1X, k2X, k4X) to CouterBase.h, Encoder.cpp, and Encoder.h. However I don't see it in /ChipObject/tEncoder.h

What are we missing here??
Reply With Quote
  #7   Spotlight this post!  
Unread 07-02-2009, 00:22
Ken Streeter's Avatar
Ken Streeter Ken Streeter is offline
Let the MAYHEM begin!
FRC #1519 (Mechanical Mayhem)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Team: Milford, NH; Me: Bedford, NH
Posts: 471
Ken Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond repute
Re: Two of Five encoders are giving identical values

Quote:
Originally Posted by M.Rehberg View Post
Our development systems have update 3, however when we try to use the "k4X", or "k2X". The compiler returns the following error:
This is a scoping issue. We found that we needed to qualify the constant with the class where it is declared. I suggest using one of the following:
Code:
  CounterBase::k1X
  CounterBase::k2X
  CounterBase::k4X
--ken
__________________
Ken Streeter - Team 1519 - Mechanical Mayhem (Milford Area Youth Homeschoolers Enriching Minds)
2015 NE District Winners with 195 & 2067, 125 & 1786, 230 & 4908, and 95 & 1307
2013 World Finalists & Archimedes Division Winners with 33 & 469
2013 & 2012 North Carolina Regional Winners with teams 435 & 4828 and 1311 & 2642
2011, 2010, 2006 Granite State Regional Winners with teams 175 & 176, 1073 & 1058, and 1276 & 133
Team 1519 Video Gallery - including Chairman's Video, and the infamous "Speed Racer!"
Reply With Quote
  #8   Spotlight this post!  
Unread 08-02-2009, 16:21
Analog's Avatar
Analog Analog is offline
Registered User
AKA: Bob Most
FRC #2619 (The Charge)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Midland, Michigan
Posts: 53
Analog will become famous soon enoughAnalog will become famous soon enough
Re: Two of Five encoders are giving identical values

Quote:
Originally Posted by Ken Streeter View Post
This is a scoping issue. We found that we needed to qualify the constant with the class where it is declared. I suggest using one of the following:
Code:
  CounterBase::k1X
  CounterBase::k2X
  CounterBase::k4X
--ken
Ken, I really appreciate your insight. Thanks.
Reply With Quote
  #9   Spotlight this post!  
Unread 09-02-2009, 23:09
1jbinder 1jbinder is offline
Registered User
FRC #0852
 
Join Date: Jan 2008
Location: Athenian School
Posts: 35
1jbinder is an unknown quantity at this point
Re: Two of Five encoders are giving identical values

Thanks for this insight. I made the code work. When you have a second could you explain why we need to do this in our code, but the library does not have to in encoder.cpp

Thanks
Julian
Team 852
Reply With Quote
  #10   Spotlight this post!  
Unread 10-02-2009, 11:51
Ken Streeter's Avatar
Ken Streeter Ken Streeter is offline
Let the MAYHEM begin!
FRC #1519 (Mechanical Mayhem)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Team: Milford, NH; Me: Bedford, NH
Posts: 471
Ken Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond reputeKen Streeter has a reputation beyond repute
Re: Two of Five encoders are giving identical values

Quote:
Originally Posted by 1jbinder View Post
Thanks for this insight. I made the code work. When you have a second could you explain why we need to do this in our code, but the library does not have to in encoder.cpp
Encoder.cpp inherits from CounterBase, so variables and constants defined in CounterBase can be referenced from within the Encoder without the need for explicit namespace references.

Your code, however, was presumably in an object which was not inheriting from CounterBase, so the explicit references are needed so the compiler knows where to find the value for k1X, k2X, k4X, etc...
__________________
Ken Streeter - Team 1519 - Mechanical Mayhem (Milford Area Youth Homeschoolers Enriching Minds)
2015 NE District Winners with 195 & 2067, 125 & 1786, 230 & 4908, and 95 & 1307
2013 World Finalists & Archimedes Division Winners with 33 & 469
2013 & 2012 North Carolina Regional Winners with teams 435 & 4828 and 1311 & 2642
2011, 2010, 2006 Granite State Regional Winners with teams 175 & 176, 1073 & 1058, and 1276 & 133
Team 1519 Video Gallery - including Chairman's Video, and the infamous "Speed Racer!"
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Team Swag? What are you giving out? Moheeb698 General Forum 18 03-03-2008 12:56
Are two speed transmissions worth it? thefro526 Technical Discussion 43 19-04-2007 21:16
Why are four states needed with Quadratuer encoders? Issues Programming 14 11-11-2005 15:02
Acceleration Sensor Connected, but values are odd.... Leav Electrical 7 04-02-2005 15:28


All times are GMT -5. The time now is 14:53.

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