View Full Version : Encoder setDistancePerPulse()
kinganu123
25-01-2011, 20:40
So I hooked up our encoder and tried out both counter and encoder
all i essentially did was this:
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 (http://usdigital.com/products/E4P-360-250-D-D-D-B), so what should I set as the distance per pulse?
basicxman
25-01-2011, 22:31
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 (http://usdigital.com/products/E4P-360-250-D-D-D-B), 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
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.
//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
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/showthread.php?t=89257
kinganu123
31-01-2011, 12:14
We had this same problem too. The quick fix appears to be to construct the Encoder with a 2x encoding type, i.e.
//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
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
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.