Go to Post Okay, Okay, I officially apologize to the the entire country of Canada - Joe Johnson [more]
Home
Go Back   Chief Delphi > Technical > Electrical
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-05-2009, 21:46
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
Misbehaving encoders

Hey guys,
We've been trying to retrofit our Lunacy bot with quadrature encoders so that we can use it for some off-season projects. Unfortunately, the encoders are not cooperating with our plans. Disconnected from the robot, we can apparently read the shift in values from the encoder--but the robot's program doesn't seem capable of reading them(we checked to make sure we were using the right ports, actually starting the encoders, etc)

So, basically what we have is a situation where the robot's digital inputs are not reading the shifts. Our theory is that both the encoder HIGH and the encoder LOW signals are falling on the same side of the HIGH/LOW division when the robot reads it, so it can't pick up the pulse modulation. Does this make sense? Or is there something else that could cause this?
__________________
Get yer robot source code here!
  #2   Spotlight this post!  
Unread 14-05-2009, 22:04
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Misbehaving encoders

Quote:
Originally Posted by nathanww View Post
Hey guys,
We've been trying to retrofit our Lunacy bot with quadrature encoders so that we can use it for some off-season projects. Unfortunately, the encoders are not cooperating with our plans. Disconnected from the robot, we can apparently read the shift in values from the encoder--but the robot's program doesn't seem capable of reading them(we checked to make sure we were using the right ports, actually starting the encoders, etc)

So, basically what we have is a situation where the robot's digital inputs are not reading the shifts. Our theory is that both the encoder HIGH and the encoder LOW signals are falling on the same side of the HIGH/LOW division when the robot reads it, so it can't pick up the pulse modulation. Does this make sense? Or is there something else that could cause this?
The theory you are describing (that you aren't reading the encoders fast enough and that they are going HIGH->LOW->HIGH so fast you don't see the "LOW" part) is known as aliasing. The Shannon-Nyquist Theorem basically states that you need to sample at least twice as fast as the highest frequency in your input in order not to miss anything. However, I don't think that's the case here, as the cRIO reads the encoder signal at many tens of KHz; you'd have to be spinning your encoder at a blazing speed to hit that.

It's more likely that it's a wiring or programming problem.

What kind of encoder are you using?

How is it currently wired?

Are you using LabView or C++, and what encoder code are you using?
  #3   Spotlight this post!  
Unread 14-05-2009, 22:09
Eugene Fang's Avatar
Eugene Fang Eugene Fang is offline
The Blue Alliance
no team
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Bay Area, CA -> Pittsburgh, PA
Posts: 769
Eugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond repute
Re: Misbehaving encoders

Quote:
Originally Posted by Jared341 View Post
The theory you are describing (that you aren't reading the encoders fast enough and that they are going HIGH->LOW->HIGH so fast you don't see the "LOW" part) is known as aliasing. The Shannon-Nyquist Theorem basically states that you need to sample at least twice as fast as the highest frequency in your input in order not to miss anything. However, I don't think that's the case here, as the cRIO reads the encoder signal at many tens of KHz; you'd have to be spinning your encoder at a blazing speed to hit that.
What if you're using VEX encoders, which, according to IFI's website, can only count properly up to 1000 rpm (it might be 1000 clicks per second, i can't remember off the top of my head. either way, there seems to be a limit)
__________________
Eugene Fang
2010 Silicon Valley Regional Dean's List Finalist

Various FLL Teams - Student (2000-2006), Mentor (2007-2010)
FRC Team 604 - Student (2007-2010), Mentor/Remote Advisor (2011-2015)
FRC Team 1323 - Mentor/Remote Advisor (2011-2014)

The Blue Alliance | TBA GameDay | TBA Android App
  #4   Spotlight this post!  
Unread 14-05-2009, 22:13
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Misbehaving encoders

Quote:
Originally Posted by Pikat View Post
What if you're using VEX encoders, which, according to IFI's website, can only count properly up to 1000 rpm (it might be 1000 clicks per second, i can't remember off the top of my head. either way, there seems to be a limit)
That's a good point - many types of encoders (particularly those with bearings, and especially sleeve bearings) can fail mechanically long before they hit the Nyquist rate. Or an encoder might have additional filtering circuitry that rejects pulses that are too short (the wording of the Vex encoder Inventor's guide implies that this is the case).

But if hand-turning an encoder on the benchtop produces a square wave and hand-turning the encoder at a similar speed with the cRIO does not, this probably isn't the issue.

Last edited by Jared Russell : 14-05-2009 at 22:15.
  #5   Spotlight this post!  
Unread 14-05-2009, 23:52
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: 802
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: Misbehaving encoders

Quote:
Originally Posted by Jared341 View Post
That's a good point - many types of encoders (particularly those with bearings, and especially sleeve bearings) can fail mechanically long before they hit the Nyquist rate.
I don't have the specs for the digital input module on me, but I seem to remember that a 256 count encoder attached directly to a CIM was about at the limit. 971 had a 64 count/rev encoder attached to the cim output shaft, and that worked fine. I think the cRIO module has a rated refresh rate of something around 7 us, which would translate to 14,290 samples/second. I ran the math ~6 months ago...
  #6   Spotlight this post!  
Unread 14-05-2009, 22:31
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
Re: Misbehaving encoders

Quote:
The theory you are describing (that you aren't reading the encoders fast enough and that they are going HIGH->LOW->HIGH so fast you don't see the "LOW" part) is known as aliasing.
Actually, the theory that I was referring to was that there wasn't enough difference between the voltage that the encoder sends for HIGH and what it sends for LOW. When we looked at this, it didn't really seem to actually touch either extreme of max/min--so we thought that it might be possible that the control system wasn't seeing these small differences because both the HIGH and LOW fall into what it considers HIGH.


Quote:
What kind of encoder are you using?
It's the US digital kit encoder

Quote:
How is it currently wired?
Each encoder's A and B outputs are wired to the signal in on the digital sidecar. We also use the power and ground on one PWM for those connections on the encoder
[/quote]

Quote:
Are you using LabView or C++, and what encoder code are you using?
We're using C++, which is

Code:
	Encoder *encoder1;
***more declarations******
encoder1=new Encoder(2,3,false,Encoder::k4X);
*****more config stuff********
void RobotInit(void) {
encoder1->Start();
encoder1->SetDistancePerPulse(100); //values are completely arbitary
encoder1->SetMinRate(1);
*****the rest of the init, now in the teleop periodic*****

printf("encoder1=%d",encoder1->Get());
    if (encoder1->GetStopped()) {
		printf("encoder stopped");
       }
__________________
Get yer robot source code here!
  #7   Spotlight this post!  
Unread 14-05-2009, 22:44
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Misbehaving encoders

Do you remember the exact voltages you were seeing for high and low? They should be close (within a volt, for sure) to 5V and 0V, respectively. Are you sure you saw the change on *both* encoder outputs?

Your code looks good. You could try changing the decoding type to Encoder::k1X and seeing if that changes anything. Then try hot swapping DI 2 and 3 and seeing if you get anything (this forces the cRIO to only examine one channel at a time).
  #8   Spotlight this post!  
Unread 15-05-2009, 01:58
Steve_Alaniz Steve_Alaniz is offline
Registered User
FRC #2848 (All Sparks)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 1997
Location: Dallas
Posts: 211
Steve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond repute
Re: Misbehaving encoders

Quote:
Originally Posted by nathanww View Post
Actually, the theory that I was referring to was that there wasn't enough difference between the voltage that the encoder sends for HIGH and what it sends for LOW. When we looked at this, it didn't really seem to actually touch either extreme of max/min--so we thought that it might be possible that the control system wasn't seeing these small differences because both the HIGH and LOW fall into what it considers HIGH.



It's the US digital kit encoder


Each encoder's A and B outputs are wired to the signal in on the digital sidecar. We also use the power and ground on one PWM for those connections on the encoder


[/quote]

First of all, the encoders will send a 0 - 5 V or NEARLY a 0-5V square wave from both A and B channels. So there's no way that theory could be correct... unless you made a mistake building the quad system or the US digital unit is defective. Since you didn't build it and US Digital is primo stuff, both are unlikely. Although I DID have my very first failed USDigital device this year.
You need an o'scope to properly look at the signals for A and B and as I said, they SHOULD be a square wave 90 degrees out of phase with each other. ( At VERY high speeds there might not be time for the signal to drop to 0 or rise to 5 but you didn't say anything that might make me think that is a possibility.)
You said you are using a PWM for power to the encoders? Do you have a jumper on the 6V enable pins for that PWM? Sorry if that seems rudimentary but it a simple mistake that even I... <ahem> .. could POSSIBLY make... in a bizarre set of circumstances... not actually admitting anything you understand.

Steve

Last edited by Steve_Alaniz : 15-05-2009 at 02:11. Reason: spelling
  #9   Spotlight this post!  
Unread 15-05-2009, 09:38
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,521
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Misbehaving encoders

"Why aren't the camera servo's moving?"

2 hours of trouble shooting later: "Guys.... we don't have 5 volt power to the servos. Anyone want to guess why?"
  #10   Spotlight this post!  
Unread 15-05-2009, 11:31
Steve_Alaniz Steve_Alaniz is offline
Registered User
FRC #2848 (All Sparks)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 1997
Location: Dallas
Posts: 211
Steve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond reputeSteve_Alaniz has a reputation beyond repute
Re: Misbehaving encoders

Quote:
Originally Posted by Steve_Alaniz View Post

You said you are using a PWM for power to the encoders? Do you have a jumper on the 6V enable pins for that PWM?

Steve

Oh wait... scratch that... you said PWM but you probably meant GPIO ports. (I just remembered PWMs are output ports only.) GPIOs have 5V continuously available. So you should have 5V present and they have internal 5V pull up resistors, so the signal should be clean.
Unless you damaged the encoder wheel installing it, this suspiciously looks like a software glitch. Still before doing any software stuff, you really need to look at the "signal in" levels with an o'scope or in a pinch a multimeter will work ( just to prove you get level changes).
I need to read these posts with greater care.

Steve

Last edited by Steve_Alaniz : 15-05-2009 at 11:40. Reason: spelling
  #11   Spotlight this post!  
Unread 15-05-2009, 11:57
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Misbehaving encoders

When you are powering your encoder from your cRIO you should see the red LED inside the encoder housing turn on. Make sure that this is the case.
  #12   Spotlight this post!  
Unread 15-05-2009, 09:53
NickE's Avatar
NickE NickE is offline
_
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Mar 2008
Rookie Year: 2008
Location: San Jose, CA
Posts: 620
NickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond reputeNickE has a reputation beyond repute
Re: Misbehaving encoders

Quote:
Originally Posted by nathanww View Post
Each encoder's A and B outputs are wired to the signal in on the digital sidecar. We also use the power and ground on one PWM for those connections on the encoder
The A and B outputs are wired to two separate digital inputs, correct?
  #13   Spotlight this post!  
Unread 15-05-2009, 12:02
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Misbehaving encoders

Quote:
Originally Posted by nathanww View Post
Each encoder's A and B outputs are wired to the signal in on the digital sidecar. We also use the power and ground on one PWM for those connections on the encoder
The encoder has four connections. Can you detail precisely where each of those connections is going? I hope you aren't really using PWM outputs for power.

How do you know the robot isn't reading the encoder properly?

Quote:
Code:
printf("encoder1=%d",encoder1->Get());
I didn't use C++ this season, and I don't have the documentation handy, so I don't know if %d is what you want. Doesn't the Get() method return a long integer?
  #14   Spotlight this post!  
Unread 15-05-2009, 12:06
Jared Russell's Avatar
Jared Russell Jared Russell is offline
Taking a year (mostly) off
FRC #0254 (The Cheesy Poofs), FRC #0341 (Miss Daisy)
Team Role: Engineer
 
Join Date: Nov 2002
Rookie Year: 2001
Location: San Francisco, CA
Posts: 3,078
Jared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond reputeJared Russell has a reputation beyond repute
Re: Misbehaving encoders

Yes, Get() returns an INT32.
  #15   Spotlight this post!  
Unread 15-05-2009, 13:44
nathanww nathanww is offline
Hacker
FRC #1678 (Citrus Circuits)
Team Role: Programmer
 
Join Date: Dec 2008
Rookie Year: 2007
Location: Davis, CA
Posts: 224
nathanww is just really nicenathanww is just really nicenathanww is just really nicenathanww is just really nice
Re: Misbehaving encoders

Quote:
The encoder has four connections. Can you detail precisely where each of those connections is going? I hope you aren't really using PWM outputs for power.

How do you know the robot isn't reading the encoder properly?
"PWM" here is referring to the cable we've spliced to, not the output on the digital sidecar

I sketched out a diagram of eaxctly how it's set up and attached it.

We know the robot isn't reading the encoder because the value from Get() never changes, and the robot always reports that it is stopped, even when moving

Quote:
When you are powering your encoder from your cRIO you should see the red LED inside the encoder housing turn on. Make sure that this is the case.
Yep--we saw this, and when we checked it with a multimeter(we don't have an o-scope), we saw fluctuation in values--it just seems that the robot isn't interpreting it correctly.
Attached Thumbnails
Click image for larger version

Name:	encoder schematic.GIF
Views:	61
Size:	4.5 KB
ID:	7946  
__________________
Get yer robot source code here!
Closed Thread


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
Encoders..... manderson5192 Programming 4 07-02-2008 10:10
encoders benjamin1748 Programming 6 07-02-2007 22:37
Encoders Ctx32 Programming 8 13-05-2006 23:54
3 Encoders stephenthe1 Programming 5 17-11-2005 19:21
encoders stephenthe1 Programming 61 09-02-2005 15:05


All times are GMT -5. The time now is 12:21.

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