DutyCycle

class wpilib.DutyCycle(source: SupportsInt | SupportsIndex)

Bases: Sendable

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. These can be attached to any SmartIO.

Constructs a DutyCycle input from a smartio channel.

Parameters:

source – The channel to use.

getFrequency() wpimath.units.hertz

Get the frequency of the duty cycle signal.

Returns:

frequency

getHighTime() wpimath.units.seconds

Get the raw high time of the duty cycle signal.

Returns:

high time of last pulse

getOutput() float

Get the output ratio of the duty cycle signal.

0 means always low, 1 means always high.

Returns:

output ratio between 0 and 1

getSourceChannel() int

Get the channel of the source.

Returns:

the source channel