// 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));
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);
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);
}
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