From: WesleyWong-972 Date: Sat, 18 Apr 2026 22:21:14 +0000 (-0700) Subject: lower reverse current X-Git-Url: https://git.taranathan.com/?a=commitdiff_plain;h=02776b5ad970268cd15655940430ad9d3e7182ba;p=FRC2026.git lower reverse current --- diff --git a/src/main/java/frc/robot/subsystems/spindexer/Spindexer.java b/src/main/java/frc/robot/subsystems/spindexer/Spindexer.java index 9b2c40e..54c2152 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/Spindexer.java +++ b/src/main/java/frc/robot/subsystems/spindexer/Spindexer.java @@ -31,10 +31,10 @@ public class Spindexer extends SubsystemBase implements SpindexerIO { // configure current limit CurrentLimitsConfigs limitConfig = new CurrentLimitsConfigs(); - limitConfig.StatorCurrentLimit = SpindexerConstants.CURRENT_SPIKE_LIMIT; + limitConfig.StatorCurrentLimit = SpindexerConstants.CURRENT_STATOR_LIMIT; limitConfig.StatorCurrentLimitEnable = true; - limitConfig.SupplyCurrentLowerLimit = SpindexerConstants.currentLimit; - limitConfig.SupplyCurrentLowerTime = 1.5; + limitConfig.SupplyCurrentLowerLimit = SpindexerConstants.FORWARD_SUPPLY_CURRENT_LIMIT; + limitConfig.SupplyCurrentLimitEnable = true; motorOne.getConfigurator().apply(limitConfig); motorTwo.getConfigurator().apply(limitConfig); motorTwo.getConfigurator().apply(new MotorOutputConfigs().withInverted(InvertedValue.Clockwise_Positive)); @@ -68,6 +68,11 @@ public class Spindexer extends SubsystemBase implements SpindexerIO { setMotorVoltages(power); } + if (state == SpindexerState.REVERSE) { + setNewCurrentLimit(SpindexerConstants.SUPPLY_CURRENT_LIMIT, SpindexerConstants.CURRENT_REVERSE_STATOR_LIMIT); + } else { + setNewCurrentLimit(SpindexerConstants.SUPPLY_CURRENT_LIMIT, SpindexerConstants.CURRENT_FORWARD_STATOR_LIMIT); + } if (!Constants.DISABLE_SMART_DASHBOARD) { SmartDashboard.putBoolean("Spindexer Running", state == SpindexerState.MAX || state == SpindexerState.CUSTOM); @@ -105,12 +110,12 @@ public class Spindexer extends SubsystemBase implements SpindexerIO { return inputs.spindexerOneCurrent + inputs.spindexerTwoCurrent; } - public void setNewCurrentLimit(double newCurrentLimit) { + public void setNewCurrentLimit(double supply, double stator) { CurrentLimitsConfigs limitConfig = new CurrentLimitsConfigs(); - limitConfig.StatorCurrentLimit = newCurrentLimit; + limitConfig.StatorCurrentLimit = stator; limitConfig.StatorCurrentLimitEnable = true; - limitConfig.SupplyCurrentLowerLimit = newCurrentLimit; - limitConfig.SupplyCurrentLowerTime = 1.5; + limitConfig.SupplyCurrentLowerLimit = supply; + limitConfig.SupplyCurrentLimitEnable = true; motorOne.getConfigurator().apply(limitConfig); motorTwo.getConfigurator().apply(limitConfig); } diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java index 9bd8483..631a8f2 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java @@ -2,12 +2,13 @@ package frc.robot.subsystems.spindexer; public class SpindexerConstants { public static final double spindexerVelocityWithBall = 6.0; // rps (for counting balls) - public static final double currentLimit = 40; // A + public static final double SUPPLY_CURRENT_LIMIT = 40; // A public static final double spindexerForwardVoltage = 1.00; // Volts (set low for testing) public static final double spindexerReverseVoltage = -1.00; // Volts public static final double GEAR_RATIO = 27.0; // unused & both motors have same gearing - public static final double CURRENT_SPIKE_LIMIT = 150.0; + public static final double CURRENT_FORWARD_STATOR_LIMIT = 150.0; + public static final double CURRENT_REVERSE_STATOR_LIMIT = 20.0; public static final double CURRENT_TIME_LIMIT = 1.0; //s public static final double JAM_CURRENT_THRESHOLD = 75.0; // A public static final double JAM_DEBOUNCE_TIME = 0.3; // seconds