405 Documentation  9.0
motorDriver.DCMotor Class Reference

Motor Driver Class. More...

Public Member Functions

def __init__ (self, idNum, nSleep_pin, in1_pin, in2_pin, timer, ch1, ch2, duty=0)
 Initializes the Motor Driver class. More...
 
def __repr__ (self)
 Define how a DCMotor object is represented.
 
def enable (self)
 Enabling Method. More...
 
def disable (self)
 Disabling method. More...
 
def setDuty (self, duty)
 Duty input. More...
 
def driveFWD (self)
 Forward Drive method. More...
 
def driveBKWD (self)
 Backward Drive method. More...
 
def brake (self)
 Brake Method. More...
 
def stop (self)
 Stop Method. More...
 

Public Attributes

 id
 
 enablePin
 
 mPin1
 
 mPin2
 
 ch1
 
 ch2
 
 duty
 
 startup_flag
 

Detailed Description

Motor Driver Class.

This class implements a motor driver for the ME405 board.

Constructor & Destructor Documentation

◆ __init__()

def motorDriver.DCMotor.__init__ (   self,
  idNum,
  nSleep_pin,
  in1_pin,
  in2_pin,
  timer,
  ch1,
  ch2,
  duty = 0 
)

Initializes the Motor Driver class.

Creates a motor driver by initializing GPIO pins and turning the motor off for safety. Stores values as self.variables in order to be used in different parts of the class.

Parameters
idNumID number of motor
nSleep_pinA pyb.Pin object to use as the enable pin. [OUT]
in1_pinA pyb.Pin object to use as the input to half bridge 1. [OUT]
in2_pinA pyb.Pin object to use as the input to half bridge 2. [OUT]
timerA pyb.Timer object to use for PWM generation on IN1_pin and IN2_pin.
ch1channel for in1_pin
ch2channel for in2_pin
dutyindicated the power assigned to the motor (default 0, min -100, max 100)

Member Function Documentation

◆ brake()

def motorDriver.DCMotor.brake (   self)

Brake Method.

Set duty cycle on ch1 and ch2 to cause motor to attempt to turn in both direction at the same rate. This causes them to remain stationary. @params None

◆ disable()

def motorDriver.DCMotor.disable (   self)

Disabling method.

Sets the enable pin object to low to stop the all motors connected to the pin (stop output to them at least, they can still coast or be pushed)

Parameters
None

◆ driveBKWD()

def motorDriver.DCMotor.driveBKWD (   self)

Backward Drive method.

Set duty on ch2 to drive motor backward continuously @params None

◆ driveFWD()

def motorDriver.DCMotor.driveFWD (   self)

Forward Drive method.

Set duty on ch1 to drive motor forward continuously @params None

◆ enable()

def motorDriver.DCMotor.enable (   self)

Enabling Method.

Sets the enable pin object to high in order to allow all motors connected to it to run.

Parameters
None

◆ setDuty()

def motorDriver.DCMotor.setDuty (   self,
  duty 
)

Duty input.

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

◆ stop()

def motorDriver.DCMotor.stop (   self)

Stop Method.

This method sets the duty cycle to be sent to the motor as 90 in both directions, therefore keeping the motor exactly where it is.

Parameters
None

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