View Single Post
  #1   Spotlight this post!  
Unread 10-01-2015, 21:38
seg9585's Avatar
seg9585 seg9585 is offline
Registered User
AKA: Eric
FRC #4276 (Surf City Vikings)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2001
Location: Boeing (Seal Beach, CA)
Posts: 519
seg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond reputeseg9585 has a reputation beyond repute
Defective Encoder? Or other Issue?

I'm having trouble getting the Encoder to increment any counts on the AM-0180 using the 2015 Java API Encoder Class. getDistance() always returns 0 when stopped or -0.5 when the motor is running, getRate() always returns 0, getStopped() always returns true.
I verified the wiring is correct (orange power, brown ground, blue DIO0 signal, yellow DIO1 signal). Opening the cover, the LED transmitter is illuminated and the encoder does spin with the shaft.
Code is below. Any ideas? Could this encoder be defective? Or are others having trouble with the new API?



import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboar d;

public class TestEncoder {
Encoder encoder;

public TestEncoder(int source1, int source2) {
encoder = new Encoder(source1, source2);
encoder.setDistancePerPulse(2);
encoder.reset();

}



public void printStatus() {
double rotations;
rotations=encoder.getDistance();
SmartDashboard.putNumber("Rotations", rotations);
SmartDashboard.putNumber("Rate", encoder.getRate());
SmartDashboard.putBoolean("Stopped", encoder.getStopped());

}

}
__________________
My FIRST legacy:

Team 204 Student 2001, 2002 (Voorhees, NJ)
Team 1493 College Mentor 2006 - 2008 (Troy, NY)
Team 2150 Intern/Professional Mentor 2007, 2009 (Palos Verdes)
Team 4123 Lead Engineering Mentor 2012 (Bellflower, CA)
Team 4276 Engineering Mentor 2012-2016 (Huntington Beach, CA)
Reply With Quote