PWMMotorController

class wpilib.PWMMotorController(name: str, channel: int)

Bases: MotorController, MotorSafety, Sendable

Common base class for all PWM Motor Controllers.

Constructor for a PWM Motor %Controller connected via PWM.

Parameters:
  • name – Name to use for SendableRegistry

  • channel – The PWM channel that the controller is attached to. 0-9 are on-board, 10-19 are on the MXP port

addFollower(follower: wpilib._wpilib.PWMMotorController) None

Make the given PWM motor controller follow the output of this one.

Parameters:

follower – The motor controller follower.

disable() None
enableDeadbandElimination(eliminateDeadband: bool) None

Optionally eliminate the deadband from a motor controller.

Parameters:

eliminateDeadband – If true, set the motor curve on the motor controller to eliminate the deadband in the middle of the range. Otherwise, keep the full range without modifying any values.

get() float

Get the recently set value of the PWM. This value is affected by the inversion property. If you want the value that is sent directly to the MotorController, use PWM::GetSpeed() instead.

Returns:

The most recently set value for the PWM between -1.0 and 1.0.

getChannel() int
getDescription() str
getInverted() bool
set(value: float) None

Set the PWM value.

The PWM value is set using a range of -1.0 to 1.0, appropriately scaling the value for the FPGA.

Parameters:

value – The speed value between -1.0 and 1.0 to set.

setInverted(isInverted: bool) None
setVoltage(output: wpimath.units.volts) None

Sets the voltage output of the PWMMotorController. Compensates for the current bus voltage to ensure that the desired voltage is output even if the battery voltage is below 12V - highly useful when the voltage outputs are “meaningful” (e.g. they come from a feedforward calculation).

NOTE: This function must be called regularly in order for voltage compensation to work properly - unlike the ordinary set function, it is not “set it and forget it.”

Parameters:

output – The voltage to output.

stopMotor() None