[CAN SPARK MAX] IDs: 10, 15, WPILib or External HAL Error: CAN: No token

I am having trouble running tank drive PID position control code.

When I deploy the code, there is a constant “CAN: Message not found” error. I am able to drive with joysticks consistently with no problems.
When I press a button bound to drive using the CAN spark max PID position control, the motors only run sometimes (ex. the first time I press the button nothing happens, I continue pressing it rapidly and maybe after 5 tries it works three times in a row, then stops working). And I get the error “[CAN SPARK MAX] IDs: 10, 15, WPILib or External HAL Error: CAN: No token”. The spark maxs with IDs 10 and 15 are my master drive motor controllers.

My code can be found here: https://github.com/Team236/2022-Robot/tree/master/src/main/java/frc/robot
The command I am having trouble with is called DriveWithPID (but the same problem happens with any command using PID).

Also, when I try to run the drive motors using the REV Hardware Client, the motor controllers do not receive any signals. I am unable to test PID using the client because the motor controllers do not respond. I have tried disconnecting the spark max from the CAN bus.

First, if you’re going to try using the REV hardware client, make sure to disconnect CAN (or remove power from the roborio) and power cycle the SparkMax. There’s a lockout feature if it has seen the robot CAN network.

Second, for intermittent functionality like that, I lean toward poor wiring (bad crimp or something). If you can reproduce it reliably, then start looking into the code that runs when doing whatever task reproduces it. You can also try creating a simple project that just drives that motor and see if you can still reproduce it.

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