|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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? ![]() |
|
#2
|
|||
|
|||
|
Re: Two of Five encoders are giving identical values
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.
![]() |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
||||||
|
||||||
|
Re: Two of Five encoders are giving identical values
From the Programming Guide:
Quote:
Code:
//TODO: need to check for errors here |
|
#5
|
||||
|
||||
|
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:
|
|
#6
|
||||
|
||||
|
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?? |
|
#7
|
|||||
|
|||||
|
Re: Two of Five encoders are giving identical values
Quote:
Code:
CounterBase::k1X CounterBase::k2X CounterBase::k4X |
|
#8
|
||||
|
||||
|
Re: Two of Five encoders are giving identical values
Ken, I really appreciate your insight. Thanks.
|
|
#9
|
|||
|
|||
|
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 |
|
#10
|
|||||
|
|||||
|
Re: Two of Five encoders are giving identical values
Quote:
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... |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |