PyTmcStepper 0.21.0__tar.gz → 0.21.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/PKG-INFO +14 -9
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/README.md +7 -7
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/pyproject.toml +10 -7
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/PyTmcStepper.egg-info/PKG-INFO +14 -9
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/PyTmcStepper.egg-info/SOURCES.txt +20 -1
- pytmcstepper-0.21.2/src/PyTmcStepper.egg-info/requires.txt +24 -0
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/__init__.py +1 -2
- pytmcstepper-0.21.2/src/tmc_driver/_tmc_exceptions.py +20 -0
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/_tmc_math.py +9 -34
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/_tmc_stallguard.py +45 -29
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/_tmc_stepperdriver.py +13 -13
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/_tmc_validation.py +1 -2
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/_tmc_xxxx.py +44 -45
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/com/__init__.py +2 -2
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com.py +27 -43
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_spi.py +10 -11
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_spi_base.py +26 -21
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_spi_circuitpython.py +4 -4
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_spi_ftdi.py +10 -11
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_spi_micropython.py +5 -5
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_uart.py +18 -24
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_uart_base.py +41 -33
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_uart_circuitpython.py +9 -9
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/com/_tmc_com_uart_micropython.py +10 -10
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/enable_control/__init__.py +2 -2
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/enable_control/_tmc_ec.py +11 -13
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/enable_control/_tmc_ec_pin.py +8 -9
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/enable_control/_tmc_ec_toff.py +4 -6
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/__init__.py +2 -2
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc.py +47 -60
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_int_ramp_generator.py +19 -16
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py +32 -44
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_step_pio.py +107 -124
- pytmcstepper-0.21.2/src/tmc_driver/motion_control/_tmc_mc_step_pio_base.py +74 -0
- pytmcstepper-0.21.2/src/tmc_driver/motion_control/_tmc_mc_step_pio_circuitpython.py +100 -0
- pytmcstepper-0.21.2/src/tmc_driver/motion_control/_tmc_mc_step_pio_micropython.py +106 -0
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py +8 -14
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py +5 -7
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/motion_control/_tmc_mc_vactual.py +22 -39
- pytmcstepper-0.21.2/src/tmc_driver/platform_utils.py +30 -0
- pytmcstepper-0.21.2/src/tmc_driver/reg/__init__.py +1 -0
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc2209_reg.py +5 -7
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc220x_reg.py +17 -19
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc224x_reg.py +28 -30
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc5160_reg.py +37 -39
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc_reg.py +20 -23
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/reg/_tmc_shared_regs.py +44 -45
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_2208.py +2 -2
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_2209.py +4 -4
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_220x.py +45 -35
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_2240.py +29 -26
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_5160.py +27 -25
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/__init__.py +9 -8
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_base.py +19 -19
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_circuitpython.py +12 -14
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_ftdi.py +15 -17
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py +27 -21
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py +16 -17
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_periphery.py +25 -20
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py +26 -26
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_logger/__init__.py +1 -3
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_logger/_tmc_logger_base.py +15 -21
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_logger/_tmc_logger_cpython.py +14 -21
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/tmc_driver/tmc_logger/_tmc_logger_micropython.py +3 -5
- pytmcstepper-0.21.2/tests/test_gpiozero.py +118 -0
- pytmcstepper-0.21.2/tests/test_tmc2209.py +143 -0
- pytmcstepper-0.21.2/tests/test_tmc2240.py +152 -0
- pytmcstepper-0.21.2/tests/test_tmc_com_spi.py +32 -0
- pytmcstepper-0.21.2/tests/test_tmc_com_uart.py +43 -0
- pytmcstepper-0.21.2/tests/test_tmc_ec_pin.py +26 -0
- pytmcstepper-0.21.2/tests/test_tmc_imports.py +46 -0
- pytmcstepper-0.21.2/tests/test_tmc_math.py +68 -0
- pytmcstepper-0.21.2/tests/test_tmc_modules.py +233 -0
- pytmcstepper-0.21.2/tests/test_tmc_move_intramp.py +132 -0
- pytmcstepper-0.21.2/tests/test_tmc_move_stepdir.py +110 -0
- pytmcstepper-0.21.2/tests/test_tmc_move_steppwmdir.py +93 -0
- pytmcstepper-0.21.2/tests/test_tmc_move_stepreg.py +146 -0
- pytmcstepper-0.21.2/tests/test_tmc_move_vactual.py +120 -0
- pytmcstepper-0.21.2/tests/test_tmc_set_current.py +204 -0
- pytmcstepper-0.21.2/tests/test_tmc_stallguard.py +138 -0
- pytmcstepper-0.21.0/src/PyTmcStepper.egg-info/requires.txt +0 -16
- pytmcstepper-0.21.0/src/tmc_driver/_tmc_exceptions.py +0 -21
- pytmcstepper-0.21.0/src/tmc_driver/platform_utils.py +0 -16
- pytmcstepper-0.21.0/src/tmc_driver/reg/__init__.py +0 -0
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/LICENSE +0 -0
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/setup.cfg +0 -0
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/PyTmcStepper.egg-info/dependency_links.txt +0 -0
- {pytmcstepper-0.21.0 → pytmcstepper-0.21.2}/src/PyTmcStepper.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyTmcStepper
|
|
3
|
-
Version: 0.21.
|
|
3
|
+
Version: 0.21.2
|
|
4
4
|
Summary: This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi
|
|
5
5
|
Author-email: Christian Köhlke <christian@koehlke.de>
|
|
6
6
|
License-Expression: GPL-3.0
|
|
@@ -17,7 +17,12 @@ Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
|
17
17
|
Requires-Python: >=3.10
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
|
-
|
|
20
|
+
Provides-Extra: uart
|
|
21
|
+
Requires-Dist: pyserial; extra == "uart"
|
|
22
|
+
Provides-Extra: spi
|
|
23
|
+
Requires-Dist: spidev; extra == "spi"
|
|
24
|
+
Provides-Extra: ftdi
|
|
25
|
+
Requires-Dist: pyftdi; extra == "ftdi"
|
|
21
26
|
Provides-Extra: raspberry-pi
|
|
22
27
|
Requires-Dist: RPi.GPIO; extra == "raspberry-pi"
|
|
23
28
|
Provides-Extra: raspberry-pi5
|
|
@@ -104,19 +109,19 @@ The following table shows the supported boards and which libraries for GPIO acce
|
|
|
104
109
|
|
|
105
110
|
Library | Installation Parameter | Boards
|
|
106
111
|
----------- | ------------------------- | -----------
|
|
107
|
-
RPi.GPIO |
|
|
108
|
-
gpiozero |
|
|
109
|
-
Jetson.GPIO |
|
|
110
|
-
periphery |
|
|
111
|
-
OPi.GPIO |
|
|
112
|
-
pyftdi |
|
|
112
|
+
RPi.GPIO | raspberry_pi | Pi4, Pi3 etc.
|
|
113
|
+
gpiozero | raspberry_pi5 | Pi5
|
|
114
|
+
Jetson.GPIO | nvidia_jetson | Nvidia Jetson
|
|
115
|
+
periphery | luckfox_pico | Luckfox Pico
|
|
116
|
+
OPi.GPIO | orange_pi | Orange Pi
|
|
117
|
+
pyftdi | ftdi | Windows/Linux
|
|
113
118
|
machine | - | Pico, Pico2, ESP32, etc.
|
|
114
119
|
|
|
115
120
|
Those libraries are needed for this library to work. You can either install the correct library yourself.
|
|
116
121
|
You can also install the needed GPIO library by specifying the Installation Parameter while installing this library:
|
|
117
122
|
|
|
118
123
|
```shell
|
|
119
|
-
pip3 install PyTmcStepper[
|
|
124
|
+
pip3 install PyTmcStepper[raspberry_pi, uart]
|
|
120
125
|
```
|
|
121
126
|
|
|
122
127
|
## Driver Support
|
|
@@ -72,19 +72,19 @@ The following table shows the supported boards and which libraries for GPIO acce
|
|
|
72
72
|
|
|
73
73
|
Library | Installation Parameter | Boards
|
|
74
74
|
----------- | ------------------------- | -----------
|
|
75
|
-
RPi.GPIO |
|
|
76
|
-
gpiozero |
|
|
77
|
-
Jetson.GPIO |
|
|
78
|
-
periphery |
|
|
79
|
-
OPi.GPIO |
|
|
80
|
-
pyftdi |
|
|
75
|
+
RPi.GPIO | raspberry_pi | Pi4, Pi3 etc.
|
|
76
|
+
gpiozero | raspberry_pi5 | Pi5
|
|
77
|
+
Jetson.GPIO | nvidia_jetson | Nvidia Jetson
|
|
78
|
+
periphery | luckfox_pico | Luckfox Pico
|
|
79
|
+
OPi.GPIO | orange_pi | Orange Pi
|
|
80
|
+
pyftdi | ftdi | Windows/Linux
|
|
81
81
|
machine | - | Pico, Pico2, ESP32, etc.
|
|
82
82
|
|
|
83
83
|
Those libraries are needed for this library to work. You can either install the correct library yourself.
|
|
84
84
|
You can also install the needed GPIO library by specifying the Installation Parameter while installing this library:
|
|
85
85
|
|
|
86
86
|
```shell
|
|
87
|
-
pip3 install PyTmcStepper[
|
|
87
|
+
pip3 install PyTmcStepper[raspberry_pi, uart]
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
## Driver Support
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "PyTmcStepper"
|
|
7
|
-
version = "0.21.
|
|
7
|
+
version = "0.21.2"
|
|
8
8
|
authors = [{ name = "Christian Köhlke", email = "christian@koehlke.de" }]
|
|
9
9
|
description = "This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi"
|
|
10
10
|
readme = "README.md"
|
|
@@ -20,18 +20,20 @@ classifiers = [
|
|
|
20
20
|
"Natural Language :: English",
|
|
21
21
|
"Topic :: System :: Hardware :: Hardware Drivers",
|
|
22
22
|
]
|
|
23
|
-
dependencies = ["pyserial"]
|
|
24
23
|
|
|
25
24
|
[project.urls]
|
|
26
25
|
Homepage = "https://github.com/Chr157i4n/PyTmcStepper"
|
|
27
26
|
"Bug Tracker" = "https://github.com/Chr157i4n/PyTmcStepper/issues"
|
|
28
27
|
|
|
29
28
|
[project.optional-dependencies]
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
uart = ["pyserial"]
|
|
30
|
+
spi = ["spidev"]
|
|
31
|
+
ftdi = ["pyftdi"]
|
|
32
|
+
raspberry_pi = ["RPi.GPIO"]
|
|
33
|
+
raspberry_pi5 = ["gpiozero"]
|
|
34
|
+
nvidia_jetson = ["Jetson.GPIO"]
|
|
35
|
+
luckfox_pico = ["python-periphery"]
|
|
36
|
+
orange_pi = ["OPi.GPIO"]
|
|
35
37
|
|
|
36
38
|
[tool.setuptools.packages.find]
|
|
37
39
|
where = ["src"]
|
|
@@ -58,6 +60,7 @@ omit = [
|
|
|
58
60
|
"*_ftdi.py",
|
|
59
61
|
"*_periphery.py",
|
|
60
62
|
"*_pio.py",
|
|
63
|
+
"*_pio*.py",
|
|
61
64
|
]
|
|
62
65
|
exclude_lines = [
|
|
63
66
|
"pragma: no cover",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyTmcStepper
|
|
3
|
-
Version: 0.21.
|
|
3
|
+
Version: 0.21.2
|
|
4
4
|
Summary: This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi
|
|
5
5
|
Author-email: Christian Köhlke <christian@koehlke.de>
|
|
6
6
|
License-Expression: GPL-3.0
|
|
@@ -17,7 +17,12 @@ Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
|
17
17
|
Requires-Python: >=3.10
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
License-File: LICENSE
|
|
20
|
-
|
|
20
|
+
Provides-Extra: uart
|
|
21
|
+
Requires-Dist: pyserial; extra == "uart"
|
|
22
|
+
Provides-Extra: spi
|
|
23
|
+
Requires-Dist: spidev; extra == "spi"
|
|
24
|
+
Provides-Extra: ftdi
|
|
25
|
+
Requires-Dist: pyftdi; extra == "ftdi"
|
|
21
26
|
Provides-Extra: raspberry-pi
|
|
22
27
|
Requires-Dist: RPi.GPIO; extra == "raspberry-pi"
|
|
23
28
|
Provides-Extra: raspberry-pi5
|
|
@@ -104,19 +109,19 @@ The following table shows the supported boards and which libraries for GPIO acce
|
|
|
104
109
|
|
|
105
110
|
Library | Installation Parameter | Boards
|
|
106
111
|
----------- | ------------------------- | -----------
|
|
107
|
-
RPi.GPIO |
|
|
108
|
-
gpiozero |
|
|
109
|
-
Jetson.GPIO |
|
|
110
|
-
periphery |
|
|
111
|
-
OPi.GPIO |
|
|
112
|
-
pyftdi |
|
|
112
|
+
RPi.GPIO | raspberry_pi | Pi4, Pi3 etc.
|
|
113
|
+
gpiozero | raspberry_pi5 | Pi5
|
|
114
|
+
Jetson.GPIO | nvidia_jetson | Nvidia Jetson
|
|
115
|
+
periphery | luckfox_pico | Luckfox Pico
|
|
116
|
+
OPi.GPIO | orange_pi | Orange Pi
|
|
117
|
+
pyftdi | ftdi | Windows/Linux
|
|
113
118
|
machine | - | Pico, Pico2, ESP32, etc.
|
|
114
119
|
|
|
115
120
|
Those libraries are needed for this library to work. You can either install the correct library yourself.
|
|
116
121
|
You can also install the needed GPIO library by specifying the Installation Parameter while installing this library:
|
|
117
122
|
|
|
118
123
|
```shell
|
|
119
|
-
pip3 install PyTmcStepper[
|
|
124
|
+
pip3 install PyTmcStepper[raspberry_pi, uart]
|
|
120
125
|
```
|
|
121
126
|
|
|
122
127
|
## Driver Support
|
|
@@ -39,6 +39,9 @@ src/tmc_driver/motion_control/_tmc_mc.py
|
|
|
39
39
|
src/tmc_driver/motion_control/_tmc_mc_int_ramp_generator.py
|
|
40
40
|
src/tmc_driver/motion_control/_tmc_mc_step_dir.py
|
|
41
41
|
src/tmc_driver/motion_control/_tmc_mc_step_pio.py
|
|
42
|
+
src/tmc_driver/motion_control/_tmc_mc_step_pio_base.py
|
|
43
|
+
src/tmc_driver/motion_control/_tmc_mc_step_pio_circuitpython.py
|
|
44
|
+
src/tmc_driver/motion_control/_tmc_mc_step_pio_micropython.py
|
|
42
45
|
src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py
|
|
43
46
|
src/tmc_driver/motion_control/_tmc_mc_step_reg.py
|
|
44
47
|
src/tmc_driver/motion_control/_tmc_mc_vactual.py
|
|
@@ -60,4 +63,20 @@ src/tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py
|
|
|
60
63
|
src/tmc_driver/tmc_logger/__init__.py
|
|
61
64
|
src/tmc_driver/tmc_logger/_tmc_logger_base.py
|
|
62
65
|
src/tmc_driver/tmc_logger/_tmc_logger_cpython.py
|
|
63
|
-
src/tmc_driver/tmc_logger/_tmc_logger_micropython.py
|
|
66
|
+
src/tmc_driver/tmc_logger/_tmc_logger_micropython.py
|
|
67
|
+
tests/test_gpiozero.py
|
|
68
|
+
tests/test_tmc2209.py
|
|
69
|
+
tests/test_tmc2240.py
|
|
70
|
+
tests/test_tmc_com_spi.py
|
|
71
|
+
tests/test_tmc_com_uart.py
|
|
72
|
+
tests/test_tmc_ec_pin.py
|
|
73
|
+
tests/test_tmc_imports.py
|
|
74
|
+
tests/test_tmc_math.py
|
|
75
|
+
tests/test_tmc_modules.py
|
|
76
|
+
tests/test_tmc_move_intramp.py
|
|
77
|
+
tests/test_tmc_move_stepdir.py
|
|
78
|
+
tests/test_tmc_move_steppwmdir.py
|
|
79
|
+
tests/test_tmc_move_stepreg.py
|
|
80
|
+
tests/test_tmc_move_vactual.py
|
|
81
|
+
tests/test_tmc_set_current.py
|
|
82
|
+
tests/test_tmc_stallguard.py
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
[ftdi]
|
|
3
|
+
pyftdi
|
|
4
|
+
|
|
5
|
+
[luckfox_pico]
|
|
6
|
+
python-periphery
|
|
7
|
+
|
|
8
|
+
[nvidia_jetson]
|
|
9
|
+
Jetson.GPIO
|
|
10
|
+
|
|
11
|
+
[orange_pi]
|
|
12
|
+
OPi.GPIO
|
|
13
|
+
|
|
14
|
+
[raspberry_pi]
|
|
15
|
+
RPi.GPIO
|
|
16
|
+
|
|
17
|
+
[raspberry_pi5]
|
|
18
|
+
gpiozero
|
|
19
|
+
|
|
20
|
+
[spi]
|
|
21
|
+
spidev
|
|
22
|
+
|
|
23
|
+
[uart]
|
|
24
|
+
pyserial
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
PyTmcStepper - Python library for Trinamic TMC stepper motor drivers
|
|
1
|
+
"""PyTmcStepper - Python library for Trinamic TMC stepper motor drivers.
|
|
3
2
|
|
|
4
3
|
This package provides a high-level interface for controlling TMC stepper motor drivers
|
|
5
4
|
via UART or SPI communication on various platforms including Raspberry Pi, Jetson, and MicroPython.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Exceptions module."""
|
|
2
|
+
|
|
3
|
+
class TmcException(Exception):
|
|
4
|
+
"""Base class for all TMC exceptions."""
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class TmcDriverException(TmcException):
|
|
8
|
+
"""Base class for all TMC driver exceptions."""
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TmcComException(TmcException):
|
|
12
|
+
"""Base class for all TMC communication exceptions."""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TmcMotionControlException(TmcException):
|
|
16
|
+
"""Base class for all TMC motion control exceptions."""
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class TmcEnableControlException(TmcException):
|
|
20
|
+
"""Base class for all TMC enable control exceptions."""
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
"""
|
|
2
|
-
TMC2209_Raspberry_Pi math library
|
|
3
|
-
"""
|
|
1
|
+
"""TMC2209_Raspberry_Pi math library."""
|
|
4
2
|
|
|
5
3
|
|
|
6
4
|
def rps_to_vactual(rps, steps_per_rev: int, fclk: int = 12000000) -> int:
|
|
7
|
-
"""
|
|
5
|
+
"""Converts rps -> vactual.
|
|
8
6
|
|
|
9
7
|
Args:
|
|
10
8
|
rps (float): revolutions per second
|
|
@@ -18,7 +16,7 @@ def rps_to_vactual(rps, steps_per_rev: int, fclk: int = 12000000) -> int:
|
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
def vactual_to_rps(vactual: int, steps_per_rev: int, fclk: int = 12000000) -> float:
|
|
21
|
-
"""
|
|
19
|
+
"""Converts vactual -> rps.
|
|
22
20
|
|
|
23
21
|
Args:
|
|
24
22
|
vactual (int): value for VACTUAL
|
|
@@ -32,7 +30,7 @@ def vactual_to_rps(vactual: int, steps_per_rev: int, fclk: int = 12000000) -> fl
|
|
|
32
30
|
|
|
33
31
|
|
|
34
32
|
def rps_to_steps(rps: float, steps_per_rev: int) -> int:
|
|
35
|
-
"""
|
|
33
|
+
"""Converts rps -> steps/second.
|
|
36
34
|
|
|
37
35
|
Args:
|
|
38
36
|
rps (float): revolutions per second
|
|
@@ -45,20 +43,12 @@ def rps_to_steps(rps: float, steps_per_rev: int) -> int:
|
|
|
45
43
|
|
|
46
44
|
|
|
47
45
|
def steps_to_rps(steps: int, steps_per_rev: int) -> float:
|
|
48
|
-
"""
|
|
49
|
-
|
|
50
|
-
Args:
|
|
51
|
-
steps (int): speed in steps per second
|
|
52
|
-
steps_per_rev (int): steps per revolution
|
|
53
|
-
|
|
54
|
-
Returns:
|
|
55
|
-
rps (float): revolutions per second
|
|
56
|
-
"""
|
|
46
|
+
"""Converts steps/second -> rps."""
|
|
57
47
|
return steps / steps_per_rev
|
|
58
48
|
|
|
59
49
|
|
|
60
50
|
def rps_to_tstep(rps: float, steps_per_rev: int, mres: int) -> int:
|
|
61
|
-
"""
|
|
51
|
+
"""Converts rps -> tstep.
|
|
62
52
|
|
|
63
53
|
Args:
|
|
64
54
|
rps (float): revolutions per second
|
|
@@ -72,22 +62,14 @@ def rps_to_tstep(rps: float, steps_per_rev: int, mres: int) -> int:
|
|
|
72
62
|
|
|
73
63
|
|
|
74
64
|
def steps_to_tstep(steps: int, mres: int) -> int:
|
|
75
|
-
"""
|
|
76
|
-
|
|
77
|
-
Args:
|
|
78
|
-
steps (int): speed in steps per second
|
|
79
|
-
mres (int): µstep resolution
|
|
80
|
-
|
|
81
|
-
Returns:
|
|
82
|
-
tstep (int): time per step
|
|
83
|
-
"""
|
|
65
|
+
"""Converts steps/second -> tstep."""
|
|
84
66
|
if steps == 0:
|
|
85
67
|
return 0
|
|
86
68
|
return int(round(12000000 / (steps * 256 / mres)))
|
|
87
69
|
|
|
88
70
|
|
|
89
71
|
def constrain(val: int, min_val: int, max_val: int) -> int:
|
|
90
|
-
"""
|
|
72
|
+
"""Constrains a value between a min and a max.
|
|
91
73
|
|
|
92
74
|
Args:
|
|
93
75
|
val (int): value that should be constrained
|
|
@@ -105,14 +87,7 @@ def constrain(val: int, min_val: int, max_val: int) -> int:
|
|
|
105
87
|
|
|
106
88
|
|
|
107
89
|
def mean(data) -> int:
|
|
108
|
-
"""
|
|
109
|
-
|
|
110
|
-
Args:
|
|
111
|
-
data (list): data to calculate the mean from
|
|
112
|
-
|
|
113
|
-
Returns:
|
|
114
|
-
int: mean of the data
|
|
115
|
-
"""
|
|
90
|
+
"""Calculates the mean of a list of numbers."""
|
|
116
91
|
count = len(data)
|
|
117
92
|
if count == 0:
|
|
118
93
|
return 0
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
# pylint: disable=too-many-branches
|
|
4
4
|
# pylint: disable=too-many-instance-attributes
|
|
5
5
|
# pylint: disable=too-many-positional-arguments
|
|
6
|
-
# pylint: disable=bare-except
|
|
7
6
|
# pylint: disable=no-member
|
|
8
7
|
# pylint: disable=unused-import
|
|
9
8
|
# pylint: disable=wildcard-import
|
|
10
9
|
# pylint: disable=unused-wildcard-import
|
|
11
|
-
"""StallGuard mixin"""
|
|
10
|
+
"""StallGuard mixin."""
|
|
12
11
|
|
|
13
12
|
import types
|
|
14
13
|
from ._tmc_stepperdriver import *
|
|
@@ -28,10 +27,11 @@ _CB_SENTINEL = object()
|
|
|
28
27
|
|
|
29
28
|
|
|
30
29
|
class StallGuard:
|
|
31
|
-
"""StallGuard
|
|
30
|
+
"""StallGuard.
|
|
32
31
|
|
|
33
|
-
This class is used to control the stallguard feature of the TMC
|
|
34
|
-
The drivers class needs to inherit from this class
|
|
32
|
+
This class is used to control the stallguard feature of the TMC
|
|
33
|
+
stepper driver. The drivers class needs to inherit from this class
|
|
34
|
+
to use the stallguard feature (mixin).
|
|
35
35
|
"""
|
|
36
36
|
|
|
37
37
|
tmc_logger: TmcLogger
|
|
@@ -46,18 +46,24 @@ class StallGuard:
|
|
|
46
46
|
|
|
47
47
|
# Stub methods - implemented by the driver class (Tmc2209, Tmc2240, Tmc5160)
|
|
48
48
|
def set_spreadcycle(self, en: bool) -> None:
|
|
49
|
-
"""Set spreadcycle mode.
|
|
49
|
+
"""Set spreadcycle mode.
|
|
50
|
+
|
|
51
|
+
Implemented by driver class.
|
|
52
|
+
"""
|
|
50
53
|
raise NotImplementedError("set_spreadcycle must be implemented by driver class")
|
|
51
54
|
|
|
52
55
|
def get_microstepping_resolution(self) -> int:
|
|
53
|
-
"""Get microstepping resolution.
|
|
56
|
+
"""Get microstepping resolution.
|
|
57
|
+
|
|
58
|
+
Implemented by driver class.
|
|
59
|
+
"""
|
|
54
60
|
raise NotImplementedError(
|
|
55
61
|
"get_microstepping_resolution must be implemented by driver class"
|
|
56
62
|
)
|
|
57
63
|
|
|
58
64
|
@property
|
|
59
65
|
def sg_callback(self):
|
|
60
|
-
"""
|
|
66
|
+
"""Stallguard callback function."""
|
|
61
67
|
return self._sg_callback
|
|
62
68
|
|
|
63
69
|
@sg_callback.setter
|
|
@@ -72,15 +78,16 @@ class StallGuard:
|
|
|
72
78
|
tmc_gpio.tmc_gpio.gpio_add_event_detect(self._pin_stallguard, callback)
|
|
73
79
|
|
|
74
80
|
def __init__(self):
|
|
75
|
-
"""
|
|
81
|
+
"""Initialize StallGuard instance variables."""
|
|
76
82
|
self._pin_stallguard: int | None = None
|
|
77
83
|
self._sg_threshold: int = 100 # threshold for stallguard
|
|
78
84
|
|
|
79
85
|
def __del__(self):
|
|
86
|
+
"""Destructor."""
|
|
80
87
|
self.deinit()
|
|
81
88
|
|
|
82
89
|
def deinit(self):
|
|
83
|
-
"""
|
|
90
|
+
"""Destructor."""
|
|
84
91
|
if hasattr(self, "_pin_stallguard") and self._pin_stallguard is not None:
|
|
85
92
|
tmc_gpio.tmc_gpio.gpio_remove_event_detect(self._pin_stallguard)
|
|
86
93
|
tmc_gpio.tmc_gpio.gpio_cleanup(self._pin_stallguard)
|
|
@@ -89,9 +96,10 @@ class StallGuard:
|
|
|
89
96
|
def set_stallguard_callback(
|
|
90
97
|
self, pin_stallguard, threshold, callback, min_speed=100
|
|
91
98
|
):
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
high value on the
|
|
99
|
+
"""Set a function to call back when the driver detects a stall.
|
|
100
|
+
|
|
101
|
+
Uses StallGuard. A high value on the DIAG pin can also mean a
|
|
102
|
+
driver error.
|
|
95
103
|
|
|
96
104
|
Args:
|
|
97
105
|
pin_stallguard (int): pin needs to be connected to DIAG
|
|
@@ -129,14 +137,17 @@ class StallGuard:
|
|
|
129
137
|
sedn: int = 3,
|
|
130
138
|
min_speed: int = 100,
|
|
131
139
|
):
|
|
132
|
-
"""
|
|
133
|
-
|
|
140
|
+
"""Enables CoolStep and sets the parameters.
|
|
141
|
+
|
|
142
|
+
The values for semin etc. can be tested with the
|
|
143
|
+
test_stallguard_threshold function.
|
|
134
144
|
|
|
135
145
|
Args:
|
|
136
146
|
semin_sg (int): lower threshold. Current will be increased if SG_Result goes below this
|
|
137
147
|
semax_sg (int): upper threshold. Current will be decreased if SG_Result goes above this
|
|
138
148
|
seup (int): current increment step
|
|
139
149
|
sedn (int): number of SG_Result readings for each current decrement
|
|
150
|
+
min_speed (int): min speed [steps/s] for CoolStep
|
|
140
151
|
"""
|
|
141
152
|
semax_sg = semax_sg - semin_sg
|
|
142
153
|
|
|
@@ -153,9 +164,10 @@ class StallGuard:
|
|
|
153
164
|
)
|
|
154
165
|
|
|
155
166
|
def get_stallguard_result(self):
|
|
156
|
-
"""
|
|
157
|
-
|
|
158
|
-
|
|
167
|
+
"""Return the current StallGuard result.
|
|
168
|
+
|
|
169
|
+
It is calculated with every fullstep.
|
|
170
|
+
Higher values means a lower motor load.
|
|
159
171
|
|
|
160
172
|
Returns:
|
|
161
173
|
sgresult (int): StallGuard Result
|
|
@@ -164,10 +176,11 @@ class StallGuard:
|
|
|
164
176
|
return self.sgresult.sgresult
|
|
165
177
|
|
|
166
178
|
def _set_stallguard_threshold(self, threshold):
|
|
167
|
-
"""
|
|
168
|
-
|
|
179
|
+
"""Sets the register bit 'SGTHRS' to a given value.
|
|
180
|
+
|
|
181
|
+
This is needed for the StallGuard interrupt callback.
|
|
169
182
|
SGRESULT becomes compared to the double of this threshold.
|
|
170
|
-
SGRESULT ≤ SGTHRS*2
|
|
183
|
+
SGRESULT ≤ SGTHRS*2.
|
|
171
184
|
|
|
172
185
|
Args:
|
|
173
186
|
threshold (int): value for SGTHRS
|
|
@@ -175,8 +188,9 @@ class StallGuard:
|
|
|
175
188
|
self.sgthrs.modify("sgthrs", int(threshold))
|
|
176
189
|
|
|
177
190
|
def _set_coolstep_threshold(self, threshold):
|
|
178
|
-
"""
|
|
179
|
-
|
|
191
|
+
"""Lower threshold velocity for switching on smart energy CoolStep.
|
|
192
|
+
|
|
193
|
+
Also enables StallGuard to DIAG output (unsigned).
|
|
180
194
|
|
|
181
195
|
Args:
|
|
182
196
|
threshold (int): threshold velocity for coolstep
|
|
@@ -184,7 +198,7 @@ class StallGuard:
|
|
|
184
198
|
self.tcoolthrs.modify("tcoolthrs", int(threshold))
|
|
185
199
|
|
|
186
200
|
def _reset_current_pos(self):
|
|
187
|
-
"""
|
|
201
|
+
"""Resets the current position of the motor to 0."""
|
|
188
202
|
if self.tmc_mc is None:
|
|
189
203
|
raise TmcMotionControlException("tmc_mc is None; cannot reset current pos")
|
|
190
204
|
self.tmc_mc.current_pos = 0
|
|
@@ -194,7 +208,8 @@ class StallGuard:
|
|
|
194
208
|
threshold: int,
|
|
195
209
|
min_speed: int,
|
|
196
210
|
):
|
|
197
|
-
"""
|
|
211
|
+
"""Internal setup for stallguard.
|
|
212
|
+
|
|
198
213
|
Args:
|
|
199
214
|
threshold (int): value for SGTHRS
|
|
200
215
|
min_speed (int): min speed [steps/s] for StallGuard
|
|
@@ -216,7 +231,8 @@ class StallGuard:
|
|
|
216
231
|
cb_success: types.FunctionType | object | None = _CB_SENTINEL,
|
|
217
232
|
cb_failure: types.FunctionType | object | None = None,
|
|
218
233
|
) -> bool:
|
|
219
|
-
"""
|
|
234
|
+
"""Homes the motor in the given direction using stallguard.
|
|
235
|
+
|
|
220
236
|
this method is using vactual to move the motor and an interrupt on the DIAG pin
|
|
221
237
|
|
|
222
238
|
Args:
|
|
@@ -268,14 +284,14 @@ class StallGuard:
|
|
|
268
284
|
|
|
269
285
|
return homing_succeeded
|
|
270
286
|
|
|
271
|
-
def test_stallguard_threshold(self, steps):
|
|
272
|
-
"""
|
|
287
|
+
def test_stallguard_threshold(self, steps: int):
|
|
288
|
+
"""Test method for tuning stallguard threshold.
|
|
273
289
|
|
|
274
290
|
run this function with your motor settings and your motor load
|
|
275
291
|
the function will determine the minimum stallguard results for each movement phase
|
|
276
292
|
|
|
277
293
|
Args:
|
|
278
|
-
steps (int):
|
|
294
|
+
steps (int): number of steps to move
|
|
279
295
|
"""
|
|
280
296
|
if not isinstance(self.tmc_mc, TmcMotionControlStepDir):
|
|
281
297
|
raise TmcMotionControlException(
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
# pylint: disable=too-many-branches
|
|
4
4
|
# pylint: disable=too-many-positional-arguments
|
|
5
5
|
# pylint: disable=import-outside-toplevel
|
|
6
|
-
# pylint: disable=bare-except
|
|
7
6
|
# pylint: disable=unused-import
|
|
8
7
|
# pylint: disable=wildcard-import
|
|
9
8
|
# pylint: disable=unused-wildcard-import
|
|
10
|
-
"""TmcStepperDriver module
|
|
9
|
+
"""TmcStepperDriver module.
|
|
11
10
|
|
|
12
11
|
this module has the function to move the motor via STEP/DIR pins
|
|
13
12
|
"""
|
|
@@ -34,7 +33,7 @@ from . import _tmc_math as tmc_math
|
|
|
34
33
|
|
|
35
34
|
|
|
36
35
|
class TmcStepperDriver:
|
|
37
|
-
"""TmcStepperDriver
|
|
36
|
+
"""TmcStepperDriver.
|
|
38
37
|
|
|
39
38
|
this class has two different functions:
|
|
40
39
|
1. change setting in the TMC-driver via UART
|
|
@@ -89,7 +88,7 @@ class TmcStepperDriver:
|
|
|
89
88
|
log_handlers: list | None = None,
|
|
90
89
|
log_formatter: logging.Formatter | None = None,
|
|
91
90
|
):
|
|
92
|
-
"""constructor
|
|
91
|
+
"""constructor.
|
|
93
92
|
|
|
94
93
|
Args:
|
|
95
94
|
tmc_ec (TmcEnableControl): TMC Enable Control object
|
|
@@ -124,10 +123,11 @@ class TmcStepperDriver:
|
|
|
124
123
|
self.tmc_ec.init(self.tmc_logger)
|
|
125
124
|
|
|
126
125
|
def __del__(self):
|
|
126
|
+
"""Destructor."""
|
|
127
127
|
self.deinit()
|
|
128
128
|
|
|
129
129
|
def deinit(self):
|
|
130
|
-
"""
|
|
130
|
+
"""Destructor."""
|
|
131
131
|
if hasattr(self, "tmc_ec") and self.tmc_ec is not None:
|
|
132
132
|
self.tmc_ec.deinit()
|
|
133
133
|
self.tmc_ec = None
|
|
@@ -141,7 +141,7 @@ class TmcStepperDriver:
|
|
|
141
141
|
# Attribute Forwarding
|
|
142
142
|
# ----------------------------
|
|
143
143
|
def __getattr__(self, name):
|
|
144
|
-
"""Forward attribute access to tmc_mc submodule dynamically"""
|
|
144
|
+
"""Forward attribute access to tmc_mc submodule dynamically."""
|
|
145
145
|
if name in self._MC_FORWARDED_ATTRS:
|
|
146
146
|
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
147
147
|
raise AttributeError(
|
|
@@ -154,7 +154,7 @@ class TmcStepperDriver:
|
|
|
154
154
|
)
|
|
155
155
|
|
|
156
156
|
def __setattr__(self, name, value):
|
|
157
|
-
"""Forward attribute setting to tmc_mc submodule dynamically"""
|
|
157
|
+
"""Forward attribute setting to tmc_mc submodule dynamically."""
|
|
158
158
|
# Forward to tmc_mc if it's a forwarded attribute and tmc_mc exists
|
|
159
159
|
if name in self._MC_FORWARDED_ATTRS:
|
|
160
160
|
# Only forward if tmc_mc is already initialized (not during __init__)
|
|
@@ -169,7 +169,7 @@ class TmcStepperDriver:
|
|
|
169
169
|
# TmcEnableControl Wrapper
|
|
170
170
|
# ----------------------------
|
|
171
171
|
def set_motor_enabled(self, en: bool):
|
|
172
|
-
"""
|
|
172
|
+
"""Enable control wrapper."""
|
|
173
173
|
if self.tmc_ec is not None:
|
|
174
174
|
self.tmc_ec.set_motor_enabled(en)
|
|
175
175
|
|
|
@@ -178,7 +178,7 @@ class TmcStepperDriver:
|
|
|
178
178
|
def run_to_position_steps(
|
|
179
179
|
self, steps, movement_abs_rel: MovementAbsRel | None = None
|
|
180
180
|
) -> StopMode:
|
|
181
|
-
"""
|
|
181
|
+
"""Motioncontrol wrapper."""
|
|
182
182
|
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
183
183
|
raise AttributeError("TmcMotionControl is not set")
|
|
184
184
|
return self.tmc_mc.run_to_position_steps(steps, movement_abs_rel)
|
|
@@ -186,23 +186,23 @@ class TmcStepperDriver:
|
|
|
186
186
|
def run_to_position_fullsteps(
|
|
187
187
|
self, steps, movement_abs_rel: MovementAbsRel | None = None
|
|
188
188
|
) -> StopMode:
|
|
189
|
-
"""
|
|
189
|
+
"""Motioncontrol wrapper."""
|
|
190
190
|
return self.run_to_position_steps(steps * self.mres, movement_abs_rel)
|
|
191
191
|
|
|
192
192
|
def run_to_position_revolutions(
|
|
193
193
|
self, revs, movement_abs_rel: MovementAbsRel | None = None
|
|
194
194
|
) -> StopMode:
|
|
195
|
-
"""
|
|
195
|
+
"""Motioncontrol wrapper."""
|
|
196
196
|
return self.run_to_position_steps(revs * self.steps_per_rev, movement_abs_rel)
|
|
197
197
|
|
|
198
198
|
def reset_position(self):
|
|
199
|
-
"""
|
|
199
|
+
"""Resets the current position to 0."""
|
|
200
200
|
self.current_pos_fullstep = 0
|
|
201
201
|
|
|
202
202
|
# Test Methods
|
|
203
203
|
# ----------------------------
|
|
204
204
|
def test_step(self):
|
|
205
|
-
"""
|
|
205
|
+
"""Test method."""
|
|
206
206
|
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
207
207
|
raise AttributeError("TmcMotionControl is not set")
|
|
208
208
|
for _ in range(100):
|