Configuring a SPARK
This page will discuss information about configuration concepts specific to only SPARK MAX and SPARK Flex. For more information on general configuration in REVLib, see this page.
Configuration Classes
SPARK MAX and SPARK Flex each have their own configuration classes, SparkMaxConfig
and SparkFlexConfig
. They are both derived from SparkBaseConfig
which includes shared configurations between the two devices. Configurations specific to SPARK MAX or SPARK Flex live in their respective configuration class.
API Documentation
For more information about what configurations and sub-configuration classes each class provides, refer to the links below:
SparkMaxConfig
SparkFlexConfig
SparkBaseConfig
Persisting Parameters
Configuring a SPARK MAX and SPARK Flex differs from other devices in REVLib with the addition of the persistMode
parameter in their configure()
methods, which specifies whether the configuration settings applied to the device should be persisted between power cycles.
Persisting parameters involves saving them to the SPARK controller's memory, which is time-intensive and blocks communication with the device. To provide flexibility, this process is not automatic, as this behavior may be unnecessary or undesirable in some cases. Therefore, users must manually specify the persist mode, and to help avoid possible pitfalls, it is a required parameter.
Use Cases
It is recommended to persist parameters during the initial configuration of the device at the start of your program to ensure that the controller retains its configuration in the event of a power cycle during operation e.g. due to a breaker trip or a brownout.
When making updates to the configuration mid-operation, it is generally recommend to not persist the applied configuration changes to avoid blocking the program, depending on the use case. While reconfiguring a device during operation is generally discouraged, some use cases may necessitate it, and it is important to make the choice whether to persist parameters as it can affect performance of the robot.
Below is an example of either case:
Defining Motor Type
Motor type is the only configuration parameter that must be set outside of a configuration object, specifically through the constructor of the SparkMax
and SparkFlex
classes. This ensures that the user makes the conscious decision the specify type of motor is being driven, as driving a brushless motor in brushed mode can permanently damage the motor.
Below is an example of how configuring for different motor types would look like:
Last updated