ME 305 Group 6 Documentation
|
A motor class for a DC motor. More...
Public Member Functions | |
def | __init__ (self, pyb.Timer PWM_tim, pyb.Pin IN1_pin, pyb.Pin IN2_pin, int timChannel1, int timChannel2, bool invert_direction=False, str name="") |
Initializes and returns an object associated with a DC Motor. More... | |
def | set_duty (self, duty) |
Set this PWM duty cycle for the motor channel. More... | |
A motor class for a DC motor.
Objects of this class can be used to apply PWM to a given DC motor.
def motor.Motor.__init__ | ( | self, | |
pyb.Timer | PWM_tim, | ||
pyb.Pin | IN1_pin, | ||
pyb.Pin | IN2_pin, | ||
int | timChannel1, | ||
int | timChannel2, | ||
bool | invert_direction = False , |
||
str | name = "" |
||
) |
Initializes and returns an object associated with a DC Motor.
Must specify correct timer channel to work with IN2_pin
PWM_tim | Passes in a timer object for generating the PWM signal. |
IN1_pin | The first input pin for this motor. |
IN2_pin | The second input pin for this motor. |
timChannel1 | The first timer channel for the motor, attached to IN1_pin |
timChannel2 | The second timer channel for the motor, attached to IN2_pin |
invert_direction | Default False, if True, invert the direction of the duty cycle input |
name | Name for easier debugging |
def motor.Motor.set_duty | ( | self, | |
duty | |||
) |
Set this PWM duty cycle for the motor channel.
This method sets the duty cycle to be sent to the motor to the given level. Positive values cause effort in one direction, negative values in the opposite direction.
duty | A signed number holding the duty cycle of the PWN signal sent to the motor |