A pyb method library housed within the motor driver board Importing this makes its methods available for use by your class. More...
Public Member Functions | |
def | __init__ (self, EN_pin, IN1_pin, IN2_pin, timer) |
Defines MotorDriver class. More... | |
def | enable (self) |
This method simply enables the motor by toggling high the EN pin of the motor object. More... | |
def | disable (self) |
Just as the enable method toggles the EN pin high, the disable method toggles the EN pin low. More... | |
def | set_duty (self, duty) |
This method sets the duty cycle to be sent to the motor to the given level. More... | |
A pyb method library housed within the motor driver board Importing this makes its methods available for use by your class.
This class implements a motor driver for the ME405 board. This will be used to drive the motor based on an actuation signal which is determined through a proportional controller meant for motor position control. The only job for this class is to make the motor driver object based on a user passing in a pinset and timer combination, and then set the duty cycle as necessary to ensure proper position control. Enable and disable features are included as a failsafe in case position control encounters errors.
def motor.MotorDriver.__init__ | ( | self, | |
EN_pin, | |||
IN1_pin, | |||
IN2_pin, | |||
timer | |||
) |
Defines MotorDriver class.
Creates a motor driver by initializing GPIO pins and turning the motor off for safety.
EN_pin | A pyb.Pin object to use as the enable pin |
IN1_pin | A pyb.Pin object to use as the input to half bridge 1 |
IN2_pin | A pyb.Pin object to use as the input to half bridge 2 |
timer | A pyb.pin object to use for pulse-width modulation generation on IN1_pin and IN2_pin |
def motor.MotorDriver.disable | ( | self | ) |
Just as the enable method toggles the EN pin high, the disable method toggles the EN pin low.
If this pin is toggled low, then PWM will not occur in the other two timer channel pins of the motor driver object
def motor.MotorDriver.enable | ( | self | ) |
This method simply enables the motor by toggling high the EN pin of the motor object.
This determines whether PWM occurs within the two other pins that determine motor duty cycle.
def motor.MotorDriver.set_duty | ( | self, | |
duty | |||
) |
This method sets the duty cycle to be sent to the motor to the given level.
Positive values cause an 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 moto |