CANSparkMaxLowLevel

class rev.CANSparkMaxLowLevel(self: rev.CANSparkMaxLowLevel, deviceID: int, type: rev._rev.CANSparkMaxLowLevel.MotorType) → None

Bases: wpilib.ErrorBase, wpilib.interfaces.SpeedController

Create a new SPARK MAX Controller

Parameters
  • deviceID – The device ID.

  • type – The motor type connected to the controller. Brushless motors must be connected to their matching color and the hall sensor plugged in. Brushed motors must be connected to the Red and Black terminals only.

class MotorType(self: rev._rev.CANSparkMaxLowLevel.MotorType, value: int) → None

Bases: pybind11_builtins.pybind11_object

Members:

kBrushed

kBrushless

kBrushed = <MotorType.kBrushed: 0>
kBrushless = <MotorType.kBrushless: 1>
property name
class ParameterStatus(self: rev._rev.CANSparkMaxLowLevel.ParameterStatus, value: int) → None

Bases: pybind11_builtins.pybind11_object

Members:

kOK

kInvalidID

kMismatchType

kAccessMode

kInvalid

kNotImplementedDeprecated

kAccessMode = <ParameterStatus.kAccessMode: 3>
kInvalid = <ParameterStatus.kInvalid: 4>
kInvalidID = <ParameterStatus.kInvalidID: 1>
kMismatchType = <ParameterStatus.kMismatchType: 2>
kNotImplementedDeprecated = <ParameterStatus.kNotImplementedDeprecated: 5>
kOK = <ParameterStatus.kOK: 0>
property name
class PeriodicFrame(self: rev._rev.CANSparkMaxLowLevel.PeriodicFrame, value: int) → None

Bases: pybind11_builtins.pybind11_object

Members:

kStatus0

kStatus1

kStatus2

kStatus0 = <PeriodicFrame.kStatus0: 0>
kStatus1 = <PeriodicFrame.kStatus1: 1>
kStatus2 = <PeriodicFrame.kStatus2: 2>
property name
class PeriodicStatus0(self: rev._rev.CANSparkMaxLowLevel.PeriodicStatus0) → None

Bases: pybind11_builtins.pybind11_object

property appliedOutput
property faults
property isFollower
property isInverted
property lock
property motorType
property roboRIO
property stickyFaults
property timestamp
class PeriodicStatus1(self: rev._rev.CANSparkMaxLowLevel.PeriodicStatus1) → None

Bases: pybind11_builtins.pybind11_object

property busVoltage
property motorTemperature
property outputCurrent
property sensorVelocity
property timestamp
class PeriodicStatus2(self: rev._rev.CANSparkMaxLowLevel.PeriodicStatus2) → None

Bases: pybind11_builtins.pybind11_object

property iAccum
property sensorPosition
property timestamp
class TelemetryID(self: rev._rev.CANSparkMaxLowLevel.TelemetryID, value: int) → None

Bases: pybind11_builtins.pybind11_object

Members:

kBusVoltage

kOutputCurrent

kVelocity

kPosition

kIAccum

kAppliedOutput

kMotorTemp

kFaults

kStickyFaults

kAnalogVoltage

kAnalogPosition

kAnalogVelocity

kAltEncPosition

kAltEncVelocity

kTotalStreams

kAltEncPosition = <TelemetryID.kAltEncPosition: 12>
kAltEncVelocity = <TelemetryID.kAltEncVelocity: 13>
kAnalogPosition = <TelemetryID.kAnalogPosition: 10>
kAnalogVelocity = <TelemetryID.kAnalogVelocity: 11>
kAnalogVoltage = <TelemetryID.kAnalogVoltage: 9>
kAppliedOutput = <TelemetryID.kAppliedOutput: 5>
kBusVoltage = <TelemetryID.kBusVoltage: 0>
kFaults = <TelemetryID.kFaults: 7>
kIAccum = <TelemetryID.kIAccum: 4>
kMotorTemp = <TelemetryID.kMotorTemp: 6>
kOutputCurrent = <TelemetryID.kOutputCurrent: 1>
kPosition = <TelemetryID.kPosition: 3>
kStickyFaults = <TelemetryID.kStickyFaults: 8>
kTotalStreams = <TelemetryID.kTotalStreams: 14>
kVelocity = <TelemetryID.kVelocity: 2>
property name
class TelemetryMessage(self: rev._rev.CANSparkMaxLowLevel.TelemetryMessage) → None

