Hi everyone! This serves as a bit of PSA on an issue we have been having with SPARK Flex. At least three separate cases have appeared on the FRC Discord, with similar characteristics. Hopefully this is able to be fixed soon, but we wanted to get this out there for visibility’s sake.
We ran into issues with the Vortex after we tested it on our swerve chassis, where it would run fine when connected over REV Hardware Client, but stutter rapidly and produce unintelligible blink codes when running with robot code. We use CTRE CANcoders with NEO 1.0s connected to SPARK MAXes for the actual drivetrain, and had the Vortex looped in on the CAN bus. All devices are on the roboRIO CAN bus (no CANivore).
The drivetrain SPARK MAXes were working as normal, and the SPARK Flex was the only device exhibiting those issues. Additionally, our internal logging software (not included or used in the minimum sample below) showed output current on the SPARK Flex oscillating wildly between 0 and 10-20A (with no load on the motor).
We were able to narrow it down to instantiating a CANSparkFlex
object at the same time as a CTRE CANcoder (no sensor reads from the CANcoder needed to be made to reproduce). After some discussion on the FRC Discord, we found that the same issue presented itself even when Phoenix was initialized at all, with their diagnostic server disabled (minimum reproducible code sample below). According to Ben from CTRE:
All that is running now is basically our enable frame, there’s no other CTRE frames on that CAN bus.
Additionally, we get this message in RIOLog when the Phoenix library is initialized, and there are CAN TX and RX sticky faults present on the SPARK Flex after running it (CANcoder initialized.mov, below).
Software
We are running with the following software:
WPILib Information:
Project Version: 2024.1.1
VS Code Version: 1.85.1
WPILib Extension Version: 2024.1.1
C++ Extension Version: 1.19.1
Java Extension Version: 1.26.2023121408
Java Debug Extension Version: 0.55.2023121302
Java Dependencies Extension Version: 0.23.2023120100
Java Version: 17
Java Location: /Users/XXX/wpilib/2024/jdk
Vendor Libraries:
CTRE-Phoenix (v5) (5.33.0)
CTRE-Phoenix (v6) (24.1.0)
REVLib (2024.2.0)
WPILib-New-Commands (1.0.0)
(Phoenix 5 is included as we were asked to test with the Phoenix 5 version of the CANcoder, the issue still persisted).
The SPARK Flex is on firmware version 2024.0.2, and all other REV devices on the CAN bus are at the latest version.
Videos
This video shows what is happening; orange blink codes indicating Sensor Fault sometimes appear, but are inconsistent. We have tested multiple SPARK Flexes and multiple Driver Stations, and the issue persists.
Here is a video of normal operation:
Curiously, when the robot is enabled and a control signal is not sent to the SPARK Flex, the following code appears (rapidly blinking magenta):
Minimum Reproducible Code Sample
package frc.robot;
import com.ctre.phoenix6.unmanaged.Unmanaged;
import com.revrobotics.CANSparkFlex;
import com.revrobotics.CANSparkLowLevel.MotorType;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.XboxController;
public class Robot extends TimedRobot {
CANSparkFlex motor = new CANSparkFlex(17, MotorType.kBrushless);
XboxController controller = new XboxController(0);
@Override
public void robotInit() {
Unmanaged.setPhoenixDiagnosticsStartTime(-1);
}
@Override
public void teleopPeriodic() {
if (controller.getAButton()) {
motor.setVoltage(-6);
} else {
motor.setVoltage(0);
}
}
}