This class implements a motor driver for the ME405 board. More...
Public Member Functions | |
| def | __init__ (self, motor, nSLEEP_pin, nFAULT_pin, IN1_pin, ch1, IN2_pin, ch2, timer) |
| def | enable (self) |
| Sets the nSLEEP pin to high which enables the motors. | |
| def | disable (self) |
| Sets the nSLEEP pin to low which disables the motors. | |
| def | set_duty (self, duty) |
| Sets the duty cycle of the motor. More... | |
| def | CheckFault (self) |
| Checks pin PB2 to see if there is a fault present. More... | |
| def | myCallback (self, IQR_source) |
| Callback function. More... | |
Public Attributes | |
| pinA15 | |
| nSLEEP pin setup | |
| pin1 | |
| Initialize timer and pins. | |
| pin2 | |
| tim | |
| tchA | |
| tchB | |
| pinPB2 | |
| nFAULT pin setup | |
| fault_state | |
| Initialize nFAULT pin self.fault_state = self.pinPB2.value() | |
| motor | |
| Initializes the motor object. | |
| extint | |
| Detects when the the nFAULT pin is set to LOW and the callback function is called. | |
| inpt | |
This class implements a motor driver for the ME405 board.
| def m_driver.MotorDriver.__init__ | ( | self, | |
| motor, | |||
| nSLEEP_pin, | |||
| nFAULT_pin, | |||
| IN1_pin, | |||
| ch1, | |||
| IN2_pin, | |||
| ch2, | |||
| timer | |||
| ) |
Creates a motor driver by initializing GP10 pins and turning the motor off for safety.
| motor | A boolean object which represents whether the motor object being created is the primary motor. |
| nSLEEP_pin | A pyb.Pin object to use as the enable pin. |
| nFAULT_pin | A pyb.Pin object to use as the fault pin. |
| IN1_pin | A pyb.Pin object to use as the input to half bridge 1. |
| ch1 | A pyb.Timer.Channel object that selects the first channel |
| IN2_pin | A pyb.Pin object to use as the input to half bridge 2. |
| ch2 | A pyb.Timer.Channel object that tselects the second channel |
| timer | A pyb.Timer object to use for PWM generation on IN1_pin and IN2_pin |
| def m_driver.MotorDriver.CheckFault | ( | self | ) |
Checks pin PB2 to see if there is a fault present.
This method checks the nFAULT pin for its value. If it is high, then it will enable the motors and resume operation. If it is low, then it will print an error message and continuously check the pin until it is set to high.
| def m_driver.MotorDriver.myCallback | ( | self, | |
| IQR_source | |||
| ) |
Callback function.
This is the callback function that is used when the nFAULT pin is set to low. It checks the instance of the motor for the primary motor and will disable the motors accordingly.
| def m_driver.MotorDriver.set_duty | ( | self, | |
| duty | |||
| ) |
Sets the duty cycle of the motor.
This method sets the duty cycle to be sent to the motor to the given motor to the given level. Positive values cause effort in one direction, negative values in the opposite direction.
| duty | A signed integer holding the duty cycle of the PWM signal sent to the motor. |