WPILibC++ 2024.3.2
frc::Tachometer Class Reference

Tachometer for getting rotational speed from a device. More...

#include <frc/counter/Tachometer.h>

Inheritance diagram for frc::Tachometer:
wpi::Sendable wpi::SendableHelper< Tachometer >

Public Member Functions

 Tachometer (DigitalSource &source)
 Constructs a new tachometer. More...
 
 Tachometer (std::shared_ptr< DigitalSource > source)
 Constructs a new tachometer. More...
 
 ~Tachometer () override
 
 Tachometer (Tachometer &&)=default
 
Tachometeroperator= (Tachometer &&)=default
 
units::hertz_t GetFrequency () const
 Gets the tachometer frequency. More...
 
units::second_t GetPeriod () const
 Gets the tachometer period. More...
 
int GetEdgesPerRevolution () const
 Gets the number of edges per revolution. More...
 
void SetEdgesPerRevolution (int edges)
 Sets the number of edges per revolution. More...
 
units::turns_per_second_t GetRevolutionsPerSecond () const
 Gets the current tachometer revolutions per second. More...
 
units::revolutions_per_minute_t GetRevolutionsPerMinute () const
 Gets the current tachometer revolutions per minute. More...
 
bool GetStopped () const
 Gets if the tachometer is stopped. More...
 
int GetSamplesToAverage () const
 Gets the number of sample to average. More...
 
void SetSamplesToAverage (int samples)
 Sets the number of samples to average. More...
 
void SetMaxPeriod (units::second_t maxPeriod)
 Sets the maximum period before the tachometer is considered stopped. More...
 
void SetUpdateWhenEmpty (bool updateWhenEmpty)
 Sets if to update when empty. More...
 
- Public Member Functions inherited from wpi::Sendable
virtual ~Sendable ()=default
 
virtual void InitSendable (SendableBuilder &builder)=0
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from wpi::SendableHelper< Tachometer >
 SendableHelper (const SendableHelper &rhs)=default
 
 SendableHelper (SendableHelper &&rhs)
 
SendableHelperoperator= (const SendableHelper &rhs)=default
 
SendableHelperoperator= (SendableHelper &&rhs)
 

Protected Member Functions

void InitSendable (wpi::SendableBuilder &builder) override
 Initializes this Sendable object. More...
 
- Protected Member Functions inherited from wpi::SendableHelper< Tachometer >
 SendableHelper ()=default
 
 ~SendableHelper ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Tachometer() [1/3]

frc::Tachometer::Tachometer ( DigitalSource source)
explicit

Constructs a new tachometer.

Parameters
sourceThe source.

◆ Tachometer() [2/3]

frc::Tachometer::Tachometer ( std::shared_ptr< DigitalSource source)
explicit

Constructs a new tachometer.

Parameters
sourceThe source.

◆ ~Tachometer()

frc::Tachometer::~Tachometer ( )
override

◆ Tachometer() [3/3]

frc::Tachometer::Tachometer ( Tachometer &&  )
default

Member Function Documentation

◆ GetEdgesPerRevolution()

int frc::Tachometer::GetEdgesPerRevolution ( ) const

Gets the number of edges per revolution.

Returns
Edges per revolution.

◆ GetFrequency()

units::hertz_t frc::Tachometer::GetFrequency ( ) const

Gets the tachometer frequency.

Returns
Current frequency.

◆ GetPeriod()

units::second_t frc::Tachometer::GetPeriod ( ) const

Gets the tachometer period.

Returns
Current period.

◆ GetRevolutionsPerMinute()

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.

Returns
Current RPM.

◆ GetRevolutionsPerSecond()

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.

Returns
Current RPS.

◆ GetSamplesToAverage()

int frc::Tachometer::GetSamplesToAverage ( ) const

Gets the number of sample to average.

Returns
Samples to average.

◆ GetStopped()

bool frc::Tachometer::GetStopped ( ) const

Gets if the tachometer is stopped.

Returns
True if the tachometer is stopped.

◆ InitSendable()

void frc::Tachometer::InitSendable ( wpi::SendableBuilder builder)
overrideprotectedvirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::Sendable.

◆ operator=()

Tachometer & frc::Tachometer::operator= ( Tachometer &&  )
default

◆ SetEdgesPerRevolution()

void frc::Tachometer::SetEdgesPerRevolution ( int  edges)

Sets the number of edges per revolution.

Parameters
edgesEdges per revolution.

◆ SetMaxPeriod()

void frc::Tachometer::SetMaxPeriod ( units::second_t  maxPeriod)

Sets the maximum period before the tachometer is considered stopped.

Parameters
maxPeriodThe max period.

◆ SetSamplesToAverage()

void frc::Tachometer::SetSamplesToAverage ( int  samples)

Sets the number of samples to average.

Parameters
samplesSamples to average.

◆ SetUpdateWhenEmpty()

void frc::Tachometer::SetUpdateWhenEmpty ( bool  updateWhenEmpty)

Sets if to update when empty.

Parameters
updateWhenEmptyTrue to update when empty.

The documentation for this class was generated from the following file: