Go to Post I want to take a moment to thank every single FIRST mentor on behalf of all the FIRSTers (students) out there, for giving us the best we can get. - Arefin Bari [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 25-01-2011, 20:40
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
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?
__________________
Reply With Quote
  #2   Spotlight this post!  
Unread 25-01-2011, 22:31
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: Encoder setDistancePerPulse()

Quote:
Originally Posted by kinganu123 View Post
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.
Reply With Quote
  #3   Spotlight this post!  
Unread 27-01-2011, 02:11
el-zoroo el-zoroo is offline
Chief Operating Officer
AKA: Zuhair
FRC #2374 (Crusaderbots)
Team Role: Leadership
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Beaverton, OR
Posts: 13
el-zoroo is an unknown quantity at this point
Re: Encoder setDistancePerPulse()

Quote:
Originally Posted by kinganu123 View Post
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!
Reply With Quote
  #4   Spotlight this post!  
Unread 27-01-2011, 09:44
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Encoder setDistancePerPulse()

Quote:
Originally Posted by el-zoroo View Post
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
Reply With Quote
  #5   Spotlight this post!  
Unread 31-01-2011, 12:14
kinganu123 kinganu123 is offline
Registered User
FRC #1747
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Piscataway, NJ
Posts: 243
kinganu123 is on a distinguished road
Re: Encoder setDistancePerPulse()

Quote:
Originally Posted by el-zoroo View Post
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?
__________________

Last edited by kinganu123 : 31-01-2011 at 12:32.
Reply With Quote
  #6   Spotlight this post!  
Unread 31-01-2011, 18:10
el-zoroo el-zoroo is offline
Chief Operating Officer
AKA: Zuhair
FRC #2374 (Crusaderbots)
Team Role: Leadership
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Beaverton, OR
Posts: 13
el-zoroo is an unknown quantity at this point
Re: Encoder setDistancePerPulse()

Quote:
Originally Posted by kinganu123 View Post
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
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 09:10.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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