A motor driver object. More...
Public Member Functions | |
def | __init__ (self, pinEN, pinIN1, pinIN2, timer_number, frequency) |
Constructor for motor driver. More... | |
def | enable (self) |
Enable the Motor. More... | |
def | disable (self) |
Disables the Motor. More... | |
def | set_duty (self, duty) |
Sets duty cycle for motor. More... | |
Public Attributes | |
pinEN | |
pinIN1 | |
pinIN2 | |
timer_number | |
timch1 | |
timch2 | |
pinEN_toggle | |
duty | |
A motor driver object.
This class implements the motor driver for our ME 405 board.
def MotorDriver.MotorDriver.__init__ | ( | self, | |
pinEN, | |||
pinIN1, | |||
pinIN2, | |||
timer_number, | |||
frequency | |||
) |
Constructor for motor driver.
Creates a motor driver by initializing GPIO pins and turning the motor off for safety.
pinEN | A pyb.Pin object to use as the enable pin. |
pinIN1 | A pyb.Pin object to use as the input to half bridge 1. |
pinIN2 | A pyb.Pin object to use as the input to half bridge 2. |
timer_number | A pyb.Timer object to use for PWM generation on pinIN1_A and pinIN2_A. |
frequency | A timer characteristic |
def MotorDriver.MotorDriver.disable | ( | self | ) |
Disables the Motor.
This method disables the motor. If the motor is already disabled, it will warn the user that it is already disabled.
def MotorDriver.MotorDriver.enable | ( | self | ) |
Enable the Motor.
This method enables the motor. If the motor is already enabled, it will warn the user that it is already enabled.
def MotorDriver.MotorDriver.set_duty | ( | self, | |
duty | |||
) |
Sets duty cycle for motor.
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 integer holding the duty cycle of the PWM signal sent to the motor. |