Class Tachometer
java.lang.Object
org.wpilib.hardware.counter.Tachometer
- All Implemented Interfaces:
AutoCloseable, TelemetryLoggable
Tachometer.
The Tachometer class measures the rate of digital pulses to determine the rotation velocity 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 TypeMethodDescriptionvoidclose()intGets the number of edges per revolution.doubleGets the tachometer frequency.doubleGets the current tachometer revolutions per minute.doubleGets the current tachometer revolutions per second.booleanGets if the tachometer is stopped.Gets the telemetry table type.voidlogTo(TelemetryTable table) Logs the object to aTelemetryTable.voidsetEdgesPerRevolution(int edgesPerRevolution) Sets the number of edges per revolution.voidsetRateWindow(int windowMilliseconds) Sets the time window used to calculate the tachometer rate.
-
Constructor Details
-
Tachometer
Constructs a new tachometer.- Parameters:
channel- The channel of the Tachometer.configuration- The edge configuration
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
getFrequency
public double getFrequency()Gets the tachometer frequency.- Returns:
- Current frequency (in hertz).
-
setRateWindow
public void setRateWindow(int windowMilliseconds) Sets the time window used to calculate the tachometer rate.- Parameters:
windowMilliseconds- The rate calculation window in milliseconds. Valid values are 5 through 255. The default is 50.
-
getEdgesPerRevolution
public int getEdgesPerRevolution()Gets the number of edges per revolution.- Returns:
- Edges per revolution.
-
setEdgesPerRevolution
public void setEdgesPerRevolution(int edgesPerRevolution) Sets the number of edges per revolution.- Parameters:
edgesPerRevolution- Edges per revolution.
-
getRevolutionsPerSecond
public double 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
public double 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
public boolean getStopped()Gets if the tachometer is stopped.The tachometer is stopped when its current frequency is zero.
- Returns:
- True if the tachometer is stopped.
-
logTo
Description copied from interface:TelemetryLoggableLogs the object to aTelemetryTable.- Specified by:
logToin interfaceTelemetryLoggable- Parameters:
table- telemetry table
-
getTelemetryType
Description copied from interface:TelemetryLoggableGets the telemetry table type. Default is no specified table type (null). A mismatch in type during logging results in a reported warning, so this should always return the same value.- Specified by:
getTelemetryTypein interfaceTelemetryLoggable- Returns:
- Table type
-