ME 405 Documentation for Joshua Clemens, Cal Poly SLO 06/09/20
motor.MotorDriver Class Reference

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

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.

Parameters
EN_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.pin object to use for pulse-width modulation generation on IN1_pin and IN2_pin

Member Function Documentation

◆ disable()

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

◆ enable()

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.

◆ set_duty()

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

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

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