Tachometer

class wpilib.counter.Tachometer(*args, **kwargs)

Bases: Sendable

Tachometer for getting rotational speed from a device.

The Tachometer class measures the time between digital pulses to determine the rotation speed of a mechanism. Examples of devices that could be used with the tachometer class are a hall effect sensor, break beam sensor, or optical sensor detecting tape on a shooter wheel. Unlike encoders, this class only needs a single digital input.

Overloaded function.

  1. __init__(self: wpilib.counter._counter.Tachometer, source: wpilib._wpilib.DigitalSource) -> None

Constructs a new tachometer.

Parameters:

source – The source.

  1. __init__(self: wpilib.counter._counter.Tachometer, source: wpilib._wpilib.DigitalSource) -> None

Constructs a new tachometer.

Parameters:

source – The source.

getEdgesPerRevolution() int

Gets the number of edges per revolution.

Returns:

Edges per revolution.

getFrequency() hertz

Gets the tachometer frequency.

Returns:

Current frequency.

getPeriod() seconds

Gets the tachometer period.

Returns:

Current period.

getRevolutionsPerMinute() revolutions_per_minute

Gets the current tachometer revolutions per minute.

SetEdgesPerRevolution must be set with a non 0 value for this to work.

Returns:

Current RPM.

getRevolutionsPerSecond() turns_per_second

Gets the current tachometer revolutions per second.

SetEdgesPerRevolution must be set with a non 0 value for this to work.

Returns:

Current RPS.

getSamplesToAverage() int

Gets the number of sample to average.

Returns:

Samples to average.

getStopped() bool

Gets if the tachometer is stopped.

Returns:

True if the tachometer is stopped.

setEdgesPerRevolution(edges: int) None

Sets the number of edges per revolution.

Parameters:

edges – Edges per revolution.

setMaxPeriod(maxPeriod: seconds) None

Sets the maximum period before the tachometer is considered stopped.

Parameters:

maxPeriod – The max period.

setSamplesToAverage(samples: int) None

Sets the number of samples to average.

Parameters:

samples – Samples to average.

setUpdateWhenEmpty(updateWhenEmpty: bool) None

Sets if to update when empty.

Parameters:

updateWhenEmpty – True to update when empty.