Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Electrical (http://www.chiefdelphi.com/forums/forumdisplay.php?f=53)
-   -   Misbehaving encoders (http://www.chiefdelphi.com/forums/showthread.php?t=77372)

nathanww 14-05-2009 21:46

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?

Jared Russell 14-05-2009 22:04

Re: Misbehaving encoders
 
Quote:

Originally Posted by nathanww (Post 859481)
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?

Eugene Fang 14-05-2009 22:09

Re: Misbehaving encoders
 
Quote:

Originally Posted by Jared341 (Post 859495)
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)

Jared Russell 14-05-2009 22:13

Re: Misbehaving encoders
 
Quote:

Originally Posted by Pikat (Post 859499)
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.

nathanww 14-05-2009 22:31

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");
      }


Jared Russell 14-05-2009 22:44

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).

AustinSchuh 14-05-2009 23:52

Re: Misbehaving encoders
 
Quote:

Originally Posted by Jared341 (Post 859501)
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...

Steve_Alaniz 15-05-2009 01:58

Re: Misbehaving encoders
 
Quote:

Originally Posted by nathanww (Post 859510)
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

Tom Line 15-05-2009 09:38

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?" :o

NickE 15-05-2009 09:53

Re: Misbehaving encoders
 
Quote:

Originally Posted by nathanww (Post 859510)
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?

Steve_Alaniz 15-05-2009 11:31

Re: Misbehaving encoders
 
Quote:

Originally Posted by Steve_Alaniz (Post 859548)

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

Jared Russell 15-05-2009 11:57

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.

Alan Anderson 15-05-2009 12:02

Re: Misbehaving encoders
 
Quote:

Originally Posted by nathanww (Post 859510)
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?

Jared Russell 15-05-2009 12:06

Re: Misbehaving encoders
 
Yes, Get() returns an INT32.

nathanww 15-05-2009 13:44

Re: Misbehaving encoders
 
1 Attachment(s)
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.


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

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