CALPOLY MECHATRONICS
Documentation for all Mechatronics Labs
motorDriver.Motor Class Reference

The Motor class sets the power of a brushed, dc motor using PWM. More...

Public Member Functions

def __init__ (self, nSLEEP_pin, IN1_pin, IN1_ch, IN2_pin, IN2_ch, timer)
 A method to initialize a Motor object. More...
 
def enable (self)
 A method to enable the motor by pulling the sleep pin high.
 
def disable (self)
 A method to disable the motor by pulling the sleep pin low.
 
def set_duty (self, duty)
 A method to set the duty cycle of the motor. More...
 

Public Attributes

 nSLEEP
 The pyb.Pin object that enables and diables the motor.
 
 timer
 The pyb.Timer object used to generate PWM for the motor.
 
 IN1
 The channel of the PWM timer corresponding to the first motor lead.
 
 IN2
 The channel of the PWM timer corresponding to the second motor lead.
 

Detailed Description

The Motor class sets the power of a brushed, dc motor using PWM.

Constructor & Destructor Documentation

◆ __init__()

def motorDriver.Motor.__init__ (   self,
  nSLEEP_pin,
  IN1_pin,
  IN1_ch,
  IN2_pin,
  IN2_ch,
  timer 
)

A method to initialize a Motor object.

Parameters
nSLEEP_pinThe pyb.Pin object that enables and diables the motor.
IN1_pinThe pyb.Pin object connected to one lead of the motor.
IN2_pinThe pyb.Pin object connected to the other lead of the motor.
IN1_chThe channel number of the PWM timer corresponding to IN1_pin.
IN2_chThe channel number of the PWM timer corresponding to IN2_pin.
timerThe pyb.Timer object used to generate PWM for the motor.

Member Function Documentation

◆ set_duty()

def motorDriver.Motor.set_duty (   self,
  duty 
)

A method to set the duty cycle of the motor.

Parameters
dutyThe duty cycle to set the motor to, from -100 to 100.

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