Package edu.wpi.first.wpilibj.counter
Class Tachometer
java.lang.Object
edu.wpi.first.wpilibj.counter.Tachometer
- All Implemented Interfaces:
Sendable
,AutoCloseable
Tachometer.
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 Summary
ConstructorsConstructorDescriptionTachometer
(int channel, EdgeConfiguration configuration) Constructs a new tachometer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
int
Gets the number of edges per revolution.double
Gets the tachometer frequency.double
Gets the tachometer period.double
Gets the current tachometer revolutions per minute.double
Gets the current tachometer revolutions per second.boolean
Gets if the tachometer is stopped.void
initSendable
(SendableBuilder builder) Initializes thisSendable
object.void
setEdgesPerRevolution
(int edgesPerRevolution) Sets the number of edges per revolution.void
setMaxPeriod
(double maxPeriod) Sets the maximum period before the tachometer is considered stopped.
-
Constructor Details
-
Tachometer
Constructs a new tachometer.- Parameters:
channel
- The channel of the Tachometer.configuration
- The edge configuration
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
-
getPeriod
Gets the tachometer period.- Returns:
- Current period (in seconds).
-
getFrequency
Gets the tachometer frequency.- Returns:
- Current frequency (in hertz).
-
getEdgesPerRevolution
Gets the number of edges per revolution.- Returns:
- Edges per revolution.
-
setEdgesPerRevolution
Sets the number of edges per revolution.- Parameters:
edgesPerRevolution
- Edges per revolution.
-
getRevolutionsPerSecond
Gets the current tachometer revolutions per second.setEdgesPerRevolution must be set with a non 0 value for this to return valid values.
- Returns:
- Current RPS.
-
getRevolutionsPerMinute
Gets the current tachometer revolutions per minute.setEdgesPerRevolution must be set with a non 0 value for this to return valid values.
- Returns:
- Current RPM.
-
getStopped
Gets if the tachometer is stopped.- Returns:
- True if the tachometer is stopped.
-
setMaxPeriod
Sets the maximum period before the tachometer is considered stopped.- Parameters:
maxPeriod
- The max period (in seconds).
-
initSendable
Description copied from interface:Sendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- sendable builder
-