Skip to content

Commit 74d6c43

Browse files
authored
Merge pull request #123 from Chr157i4n/dev
version 0.8.0
2 parents 490fe0b + 84ad25d commit 74d6c43

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4408
-3689
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,15 @@ jobs:
4545
pip install mock
4646
pip install pyserial
4747
pip install spidev
48+
pip install pyftdi
4849
- name: Analysing the code with pylint
4950
run: |
5051
pylint $(find -wholename './src/*.py') \
5152
--disable=C0103 \
5253
--disable=W0511 \
5354
--disable=W0012 \
5455
--disable=R0801 \
55-
--extension-pkg-whitelist=RPi \
56-
--extension-pkg-whitelist=RPi.GPIO \
57-
--extension-pkg-whitelist=spidev \
56+
--unsafe-load-any-extension=y \
5857
--max-line-length=160
5958
6059
@@ -82,6 +81,7 @@ jobs:
8281
pip install Mock.GPIO
8382
pip install pyserial
8483
pip install spidev
84+
pip install pyftdi
8585
- name: Run unittests
8686
run: |
8787
python -m unittest

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## version 0.8.0
4+
5+
- added support for FT232H (can be used on Windows; currently only with TMC2240 and SPI)
6+
- added missing deinit in TmcEnableControl
7+
38
## version 0.7.8
49

510
- fixed RPi4 using wrong gpio lib

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ gpiozero | RASPBERRY_PI5 | Pi5
6767
Jetson.GPIO | NVIDIA_JETSON | Nvidia Jetson
6868
pheriphery | LUCKFOX_PICO | Luckfox Pico
6969
OPi.GPIO | ORANGE_PI | Orange Pi
70+
pyftdi | - | Windows/Linux
7071

7172
Those libraries are needed for this library to work. You can either install the correct library yourself.
7273
You can also install the needed GPIO library by specifing the Installation Parameter while installing this library:
@@ -118,10 +119,11 @@ Further methods of controlling the motion of a motor could be:
118119

119120
### Com
120121

