Using absolute encoder with a Neo?

Hello all,

We have a REV Through Bore Encoder that we’re trying to use with a Neo driving our arm. We have an absolute encoder adapter so we can use both the Neo and the encoder at the same time. I’m not sure how to program this, because the docs don’t give any great examples and the Spark Max API isn’t great. We can’t get it to work, as the code compiles but immediately crashes.

encoder = armMotor.getAbsoluteEncoder(Type.kDutyCycle);
java.lang.IllegalStateException: An alternate encoder cannot be used while limit switch and/or absolute encoder is active

We don’t have a limit switch. Any clues on how to fix this?

1 Like

I “think” i know ur problem, but it would help if you sent the full code.

1 Like

I will second @DrPhi, please send your full code. The entire file would be helpful, a link to your GitHub (if you use that) would be best

Change line 465 of frc.robot.interfaces.CANSparkMax to

return getAbsoluteEncoder(Type.kDutyCycle).getPosition();

Same for line 469 :slight_smile:

1 Like

Goodness me, that was a quick finding! I pushed my commits, here is the line that was giving me problems.

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