Issue With .setPosition with SparkMax

We are trying to use a relative and absolute encoder on a steer motor for a swerve drive. When we attempt to pass a sensor position through .setPosition we are getting the following error.
[CAN SPARK] IDs: 1, 4, 6, 7, timed out while waiting for Periodic Status 2.

If we comment out the line
steerEncoder.setPosition((getAbsAngleDeg() * quadCountsPerRotation) / 360);

it will build and deploy as expected. Any ideas?

Are the other methods with encoder working? If not it may be something to do with the creation of the encoder itself in the code.

Are you trying to set the position of an absolute encoder?

If so, that doesn’t work, you’re not meant to set the position on an absolute encoder. At most, you can set the offset, to change it’s zero position using the REV Hardware Client.

No, it is a quadrature encoder the issue is were confused why only when we try and set a position on it or set a scale on the position it gives the error



on the second image you can see the setPosition command which if deleted or commented out lets the code run as intended.

Hmmm specifically what encoder is it? CTRE mag encoder, REV through bore, etc.

Quadrature encoders are not absolute encoders and are not as reliable, they start with 0 not any internal reading. You would have to realign your wheels at the start.

these we used them last year with no issue at all but this year we switched to using SPARKmaxes from Talon SRX which have different implementations but should still work

I am aware, but the issue is when I try to use the setPosition command it gives the error

1 Like

Are you sure you connected them correctly? Are you using the Spark Max data port breakout adapter?

A quadrature encoder is not 7 counts per rev.

ikik that was simply for a test its normally 4096

were using the alternate encoder adapters but we have the breakout boards. we were printing out values through smart dash but it wouldnt set position but when we switched some stuff from just RelativeEncoder to AlternateEncoder it stopped giving errors for set position but also stopped printing values on smart dash.

I would like to know if you found any solution to this problem we are having the same problem except i get periodic status 1.

So from what I understand it mostly means that there is to much going on slash to much clutter so maybe try and clean the code up to make it run smoother but we fixed it by straight up getting new swerve drives(we were doing that anyway not to fix the problem)