Problems with reading Rev Through Bore encoder

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());

}

If using a brushless motor on the Spark Max (seems to be the case based on your code) and the through bore is connected to the data port on the Spark Max, you have to use the through bore in alternate encoder mode as a quadrature encoder.

https://docs.revrobotics.com/through-bore-encoder/application-examples

It would be good to describe just how you have things wired up, this can make a big difference.

We discovered our error about an hour ago. We were using the Alternate Encoder Adapter by mistake. When we used the Absolute Encoder Adapter, it worked.

Thanks Yall

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.