Package edu.wpi.first.wpilibj
Class DutyCycle
java.lang.Object
edu.wpi.first.wpilibj.DutyCycle
- All Implemented Interfaces:
Sendable
,AutoCloseable
Class to read a duty cycle PWM input.
PWM input signals are specified with a frequency and a ratio of high to low in that frequency. There are 8 of these in the roboRIO, and they can be attached to any SmartIO Channel.
These can be combined as the input of an AnalogTrigger to a Counter in order to implement rollover checking.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the DutyCycle and free all resources.double
Get the frequency of the duty cycle signal.int
Get the raw high time of the duty cycle signal.double
Get the output ratio of the duty cycle signal.int
Get the channel of the source.void
initSendable
(SendableBuilder builder) Initializes thisSendable
object.
-
Constructor Details
-
DutyCycle
Constructs a DutyCycle input from a smartio channel.- Parameters:
channel
- The channel to use.
-
-
Method Details
-
close
Close the DutyCycle and free all resources.- Specified by:
close
in interfaceAutoCloseable
-
getFrequency
Get the frequency of the duty cycle signal.- Returns:
- frequency in Hertz
-
getOutput
Get the output ratio of the duty cycle signal.0 means always low, 1 means always high.
- Returns:
- output ratio between 0 and 1
-
getHighTimeNanoseconds
Get the raw high time of the duty cycle signal.- Returns:
- high time of last pulse in nanoseconds
-
getSourceChannel
Get the channel of the source.- Returns:
- the source channel
-
initSendable
Description copied from interface:Sendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- sendable builder
-