|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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? |
|
#2
|
|||||
|
|||||
|
Re: Misbehaving encoders
Quote:
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
|
|||||
|
|||||
|
Re: Misbehaving encoders
Quote:
|
|
#4
|
|||||
|
|||||
|
Re: Misbehaving encoders
Quote:
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
|
||||
|
||||
|
Re: Misbehaving encoders
Quote:
Quote:
Quote:
[/quote] Quote:
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");
}
|
|
#6
|
|||||
|
|||||
|
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). |
|
#7
|
|||
|
|||
|
Re: Misbehaving encoders
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...
|
|
#8
|
|||
|
|||
|
Re: Misbehaving encoders
Quote:
[/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
|
||||
|
||||
|
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
|
||||
|
||||
|
Re: Misbehaving encoders
The A and B outputs are wired to two separate digital inputs, correct?
|
|
#11
|
|||
|
|||
|
Re: Misbehaving encoders
Quote:
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 |
|
#12
|
|||||
|
|||||
|
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.
|
|
#13
|
|||||
|
|||||
|
Re: Misbehaving encoders
Quote:
How do you know the robot isn't reading the encoder properly? Quote:
|
|
#14
|
|||||
|
|||||
|
Re: Misbehaving encoders
Yes, Get() returns an INT32.
|
|
#15
|
|||
|
|||
|
Re: Misbehaving encoders
Quote:
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:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |