ME 405 Term Project
Loading...
Searching...
No Matches
motor.Motor Class Reference

Public Member Functions

 __init__ (self, Pin PWM_pin, Pin DIR_pin, Pin nSLP_pin, int tim_num, int chan_num)
 set_effort (self, float effort)
 enable (self)
 disable (self)
 get_state (self)

Public Attributes

 PWM_pin = Pin(PWM_pin, mode=Pin.OUT_PP, value=0)
 DIR_pin = Pin(DIR_pin, mode=Pin.OUT_PP, value=0)
 nSLP_pin = Pin(nSLP_pin, mode=Pin.OUT_PP, value=0)
 tim_obj = Timer(tim_num, freq=20000)
 chan_obj = self.tim_obj.channel(chan_num, pin=self.PWM_pin, mode=Timer.PWM, pulse_width_percent = 0)
int effort = 0
 if motor not enabled, don't change the pulse_width_percent yet
bool enabled = False
 if motor not enabled, don't change the pulse_width_percent yet

Detailed Description

A motor driver interface encapsulated in a Python class. Works with
   motor drivers using separate PWM and direction inputs such as the DRV8838
   drivers present on the Romi chassis from Pololu.

Constructor & Destructor Documentation

◆ __init__()

motor.Motor.__init__ ( self,
Pin PWM_pin,
Pin DIR_pin,
Pin nSLP_pin,
int tim_num,
int chan_num )
Initializes a Motor object

Member Function Documentation

◆ disable()

motor.Motor.disable ( self)
Disables the motor driver by taking it into sleep mode

◆ enable()

motor.Motor.enable ( self)
Enables the motor driver by taking it out of sleep mode into brake mode

◆ get_state()

motor.Motor.get_state ( self)
Report values for motor state

◆ set_effort()

motor.Motor.set_effort ( self,
float effort )
Sets the present effort requested from the motor based on an input value between -100 and 100

Member Data Documentation

◆ chan_obj

motor.Motor.chan_obj = self.tim_obj.channel(chan_num, pin=self.PWM_pin, mode=Timer.PWM, pulse_width_percent = 0)

◆ DIR_pin

motor.Motor.DIR_pin = Pin(DIR_pin, mode=Pin.OUT_PP, value=0)

◆ effort

motor.Motor.effort = 0

if motor not enabled, don't change the pulse_width_percent yet

motor must already be enabled, so it's okay to set effort

◆ enabled

bool motor.Motor.enabled = False

if motor not enabled, don't change the pulse_width_percent yet

◆ nSLP_pin

motor.Motor.nSLP_pin = Pin(nSLP_pin, mode=Pin.OUT_PP, value=0)

◆ PWM_pin

motor.Motor.PWM_pin = Pin(PWM_pin, mode=Pin.OUT_PP, value=0)

◆ tim_obj

motor.Motor.tim_obj = Timer(tim_num, freq=20000)

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