Matthew's Portfolio
motor.motorDriver Class Reference

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...
 

Public Attributes

 debugFlag
 Debugging flag for detailed analysis while running.
 
 nSLEEP_pin
 Used to enable or disable the motor.
 
 timer
 Object for the timer attribute.
 
 IN1
 The timer channel object for half bridge 1.
 
 IN2
 The timer channel object for half bridge 2.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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.

Parameters
debugFlagEnables or prevents certain print statements from appearing.
nSLEEP_pinA pyb.Pin object to use as the enable pin.
IN1_pinA pyb.Pin object to use as the input to half bridge 1.
IN2_pinA pyb.Pin object to use as the input to half bridge 2.
timerA pyb.Timer object to use for PWM generation on IN1_pin and IN2_pin. An example is: Timer(3, freq=20000).
ch1A channel that will be used for the timer. This must be consistent with the channel options for the specific motor.
ch2A channel that will be used for the timer. This must be consistent with the channel options for the specific motor.

Member Function Documentation

◆ setDuty()

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.

Parameters
dutyA signed integer holding the duty cycle of the PWM signal sent to the motor.

The documentation for this class was generated from the following file: