ME405: Mechatronics
Project Documentation and Portfolio by Neil Patel
motor.MotorDriver Class Reference

Public Member Functions

def __init__ (self, nSLEEP_pin=pyb.Pin.board.PA15, nFAULT_pin=pyb.Pin.board.PB2, INx_pin=pyb.Pin.board.PB5, OUTx_pin=pyb.Pin.board.PB4, INy_pin=pyb.Pin.board.PB1, OUTy_pin=pyb.Pin.board.PB0, INxy_timer=pyb.Timer(3), frequency=80000)
 ! More...
 
def enable (self)
 Enables the motors. More...
 
def disable (self)
 Disables the motors. More...
 
def fault_CB (self)
 A callback which disables the motors on fault detection. More...
 
def clear_fault (self)
 Clears the fault so the motors can be used. More...
 
def set_level_1 (self, direction, level)
 Spins motor 1 in direction at level of its max power. More...
 
def set_level_2 (self, direction, level)
 Spins motor 2 in direction at level of its max power. More...
 

Public Attributes

 enabled
 
 nsleep
 
 nfault
 
 m1p
 
 m2p
 
 m1m
 
 m2m
 
 tim
 
 freq
 
 ch1
 
 ch2
 
 ch3
 
 ch4
 

Constructor & Destructor Documentation

◆ __init__()

def motor.MotorDriver.__init__ (   self,
  nSLEEP_pin = pyb.Pin.board.PA15,
  nFAULT_pin = pyb.Pin.board.PB2,
  INx_pin = pyb.Pin.board.PB5,
  OUTx_pin = pyb.Pin.board.PB4,
  INy_pin = pyb.Pin.board.PB1,
  OUTy_pin = pyb.Pin.board.PB0,
  INxy_timer = pyb.Timer(3),
  frequency = 80000 
)

!

Initializes the pins for the motors, as well as the timer.

Parameters
[in]nSLEEP_pinpyb.Pin, Pin for not sleep
The default is pyb.Pin.board.PA15.
[in]nFAULT_pinpyb.Pin, Pin for not fault
The default is pyb.Pin.board.PB2.
[in]INx_pinpyb.Pin, pin connected to positive on motor x
The default is pyb.Pin.board.PB5.
[in]OUTx_pinpyb.Pin, pin connected to negative on motor x
The default is pyb.Pin.board.PB4.
[in]INy_pinpyb.Pin, pin connected to positive on motor y
The default is pyb.Pin.board.PB1.
[in]OUTy_pinpyb.Pin, pin connected to negative on motor y
The default is pyb.Pin.board.PB0.
[in]INxy_timerpyb.Timer(), chooses which timer to use for PWM
The default is pyb.Timer(3).
[in]frequencyINT, defines the PWM frequency
The default is 80000
Returns
Returns nothing.

Member Function Documentation

◆ clear_fault()

def motor.MotorDriver.clear_fault (   self)

Clears the fault so the motors can be used.

Returns
Returns nothing

◆ disable()

def motor.MotorDriver.disable (   self)

Disables the motors.

Returns
Returns nothing

◆ enable()

def motor.MotorDriver.enable (   self)

Enables the motors.

Returns
Returns nothing

◆ fault_CB()

def motor.MotorDriver.fault_CB (   self)

A callback which disables the motors on fault detection.

Returns
Returns nothing

◆ set_level_1()

def motor.MotorDriver.set_level_1 (   self,
  direction,
  level 
)

Spins motor 1 in direction at level of its max power.

Parameters
directionBoolean representing direcction of motor spin
levelInteger representing percentage level of motor power
Returns
Returns nothing

◆ set_level_2()

def motor.MotorDriver.set_level_2 (   self,
  direction,
  level 
)

Spins motor 2 in direction at level of its max power.

Parameters
directionBoolean representing direcction of motor spin
levelInteger representing percentage level of motor power
Returns
Returns nothing

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