SparkMaxAlternateEncoder
- class rev.SparkMaxAlternateEncoder
Bases:
RelativeEncoder
Get an instance of this class by using CANSparkMax::GetEncoder() or CANSparkMax::GetEncoder(CANSparkMax::EncoderType, int).
- class Type(value: int)
Bases:
pybind11_object
The type of encoder wired as an Alternate Encoder on a SPARK MAX
Members:
kQuadrature
- kQuadrature = <Type.kQuadrature: 0>
- property name
- property value
- getAverageDepth() int
Get the average sampling depth for a quadrature encoder.
- Returns:
The average sampling depth
- getCountsPerRevolution() int
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
- getInverted() bool
Get the phase of the MotorFeedbackSensor. This will just return false if the user tries to get inverted while the SparkMax is Brushless and using the hall effect sensor.
- Returns:
The phase of the encoder
- getMeasurementPeriod() int
Get the number of samples for reading from a quadrature encoder. This value sets the number of samples in the average for velocity readings.
- Returns:
Measurement period in microseconds
- getPosition() float
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
- getPositionConversionFactor() float
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
- getVelocity() float
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
- getVelocityConversionFactor() float
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(depth: int) rev._rev.REVLibError
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.
- Parameters:
depth – The average sampling depth between 1 and 64 (default)
- Returns:
REVLibError::kOk if successful
- setInverted(inverted: bool) rev._rev.REVLibError
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.
- Parameters:
inverted – The phase of the encoder
- Returns:
REVLibError::kOk if successful
- setMeasurementPeriod(period_ms: int) rev._rev.REVLibError
Set the measurement period for velocity measurements of a quadrature encoder.
The basic formula to calculate velocity is change in position / change in time. This parameter sets the change in time for measurement.
- Parameters:
period_ms – Measurement period in milliseconds. This number may be between 1 and 100 (default).
- Returns:
REVLibError::kOk if successful
- setPosition(position: float) rev._rev.REVLibError
Set the position of the encoder.
- Parameters:
position – Number of rotations of the motor
- Returns:
REVLibError::kOk if successful
- setPositionConversionFactor(factor: float) rev._rev.REVLibError
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(factor: float) rev._rev.REVLibError
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