Mechatronics
Documentation for ME 405 labs
drivers.Motor.Motor Class Reference

This class implements a motor driver for the ME405 board. More...

Public Member Functions

def __init__ (self, pin_ch1, pin_ch2, timer)
 Creates a motor driver by initializing GPIO pins and turning the motor off for safety. More...
 
def disable (self)
 Disable the motor and set its speed to zero. More...
 
def set_duty (self, duty)
 Set the motor duty cycle. More...
 

Public Attributes

 ch1
 Forward direction PWM channel.
 
 ch2
 Reverse direction PWM channel.
 

Detailed Description

This class implements a motor driver for the ME405 board.

Constructor & Destructor Documentation

◆ __init__()

def drivers.Motor.Motor.__init__ (   self,
  pin_ch1,
  pin_ch2,
  timer 
)

Creates a motor driver by initializing GPIO pins and turning the motor off for safety.

Parameters
pin_ch1A pyb.Pin object to use as the input to half bridge 1.
pin_ch2A pyb.Pin object to use as the input to half bridge 2.
timerA pyb.Timer object to use for PWM generation on either pin.

Member Function Documentation

◆ disable()

def drivers.Motor.Motor.disable (   self)

Disable the motor and set its speed to zero.

Caution: this method will disable any motors attached to its enable pin.

◆ set_duty()

def drivers.Motor.Motor.set_duty (   self,
  duty 
)

Set the motor duty cycle.

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: