How to 'clear' reference in CANPIDController

We’re using setReference on CANPIDController to set our SparkMax to approach a kSmartVelocity reference point. We would like to be able to “clear” that reference (that is, bail out of the PID Control loop on the SparkMax and just allow the motors to naturally spin down while in Coast).

We can call “setReference(0)” , but that actually makes the motors “work” to approach 0 as quickly as possible. Is there a simple way to “clear” to just return the SparkMax to the state it was in before the initial setReference call?

Thanks for any insight you can provide!

Make sure the motor is in coast mode and call set(0).

1 Like

Unfortunately CANPIDController does not have a “set” routine, only “setReference”. The problem with “setReference(0)” is that it actually tries to do work with motors to forcefully stop the rotation, which we don’t want.

Were you talking about the “set” or “stopMotor” routines on the CANSparkMax instance that is the owner of the CANPIDController? Does that implicitly cancel the CANPIDController’s reference?

Thanks!

Oh yeah sorry. Call spark.set(0)