Skip to content

Commit f647f6c

Browse files
Lam-NathanLam-Nathan
Lam-Nathan
authored and
Lam-Nathan
committed
Motor calibration
1 parent 43b7cad commit f647f6c

File tree

3 files changed

+44
-42
lines changed

3 files changed

+44
-42
lines changed

demos/MVP/motorControl.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ def __init__(self):
116116
self._instances.append(self)
117117

118118
#-------------------------------------------------------------------------------
119-
# Move FORWARD
120-
def forward(self):
121-
#print("Forward")
119+
# Move BACKWARD
120+
def backward(self):
121+
#print("Backward")
122122
GPIO.output(_RIGHT_MOTOR_1, False)
123123
GPIO.output(_RIGHT_MOTOR_2, True)
124124
GPIO.output(_LEFT_MOTOR_1, True)
@@ -132,9 +132,9 @@ def forward(self):
132132
'''
133133

134134
#-------------------------------------------------------------------------------
135-
# Move BACKWARD
136-
def backward(self):
137-
#print("Backward")
135+
# Move FORWARD
136+
def forward(self):
137+
#print("Forward")
138138
GPIO.output(_RIGHT_MOTOR_1, True)
139139
GPIO.output(_RIGHT_MOTOR_2, False)
140140
GPIO.output(_LEFT_MOTOR_1, False)
@@ -148,9 +148,9 @@ def backward(self):
148148
'''
149149

150150
#-------------------------------------------------------------------------------
151-
# Move RIGHT
152-
def right(self):
153-
#print("right")
151+
# Move LEFT
152+
def left(self):
153+
#print("left")
154154
GPIO.output(_RIGHT_MOTOR_1, True)
155155
GPIO.output(_RIGHT_MOTOR_2, False)
156156
GPIO.output(_LEFT_MOTOR_1, True)
@@ -164,9 +164,9 @@ def right(self):
164164
'''
165165

166166
#-------------------------------------------------------------------------------
167-
# Move LEFT
168-
def left(self):
169-
#print("Left")
167+
# Move RIGHT
168+
def right(self):
169+
#print("right")
170170
GPIO.output(_RIGHT_MOTOR_1, False)
171171
GPIO.output(_RIGHT_MOTOR_2, True)
172172
GPIO.output(_LEFT_MOTOR_1, False)

motorControl.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
_STEP_DURATION = 1000
6262

6363
# Controls motor strength
64-
_MOTOR_SPEED = 400
64+
_MOTOR_SPEED = 1000
6565

6666
# Turn duration in milliseconds.
6767
_TURN_DURATION = 1800
@@ -74,8 +74,9 @@
7474
GPIO.setup(_RIGHT_MOTOR_PWM_SPEED, GPIO.OUT)
7575
GPIO.setup(_LEFT_MOTOR_PWM_SPEED, GPIO.OUT)
7676

77-
right_motor = GPIO.PWM(_RIGHT_MOTOR_PWM_SPEED, _MOTOR_SPEED)
78-
left_motor= GPIO.PWM(_LEFT_MOTOR_PWM_SPEED, _MOTOR_SPEED)
77+
right_motor = GPIO.PWM(_RIGHT_MOTOR_PWM_SPEED, 1400)
78+
left_motor = GPIO.PWM(_LEFT_MOTOR_PWM_SPEED, _MOTOR_SPEED)
79+
7980
right_motor.start(50)
8081
left_motor.start(50)
8182

@@ -101,9 +102,9 @@ def __init__(self):
101102
self._instances.append(self)
102103

103104
#-------------------------------------------------------------------------------
104-
# Move FORWARD
105-
def forward(self):
106-
#print("Forward")
105+
# Move BACKWARD
106+
def backward(self):
107+
#print("Backward")
107108
GPIO.output(_RIGHT_MOTOR_1, False)
108109
GPIO.output(_RIGHT_MOTOR_2, True)
109110
GPIO.output(_LEFT_MOTOR_1, True)
@@ -117,9 +118,9 @@ def forward(self):
117118
'''
118119

