PWM

class wpilib.PWM(channel: SupportsInt | SupportsIndex, register_sendable: bool = True)

Bases: Sendable

Class for sending pulse-width modulation (PWM) signals.

Allocate a PWM given a channel number.

Checks channel value range and allocates the appropriate channel. The allocation is only done to help users ensure that they don’t double assign channels.

Parameters:
  • channel – The SmartIO channel number.

  • register_sendable – If true, adds this instance to SendableRegistry

get_channel() int
get_pulse_time() wpimath.units.microseconds

Get the PWM pulse time directly from the hardware.

Read a microsecond value from a PWM channel.

Returns:

Microsecond PWM control value. Range 0 - 4096.

set_disabled() None

Temporarily disables the PWM output. The next set call will re-enable the output.

set_output_period(period: wpimath.units.milliseconds) None

Sets the PWM output period.

Parameters:

period – The output period to apply to this channel, in milliseconds. Valid values are 5ms, 10ms, and 20ms. Default is 20 ms.

set_pulse_time(time: wpimath.units.microseconds) None

Set the PWM pulse time directly to the hardware.

Write a microsecond value to a PWM channel.

Parameters:

time – Microsecond PWM value. Range 0 - 4096.

set_sim_device(device: SupportsInt | SupportsIndex) None

Indicates this input is used by a simulated device.

Parameters:

device – simulated device handle