Interface CANEncoder

All Superinterfaces:
CANSensor, MotorFeedbackSensor
All Known Subinterfaces:
RelativeEncoder
All Known Implementing Classes:
SparkMaxAlternateEncoder, SparkMaxRelativeEncoder

@Deprecated(forRemoval=true) public interface CANEncoder extends MotorFeedbackSensor
Deprecated, for removal: This API element is subject to removal in a future version.
use RelativeEncoder instead.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the average sampling depth for a quadrature encoder.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the counts per revolution of the quadrature encoder.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the phase of the MotorFeedbackSensor.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the number of samples for reading from a quadrature encoder.
    double
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the position of the motor.
    double
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the conversion factor for position of the encoder.
    double
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the velocity of the motor.
    double
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the conversion factor for velocity of the encoder.
    setAverageDepth(int depth)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the average sampling depth for a quadrature encoder.
    setInverted(boolean inverted)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the phase of the MotorFeedbackSensor so that it is set to be in phase with the motor itself.
    setMeasurementPeriod(int period_us)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the measurement period for velocity measurements of a quadrature encoder.
    setPosition(double position)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the position of the encoder.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the conversion factor for position of the encoder.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set the conversion factor for velocity of the encoder.
  • Method Details

    • getPosition

      double getPosition()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the position of the motor. This returns the native units of 'rotations' by default, and can be changed by a scale factor using setPositionConversionFactor().
      Returns:
      Number of rotations of the motor
    • getVelocity

      double getVelocity()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the velocity of the motor. This returns the native units of 'RPM' by default, and can be changed by a scale factor using setVelocityConversionFactor().
      Returns:
      Number the RPM of the motor
    • setPosition

      REVLibError setPosition(double position)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the position of the encoder. By default the units are 'rotations' and can be changed by a scale factor using setPositionConversionFactor().
      Parameters:
      position - Number of rotations of the motor
      Returns:
      REVLibError.kOk if successful
    • setPositionConversionFactor

      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the conversion factor for position of the encoder. Multiplied by the native output units to give you position.
      Parameters:
      factor - The conversion factor to multiply the native units by
      Returns:
      REVLibError.kOk if successful
    • setVelocityConversionFactor

      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity
      Parameters:
      factor - The conversion factor to multiply the native units by
      Returns:
      REVLibError.kOk if successful
    • getPositionConversionFactor

      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the conversion factor for position of the encoder. Multiplied by the native output units to give you position
      Returns:
      The conversion factor for position
    • getVelocityConversionFactor

      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the conversion factor for velocity of the encoder. Multiplied by the native output units to give you velocity
      Returns:
      The conversion factor for velocity
    • setAverageDepth

      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the average sampling depth for a quadrature encoder. This value sets the number of samples in the average for velocity readings. This can be any value from 1 to 64.

      When the SparkMax controller is in Brushless mode, this will not change any behavior.

      Parameters:
      depth - The average sampling depth between 1 and 64 (default)
      Returns:
      REVLibError.kOk if successful
    • getAverageDepth

      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the average sampling depth for a quadrature encoder.
      Returns:
      The average sampling depth
    • setMeasurementPeriod

      Deprecated, for removal: This API element is subject to removal in a future version.
      Set the measurement period for velocity measurements of a quadrature encoder. When the SparkMax controller is in Brushless mode, this will not change any behavior.

      The basic formula to calculate velocity is change in position / change in time. This parameter sets the change in time for measurement.

      Parameters:
      period_us - Measurement period in milliseconds. This number may be between 1 and 100 (default).
      Returns:
      REVLibError.kOk if successful
    • getMeasurementPeriod

      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the number of samples for reading from a quadrature encoder.
      Returns:
      Number of samples
    • getCountsPerRevolution

      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the counts per revolution of the quadrature encoder.

      For a description on the difference between CPR, PPR, etc. go to https://www.cuidevices.com/blog/what-is-encoder-ppr-cpr-and-lpr

      Returns:
      Counts per revolution
    • setInverted

      REVLibError setInverted(boolean inverted)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: MotorFeedbackSensor
      Set the phase of the MotorFeedbackSensor so that it is set to be in phase with the motor itself. This only works for quadrature encoders and analog sensors. This will throw an error if the user tries to set the inversion of the hall sensor.
      Specified by:
      setInverted in interface CANSensor
      Specified by:
      setInverted in interface MotorFeedbackSensor
      Parameters:
      inverted - The phase of the sensor
      Returns:
      REVLibError.kOk if successful
    • getInverted

      boolean getInverted()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: MotorFeedbackSensor
      Get the phase of the MotorFeedbackSensor. This will just return false if the user tries to get the inversion of the hall sensor.
      Specified by:
      getInverted in interface CANSensor
      Specified by:
      getInverted in interface MotorFeedbackSensor
      Returns:
      The phase of the sensor