REV Spark Max Migration to 2025

Hello Again Delphi!

Since the new season has started, the long process of migrating everything over to 2025 has begun. As of now, we have correctly migrated everything over to versions of 2025 except the CANSparkMax code. I have been onto the REV page for migration (Migrating to REVLib 2025 | REVLib), and I can’t seem to find a way to fix our CANSparkMaxUtil for our Spark Max Controllers. The code is below, any help would be great! Out git hub is online as well: GitHub - FRCTeam3543/FRC3543_SwerveBaseCode

public static void setCANSparkMaxBusUsage(
SparkMax motor, Usage usage, boolean enableFollowing) {
if (enableFollowing) {
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus0, 10);
} else {
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus0, 500);
}
if (usage == Usage.kAll) {
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus1, 20);
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus2, 20);
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus3, 50);
} else if (usage == Usage.kPositionOnly) {
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus1, 500);
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus2, 20);
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus3, 500);
} else if (usage == Usage.kVelocityOnly) {
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus1, 20);
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus2, 500);
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus3, 500);
} else if (usage == Usage.kMinimal) {
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus1, 500);
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus2, 500);
motor.setPeriodicFramePeriod(CANSparkLowLevel.PeriodicFrame.kStatus3, 500);
}
}

and finally

CANSparkLowLevel.enableExternalUSBControl(true);

Thanks Delphi!!

Okay, and precisely what’s wrong with it? What have you tried? Where are you stuck?

Is the issue setting the status frame periods?
On the migration page they have a “Setting status periods” section.

Migrating configuring status frame periods are explained in this section of the migration guide. The biggest difference is that the settings are broken up by signals in each status, but ultimately the status frames are being configured.

It looks like this the code snippet you included is meant to limit the SPARK’s CAN utilization depending on the device’s specific use, but with 2025 REVLib and firmware, a majority of status frames are disabled by default and relevant status frame are automatically enabled when a .getX() for a sensor is called in the program.

Unfortunately enableExternalUSBControl() was removed for 2025 due to refactoring of our infrastructure, and it is not currently planned to be added back.

1 Like

So the enableExternalUSBControl() is removed fully. Okay! So I see where the frame status is being defined and the before + the after. The only thing now would be what it would be replaced with:

config.signals.primaryEncoderPositionPeriodMs(5);
 or 
max.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);
or
double position = max.getEncoder().getPosition();

To just set the status frame period, it would be both of the first two:

config.signals.primaryEncoderPositionPeriodMs(5);
max.configure(config, ResetMode.kResetSafeParameters, PersistMode.kPersistParameters);

More specifically, for your usage == Usage.kAll case, it would look like this:

SparkMaxConfig config = new SparkMaxConfig();

config.signals
    .primaryEncoderVelocityPeriodMs(20)  // Previously status 1
    .primaryEncoderPositionPeriodMs(20)  // Previously status 2
    .analogVoltage(50);                  // Previously status 3

motor.configure(config, ResetMode.kResetSafeParameters, PersistParameters.kPersistParameters);

Hope that helps

1 Like

Ha! Yes thank you! That worked perfectly!!

Hi, with the new season changes, we found our library is broken because of the REVLib changes. I scanned through the Migration document and fixed most of the issues. But it doesn’t have answers to some of the issues. Here are the broken features that I can’t find fixes for:

  1. Voltage Compensation feature seems to be gone but I can’t find any mention on what replaces it. I am assuming it is replaced by ControlType.kVoltage. Please confirm.
  2. restoreFactoryDefaults is gone. I read the migration doc but want to confirm if I understand it correctly. If I just want to reset everything to factory default, should I create an empty SparkMaxConfig and call max.configure with the empty SparkMaxConfig and use kResetSafeParameters and kPersistParameters?
  3. setClosedLoopRampRate and setOpenLoopRampRate are gone. What are the replacements?

Voltage compensation, closed loop ramp rate, and open loop ramp rate are now a part of SparkBaseConfig.

Yes, if you just want to reset the parameters without configuring anything else then doing what you said works:

   max.configure(new SparkMaxConfig(), ResetMode.kResetSafeParameters, ...);

Thanks for the quick response. I have implemented all that. But I got another question. For follower mode, I found a disableFollowerMode but I don’t see a corresponding “enableFollowerMode”. From looking at the code, it looks like the follow method is an implicit “enable” because the disableFollowerMode method is exactly identical to the follow method except for setting the leaderId to zero and invert to false. Please confirm.