Bases: pybind11_builtins.pybind11_object

property id
property lowerBnd
property name
property timestamp
property units
property upperBnd
property value
static enableExternalUSBControl(enable: bool) → None

Allow external controllers to recieve control commands over USB. For example, a configuration where the heartbeat (and enable/disable) is sent by the main controller, but control frames are sent by other CAN devices over USB.

This is global for all controllers on the same bus.

This does not disable sending control frames from this device. To prevent conflicts, do not enable this feature and also send Set() for SetReference() from the controllers you wish to control.

Parameters

enable – Enable or disable external control

getDeviceId(self: rev.CANSparkMaxLowLevel) → int

Get the configured Device ID of the SPARK MAX.

Returns

int device ID

getFirmwareString(self: rev.CANSparkMaxLowLevel) → str

Get the firmware version of the SPARK MAX as a string.

Returns

std::string Human readable firmware version string

getFirmwareVersion(self: rev.CANSparkMaxLowLevel) → int

Get the firmware version of the SPARK MAX.

Returns

uint32_t Firmware version integer. Value is represented as 4 bytes, Major.Minor.Build H.Build L

getInitialMotorType(self: rev.CANSparkMaxLowLevel) → rev._rev.CANSparkMaxLowLevel.MotorType

Get the motor type setting from when the SparkMax was created.

This does not use the Get Parameter API which means it does not read what motor type is stored on the SparkMax itself. Instead, it reads the stored motor type from when the SparkMax object was first created.

Returns

MotorType Motor type setting

getMotorType(self: rev.CANSparkMaxLowLevel) → rev._rev.CANSparkMaxLowLevel.MotorType

Get the motor type setting for the SPARK MAX.

This uses the Get Parameter API and should be used infrequently. This function uses a non-blocking call and will return a cached value if the parameter is not returned by the timeout. The timeout can be changed by calling SetCANTimeout(int milliseconds)

Returns

MotorType Motor type setting

getSerialNumber(self: rev.CANSparkMaxLowLevel) → List[int]

Get the unique serial number of the SPARK MAX. Currently not implemented.

Returns

std::vector<uint8_t> Vector of bytes representig the unique serial number

kAPIBuildVersion = 4
kAPIMajorVersion = 1
kAPIMinorVersion = 5
kAPIVersion = 17104900
restoreFactoryDefaults(self: rev.CANSparkMaxLowLevel, persist: bool = False)rev.CANError

Restore motor controller parameters to factory default

Parameters

persist – If true, burn the flash with the factory default parameters

Returns

CANError Set to CANError::kOk if successful

setControlFramePeriodMs(self: rev.CANSparkMaxLowLevel, periodMs: int) → None

Set the control frame send period for the native CAN Send thread. To disable periodic sends, set periodMs to 0.

Parameters

periodMs – The send period in milliseconds between 1ms and 100ms or set to 0 to disable periodic sends. Note this is not updated until the next call to Set() or SetReference().

static setEnable(enable: bool) → None

Send enabled or disabled command to controllers. This is global for all controllers on the same bus, and will only work for non-roboRIO targets in non-competiton use. This function will also not work if a roboRIO is present on the CAN bus.

This does not disable sending control frames from this device. To prevent conflicts, do not enable this feature and also send Set() for SetReference() from the controllers you wish to control.

Parameters

enable – Enable or disable external control

setMotorType(self: rev.CANSparkMaxLowLevel, type: rev._rev.CANSparkMaxLowLevel.MotorType)rev.CANError
setPeriodicFramePeriod(self: rev.CANSparkMaxLowLevel, frame: rev._rev.CANSparkMaxLowLevel.PeriodicFrame, periodMs: int)rev.CANError

Set the rate of transmission for periodic frames from the SPARK MAX

Each motor controller sends back three status frames with different data at set rates. Use this function to change the default rates.

Defaults: Status0 - 10ms Status1 - 20ms Status2 - 50ms

This value is not stored in the FLASH after calling burnFlash() and is reset on powerup.

Refer to the SPARK MAX reference manual on details for how and when to configure this parameter.

Parameters
  • frameID – The frame ID can be one of PeriodicFrame type

  • periodMs – The rate the controller sends the frame to the controller.

Returns

CANError Set to CANError::kOk if successful