Package com.revrobotics
Class CANSparkMax
- java.lang.Object
-
- com.revrobotics.CANSparkLowLevel
-
- com.revrobotics.CANSparkBase
-
- com.revrobotics.CANSparkMax
-
- All Implemented Interfaces:
edu.wpi.first.wpilibj.motorcontrol.MotorController
,java.lang.AutoCloseable
public class CANSparkMax extends CANSparkBase
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.revrobotics.CANSparkBase
CANSparkBase.ControlType, CANSparkBase.ExternalFollower, CANSparkBase.FaultID, CANSparkBase.IdleMode, CANSparkBase.InputMode, CANSparkBase.SoftLimitDirection
-
Nested classes/interfaces inherited from class com.revrobotics.CANSparkLowLevel
CANSparkLowLevel.FollowConfig, CANSparkLowLevel.MotorType, CANSparkLowLevel.PeriodicFrame, CANSparkLowLevel.PeriodicStatus0, CANSparkLowLevel.PeriodicStatus1, CANSparkLowLevel.PeriodicStatus2, CANSparkLowLevel.SparkModel
-
-
Field Summary
-
Fields inherited from class com.revrobotics.CANSparkLowLevel
expectedSparkModel, isClosed, kAPIBuildVersion, kAPIMajorVersion, kAPIMinorVersion, kAPIVersion, motorType, sparkMaxHandle
-
-
Constructor Summary
Constructors Constructor Description CANSparkMax(int deviceId, CANSparkLowLevel.MotorType type)
Create a new object to control a SPARK MAX motor ControllerCANSparkMax(int deviceId, CANSparkMaxLowLevel.MotorType type)
Deprecated, for removal: This API element is subject to removal in a future version.UseCANSparkMax(int, CANSparkLowLevel.MotorType)
instead
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RelativeEncoder
getAlternateEncoder(int countsPerRev)
Returns an object for interfacing with a quadrature encoder connected to the alternate encoder mode data port pins.RelativeEncoder
getAlternateEncoder(AlternateEncoderType encoderType, int countsPerRev)
Deprecated, for removal: This API element is subject to removal in a future version.RelativeEncoder
getAlternateEncoder(SparkMaxAlternateEncoder.Type encoderType, int countsPerRev)
Returns an object for interfacing with a quadrature encoder connected to the alternate encoder mode data port pins.RelativeEncoder
getEncoder()
Returns an object for interfacing with the encoder connected to the encoder pins or front port of the SPARK MAX.-
Methods inherited from class com.revrobotics.CANSparkBase
burnFlash, clearFaults, disable, disableVoltageCompensation, enableSoftLimit, enableVoltageCompensation, follow, follow, follow, follow, get, getAbsoluteEncoder, getAbsoluteEncoder, getAbsoluteEncoder, getAnalog, getAnalog, getAnalog, getAnalog, getAppliedOutput, getBusVoltage, getClosedLoopRampRate, getEncoder, getEncoder, getEncoder, getFault, getFaults, getFeedbackDeviceID, getForwardLimitSwitch, getForwardLimitSwitch, getForwardLimitSwitch, getIdleMode, getInverted, getLastError, getMotorTemperature, getOpenLoopRampRate, getOutputCurrent, getPIDController, getReverseLimitSwitch, getReverseLimitSwitch, getReverseLimitSwitch, getSoftLimit, getStickyFault, getStickyFaults, getVoltageCompensationNominalVoltage, isFollower, isSoftLimitEnabled, set, setCANTimeout, setClosedLoopRampRate, setIdleMode, setInverted, setOpenLoopRampRate, setSecondaryCurrentLimit, setSecondaryCurrentLimit, setSmartCurrentLimit, setSmartCurrentLimit, setSmartCurrentLimit, setSoftLimit, setVoltage, stopMotor
-
Methods inherited from class com.revrobotics.CANSparkLowLevel
close, enableExternalUSBControl, getDeviceId, getFirmwareString, getFirmwareVersion, getInitialMotorType, getMotorType, getSafeFloat, getSerialNumber, restoreFactoryDefaults, restoreFactoryDefaults, setCANMaxRetries, setControlFramePeriodMs, setPeriodicFramePeriod, setPeriodicFramePeriod, setPeriodicFrameTimeout, throwIfClosed
-
-
-
-
Constructor Detail
-
CANSparkMax
public CANSparkMax(int deviceId, CANSparkLowLevel.MotorType type)
Create a new object to control a SPARK MAX motor Controller- Parameters:
deviceId
- The device ID.type
- The motor type connected to the controller. Brushless motor wires must be connected to their matching colors and the hall sensor must be plugged in. Brushed motors must be connected to the Red and Black terminals only.
-
CANSparkMax
@Deprecated(forRemoval=true) public CANSparkMax(int deviceId, CANSparkMaxLowLevel.MotorType type)
Deprecated, for removal: This API element is subject to removal in a future version.UseCANSparkMax(int, CANSparkLowLevel.MotorType)
insteadCreate a new object to control a SPARK MAX motor Controller- Parameters:
deviceId
- The device ID.type
- The motor type connected to the controller. Brushless motor wires must be connected to their matching colors and the hall sensor must be plugged in. Brushed motors must be connected to the Red and Black terminals only.
-
-
Method Detail
-
getEncoder
public RelativeEncoder getEncoder()
Returns an object for interfacing with the encoder connected to the encoder pins or front port of the SPARK MAX.For a SPARK MAX in brushless mode, it is assumed that the default encoder type is hall effect and the counts per revolution is 42.
For a SPARK MAX in brushed mode, use
CANSparkBase.getEncoder(com.revrobotics.SparkRelativeEncoder.Type, int)
.- Specified by:
getEncoder
in classCANSparkBase
- Returns:
- An object for interfacing with the integrated encoder.
-
getAlternateEncoder
public RelativeEncoder getAlternateEncoder(int countsPerRev)
Returns an object for interfacing with a quadrature encoder connected to the alternate encoder mode data port pins. These are defined as:- Pin 4 (Forward Limit Switch): Index
- Pin 6 (Multi-function): Encoder A
- Pin 8 (Reverse Limit Switch): Encoder B
This call will disable support for the limit switch inputs.
- Parameters:
countsPerRev
- The counts per revolution of the encoder- Returns:
- An object for interfacing with a quadrature encoder connected to the alternate encoder mode data port pins
-
getAlternateEncoder
public RelativeEncoder getAlternateEncoder(SparkMaxAlternateEncoder.Type encoderType, int countsPerRev)
Returns an object for interfacing with a quadrature encoder connected to the alternate encoder mode data port pins. These are defined as:- Pin 4 (Forward Limit Switch): Index
- Pin 6 (Multi-function): Encoder A
- Pin 8 (Reverse Limit Switch): Encoder B
This call will disable support for the limit switch inputs.
- Parameters:
encoderType
- The encoder type for the motor: currently only kQuadraturecountsPerRev
- The counts per revolution of the encoder- Returns:
- An object for interfacing with a quadrature encoder connected to the alternate encoder mode data port pins
-
getAlternateEncoder
@Deprecated(forRemoval=true) public RelativeEncoder getAlternateEncoder(AlternateEncoderType encoderType, int countsPerRev)
Deprecated, for removal: This API element is subject to removal in a future version.Returns an object for interfacing with a quadrature encoder connected to the alternate encoder mode data port pins. These are defined as:- Pin 4 (Forward Limit Switch): Index
- Pin 6 (Multi-function): Encoder A
- Pin 8 (Reverse Limit Switch): Encoder B
This call will disable support for the limit switch inputs.
- Parameters:
encoderType
- The encoder type for the motor: currently only kQuadraturecountsPerRev
- The counts per revolution of the encoder- Returns:
- An object for interfacing with a quadrature encoder connected to the alternate encoder mode data port pins
-
-