WPILibC++ 2025.2.1
|
Tachometer for getting rotational speed from a device. More...
#include <frc/counter/Tachometer.h>
Public Member Functions | |
Tachometer (DigitalSource &source) | |
Constructs a new tachometer. | |
Tachometer (std::shared_ptr< DigitalSource > source) | |
Constructs a new tachometer. | |
Tachometer (Tachometer &&)=default | |
Tachometer & | operator= (Tachometer &&)=default |
~Tachometer () override=default | |
units::hertz_t | GetFrequency () const |
Gets the tachometer frequency. | |
units::second_t | GetPeriod () const |
Gets the tachometer period. | |
int | GetEdgesPerRevolution () const |
Gets the number of edges per revolution. | |
void | SetEdgesPerRevolution (int edges) |
Sets the number of edges per revolution. | |
units::turns_per_second_t | GetRevolutionsPerSecond () const |
Gets the current tachometer revolutions per second. | |
units::revolutions_per_minute_t | GetRevolutionsPerMinute () const |
Gets the current tachometer revolutions per minute. | |
bool | GetStopped () const |
Gets if the tachometer is stopped. | |
int | GetSamplesToAverage () const |
Gets the number of sample to average. | |
void | SetSamplesToAverage (int samples) |
Sets the number of samples to average. | |
void | SetMaxPeriod (units::second_t maxPeriod) |
Sets the maximum period before the tachometer is considered stopped. | |
void | SetUpdateWhenEmpty (bool updateWhenEmpty) |
Sets if to update when empty. | |
Public Member Functions inherited from wpi::Sendable | |
virtual constexpr | ~Sendable ()=default |
Public Member Functions inherited from wpi::SendableHelper< Tachometer > | |
constexpr | SendableHelper (const SendableHelper &rhs)=default |
constexpr | SendableHelper (SendableHelper &&rhs) |
constexpr SendableHelper & | operator= (const SendableHelper &rhs)=default |
constexpr SendableHelper & | operator= (SendableHelper &&rhs) |
Protected Member Functions | |
void | InitSendable (wpi::SendableBuilder &builder) override |
Initializes this Sendable object. | |
Protected Member Functions inherited from wpi::SendableHelper< Tachometer > | |
constexpr | SendableHelper ()=default |
constexpr | ~SendableHelper () |
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.
|
explicit |
Constructs a new tachometer.
source | The source. |
|
explicit |
Constructs a new tachometer.
source | The source. |
|
default |
|
overridedefault |
int frc::Tachometer::GetEdgesPerRevolution | ( | ) | const |
Gets the number of edges per revolution.
units::hertz_t frc::Tachometer::GetFrequency | ( | ) | const |
Gets the tachometer frequency.
units::second_t frc::Tachometer::GetPeriod | ( | ) | const |
Gets the tachometer period.
units::revolutions_per_minute_t frc::Tachometer::GetRevolutionsPerMinute | ( | ) | const |
Gets the current tachometer revolutions per minute.
SetEdgesPerRevolution must be set with a non 0 value for this to work.
units::turns_per_second_t frc::Tachometer::GetRevolutionsPerSecond | ( | ) | const |
Gets the current tachometer revolutions per second.
SetEdgesPerRevolution must be set with a non 0 value for this to work.
int frc::Tachometer::GetSamplesToAverage | ( | ) | const |
Gets the number of sample to average.
bool frc::Tachometer::GetStopped | ( | ) | const |
Gets if the tachometer is stopped.
|
overrideprotectedvirtual |
|
default |
void frc::Tachometer::SetEdgesPerRevolution | ( | int | edges | ) |
Sets the number of edges per revolution.
edges | Edges per revolution. |
void frc::Tachometer::SetMaxPeriod | ( | units::second_t | maxPeriod | ) |
Sets the maximum period before the tachometer is considered stopped.
maxPeriod | The max period. |
void frc::Tachometer::SetSamplesToAverage | ( | int | samples | ) |
Sets the number of samples to average.
samples | Samples to average. |
void frc::Tachometer::SetUpdateWhenEmpty | ( | bool | updateWhenEmpty | ) |
Sets if to update when empty.
updateWhenEmpty | True to update when empty. |