Skip to content

Latest commit

 

History

History
172 lines (121 loc) · 7.61 KB

sparkflex.md

File metadata and controls

172 lines (121 loc) · 7.61 KB

SparkFlex

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/" %}

Getting Started

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

Documentation

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 %}

Tuning PID

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" %}

YAGSL Checklist

  • 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.

Communication

The SparkFlex is only capable of communicating via CAN and may see some exciting new features soon with CAN FD support!

Module example configuration

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
  }
}

Example pidfproperties.json

{
  "drive": {
    "p": 0.0020645,
    "i": 0,
    "d": 0,
    "f": 0,
    "iz": 0
  },
  "angle": {
    "p": 0.01,
    "i": 0,
    "d": 0,
    "f": 0,
    "iz": 0
  }
}

Example physicalproperties.json

{
  "conversionFactor": {
    "drive": 0.047286787200699704,
    "angle": 16.8
  },
  "currentLimit": {
    "drive": 40,
    "angle": 20
  },
  "rampRate": {
    "drive": 0.25,
    "angle": 0.25
  },
  "wheelGripCoefficientOfFriction": 1.19,
  "optimalVoltage": 12
}