Class SparkBaseConfig
- Direct Known Subclasses:
SparkFlexConfig
,SparkMaxConfig
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionfinal AbsoluteEncoderConfig
final AnalogSensorConfig
final ClosedLoopConfig
final EncoderConfig
final LimitSwitchConfig
final SignalsConfig
final SoftLimitConfig
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapply
(AbsoluteEncoderConfig config) Applies settings from anAbsoluteEncoderConfig
to thisSparkBaseConfig
.apply
(AnalogSensorConfig config) Applies settings from anAnalogSensorConfig
to thisSparkBaseConfig
.apply
(ClosedLoopConfig config) Applies settings from aClosedLoopConfig
to thisSparkBaseConfig
.apply
(EncoderConfig config) Applies settings from anEncoderConfig
to thisSparkBaseConfig
.apply
(LimitSwitchConfig config) Applies settings from aLimitSwitchConfig
to thisSparkBaseConfig
.apply
(SignalsConfig config) Applies settings from aSignalsConfig
to thisSparkBaseConfig
.apply
(SoftLimitConfig config) Applies settings from aSoftLimitConfig
to thisSparkBaseConfig
.apply
(SparkBaseConfig config) Applies settings from anotherSparkBaseConfig
to this one, including all of its nested configurations.closedLoopRampRate
(double rate) Sets the ramp rate for closed loop control modes.Disables follower mode on the controller.Disables the voltage compensation setting for all modes on the SPARK.flatten()
follow
(int leaderCanId) Causes this controller's output to mirror the provided leader.follow
(int leaderCanId, boolean invert) Causes this controller's output to mirror the provided leader.Causes this controller's output to mirror the provided leader.Causes this controller's output to mirror the provided leader.idleMode
(SparkBaseConfig.IdleMode idleMode) Sets the idle mode setting for the SPARK.inverted
(boolean inverted) Common interface for inverting direction of a speed controller.openLoopRampRate
(double rate) Sets the ramp rate for open loop control modes.secondaryCurrentLimit
(double limit) Sets the secondary current limit in Amps.secondaryCurrentLimit
(double limit, int chopCycles) Sets the secondary current limit in Amps.smartCurrentLimit
(int stallLimit) Sets the current limit in Amps.smartCurrentLimit
(int stallLimit, int freeLimit) Sets the current limit in Amps.smartCurrentLimit
(int stallLimit, int freeLimit, int limitRpm) Sets the current limit in Amps.voltageCompensation
(double nominalVoltage) Sets the voltage compensation setting for all modes on the SPARK and enables voltage compensation.
-
Field Details
-
absoluteEncoder
-
analogSensor
-
encoder
-
limitSwitch
-
softLimit
-
closedLoop
-
signals
-
-
Constructor Details
-
SparkBaseConfig
public SparkBaseConfig()
-
-
Method Details
-
apply
Applies settings from anotherSparkBaseConfig
to this one, including all of its nested configurations.Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.
- Parameters:
config
- TheSparkBaseConfig
to copy settings from- Returns:
- The updated
SparkBaseConfig
for method chaining
-
apply
Applies settings from anAbsoluteEncoderConfig
to thisSparkBaseConfig
.Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.
- Parameters:
config
- TheAbsoluteEncoderConfig
to copy settings from- Returns:
- The updated
SparkBaseConfig
for method chaining
-
apply
Applies settings from anAnalogSensorConfig
to thisSparkBaseConfig
.Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.
- Parameters:
config
- TheAnalogSensorConfig
to copy settings from- Returns:
- The updated
SparkBaseConfig
for method chaining
-
apply
Applies settings from anEncoderConfig
to thisSparkBaseConfig
.Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.
- Parameters:
config
- TheEncoderConfig
to copy settings from- Returns:
- The updated
SparkBaseConfig
for method chaining
-
apply
Applies settings from aLimitSwitchConfig
to thisSparkBaseConfig
.Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.
- Parameters:
config
- TheLimitSwitchConfig
to copy settings from- Returns:
- The updated
SparkBaseConfig
for method chaining
-
apply
Applies settings from aSoftLimitConfig
to thisSparkBaseConfig
.Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.
- Parameters:
config
- TheSoftLimitConfig
to copy settings from- Returns:
- The updated
SparkBaseConfig
for method chaining
-
apply
Applies settings from aClosedLoopConfig
to thisSparkBaseConfig
.Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.
- Parameters:
config
- TheClosedLoopConfig
to copy settings from- Returns:
- The updated
SparkBaseConfig
for method chaining
-
apply
Applies settings from aSignalsConfig
to thisSparkBaseConfig
.Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.
- Parameters:
config
- TheSignalsConfig
to copy settings from- Returns:
- The updated
SparkBaseConfig
for method chaining
-
idleMode
Sets the idle mode setting for the SPARK.- Parameters:
idleMode
- Coast or brake- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
inverted
Common interface for inverting direction of a speed controller.This call has no effect if the controller is a follower. To invert a follower, see the follow() method.
- Parameters:
inverted
- True for inverted- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
smartCurrentLimit
Sets the current limit in Amps.The motor controller will reduce the controller voltage output to avoid surpassing this limit. This limit is enabled by default and used for brushless only. This limit is highly recommended when using the NEO brushless motor.
The NEO Brushless Motor has a low internal resistance, which can mean large current spikes that could be enough to cause damage to the motor and controller. This current limit provides a smarter strategy to deal with high current draws and keep the motor and controller operating in a safe region.
- Parameters:
stallLimit
- The current limit in Amps.- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
smartCurrentLimit
Sets the current limit in Amps.The motor controller will reduce the controller voltage output to avoid surpassing this limit. This limit is enabled by default and used for brushless only. This limit is highly recommended when using the NEO brushless motor.
The NEO Brushless Motor has a low internal resistance, which can mean large current spikes that could be enough to cause damage to the motor and controller. This current limit provides a smarter strategy to deal with high current draws and keep the motor and controller operating in a safe region.
The controller can also limit the current based on the RPM of the motor in a linear fashion to help with controllability in closed loop control. For a response that is linear the entire RPM range leave limit RPM at 0.
- Parameters:
stallLimit
- The current limit in Amps at 0 RPM.freeLimit
- The current limit at free speed (5700RPM for NEO).- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
smartCurrentLimit
Sets the current limit in Amps.The motor controller will reduce the controller voltage output to avoid surpassing this limit. This limit is enabled by default and used for brushless only. This limit is highly recommended when using the NEO brushless motor.
The NEO Brushless Motor has a low internal resistance, which can mean large current spikes that could be enough to cause damage to the motor and controller. This current limit provides a smarter strategy to deal with high current draws and keep the motor and controller operating in a safe region.
The controller can also limit the current based on the RPM of the motor in a linear fashion to help with controllability in closed loop control. For a response that is linear the entire RPM range leave limit RPM at 0.
- Parameters:
stallLimit
- The current limit in Amps at 0 RPM.freeLimit
- The current limit at free speed (5700RPM for NEO).limitRpm
- RPM less than this value will be set to the stallLimit, RPM values greater than limitRpm will scale linearly to freeLimit- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
secondaryCurrentLimit
Sets the secondary current limit in Amps.The motor controller will disable the output of the controller briefly if the current limit is exceeded to reduce the current. This limit is a simplified 'on/off' controller. This limit is enabled by default but is set higher than the default Smart Current Limit.
The time the controller is off after the current limit is reached is determined by the parameter limitCycles, which is the number of PWM cycles (20kHz). The recommended value is the default of 0 which is the minimum time and is part of a PWM cycle from when the over current is detected. This allows the controller to regulate the current close to the limit value.
The total time is set by the equation
t = (50us - t0) + 50us * limitCycles t = total off time after over current t0 = time from the start of the PWM cycle until over current is detected
- Parameters:
limit
- The current limit in Amps.- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
secondaryCurrentLimit
Sets the secondary current limit in Amps.The motor controller will disable the output of the controller briefly if the current limit is exceeded to reduce the current. This limit is a simplified 'on/off' controller. This limit is enabled by default but is set higher than the default Smart Current Limit.
The time the controller is off after the current limit is reached is determined by the parameter limitCycles, which is the number of PWM cycles (20kHz). The recommended value is the default of 0 which is the minimum time and is part of a PWM cycle from when the over current is detected. This allows the controller to regulate the current close to the limit value.
The total time is set by the equation
t = (50us - t0) + 50us * limitCycles t = total off time after over current t0 = time from the start of the PWM cycle until over current is detected
- Parameters:
limit
- The current limit in Amps.chopCycles
- The number of additional PWM cycles to turn the driver off after overcurrent is detected.- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
openLoopRampRate
Sets the ramp rate for open loop control modes.This is the maximum rate at which the motor controller's output is allowed to change.
- Parameters:
rate
- Time in seconds to go from 0 to full throttle.- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
closedLoopRampRate
Sets the ramp rate for closed loop control modes.This is the maximum rate at which the motor controller's output is allowed to change.
- Parameters:
rate
- Time in seconds to go from 0 to full throttle.- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
voltageCompensation
Sets the voltage compensation setting for all modes on the SPARK and enables voltage compensation.- Parameters:
nominalVoltage
- Nominal voltage to compensate output to- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
disableVoltageCompensation
Disables the voltage compensation setting for all modes on the SPARK.- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
follow
Causes this controller's output to mirror the provided leader.Only voltage output is mirrored. Settings changed on the leader do not affect the follower.
The motor will spin in the same direction as the leader. This can be changed by passing a true constant after the leader parameter.
Following anything other than a CAN-enabled SPARK is not officially supported.
- Parameters:
leader
- The motor controller to follow.- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
follow
Causes this controller's output to mirror the provided leader.Only voltage output is mirrored. Settings changed on the leader do not affect the follower.
Following anything other than a CAN-enabled SPARK is not officially supported.
- Parameters:
leader
- The motor controller to follow.invert
- Set the follower to output opposite of the leader- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
follow
Causes this controller's output to mirror the provided leader.Only voltage output is mirrored. Settings changed on the leader do not affect the follower.
The motor will spin in the same direction as the leader. This can be changed by passing a true constant after the deviceID parameter.
Following anything other than a CAN-enabled SPARK is not officially supported.
- Parameters:
leaderCanId
- The CAN ID of the device to follow.- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
follow
Causes this controller's output to mirror the provided leader.Only voltage output is mirrored. Settings changed on the leader do not affect the follower.
Following anything other than a CAN-enabled SPARK is not officially supported.
- Parameters:
leaderCanId
- The CAN ID of the device to follow.invert
- Set the follower to output opposite of the leader- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
disableFollowerMode
Disables follower mode on the controller.- Returns:
- The modified
SparkBaseConfig
object for method chaining
-
flatten
- Overrides:
flatten
in classBaseConfig
-