PWM
- class wpilib.PWM(channel: SupportsInt | SupportsIndex, registerSendable: bool = True)
Bases:
SendableClass 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.
registerSendable – If true, adds this instance to SendableRegistry
- getChannel() int
- getPulseTime() 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.
- setDisabled() None
Temporarily disables the PWM output. The next set call will re-enable the output.
- setOutputPeriod(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.
- setPulseTime(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.
- setSimDevice(device: SupportsInt | SupportsIndex) None
Indicates this input is used by a simulated device.
- Parameters:
device – simulated device handle