During individual motor testing on the robot’s four wheels (four NEO brushless motors with SPARK MAX controllers) we discovered that as we stepped through the list of individual motors to test, the previous motor that was tested would turn on simultaneously with the next motor to be tested although the previous motor was no longer in the Java code.
That is, for example:
test only motor #1 by coding it alone in the Java code.
deploy and enable code and motor #1 runs correctly.
disable code.
change code to only motor #2 (change the single digit “1” to a “2”) and deploy the code.
enable code and both motors #1 and #2 run.
disable code.
enable code and only #2 runs which is now correct.
The pattern seems to be whatever motors that were previously running when the code was disabled will start to run again after deploying new code, if the new code does not set a new speed for them. It appears that a background process that isn’t cancelled with the new deploy has memory of the old speed and is used for the first enable after deployment, if a motor’s speed is not updated in the code. The second sequence of disable / enable finally clears that old motor speed and the previous motor is turned off and just the new motor runs as expected.
Issue appears with firmware update 1.0.385 and earlier versions that we had. Visual Studio Code Java library SparkMax-Java 1.0.28
Code snippet for motor #1:
private static CANSparkMax motor = new CANSparkMax(1, CANSParkMaxLowLevel.MotorType.kBrushless);
motor.set(0.5);
Then motor #2 by changing the “1” to a “2”
private static CANSparkMax motor = new CANSparkMax(2, CANSParkMaxLowLevel.MotorType.kBrushless);
motor.set(0.5);
This brings home the best practices for motor testing:
- All wheels in the air to prevent robot movement
- Stay away from anything that could move such as wheels, belts, intake/discharge mechanisms, elevators - expect the unexpected - motors can run at any time for inexplicable reasons