121-
Com | Class | Driver | Notes
122-
-- | -- | -- | --
123-
UART | [TmcComUart](src/tmc_driver/com/_tmc_com_uart.py) | all | Communication via UART (RX, TX). See [Wiring](#uart)<br />[pyserial](https://pypi.org/project/pyserial) needs to be installed
124-
SPI | [TmcComSpi](src/tmc_driver/com/_tmc_com_spi.py) | TMC2240 | Communication via SPI (MOSI, MISO, CLK, CS). See [Wiring](#spi)<br />[spidev](https://pypi.org/project/spidev) needs to be installed
122+
Com | Class | Driver | Notes
123+
-- | -- | -- | --
124+
UART | [TmcComUart](src/tmc_driver/com/_tmc_com_uart.py) | all | Communication via UART (RX, TX). See [Wiring](#uart)<br />[pyserial](https://pypi.org/project/pyserial) needs to be installed
125+
SPI | [TmcComSpi](src/tmc_driver/com/_tmc_com_spi.py) | TMC2240 | Communication via SPI (MOSI, MISO, CLK, CS). See [Wiring](#spi)<br />[spidev](https://pypi.org/project/spidev) needs to be installed
126+
SPI over FT232H | [TmcComSpiFtdi](src/tmc_driver/com/_tmc_com_spi_ftdi.py) | TMC2240 | Communication via SPI using a FT232H. This can be used on any OS.<br />[pyftdi](https://pypi.org/project/pyftdi) needs to be installed
125127

126128
## Wiring
127129

Lines changed: 83 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,83 @@
1-
"""
2-
debug file for debuging the UART connection
3-
"""
4-
5-
import time
6-
try:
7-
from src.tmc_driver.tmc_2209 import *
8-
except ModuleNotFoundError:
9-
from tmc_driver.tmc_2209 import *
10-
11-
12-
print("---")
13-
print("SCRIPT START")
14-
print("---")
15-
16-
17-
18-
19-
20-
#-----------------------------------------------------------------------
21-
# initiate the Tmc2209 class
22-
# use your pins for pin_en, pin_step, pin_dir here
23-
#-----------------------------------------------------------------------
24-
if BOARD == Board.RASPBERRY_PI:
25-
tmc = Tmc2209(None, None)
26-
elif BOARD == Board.RASPBERRY_PI5:
27-
tmc = Tmc2209(None, None)
28-
elif BOARD == Board.NVIDIA_JETSON:
29-
tmc = Tmc2209(None, None)
30-
else:
31-
# just in case
32-
tmc = Tmc2209(None, None)
33-
34-
35-
if BOARD == Board.RASPBERRY_PI:
36-
tmc.tmc_com = TmcComUart("/dev/serial0")
37-
elif BOARD == Board.RASPBERRY_PI5:
38-
tmc.tmc_com = TmcComUart("/dev/ttyAMA0")
39-
elif BOARD == Board.NVIDIA_JETSON:
40-
tmc.tmc_com = TmcComUart("/dev/ttyTHS1")
41-
42-
tmc.tmc_com.tmc_logger = tmc.tmc_logger
43-
tmc.tmc_com.init()
44-
45-
46-
#-----------------------------------------------------------------------
47-
# set the loglevel of the libary (currently only printed)
48-
# set whether the movement should be relative or absolute
49-
# both optional
50-
#-----------------------------------------------------------------------
51-
tmc.tmc_logger.loglevel = Loglevel.DEBUG
52-
tmc.movement_abs_rel = MovementAbsRel.ABSOLUTE
53-
54-
55-
56-
57-
58-
59-
60-
#-----------------------------------------------------------------------
61-
# these functions read and print the current settings in the TMC register
62-
#-----------------------------------------------------------------------
63-
print("---\n---")
64-
65-
tmc.test_com()
66-
67-
68-
print("---\n---")
69-
70-
71-
72-
73-
74-
#-----------------------------------------------------------------------
75-
# deinitiate the Tmc2209 class
76-
#-----------------------------------------------------------------------
77-
del tmc
78-
79-
print("---")
80-
print("SCRIPT FINISHED")
81-
print("---")
1+
"""
2+
debug file for debuging the UART connection
3+
"""
4+
5+
import time
6+
try:
7+
from src.tmc_driver.tmc_2209 import *
8+
from src.tmc_driver.com._tmc_com_uart import *
9+
except ModuleNotFoundError:
10+
from tmc_driver.tmc_2209 import *
11+
from tmc_driver.com._tmc_com_uart import *
12+
13+
14+
print("---")
15+
print("SCRIPT START")
16+
print("---")
17+
18+
19+
20+
21+
22+
#-----------------------------------------------------------------------
23+
# initiate the Tmc2209 class
24+
# use your pins for pin_en, pin_step, pin_dir here
25+
#-----------------------------------------------------------------------
26+
if tmc_gpio.BOARD == Board.RASPBERRY_PI:
27+
tmc = Tmc2209(None, None)
28+
elif tmc_gpio.BOARD == Board.RASPBERRY_PI5:
29+
tmc = Tmc2209(None, None)
30+
elif tmc_gpio.BOARD == Board.NVIDIA_JETSON:
31+
tmc = Tmc2209(None, None)
32+
else:
33+
# just in case
34+
tmc = Tmc2209(None, None)
35+
36+
37+
if tmc_gpio.BOARD == Board.RASPBERRY_PI:
38+
tmc.tmc_com = TmcComUart("/dev/serial0")
39+
elif tmc_gpio.BOARD == Board.RASPBERRY_PI5:
40+
tmc.tmc_com = TmcComUart("/dev/ttyAMA0")
41+
elif tmc_gpio.BOARD == Board.NVIDIA_JETSON:
42+
tmc.tmc_com = TmcComUart("/dev/ttyTHS1")
43+
44+
tmc.tmc_com.tmc_logger = tmc.tmc_logger
45+
tmc.tmc_com.init()
46+
47+
48+
#-----------------------------------------------------------------------
49+
# set the loglevel of the libary (currently only printed)
50+
# set whether the movement should be relative or absolute
51+
# both optional
52+
#-----------------------------------------------------------------------
53+
tmc.tmc_logger.loglevel = Loglevel.DEBUG
54+
tmc.movement_abs_rel = MovementAbsRel.ABSOLUTE
55+
56+
57+
58+
59+
60+
61+
62+
#-----------------------------------------------------------------------
63+
# these functions read and print the current settings in the TMC register
64+
#-----------------------------------------------------------------------
65+
print("---\n---")
66+
67+
tmc.test_com()
68+
69+
70+
print("---\n---")
71+
72+
73+
74+
75+
76+
#-----------------------------------------------------------------------
77+
# deinitiate the Tmc2209 class
78+
#-----------------------------------------------------------------------
79+
del tmc
80+
81+
print("---")
82+
print("SCRIPT FINISHED")
83+
print("---")
Lines changed: 87 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,87 @@
1-
"""
2-
test file for testing the UART connection
3-
"""
4-
5-
import time
6-
try:
7-
from src.tmc_driver.tmc_2209 import *
8-
except ModuleNotFoundError:
9-
from tmc_driver.tmc_2209 import *
10-
11-
12-
print("---")
13-
print("SCRIPT START")
14-
print("---")
15-
16-
17-
tmc:Tmc2209 = None
18-
19-
20-
#-----------------------------------------------------------------------
21-
# initiate the Tmc2209 class
22-
# use your pins for pin_en, pin_step, pin_dir here
23-
#-----------------------------------------------------------------------
24-
if BOARD == Board.RASPBERRY_PI:
25-
tmc = Tmc2209(None, None, TmcComUart("/dev/serial0"), loglevel=Loglevel.DEBUG)
26-
elif BOARD == Board.RASPBERRY_PI5:
27-
tmc = Tmc2209(None, None, TmcComUart("/dev/ttyAMA0"), loglevel=Loglevel.DEBUG)
28-
elif BOARD == Board.NVIDIA_JETSON:
29-
tmc = Tmc2209(None, None, TmcComUart("/dev/ttyTHS1"), loglevel=Loglevel.DEBUG)
30-
else:
31-
# just in case
32-
tmc = Tmc2209(None, None, TmcComUart("/dev/serial0"), loglevel=Loglevel.DEBUG)
33-
34-
35-
#-----------------------------------------------------------------------
36-
# set the loglevel of the libary (currently only printed)
37-
# set whether the movement should be relative or absolute
38-
# both optional
39-
#-----------------------------------------------------------------------
40-
tmc.tmc_logger.loglevel = Loglevel.DEBUG
41-
tmc.movement_abs_rel = MovementAbsRel.ABSOLUTE
42-
43-
44-
45-
46-
47-
#-----------------------------------------------------------------------
48-
# these functions change settings in the TMC register
49-
#-----------------------------------------------------------------------
50-
tmc.set_direction_reg(False)
51-
tmc.set_current(300)
52-
tmc.set_interpolation(True)
53-
tmc.set_spreadcycle(False)
54-
tmc.set_microstepping_resolution(2)
55-
tmc.set_internal_rsense(False)
56-
57-
58-
print("---\n---")
59-
60-
61-
62-
63-
64-
#-----------------------------------------------------------------------
65-
# these functions read and print the current settings in the TMC register
66-
#-----------------------------------------------------------------------
67-
tmc.read_ioin()
68-
tmc.read_chopconf()
69-
tmc.read_drv_status()
70-
tmc.read_gconf()
71-
72-
print("---\n---")
73-
74-
75-
76-
77-
78-
#-----------------------------------------------------------------------
79-
# deinitiate the Tmc2209 class
80-
#-----------------------------------------------------------------------
81-
del tmc
82-
83-
print("---")
84-
print("SCRIPT FINISHED")
85-
print("---")
1+
"""
2+
test file for testing the UART connection
3+
"""
4+
5+
import time
6+
try:
7+
from src.tmc_driver.tmc_2209 import *
8+
from src.tmc_driver.com._tmc_com_uart import *
9+
except ModuleNotFoundError:
10+
from tmc_driver.tmc_2209 import *
11+
from tmc_driver.com._tmc_com_uart import *
12+
13+
14+
print("---")
15+
print("SCRIPT START")
16+
print("---")
17+
18+
19+
tmc:Tmc2209 = None
20+
21+
22+
#-----------------------------------------------------------------------
23+
# initiate the Tmc2209 class
24+
# use your pins for pin_en, pin_step, pin_dir here
25+
#-----------------------------------------------------------------------
26+
if tmc_gpio.BOARD == Board.RASPBERRY_PI:
27+
tmc = Tmc2209(None, None, TmcComUart("/dev/serial0"), loglevel=Loglevel.DEBUG)
28+
elif tmc_gpio.BOARD == Board.RASPBERRY_PI5:
29+
tmc = Tmc2209(None, None, TmcComUart("/dev/ttyAMA0"), loglevel=Loglevel.DEBUG)
30+
elif tmc_gpio.BOARD == Board.NVIDIA_JETSON:
31+
tmc = Tmc2209(None, None, TmcComUart("/dev/ttyTHS1"), loglevel=Loglevel.DEBUG)
32+
else:
33+
# just in case
34+
tmc = Tmc2209(None, None, TmcComUart("/dev/serial0"), loglevel=Loglevel.DEBUG)
35+
36+
37+
#-----------------------------------------------------------------------
38+
# set the loglevel of the libary (currently only printed)
39+
# set whether the movement should be relative or absolute
40+
# both optional
41+
#-----------------------------------------------------------------------
42+
tmc.tmc_logger.loglevel = Loglevel.DEBUG
43+
tmc.movement_abs_rel = MovementAbsRel.ABSOLUTE
44+
45+
46+
47+
48+
49+
#-----------------------------------------------------------------------
50+
# these functions change settings in the TMC register
51+
#-----------------------------------------------------------------------
52+
tmc.set_direction_reg(False)
53+
tmc.set_current(300)
54+
tmc.set_interpolation(True)
55+
tmc.set_spreadcycle(False)
56+
tmc.set_microstepping_resolution(2)
57+
tmc.set_internal_rsense(False)
58+
59+
60+
print("---\n---")
61+
62+
63+
64+
65+
66+
#-----------------------------------------------------------------------
67+
# these functions read and print the current settings in the TMC register
68+
#-----------------------------------------------------------------------
69+
tmc.read_ioin()
70+
tmc.read_chopconf()
71+
tmc.read_drv_status()
72+
tmc.read_gconf()
73+
74+
print("---\n---")
75+
76+
77+
78+
79+
80+
#-----------------------------------------------------------------------
81+
# deinitiate the Tmc2209 class
82+
#-----------------------------------------------------------------------
83+
del tmc
84+
85+
print("---")
86+
print("SCRIPT FINISHED")
87+
print("---")

0 commit comments

Comments
 (0)