Go to Post So remember, no matter what the odds, your wildest dreams can come true with science and technology. - Ian Curtis [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 15-10-2013, 11:23
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Encoders Programming

Hello my name is David and I'm tge lead programmer for FRC Team 4780 and I was wondering if anyone could tell me how to programm the 2013 KOP quadrature encoders.
Reply With Quote
  #2   Spotlight this post!  
Unread 15-10-2013, 11:38
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 434
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Encoders Programming

Everything covered in your other thread is directly applicable.
http://www.chiefdelphi.com/forums/sh...d.php?t=119184
__________________
http://team2168.org
Reply With Quote
  #3   Spotlight this post!  
Unread 15-10-2013, 13:19
Domenic Rodriguez's Avatar
Domenic Rodriguez Domenic Rodriguez is offline
Registered User
FRC #0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Sep 2010
Rookie Year: 2011
Location: Grove City, PA
Posts: 213
Domenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura about
Re: Encoders Programming

Also you should check out the Javadoc page for the Encoder class. If you weren't aware, you can find the Javadoc for WPILib at 'C:\Users\username\sunspotfrcsdk\doc\javadoc\index.html' on any computer set up for Java development. Alternatively, here's a link to a copy on the web. Particularly note the Encoder#get() and Encoder#getRate() methods, which give you the position and the rotation rate of the encoder respectively.
__________________

LuNaTeCs - Learning Under Nurturing Adults Teaching Engineering Concepts and Skills - Small and Mighty!

FRC 316 LuNaTeCs - Student (2011-2014), Lead Programmer (2011-2014), Team Captain (2013-2014), Operator (2013), Drive Coach (2014), Mentor (2015-????)
'11 Philly Regional Finalists, '13 Chestnut Hill Finalists, '13 Lenape Champions, '13 Archimedes Division, '14 Chestnut Hill Champions, '14 Lenape Champions
FTC 7071 EngiNerds - Founding Advisor (2013-2014) | FRC 5420 Velocity - Founding Advisor (2015)
Grove City College Class of '18, Electrical/Computer Engineering (B.S.E.E)

Reply With Quote
  #4   Spotlight this post!  
Unread 15-10-2013, 13:38
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Encoders Programming

Quote:
Originally Posted by TenaciousDrones View Post
I was wondering if anyone could tell me how to programm the 2013 KOP quadrature encoders.
It depends on where the encoder is located (e.g. drive wheel gearbox, frisbee shooter wheel, etc) and what you are trying to accomplish with the signal (e.g. track distance in autonomous, control wheel speed, etc).


Reply With Quote
  #5   Spotlight this post!  
Unread 30-10-2013, 08:46
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: Encoders Programming

Im using them on the Toughbox Mini (am-0654) to track distance in autonomous.

Last edited by TenaciousDrones : 30-10-2013 at 08:53.
Reply With Quote
  #6   Spotlight this post!  
Unread 30-10-2013, 08:53
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: Encoders Programming

Hey so I've been trying to get the encoders programmed on the Toughbox Mini (am-0654) but have been running into a problem. Everytime I get a distance from the encoders it goes from 0.3 to 0.0, any suggestions?

public void takeJoystickInputs(Joystick right) {
SmartDashboard.putData("Left Encoder Distance", leftEncoder);
SmartDashboard.putData("Right Encoder Distance", rightEncoder);
if ((36+((leftEncoder.getDistance()+ -rightEncoder.getDistance())/2)) > 0) {robotDrive2.arcadeDrive(right.getY(), -right.getX());}
else robotDrive2.drive(0, 0);
//robotDrive2.arcadeDrive(right.getY(), -right.getX());
}
Reply With Quote
  #7   Spotlight this post!  
Unread 30-10-2013, 09:50
Domenic Rodriguez's Avatar
Domenic Rodriguez Domenic Rodriguez is offline
Registered User
FRC #0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Sep 2010
Rookie Year: 2011
Location: Grove City, PA
Posts: 213
Domenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura about
Re: Encoders Programming

Quote:
Originally Posted by TenaciousDrones View Post
Hey so I've been trying to get the encoders programmed on the Toughbox Mini (am-0654) but have been running into a problem. Everytime I get a distance from the encoders it goes from 0.3 to 0.0, any suggestions?

Code:
public void takeJoystickInputs(Joystick right) {
    SmartDashboard.putData("Left Encoder Distance", leftEncoder);
    SmartDashboard.putData("Right Encoder Distance", rightEncoder);
    if ((36+((leftEncoder.getDistance()+ -rightEncoder.getDistance())/2)) > 0) {
        robotDrive2.arcadeDrive(right.getY(), -right.getX());
    } else robotDrive2.drive(0, 0);
        //robotDrive2.arcadeDrive(right.getY(), -right.getX());
}
Check the wiring of the encoders/PWMs. I know that my team has had similar issues when the PWM cables were plugged in backwards.

Also note that using the Encoder#getDistance() method requires you to have set a distance with Encoder#setDistancePerPulse(double). If you didn't set this value, you will be getting inaccurate readings. Assuming the encoders are 360 pulses/revolution (which the kit E4Ps should be), the number you need is just the distance your robot travels in one encoder revolution divided by 360.
__________________

LuNaTeCs - Learning Under Nurturing Adults Teaching Engineering Concepts and Skills - Small and Mighty!

FRC 316 LuNaTeCs - Student (2011-2014), Lead Programmer (2011-2014), Team Captain (2013-2014), Operator (2013), Drive Coach (2014), Mentor (2015-????)
'11 Philly Regional Finalists, '13 Chestnut Hill Finalists, '13 Lenape Champions, '13 Archimedes Division, '14 Chestnut Hill Champions, '14 Lenape Champions
FTC 7071 EngiNerds - Founding Advisor (2013-2014) | FRC 5420 Velocity - Founding Advisor (2015)
Grove City College Class of '18, Electrical/Computer Engineering (B.S.E.E)

Reply With Quote
  #8   Spotlight this post!  
Unread 30-10-2013, 12:43
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: Encoders Programming

Hey so I've been trying to get the encoders programmed on the Toughbox Mini (am-0654) but have been running into a problem. Everytime I get a distance from the encoders it goes from 0.3 to 0.0, any suggestions?

public void takeJoystickInputs(Joystick right) {
SmartDashboard.putData("Left Encoder Distance", leftEncoder);
SmartDashboard.putData("Right Encoder Distance", rightEncoder);
if ((36+((leftEncoder.getDistance()+ -rightEncoder.getDistance())/2)) > 0) {robotDrive2.arcadeDrive(right.getY(), -right.getX());}
else robotDrive2.drive(0, 0);
//robotDrive2.arcadeDrive(right.getY(), -right.getX());
}
Reply With Quote
  #9   Spotlight this post!  
Unread 30-10-2013, 14:04
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,102
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Encoders Programming

Quote:
Originally Posted by TenaciousDrones View Post
Hey so I've been trying to get the encoders programmed on the Toughbox Mini (am-0654) but have been running into a problem. Everytime I get a distance from the encoders it goes from 0.3 to 0.0, any suggestions?
Can you draw and post a sketch of how you have it wired? Or take a couple of pictures (preferably with your camera set to "macro").


Reply With Quote
  #10   Spotlight this post!  
Unread 30-10-2013, 15: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,590
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: Encoders Programming

Quote:
Originally Posted by TenaciousDrones View Post
Hey so I've been trying to get the encoders programmed on the Toughbox Mini (am-0654) but have been running into a problem. Everytime I get a distance from the encoders it goes from 0.3 to 0.0, any suggestions?
Can you show your constructor call for the LeftEncoder and RightEncoder object?

An encoder that toggles between 0 and another value is because the software is only reading a single channel, instead of both channels. This could be because of a wiring problem or a software initialization problem (as in you hooked channel A and B to DIO 1 and 2, but told the software to use DIO 2 and 3.

Switching A & B makes the encoder count in reverse, but still counts.
Reply With Quote
  #11   Spotlight this post!  
Unread 31-10-2013, 09:21
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: Encoders Programming

public void takeEncoderInputs() {
leftEncoder.start();
rightEncoder.start();
leftEncoder.setDistancePerPulse(18.84/1620);
rightEncoder.setDistancePerPulse(18.84/1620);
leftEncoder.getDistance();
rightEncoder.getDistance();
SmartDashboard.putData("Left Encoder Distance", leftEncoder);
SmartDashboard.putData("Right Encoder Distance", rightEncoder);
Reply With Quote
  #12   Spotlight this post!  
Unread 31-10-2013, 12:05
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,590
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: Encoders Programming

Quote:
Originally Posted by TenaciousDrones View Post
public void takeEncoderInputs() {
leftEncoder.start();
rightEncoder.start();
leftEncoder.setDistancePerPulse(18.84/1620);
rightEncoder.setDistancePerPulse(18.84/1620);
leftEncoder.getDistance();
rightEncoder.getDistance();
SmartDashboard.putData("Left Encoder Distance", leftEncoder);
SmartDashboard.putData("Right Encoder Distance", rightEncoder);
None of those are the constructor for leftEncoder or rightEncoder. Look for the part where you use new.
Reply With Quote
  #13   Spotlight this post!  
Unread 31-10-2013, 12:11
Domenic Rodriguez's Avatar
Domenic Rodriguez Domenic Rodriguez is offline
Registered User
FRC #0316 (LuNaTeCs)
Team Role: College Student
 
Join Date: Sep 2010
Rookie Year: 2011
Location: Grove City, PA
Posts: 213
Domenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura aboutDomenic Rodriguez has a spectacular aura about
Re: Encoders Programming

Looking at your other thread, I see you are using the AS5145B Magnetic Encoders, not the US Digital E4Ps. According to this page, these encoders output 1024 pulses per revolution, unlike the E4Ps which are only 360 pulses/revolution.

Have you looked at this page yet? It explains how quadrature encoders work, and gives some examples of how to use the WPILib Encoder class.

The constructor call is where you create the Encoder object, usually as an instance variable of your robot class. For example, to create an Encoder with the A channel in DIO 1, the B channel in DIO 2, counting the normal direction and 4X decoding, you would use this:
Code:
Encoder myEncoder = new Encoder(1, 2, false, EncodingType.k4X);
Here's a simple example of using encoders to drive a robot in autonomous: https://gist.github.com/DomenicP/7252269
__________________

LuNaTeCs - Learning Under Nurturing Adults Teaching Engineering Concepts and Skills - Small and Mighty!

FRC 316 LuNaTeCs - Student (2011-2014), Lead Programmer (2011-2014), Team Captain (2013-2014), Operator (2013), Drive Coach (2014), Mentor (2015-????)
'11 Philly Regional Finalists, '13 Chestnut Hill Finalists, '13 Lenape Champions, '13 Archimedes Division, '14 Chestnut Hill Champions, '14 Lenape Champions
FTC 7071 EngiNerds - Founding Advisor (2013-2014) | FRC 5420 Velocity - Founding Advisor (2015)
Grove City College Class of '18, Electrical/Computer Engineering (B.S.E.E)

Reply With Quote
  #14   Spotlight this post!  
Unread 01-11-2013, 08:52
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: Encoders Programming

My bad, here you go

driveTrainLeftEncoder = new Encoder(1, 1, 1, 2, false, EncodingType.k4X);
driveTrainRightEncoder = new Encoder(1, 3, 1, 4, false, EncodingType.k4X);
Reply With Quote
  #15   Spotlight this post!  
Unread 01-11-2013, 11:24
TenaciousDrones's Avatar
TenaciousDrones TenaciousDrones is offline
FRC Team 4780
FRC #4780 (The Tenacious Drones)
 
Join Date: Sep 2013
Rookie Year: 2012
Location: Parma, Ohio
Posts: 57
TenaciousDrones is an unknown quantity at this point
Re: Encoders Programming

I've gone through my wiring and code several times and still can't figure out why the encoders' values keep resetting. It feel like I'm so close but so far away from because of this.
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 13:02.

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