Motor Driver Class. More...
Public Member Functions | |
| def | __init__ (self, idNum, nSleep_pin, in1_pin, in2_pin, timer, ch1, ch2, duty=0) |
| Initializes the Motor Driver class. More... | |
| def | __repr__ (self) |
| Define how a DCMotor object is represented. | |
| def | enable (self) |
| Enabling Method. More... | |
| def | disable (self) |
| Disabling method. More... | |
| def | setDuty (self, duty) |
| Duty input. More... | |
| def | driveFWD (self) |
| Forward Drive method. More... | |
| def | driveBKWD (self) |
| Backward Drive method. More... | |
| def | brake (self) |
| Brake Method. More... | |
| def | stop (self) |
| Stop Method. More... | |
Public Attributes | |
| id | |
| enablePin | |
| mPin1 | |
| mPin2 | |
| ch1 | |
| ch2 | |
| duty | |
| startup_flag | |
Motor Driver Class.
This class implements a motor driver for the ME405 board.
| def motorDriver.DCMotor.__init__ | ( | self, | |
| idNum, | |||
| nSleep_pin, | |||
| in1_pin, | |||
| in2_pin, | |||
| timer, | |||
| ch1, | |||
| ch2, | |||
duty = 0 |
|||
| ) |
Initializes the Motor Driver class.
Creates a motor driver by initializing GPIO pins and turning the motor off for safety. Stores values as self.variables in order to be used in different parts of the class.
| idNum | ID number of motor |
| nSleep_pin | A pyb.Pin object to use as the enable pin. [OUT] |
| in1_pin | A pyb.Pin object to use as the input to half bridge 1. [OUT] |
| in2_pin | A pyb.Pin object to use as the input to half bridge 2. [OUT] |
| timer | A pyb.Timer object to use for PWM generation on IN1_pin and IN2_pin. |
| ch1 | channel for in1_pin |
| ch2 | channel for in2_pin |
| duty | indicated the power assigned to the motor (default 0, min -100, max 100) |
| def motorDriver.DCMotor.brake | ( | self | ) |
Brake Method.
Set duty cycle on ch1 and ch2 to cause motor to attempt to turn in both direction at the same rate. This causes them to remain stationary. @params None
| def motorDriver.DCMotor.disable | ( | self | ) |
Disabling method.
Sets the enable pin object to low to stop the all motors connected to the pin (stop output to them at least, they can still coast or be pushed)
| None |
| def motorDriver.DCMotor.driveBKWD | ( | self | ) |
Backward Drive method.
Set duty on ch2 to drive motor backward continuously @params None
| def motorDriver.DCMotor.driveFWD | ( | self | ) |
Forward Drive method.
Set duty on ch1 to drive motor forward continuously @params None
| def motorDriver.DCMotor.enable | ( | self | ) |
Enabling Method.
Sets the enable pin object to high in order to allow all motors connected to it to run.
| None |
| def motorDriver.DCMotor.setDuty | ( | self, | |
| duty | |||
| ) |
Duty input.
This method sets the duty cycle to be sent to the 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 |
| def motorDriver.DCMotor.stop | ( | self | ) |
Stop Method.
This method sets the duty cycle to be sent to the motor as 90 in both directions, therefore keeping the motor exactly where it is.
| None |