Meyenberg_Project
MotorDriver.MotorDriver Class Reference

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

Public Member Functions

def __init__ (self, nSLEEP_pin, IN1_pin, IN2_pin, timer, ch1, ch2)
 Creates a motor driver by initializing GPIO pins and turning the motor off for safety. More...
 
def enable (self)
 method is called when the user desires to enable the motor. More...
 
def disable (self)
 method is called when the user desires to disable the motor. More...
 
def set_duty (self, duty)
 This method sets the duty cycle to be sent to the motor to the given level. More...
 

Public Attributes

 nSLEEP_pin
 init pin connected to nsleep DRV8847 Pin as output
 
 IN1_pin
 init DRV8847 Pin IN1 which will be used to drive the motor in either a forward or reverse direction
 
 IN2_pin
 init DRV8847 Pin IN1 which will be used to drive the motor in either a forward or reverse direction
 
 timer
 init timer (fill in once you better understand this oned)
 
 ch1
 specifies which channel to use for timer
 
 ch2
 specifies which channel to use for timer
 
 t3ch1
 init timer 3 channel 1
 
 t3ch2
 init timer 3 channel 2
 
 nFault
 flag to indicate nFault
 
 FaultInt
 interrupt that is called when the nfault pin is high
 
 duty
 DRV8847 Pin IN1 goes "high" (with associated duty cycle) More...
 

Detailed Description

This class implements a motor driver for the ME405 board.

Constructor & Destructor Documentation

◆ __init__()

def MotorDriver.MotorDriver.__init__ (   self,
  nSLEEP_pin,
  IN1_pin,
  IN2_pin,
  timer,
  ch1,
  ch2 
)

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

Parameters
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.
ch1A value to select the channel on the timer
ch2A value to select the channel on the timer

Member Function Documentation

◆ disable()

def MotorDriver.MotorDriver.disable (   self)

method is called when the user desires to disable the motor.

This sets the output of nsleep DRV8847 Pin to 0 (low).

◆ enable()

def MotorDriver.MotorDriver.enable (   self)

method is called when the user desires to enable the motor.

This sets the output of nsleep DRV8847 Pin to 1 (high).

◆ set_duty()

def MotorDriver.MotorDriver.set_duty (   self,
  duty 
)

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

Member Data Documentation

◆ duty

MotorDriver.MotorDriver.duty

DRV8847 Pin IN1 goes "high" (with associated duty cycle)

DRV8847 Pin IN2 goes low


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