Motor class to allow for several motors to be used. More...
Public Member Functions | |
def | __init__ (self, debugFlag, nSLEEP_pin, IN1_pin, IN2_pin, timer, ch1, ch2) |
Creates a motor driver by initializing GPIO pins. More... | |
def | enable (self) |
Enable the motor to allow for PWM to actuate the motor. | |
def | disable (self) |
Disable the motor to prevent the PWM to actuate the motor. | |
def | setDuty (self, duty) |
Set the duty of the motors. More... | |
Motor class to allow for several motors to be used.
This class will allow for the enabling and disabling of the motors, as well as the ability to set the motors to a specified duty cycle through PWM.
def motor.motorDriver.__init__ | ( | self, | |
debugFlag, | |||
nSLEEP_pin, | |||
IN1_pin, | |||
IN2_pin, | |||
timer, | |||
ch1, | |||
ch2 | |||
) |
Creates a motor driver by initializing GPIO pins.
The user will have to input the pins for the motor and the potential timers and channels as specified in the manufacturers specifications for the specific motor.
debugFlag | Enables or prevents certain print statements from appearing. |
nSLEEP_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.Timer object to use for PWM generation on IN1_pin and IN2_pin. An example is: Timer(3, freq=20000). |
ch1 | A channel that will be used for the timer. This must be consistent with the channel options for the specific motor. |
ch2 | A channel that will be used for the timer. This must be consistent with the channel options for the specific motor. |
def motor.motorDriver.setDuty | ( | self, | |
duty | |||
) |
Set the duty of the motors.
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. |