Setting Coast Mode AFTER Match Ends

The Spectrum build thread mentioned being able to set a motor controller mode (brake/coast) using a joystick button after the match ends.

Does anyone know how this witchcraft is done in LabView with a Spark Max?

1 Like

The SPARK MAXs will need to be on the CAN bus if they aren’t already. This is all you need to set a motor controller to coast:

Coast Mode

You can throw it in (or Periodic, which will let it work in teleop as well) and read the joystick the same way you normally would. Disabling the robot just prevents motors/pneumatics from actuating; they can still be configured, and joystick data is still sent (unlike autonomous).

If you always want the motor controller to go to coast after match end, you could do this in

Checking for the first run call prevents the Set API from being run frequently as REV advises, and the check for Teleop Disabled is to prevent it from switching during Autonomous Disabled (happens briefly on the changeover from auto to teleop).

You could also run it after a set amount of time if it’s to let a climber drop for easier robot retrieval.

Regardless, it’s important to remember that SPARK MAXs retain their control mode. If you do something like this, be sure to also set the mode to brake in so that they always set back when the robot boots (or, alternatively, on the first runs of autonomous and teleop so that they always set back on enable; this might be more practical for practicing).

1 Like

Thanks for the clear explanation!

1 Like

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