A driver class for interacting with two motors while also protecting against over-current. More...
Public Member Functions | |
| def | __init__ (self, pin_nSLEEP=Pin("A15", mode=Pin.OUT_PP), pin_nFAULT=Pin("B2", mode=Pin.OUT_PP), pin_IN1=Pin("B4", mode=Pin.OUT_PP), pin_IN2=Pin("B5", mode=Pin.OUT_PP), pin_IN3=Pin("B0", mode=Pin.OUT_PP), pin_IN4=Pin("B1", mode=Pin.OUT_PP), timer=Timer(3, freq=20000)) |
| Initialize a motor driver instance. More... | |
| def | enable (self) |
| Enable the motor driver. More... | |
| def | disable (self) |
| Disable the motor driver and set motor speeds to zero. More... | |
| def | fault_callback (self, _) |
| Disable the motor driver when an overcurrent fault is detected. | |
| def | reset (self) |
| Reset the motor driver after having been disabled by an overcurrent fault. More... | |
Public Attributes | |
| nSLEEP | |
| Sleep Pin (active high) | |
| enabled | |
| Enabled state of the MotorDriver. | |
| FAULTED | |
| A boolean flag indicating if the MotorDriver was disabled due to an over-current fault. | |
| nFAULT | |
| Fault Pin (active high) for detecting overcurrent. | |
| fault_int | |
| Interrupt to read Fault Pin. | |
| ch1 | |
| Motor object on Channel 1. | |
| ch2 | |
| Motor object on Channel 2. | |
A driver class for interacting with two motors while also protecting against over-current.
This motor driver object mirrors the Texas Instruments DRV8847 chip as configured on the ME 405 board. It allows the user to drive two Motor objects independently, with a common enable pin and a common fault pin. Only one MotorDriver object should exist at a time.
| def drivers.Motor.MotorDriver.__init__ | ( | self, | |
pin_nSLEEP = Pin("A15", mode=Pin.OUT_PP), |
|||
pin_nFAULT = Pin("B2", mode=Pin.OUT_PP), |
|||
pin_IN1 = Pin("B4", mode=Pin.OUT_PP), |
|||
pin_IN2 = Pin("B5", mode=Pin.OUT_PP), |
|||
pin_IN3 = Pin("B0", mode=Pin.OUT_PP), |
|||
pin_IN4 = Pin("B1", mode=Pin.OUT_PP), |
|||
timer = Timer(3, freq=20000) |
|||
| ) |
Initialize a motor driver instance.
Create a motor driver object mirroring the Texas Instruments DRV8847 chip. If no arguments are passed, the driver will assume the pins are as specified in the lab spec. While it is never necessary to use both channels of this driver, it assumes that two are connected.
| pin_nSLEEP | A pyb.Pin object to use as the enable pin. |
| pin_nFAULT | A pyb.Pin object to use as the over-current interrupt pin. |
| pin_IN1 | A pyb.Pin object to use as the input to half bridge 1. |
| pin_IN2 | A pyb.Pin object to use as the input to half bridge 2. |
| pin_IN3 | A pyb.Pin object to use as the input to half bridge 3. |
| pin_IN4 | A pyb.Pin object to use as the input to half bridge 4. |
| def drivers.Motor.MotorDriver.disable | ( | self | ) |
Disable the motor driver and set motor speeds to zero.
Caution: this method will disable both motors attached to its enable pin.
| def drivers.Motor.MotorDriver.enable | ( | self | ) |
Enable the motor driver.
Caution: this method will enable all motors attached to its enable pin.
| def drivers.Motor.MotorDriver.reset | ( | self | ) |
Reset the motor driver after having been disabled by an overcurrent fault.
If the user elects not to resume operation, a KeyboardInterrupt is raised.