View Single Post
  #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