119120
#-------------------------------------------------------------------------------
120-
# Move BACKWARD
121-
def backward(self):
122-
#print("Backward")
121+
# Move FORWARD
122+
def forward(self):
123+
#print("Forward")
123124
GPIO.output(_RIGHT_MOTOR_1, True)
124125
GPIO.output(_RIGHT_MOTOR_2, False)
125126
GPIO.output(_LEFT_MOTOR_1, False)
@@ -133,9 +134,9 @@ def backward(self):
133134
'''
134135

135136
#-------------------------------------------------------------------------------
136-
# Move RIGHT
137-
def right(self):
138-
#print("right")
137+
# Move LEFT
138+
def left(self):
139+
#print("left")
139140
GPIO.output(_RIGHT_MOTOR_1, True)
140141
GPIO.output(_RIGHT_MOTOR_2, False)
141142
GPIO.output(_LEFT_MOTOR_1, True)
@@ -149,9 +150,9 @@ def right(self):
149150
'''
150151

151152
#-------------------------------------------------------------------------------
152-
# Move LEFT
153-
def left(self):
154-
#print("Left")
153+
# Move RIGHT
154+
def right(self):
155+
#print("right")
155156
GPIO.output(_RIGHT_MOTOR_1, False)
156157
GPIO.output(_RIGHT_MOTOR_2, True)
157158
GPIO.output(_LEFT_MOTOR_1, False)

motor_test/motorControl.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
_STEP_DURATION = 1000
6262

6363
# Controls motor strength
64-
_MOTOR_SPEED = 400
64+
_MOTOR_SPEED = 1000
6565

6666
# Turn duration in milliseconds.
6767
_TURN_DURATION = 1800
@@ -74,8 +74,9 @@
7474
GPIO.setup(_RIGHT_MOTOR_PWM_SPEED, GPIO.OUT)
7575
GPIO.setup(_LEFT_MOTOR_PWM_SPEED, GPIO.OUT)
7676

77-
right_motor = GPIO.PWM(_RIGHT_MOTOR_PWM_SPEED, _MOTOR_SPEED)
78-
left_motor= GPIO.PWM(_LEFT_MOTOR_PWM_SPEED, _MOTOR_SPEED)
77+
right_motor = GPIO.PWM(_RIGHT_MOTOR_PWM_SPEED, 1400)
78+
left_motor = GPIO.PWM(_LEFT_MOTOR_PWM_SPEED, _MOTOR_SPEED)
79+
7980
right_motor.start(50)
8081
left_motor.start(50)
8182

@@ -101,9 +102,9 @@ def __init__(self):
101102
self._instances.append(self)
102103

103104
#-------------------------------------------------------------------------------
104-
# Move FORWARD
105-
def forward(self):
106-
#print("Forward")
105+
# Move BACKWARD
106+
def backward(self):
107+
#print("Backward")
107108
GPIO.output(_RIGHT_MOTOR_1, False)
108109
GPIO.output(_RIGHT_MOTOR_2, True)
109110
GPIO.output(_LEFT_MOTOR_1, True)
@@ -117,9 +118,9 @@ def forward(self):
117118
'''
118119

119120
#-------------------------------------------------------------------------------
120-
# Move BACKWARD
121-
def backward(self):
122-
#print("Backward")
121+
# Move FORWARD
122+
def forward(self):
123+
#print("Forward")
123124
GPIO.output(_RIGHT_MOTOR_1, True)
124125
GPIO.output(_RIGHT_MOTOR_2, False)
125126
GPIO.output(_LEFT_MOTOR_1, False)
@@ -133,9 +134,9 @@ def backward(self):
133134
'''
134135

135136
#-------------------------------------------------------------------------------
136-
# Move RIGHT
137-
def right(self):
138-
#print("right")
137+
# Move LEFT
138+
def left(self):
139+
#print("left")
139140
GPIO.output(_RIGHT_MOTOR_1, True)
140141
GPIO.output(_RIGHT_MOTOR_2, False)
141142
GPIO.output(_LEFT_MOTOR_1, True)
@@ -149,9 +150,9 @@ def right(self):
149150
'''
150151

151152
#-------------------------------------------------------------------------------
152-
# Move LEFT
153-
def left(self):
154-
#print("Left")
153+
# Move RIGHT
154+
def right(self):
155+
#print("right")
155156
GPIO.output(_RIGHT_MOTOR_1, False)
156157
GPIO.output(_RIGHT_MOTOR_2, True)
157158
GPIO.output(_LEFT_MOTOR_1, False)

0 commit comments

Comments
 (0)