Matthew Tagupa's ME 405 Labs and Term Project
MotorDriver.MotorDriver Class Reference

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
 

Detailed Description

A motor driver object.

This class implements the motor driver for our ME 405 board.

Author
Matthew Tagupa
Date
April 29, 2020

Constructor & Destructor Documentation

◆ __init__()

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.

Parameters
pinENA pyb.Pin object to use as the enable pin.
pinIN1A pyb.Pin object to use as the input to half bridge 1.
pinIN2A pyb.Pin object to use as the input to half bridge 2.
timer_numberA pyb.Timer object to use for PWM generation on pinIN1_A and pinIN2_A.
frequencyA timer characteristic

Member Function Documentation

◆ disable()

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.

◆ enable()

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.

◆ set_duty()

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.

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: