Hi, we probably did not configure something correctly, but we don’t know what it was.
We are trying to use Rev Through Bore encoder, plugging it into SparkMax that’s driving the motor of the elevator.
However, we are getting weird readings out if that encoder, and this is happening with all three encoders that we had.
When I manually lift the arm up and down (by hand), instead of seeing continuously changing angle im smartdashboard for “angleSeen” as shown below… we see it angleSeen mostly stay constant when arm moves, and sometimes jumping to a new value which seems random.
Using Rev client we have reset the zero on the encoder, but no luck so far.
Can you think of what we missed or didn’t configure corretly? Thanks
Constructor:
leadMotor = new CANSparkMax(Constants.CANIDs.kArmMotorLeft, MotorType.kBrushless);
leadMotor.restoreFactoryDefaults();
leadMotor.setInverted(false);
leadMotor.setIdleMode(IdleMode.kBrake);
followMotor = new CANSparkMax(Constants.CANIDs.kArmMotorRight, MotorType.kBrushless);
followMotor.restoreFactoryDefaults();
followMotor.follow(leadMotor, true);
m_encoder = followMotor.getAbsoluteEncoder(Type.kDutyCycle);
m_encoder.setPositionConversionFactor(360); // is this right?
m_encoder.setVelocityConversionFactor(60); // is this right?
m_encoder.setInverted(kEncoderInverted);
Periodic function of the elevator subsystem:
@Override
public void periodic() {
double setPoint = getAngleGoal();
pidController.setReference(setPoint, CANSparkMax.ControlType.kSmartMotion);
SmartDashboard.putNumber("angleSeen", m_encoder.getPosition());
SmartDashboard.putNumber("angleWanted", getAngleGoal());
}