nerf-turret 1
Infrared targeting nerf turret
Loading...
Searching...
No Matches
motor_driver.MotorDriver Class Reference

This class implements a motor driver for an ME 405 kit. More...

Public Member Functions

def __init__ (self, str en_pin, str in1pin, str in2pin, int timer, int ch1, int ch2)
 Creates a motor driver and configures the appropriate pins, timers, and timer channels.
 
def enable_motor (self)
 Enables the motor by driving the enable pin high.
 
def disable_motor (self)
 Disables the motor by driving the enable pin low.
 
def set_duty_cycle (self, int level)
 Drives the motor at a given duty cycle.
 

Public Attributes

 en_pin
 Pin object for the enable pin.
 
 in1pin
 Pin object for pin 1.
 
 in2pin
 Pin object for pin 2.
 
 timer
 Timer object for the motor driver.
 
 pwm1
 Channel object for PWM channel 1.
 
 pwm2
 Channel object for PWM channel 2.
 

Detailed Description

This class implements a motor driver for an ME 405 kit.

Constructor & Destructor Documentation

◆ __init__()

def motor_driver.MotorDriver.__init__ (   self,
str  en_pin,
str  in1pin,
str  in2pin,
int  timer,
int  ch1,
int  ch2 
)

Creates a motor driver and configures the appropriate pins, timers, and timer channels.

Parameters
en_pinString containing the pin label of the enable pin (e.g. 'A10' for pin A10)
in1pinString containing the pin label of the first PWM channel
in2pinString containing the pin label of the second PWM channel
timerNumber of the timer to configure, given as integer (e.g. 5 for TIM5)
ch1The channel number of the first PWM channel, given as integer (e.g. 1 for TIMx CH1)
ch2The channel number of the second PWM channel, given as integer

Member Function Documentation

◆ set_duty_cycle()

def motor_driver.MotorDriver.set_duty_cycle (   self,
int  level 
)

Drives the motor at a given duty cycle.

Parameters
levelPWM duty cycle to drive the motor at. Given as integer from -100 to 100 (inclusive). The sign affects the direction the motor will be driven.

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