|
ME 405 Term Project
|
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 | |
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.
| motor.Motor.__init__ | ( | self, | |
| Pin | PWM_pin, | ||
| Pin | DIR_pin, | ||
| Pin | nSLP_pin, | ||
| int | tim_num, | ||
| int | chan_num ) |
Initializes a Motor object
| motor.Motor.disable | ( | self | ) |
Disables the motor driver by taking it into sleep mode
| motor.Motor.enable | ( | self | ) |
Enables the motor driver by taking it out of sleep mode into brake mode
| motor.Motor.get_state | ( | self | ) |
Report values for motor state
| motor.Motor.set_effort | ( | self, | |
| float | effort ) |
Sets the present effort requested from the motor based on an input value between -100 and 100
| motor.Motor.chan_obj = self.tim_obj.channel(chan_num, pin=self.PWM_pin, mode=Timer.PWM, pulse_width_percent = 0) |
| motor.Motor.DIR_pin = Pin(DIR_pin, mode=Pin.OUT_PP, value=0) |
| 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
| bool motor.Motor.enabled = False |
if motor not enabled, don't change the pulse_width_percent yet
| motor.Motor.nSLP_pin = Pin(nSLP_pin, mode=Pin.OUT_PP, value=0) |
| motor.Motor.PWM_pin = Pin(PWM_pin, mode=Pin.OUT_PP, value=0) |
| motor.Motor.tim_obj = Timer(tim_num, freq=20000) |