Skip to content

Commit

Permalink
Switch from potentiometer to encoder on elevator
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyfurion committed Apr 6, 2018
1 parent 6a41a94 commit 216885b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Binary file modified bin/org/usfirst/frc/team334/robot/subsystems/elevator.class
Binary file not shown.
3 changes: 2 additions & 1 deletion src/org/usfirst/frc/team334/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public class Constants {
// Elevator Sensors (Limit Switches + Potentiometer)
public static final int ELEVATOR_LIMIT_TOP = 6;
public static final int ELEVATOR_LIMIT_BOTTOM = 7;
public static final int ELEVATOR_POTENTIOMETER = 4;
public static final int ELEVATOR_ENCODER_A = 8;
public static final int ELEVATOR_ENCODER_B = 9;

// Elevator Pot PID
public static final double ELEVATOR_POT_P = 0;
Expand Down
15 changes: 7 additions & 8 deletions src/org/usfirst/frc/team334/robot/subsystems/Elevator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import org.usfirst.frc.team334.robot.Constants;

import edu.wpi.first.wpilibj.AnalogPotentiometer;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.VictorSP;
import edu.wpi.first.wpilibj.command.PIDSubsystem;

Expand All @@ -16,7 +16,7 @@ public class Elevator extends PIDSubsystem {
private DigitalInput rTopLimit;
private DigitalInput rBottomLimit;

private AnalogPotentiometer rPotentiometer;
private Encoder rEncoder;

public Elevator() {
super(Constants.ELEVATOR_POT_P, Constants.ELEVATOR_POT_I, Constants.ELEVATOR_POT_D);
Expand All @@ -27,7 +27,7 @@ public Elevator() {
rTopLimit = new DigitalInput(Constants.ELEVATOR_LIMIT_TOP);
rBottomLimit = new DigitalInput(Constants.ELEVATOR_LIMIT_BOTTOM);

rPotentiometer = new AnalogPotentiometer(Constants.ELEVATOR_POTENTIOMETER);
rEncoder = new Encoder(Constants.ELEVATOR_ENCODER_A, Constants.ELEVATOR_ENCODER_B);

this.disable();
this.setAbsoluteTolerance(1);
Expand All @@ -46,13 +46,12 @@ public void stop() {

@Override
protected double returnPIDInput() {
return rPotentiometer.get();
return rEncoder.get();
}

@Override
protected void usePIDOutput(double output) {
// System.out.println("Error: " + output + "Potentiometer Value: " +
// rPotentiometer.get());
System.out.println("Error: " + output + "Encoder Value: " + rEncoder.get());
setMotors(output * Constants.ELEVATOR_SPEED_MULTIPLIER);
}

Expand All @@ -64,8 +63,8 @@ public boolean isTooLow() {
return rBottomLimit.get();
}

public AnalogPotentiometer getPotentiometer() {
return rPotentiometer;
public Encoder getEncoder() {
return rEncoder;
}

public void initDefaultCommand() {
Expand Down

0 comments on commit 216885b

Please sign in to comment.