Initial Commit
This commit is contained in:
@@ -2,22 +2,29 @@ import time
|
||||
|
||||
from RPi import GPIO
|
||||
|
||||
"""This module controls the Motor and Servo module.
|
||||
"""This module controls the Motor and Servo control.
|
||||
|
||||
This module provides an interface for interacting with
|
||||
the motor on the Traxxas Slash using a Raspberry Pi
|
||||
3B+.
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
class MotorController:
|
||||
def __init__(self, control_pin, frequency, duty_cycle=0):
|
||||
def __init__(self, pin_number, frequency, duty_cycle=0):
|
||||
self._duty_cycle = duty_cycle
|
||||
self._operating_frequency = frequency
|
||||
self._running = False
|
||||
self.pin_number = pin_number
|
||||
|
||||
# Pulse width was mentioned to be 6-7.2% by uni group.
|
||||
|
||||
GPIO.setmode(GPIO.OUT)
|
||||
GPIO.setup(self._control_pin, self._operating_frequency)
|
||||
self._control_pin = GPIO.PWM(control_pin, self._duty_cycle)
|
||||
GPIO.setup(self.pin_number, self._operating_frequency)
|
||||
self._control_pin = GPIO.PWM(self.pin_number, self._duty_cycle)
|
||||
|
||||
|
||||
@property
|
||||
def duty_cycle(self):
|
||||
@@ -28,6 +35,7 @@ class MotorController:
|
||||
if value > 0 and value < 100:
|
||||
self._duty_cycle = value
|
||||
# Change the current duty cycle of the GPIO.
|
||||
self.control.changeDutyCycle
|
||||
|
||||
def start(self):
|
||||
if self._running:
|
||||
@@ -38,4 +46,33 @@ class MotorController:
|
||||
def stop(self):
|
||||
self._control_pin.stop()
|
||||
|
||||
|
||||
def arm(self):
|
||||
|
||||
class MotorDetails:
|
||||
def __init__(self):
|
||||
|
||||
@property
|
||||
def minDutyCycle(self):
|
||||
return self._minDutyCycle
|
||||
|
||||
@minDutyCycle.setter
|
||||
def minDutyCycle(self, value):
|
||||
self._minDutyCycle = value
|
||||
|
||||
@property
|
||||
def maxDutyCycle(self):
|
||||
return self._maxDutyCycle
|
||||
|
||||
@maxDutyCycle.setter
|
||||
def maxDutyCycle(self, value):
|
||||
self._maxDutyCycle = value
|
||||
|
||||
@property
|
||||
def idle(self):
|
||||
return self._idle
|
||||
|
||||
|
||||
|
||||
max_reverse = 1000
|
||||
idle = 1500
|
||||
max_forward = 2000
|
||||
|
||||
Reference in New Issue
Block a user