Public Member Functions | |
| def | __init__ (self, nSLEEP_pin, nFAULT_pin, mDriverFlag=True) |
| Creates a motor driver by initializing GPIO pins. More... | |
| def | enable (self) |
| Enable the motor to allow for PWM to actuate the motor. More... | |
| def | disable (self) |
| Disable the motor to prevent the PWM to actuate the motor. More... | |
| def | faultCB (self, IRQ_src) |
| Callback method for fault detection. More... | |
| def | clearFault (self, IRQ_src) |
| Callback method for clearing a fault. More... | |
| def | channel (self, IN1_pin, IN2_pin, IN_timer, ch1, ch2, mChFlag=False) |
| Method for generation of motor channel objects. More... | |
Public Attributes | |
| mDriverFlag | |
| Debugging flag for detailed analysis while running. | |
| nSLEEP_pin | |
| Used to enable or disable the motor. | |
| nFAULT_pin | |
| Interupt triggered by fault detection in the motor driver. More... | |
| ButtonInt | |
| Pin attribute for blue user button. More... | |
| motorList | |
| List containing copies of each motor channel instantiated. More... | |
| fault | |
| Boolean variable for fault detection. More... | |
| ignoreFault | |
| Boolean variable to ignore unwanted faults. More... | |
| def motorDriver.motorDriver.__init__ | ( | self, | |
| nSLEEP_pin, | |||
| nFAULT_pin, | |||
mDriverFlag = True |
|||
| ) |
Creates a motor driver by initializing GPIO pins.
The user will have to input the pins for the motor and the potential timers and channels as specified in the manufacturers specifications for the specific motor. Since both motors are connected to one motor driver, the motor driver serves as a parent to the two motors, containing any details common to both motors.
Example:
self.motorDriverObj = motorDriver(Pin.cpu.A15 , Pin.cpu.B2, driverFlag = True)
| nSLEEP_pin | A pyb.Pin object to use as the enable/disable pin. |
| nFAULT_pin | A pyb.Pin object used to detect faults such as high current, a stalled shaft, or any other unwanted condition. |
| mDriverFlag | Enables or prevents certain print statements from appearing. |
| def motorDriver.motorDriver.channel | ( | self, | |
| IN1_pin, | |||
| IN2_pin, | |||
| IN_timer, | |||
| ch1, | |||
| ch2, | |||
mChFlag = False |
|||
| ) |
Method for generation of motor channel objects.
To allow for the motor driver parent to have access to methods of each individual channel, a method within the motor driver class is responsible for instantiating motor objects. Each object is then "copied" into a list within this class, such that it can be refrenced by other methods.
Example:
self.motX = self.motorDriver.channel( Pin.cpu.B0, Pin.cpu.B1, Timer(3, freq=20000), 3, 4, chFlag = True)
| IN1_pin | First pin used for PWM |
| IN2_pin | Second pin used for PWM |
| IN_timer | Shared timer object for both PWM pins, containing timer number and frequency information |
| ch1 | First channel of timer |
| ch2 | Second channel of timer |
| mChFlag | Debugging flag for motor channel print statements |
| def motorDriver.motorDriver.clearFault | ( | self, | |
| IRQ_src | |||
| ) |
Callback method for clearing a fault.
When this callback is triggered by a falling edge on PC13 (connected to the blue user button), two boolean variables are changed. First, self.fault is set back to False to allow program operation to continue. Secondly, self.ignoreFault is set to True in order to skip the next fault incorrectly detected by the nFAULT pin.
| IRQ_src | interupt request |
| def motorDriver.motorDriver.disable | ( | self | ) |
Disable the motor to prevent the PWM to actuate the motor.
Sets the nSLEEP pin low, as well as setting each motor duty cycle to zero.
| def motorDriver.motorDriver.enable | ( | self | ) |
Enable the motor to allow for PWM to actuate the motor.
Sets the nSLEEP pin high, allowing all other pins related to the motor to function
| def motorDriver.motorDriver.faultCB | ( | self, | |
| IRQ_src | |||
| ) |
Callback method for fault detection.
When this callback is triggered by a falling edge on PB2 (connected to the nFAULT pin), self.fault is set to True (with the exception of the "false alarm" case discussed in documentation for self.ignoreFault.
| IRQ_src | interupt request |
| motorDriver.motorDriver.ButtonInt |
Pin attribute for blue user button.
The blue button on the board has been used to clear faults caught by the nFAULT pin. Namely, the callback function clearFault() is called.
| motorDriver.motorDriver.fault |
Boolean variable for fault detection.
Initially set to False and set to True on a falling edge of the nFault pin
| motorDriver.motorDriver.ignoreFault |
Boolean variable to ignore unwanted faults.
For reasons not yet fully understood, when a fault is cleared, the enable action triggers a fault. However, this is a false alarm, so it is desired to use logic to skip this fault. Set to 'Trueonly whenclearFault()` is called, and set back to false upon the false fault callback.
| motorDriver.motorDriver.motorList |
List containing copies of each motor channel instantiated.
In order to keep "copies" of each motor channel created, the function channel() appends to self.motorList the channel object being returned. With these copies, the more broad motor driver can still use the methods of each motor channel.
| motorDriver.motorDriver.nFAULT_pin |
Interupt triggered by fault detection in the motor driver.
Upon any fault in the combined motor driver (falling edge on PB2), a callback is triggered, and self.fault is set to True. This variable is a flag for program operation to halt, and can only start back up once the fault has been cleared.