This page refers to the REV SparkFlex while attached to a BRUSHLESS MOTOR (REV Vortex's) .
{% embed url="https://www.revrobotics.com/next-generation-spark-neo/" %}
{% embed url="https://www.revrobotics.com/rev-21-1652/" %}
{% embed url="https://www.revrobotics.com/rev-11-2159/" %}
An small example program to create a CANSparkFlex
object is as follows.
import com.revrobotics.CANSparkFlex;
import com.revrobotics.CANSparkLowLevel.MotorType;
new CANSparkFlex(10, MotorType.kBrushless);
The SparkFlex allows you to test the motor controller PID, run the motor at a set percentage, and update the firmware all from the REV Hardware Client. Installation of the REV Hardware client is required to use the SparkFlex for YAGSL.
{% embed url="https://docs.revrobotics.com/rev-hardware-client/gs/install" %} REV Hardware Client Installation guide + download {% endembed %}
{% embed url="https://docs.revrobotics.com/brushless/spark-flex/gs/make-it-spin" %} Make it spin using the REV Hardware Client {% endembed %}
{% hint style="warning" %} The SparkFlex must be disconnected from the CAN bus on startup to run via the REV Hardware Client! {% endhint %}
To tune the PID of the SparkFlex you need to open up the REV Hardware Client select the SparkFlex then open the telemetry tab and set it to position control while messing with the parameters in the lefthand pane.
{% embed url="https://docs.revrobotics.com/rev-hardware-client/ion/telemetry" %}
- Set all SparkFlex's to unique CAN ID's.
- Update all SparkFlex's to the latest firmware.
- The SparkFlex rotates the motor counterclockwise positive. (Invert the SparkFlex programmatically if it does not rotate counterclockwise positive).
- Tune the PID value's for one drive motor.
- Tune the PID value's for one steering/azimuth/angle motor.
The SparkFlex is only capable of communicating via CAN and may see some exciting new features soon with CAN FD support!
The following example is one for a module configuration file, e.g. frontleft.json
, frontright.json
, backleft.json
, and backright.json
.
{
"drive": {
"type": "sparkflex",
"id": 5,
"canbus": null
},
"angle": {
"type": "sparkflex",
"id": 6,
"canbus": null
},
"encoder": {
"type": "cancoder",
"id": 11,
"canbus": null
},
"inverted": {
"drive": false,
"angle": false
},
"absoluteEncoderOffset": -18.281,
"location": {
"front": -12,
"left": -12
}
}