|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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");
}
|
|
#2
|
|||||
|
|||||
|
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). |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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?" ![]() |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||||
|
|||||
|
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.
|
|
#7
|
||||
|
||||
|
Re: Misbehaving encoders
The A and B outputs are wired to two separate digital inputs, correct?
|
|
#8
|
|||||
|
|||||
|
Re: Misbehaving encoders
Quote:
How do you know the robot isn't reading the encoder properly? Quote:
|
|
#9
|
|||||
|
|||||
|
Re: Misbehaving encoders
Yes, Get() returns an INT32.
|
|
#10
|
|||
|
|||
|
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:
|
|
#11
|
|||||
|
|||||
|
Re: Misbehaving encoders
Quote:
Everything looks correct to me. So the problem is either really obscure, or right under our noses. More ideas: 1. Are you sure you are using the correct port on the cRIO for the sidecar? Are you sure the sidecar is fully powered (12V power from the main breaker is necessary)? 2. Try commenting out the encoder code and instead creating DigitalInputs on the same two DIO lines. Call Get() on that and turn the encoder to make sure that you can at least see the two lines fluctuating. 3. Since you have a multimeter, verify that you are getting (close to) 0V and 5V on the Ch A and Ch B outputs as you rotate the powered encoder. |
|
#12
|
|||
|
|||
|
Re: Misbehaving encoders
Quote:
Sounds right. Are you doing this in Autonomous mode? We couldn't read our sensors in autonomous. They act like they never change. I wasn't involved with the software but The sensors worked in teleop mode so we proved they were working. Not sure what the problem was. They may not have been set up as global variables ... something like that. Steve |
|
#13
|
|||||
|
|||||
|
Re: Misbehaving encoders
You've shown three wires going to one thing, and one wire going to another. The sketch doesn't show which pins on those "things" the wires go to. If your labeling of the wires on the left matches the order they're connected to the GPIO pins, I think you have +5 and ground reversed.
|
|
#14
|
|||
|
|||
|
Re: Misbehaving encoders
Quote:
And yeah, we're running it in the teleop mode,and we have other sensors on the GPIO that work fine |
|
#15
|
|||||
|
|||||
|
Re: Misbehaving encoders
Quote:
An actual photograph of your wiring would help a lot at this point. So would a good closeup of how you have the encoder disk attached. Your code looks fine to me (except for a nagging worry about using the %d format specifier with a long integer). |
![]() |
| 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 |