ME 405 Romi
Loading...
Searching...
No Matches
motor.py
Go to the documentation of this file.
1
from
pyb
import
Pin, Timer
2
from
time
import
sleep_ms
3
8
class
Motor
:
9
14
def
__init__
(self, PWM, DIR, nSLP, timer, ch):
15
#Initializes a Motor object
16
self.
nSLP
= Pin(nSLP, mode=Pin.OUT_PP, value=0)
# Defining left motor pins
17
self.
dir
= Pin(DIR, mode=Pin.OUT_PP, value=0)
18
self.
timCH
= timer.channel(ch, pin=PWM, mode=Timer.PWM, pulse_width_percent=0)
19
20
22
def
set_effort
(self, effort):
23
if
effort < 0:
24
self.
dir
.high()
25
self.
timCH
.pulse_width_percent(-effort)
26
else
:
27
self.
dir
.low()
28
self.
timCH
.pulse_width_percent(effort)
29
30
32
def
enable
(self):
33
self.
nSLP
.high()
34
self.
timCH
.pulse_width_percent(0)
35
37
def
disable
(self):
38
self.
nSLP
.low()
motor.Motor
The Motor Diver Class.
Definition
motor.py:8
motor.Motor.timCH
timCH
Definition
motor.py:18
motor.Motor.nSLP
nSLP
Definition
motor.py:16
motor.Motor.__init__
__init__(self, PWM, DIR, nSLP, timer, ch)
Motor Initialization.
Definition
motor.py:14
motor.Motor.enable
enable(self)
Enable Enables the motor driver by taking it out of sleep mode into brake mode.
Definition
motor.py:32
motor.Motor.set_effort
set_effort(self, effort)
Set Effort Sets the present effort requested from the motor based on an input value between -100 and ...
Definition
motor.py:22
motor.Motor.dir
dir
Definition
motor.py:17
motor.Motor.disable
disable(self)
Disable Disables the motor driver by taking it into sleep mode.
Definition
motor.py:37
vscode_python
motor.py
Generated by
1.15.0