Skip to content

Commit 6836f15

Browse files
committed
Merge branch 'master' of github.com:freaf87/FSEDevBoard
2 parents 39375fc + f9fd607 commit 6836f15

5 files changed

Lines changed: 20 additions & 26 deletions

File tree

02_Code/FSEDevBoard/FseDevBoard/buzzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def buzzForTime(self, time):
4747
sleep(time)
4848

4949
if __name__ == "__main__":
50-
with BUZZER(21) as buzzer:
50+
with BUZZER(4) as buzzer:
5151
while True:
5252
for i in list(range(40,0,-1)):
5353
print ("distance = {0} cm".format(i))

02_Code/FSEDevBoard/FseDevBoard/rgbLed.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from os.path import dirname
1818
sys.path.append(dirname(__file__))
1919

20-
2120
from pca9685 import PWM_Driver
2221
import time
2322
import sys

02_Code/FSEDevBoard/FseDevBoard/tb6612fng.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
"""Driver for 2 TB6612FNG DC motors mounted to a single chassis."""
1919
import sys
20+
import os
2021
from os.path import dirname
2122
sys.path.append(dirname(__file__))
2223

@@ -28,27 +29,23 @@
2829
class MotorDriver(GPIO_Manager):
2930
"""Interface with 2 TB6612FNG DC Motor drivers."""
3031
# Configure motor 1
31-
_m1_dir1_pin = 6
32-
_m1_dir2_pin = 12
33-
_m1_pwm_pin_annex = 5 # solve error mapping (Vers.01)
34-
_m1_pwm_pin = 18
32+
_m1_dir1_pin = 19
33+
_m1_dir2_pin = 16
34+
_m1_pwm_pin = 12
3535

3636
# Configure motor 2
37-
_m2_dir1_pin = 19
38-
_m2_dir2_pin = 16
39-
_m2_pwm_pin_annex = 26 # solve error mapping (Vers.01)
37+
_m2_dir1_pin = 26
38+
_m2_dir2_pin = 20
4039
_m2_pwm_pin = 13
4140

42-
_standby_pin = 20
41+
_standby_pin = 21
4342

4443
PWM_OUTPUTS = [_m1_pwm_pin, _m2_pwm_pin]
4544

46-
INPUT_PINS = [_m1_pwm_pin_annex, _m2_pwm_pin_annex]
47-
4845
OUTPUT_PINS = [_m1_dir1_pin, _m1_dir2_pin,
4946
_m2_dir1_pin, _m2_dir2_pin,
5047
_standby_pin]
51-
_pins = PWM_OUTPUTS + INPUT_PINS + OUTPUT_PINS
48+
_pins = PWM_OUTPUTS + OUTPUT_PINS
5249

5350
@staticmethod
5451
def to_dc(dc):
@@ -64,11 +61,6 @@ def __init__(self):
6461
for pin in self.PWM_OUTPUTS:
6562
wiringpi.pinMode(pin, wiringpi.PWM_OUTPUT)
6663

67-
for pin in self.INPUT_PINS:
68-
wiringpi.pinMode(pin, wiringpi.INPUT)
69-
# Make sure all annex_pin are set LOW
70-
wiringpi.pullUpDnControl(pin, wiringpi.PUD_DOWN)
71-
7264
def right_forward(self):
7365
"""Drive right motor forward."""
7466
wiringpi.digitalWrite(self._m1_dir1_pin, wiringpi.LOW)
@@ -138,28 +130,28 @@ def __exit__(self, *args):
138130
with MotorDriver() as tb6612fng:
139131
while True:
140132
print("forward")
141-
tb6612fng.forward()
133+
tb6612fng.forward(50)
142134
time.sleep(3)
143135

144136
tb6612fng.stop()
145137
time.sleep(3)
146138

147139
print("reverse")
148-
tb6612fng.reverse()
140+
tb6612fng.reverse(50)
149141
time.sleep(3)
150142

151143
tb6612fng.stop()
152144
time.sleep(3)
153145

154146
print("left")
155-
tb6612fng.left()
147+
tb6612fng.left(50)
156148
time.sleep(3)
157149

158150
tb6612fng.stop()
159151
time.sleep(3)
160152

161153
print("right")
162-
tb6612fng.right()
154+
tb6612fng.right(50)
163155
time.sleep(3)
164156

165157
tb6612fng.stop()

02_Code/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# FSEDevBoard package
2-
2+
33
## Installing
44
% sudo apt install python3 python3-pip
55
% pip3 install virtualenv
@@ -14,5 +14,8 @@
1414
(venv) % pip3 install FseDevBoard-0.0.1.tar.gz
1515

1616
### Running the PDC example
17-
(venv) % cd ../../applications
18-
(venv) % python3 PDC.py
17+
Note: Because applications using PWM must have root privileges, it is necessary to switch to root so that the venv is respected.
18+
% sudo su
19+
% source venv/bin/activate
20+
(venv) % cd ../../applications
21+
(venv) % python3 PDC.py

02_Code/applications/PDC.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class PDC(object):
3131
def __init__(self):
3232
self.ultrasonic = HCSR04(15, 14)
3333
self.rgbled = RGBLED()
34-
self.buzzer = BUZZER(21)
34+
self.buzzer = BUZZER(4)
3535
self.rgbled.pwmDriver.setPwmFreq(600)
3636

3737
def setPDCColor(self, color):

0 commit comments

Comments
 (0)