Class CANSparkFlex

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

    public class CANSparkFlex
    extends CANSparkBase
    • Constructor Detail

      • CANSparkFlex

        public CANSparkFlex​(int deviceId,
                            CANSparkLowLevel.MotorType type)
        Create a new object to control a SPARK Flex 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

      • getExternalEncoder

        public RelativeEncoder getExternalEncoder​(int countsPerRev)
        Returns an object for interfacing with an external quadrature encoder
        Parameters:
        countsPerRev - The counts per revolution of the encoder
        Returns:
        An object for interfacing with an external quadrature encoder
      • getExternalEncoder

        public RelativeEncoder getExternalEncoder​(SparkFlexExternalEncoder.Type encoderType,
                                                  int countsPerRev)
        Returns an object for interfacing with an external quadrature encoder
        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 an external quadrature encoder