Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Encoder setDistancePerPulse() (http://www.chiefdelphi.com/forums/showthread.php?t=90111)

kinganu123 25-01-2011 20:40

Encoder setDistancePerPulse()
 
So I hooked up our encoder and tried out both counter and encoder
all i essentially did was this:
Code:

roboInti{
sensor.start();
}
teleopPeriodic{
System.out.println(senser.getCount());
or
System.out.println(senser.getRate());
}

Now if I used a counter, I'd get crazy numbers. I'd run it for 5 seconds, and I'd get 448705 as my last number, which makes no sense.
If I used the getRate(), I get NaN
I'm assuming that I need to use setDistancePerPulse
I have the E4P, so what should I set as the distance per pulse?

basicxman 25-01-2011 22:31

Re: Encoder setDistancePerPulse()
 
Quote:

Originally Posted by kinganu123 (Post 1008359)
Now if I used a counter, I'd get crazy numbers. I'd run it for 5 seconds, and I'd get 448705 as my last number, which makes no sense.
If I used the getRate(), I get NaN
I'm assuming that I need to use setDistancePerPulse
I have the E4P, so what should I set as the distance per pulse?

Distance per pulse is something you set based on your wheel radius and other factors. The kit encoder this year is 1440 pulses per revolution (1440) thus 0.25 degrees per pulse.

el-zoroo 27-01-2011 02:11

Re: Encoder setDistancePerPulse()
 
Quote:

Originally Posted by kinganu123 (Post 1008359)
If I used the getRate(), I get NaN

We had this same problem too. The quick fix appears to be to construct the Encoder with a 2x encoding type, i.e.
Code:

//Assuming Encoder is connected to DIO 1 and 2 and not reversed
Encoder sensor = new Encoder(1,2,false,CounterBase.EncodingType.k2x)

I do not know if it is a bug with the WPILib. Maybe someone else can confirm.

Hope that helps! :)

Joe Ross 27-01-2011 09:44

Re: Encoder setDistancePerPulse()
 
Quote:

Originally Posted by el-zoroo (Post 1009508)
I do not know if it is a bug with the WPILib. Maybe someone else can confirm.

It's a bug in the fpga. http://www.chiefdelphi.com/forums/sh...ad.php?t=89257

kinganu123 31-01-2011 12:14

Re: Encoder setDistancePerPulse()
 
Quote:

Originally Posted by el-zoroo (Post 1009508)
We had this same problem too. The quick fix appears to be to construct the Encoder with a 2x encoding type, i.e.
Code:

//Assuming Encoder is connected to DIO 1 and 2 and not reversed
Encoder sensor = new Encoder(1,2,false,CounterBase.EncodingType.k2x)

I do not know if it is a bug with the WPILib. Maybe someone else can confirm.

Hope that helps! :)

This definitely helps, but i get weird numbers like 0.0.0054465 and .00045678
Any idea what it means?

UPDATE
nvm, I did a powercycle and i got better numbers
what are the units the encoder returns?

el-zoroo 31-01-2011 18:10

Re: Encoder setDistancePerPulse()
 
Quote:

Originally Posted by kinganu123 (Post 1012428)
what are the units the encoder returns?

The encoder returns distance per second. The exact units depend on what units you used in distancePerPulse(). I think you will have to divide the rate by 2 because of the 2x Encoding type.

Hope that helps :D


All times are GMT -5. The time now is 22:19.

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