]> git.taranathan.com Git - FRC2026.git/commitdiff
lower reverse current
authorWesleyWong-972 <wesleycwong@gmail.com>
Sat, 18 Apr 2026 22:21:14 +0000 (15:21 -0700)
committerWesleyWong-972 <wesleycwong@gmail.com>
Sat, 18 Apr 2026 22:21:14 +0000 (15:21 -0700)
src/main/java/frc/robot/subsystems/spindexer/Spindexer.java
src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java

index 9b2c40e81555f7bfcc165df9c0d8d9a9510a8a99..54c215211f3b73ff4f96673de6c3d01e6aa52492 100644 (file)
@@ -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);
     }
index 9bd84836c7bba660f1e034095872899042677f94..631a8f2e0cb722aa2c71031f23dcdef8ce2d7162 100644 (file)
@@ -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