Class CANSparkMax

  • All Implemented Interfaces:
    edu.wpi.first.wpilibj.motorcontrol.MotorController, java.lang.AutoCloseable

    public class CANSparkMax
    extends CANSparkBase
    • 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.
        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.
    • Method Detail

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

        @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 kQuadrature
        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