CANAnalog

class rev.CANAnalog(self: rev.CANAnalog, device: rev.CANSparkMax, mode: rev._rev.CANAnalog.AnalogMode) → None

Bases: rev.CANSensor

class AnalogMode(self: rev._rev.CANAnalog.AnalogMode, value: int) → None

Bases: pybind11_builtins.pybind11_object

Analog sensors have the ability to either be absolute or relative. By default, GetAnalog() will return an absolute analog sensor, but it can also be configured to be a relative sensor instead.

Members:

kAbsolute

kRelative

kAbsolute = <AnalogMode.kAbsolute: 0>
kRelative = <AnalogMode.kRelative: 1>
property name
getAverageDepth(self: rev.CANAnalog) → int

Get the averafe sampling depth for a quadrature encoder.

Returns

The average sampling depth

getInverted(self: rev.CANAnalog) → bool

Get the phase of the CANSensor. 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(self: rev.CANAnalog) → 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(self: rev.CANAnalog) → float

Get the position of the motor. Returns value in the native unit of ‘volt’ by default, and can be changed by a scale factor using setPositionConversionFactor().

Returns

Position of the sensor in volts

getPositionConversionFactor(self: rev.CANAnalog) → float

Get the current conversion factor for the position of the analog sensor.

Returns

Analog position conversion factor

getVelocity(self: rev.CANAnalog) → float

Get the velocity of the motor. Returns value in the native units of ‘volts per second’ by default, and can be changed by a scale factor using setVelocityConversionFactor().

Returns

Velocity of the sensor in volts per second

getVelocityConversionFactor(self: rev.CANAnalog) → float

Get the current conversion factor for the velocity of the analog sensor.

Returns

Analog velocity conversion factor

getVoltage(self: rev.CANAnalog) → float

Get the voltage of the analog sensor.

Returns

Voltage of the sensor

setAverageDepth(self: rev.CANAnalog, depth: int)rev.CANError

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

CANError.kOK if successful

setInverted(self: rev.CANAnalog, inverted: bool)rev.CANError

Set the phase of the CANSensor so that it is set to be in phase with the motor itself. This only works for quadrature encoders. This will throw an error if the user tries to set inverted while the SparkMax is Brushless and using the hall effect sensor.

Parameters

inverted – The phase of the encoder

Returns

CANError.kOK if successful

setMeasurementPeriod(self: rev.CANAnalog, period_ms: int)rev.CANError

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 positon / 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

CANError.kOK if successful

setPositionConversionFactor(self: rev.CANAnalog, factor: float)rev.CANError

Set the conversion factor for the position of the analog sensor. By default, revolutions per volt is 1. Changing the position conversion factor will also change the position units.

Parameters

factor – The conversion factor which will be multiplied by volts

Returns

CANError Set to CANError.kOK if successful

setVelocityConversionFactor(self: rev.CANAnalog, factor: float)rev.CANError

Set the conversion factor for the veolocity of the analog sensor. By default, revolutions per volt second is 1. Changing the velocity conversion factor will also change the velocity units.

Parameters

factor – The conversion factor which will be multipled by volts per second

Returns

CANError Set to CANError.kOK is successful