PyTmcStepper 0.11.0__tar.gz → 0.13.0__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.11.0 → pytmcstepper-0.13.0}/PKG-INFO +17 -10
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/README.md +16 -9
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/pyproject.toml +1 -1
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/PyTmcStepper.egg-info/PKG-INFO +17 -10
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_math.py +2 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_stallguard.py +34 -14
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_stepperdriver.py +82 -76
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_xxxx.py +34 -2
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/enable_control/_tmc_ec_pin.py +3 -3
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc.py +5 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_int_ramp_generator.py +48 -12
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py +23 -21
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py +1 -22
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_vactual.py +7 -8
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc220x_reg.py +1 -1
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc5160_reg.py +20 -20
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc_reg.py +45 -2
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_220x.py +1 -4
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_2240.py +11 -16
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_5160.py +51 -16
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_ftdi.py +0 -2
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py +43 -18
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_periphery.py +11 -4
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py +21 -5
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_logger/_tmc_logger_base.py +2 -2
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_logger/_tmc_logger_cpython.py +2 -1
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/LICENSE +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/setup.cfg +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/PyTmcStepper.egg-info/SOURCES.txt +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/PyTmcStepper.egg-info/dependency_links.txt +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/PyTmcStepper.egg-info/requires.txt +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/PyTmcStepper.egg-info/top_level.txt +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/__init__.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_exceptions.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_validation.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/__init__.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_spi.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_spi_base.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_spi_ftdi.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_spi_micropython.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_uart.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_uart_base.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_uart_micropython.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/enable_control/__init__.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/enable_control/_tmc_ec.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/enable_control/_tmc_ec_toff.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/__init__.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/platform_utils.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/__init__.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc2209_reg.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc224x_reg.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc_shared_regs.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_2208.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_2209.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/__init__.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_base.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_logger/__init__.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_logger/_tmc_logger_micropython.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/tests/test_tmc2209.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/tests/test_tmc2240.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/tests/test_tmc_com_spi.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/tests/test_tmc_com_uart.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/tests/test_tmc_ec_pin.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/tests/test_tmc_math.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/tests/test_tmc_modules.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/tests/test_tmc_move.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/tests/test_tmc_set_current.py +0 -0
- {pytmcstepper-0.11.0 → pytmcstepper-0.13.0}/tests/test_tmc_stallguard.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyTmcStepper
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
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
|
|
@@ -37,9 +37,9 @@ Dynamic: license-file
|
|
|
37
37
|
|
|
38
38
|
\
|
|
39
39
|
\
|
|
40
|
-
This is a Python
|
|
40
|
+
This is a Python library to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
|
|
41
41
|
|
|
42
|
-
This code is still experimental, so use it
|
|
42
|
+
This code is still experimental, so use it at your own risk.
|
|
43
43
|
|
|
44
44
|
This library is programmed in pure Python. The performance of Python is not good enough to drive the motor with high speed.
|
|
45
45
|
So if you move the motor with high speed using this library the motor will lose steps.
|
|
@@ -47,13 +47,13 @@ So if you move the motor with high speed using this library the motor will lose
|
|
|
47
47
|
Tested on a [Bigtreetech TMC2209 V1.2](https://github.com/bigtreetech/BIGTREETECH-Stepper-Motor-Driver/tree/master/TMC2209/V1.2) and [Bigtreetech TMC2209 V1.3](https://github.com/bigtreetech/BIGTREETECH-Stepper-Motor-Driver/tree/master/TMC2209/V1.3).
|
|
48
48
|
|
|
49
49
|
It has a rSense of 110 mOhm and it uses one Pin (PDN_UART) for UART RX and TX.
|
|
50
|
-
So the PDN_UART-Pin needs to be connected to the
|
|
50
|
+
So the PDN_UART-Pin needs to be connected to the Raspberry Pis RX-Pin directly and to the TX-Pin with an 1kOhm resistor.
|
|
51
51
|
You can read more about this in the datasheet from Trinamic.
|
|
52
52
|
|
|
53
53
|
Because the TMC2209 uses one shared pin for transmit and receive in the UART communication line, the Raspberry Pi also receives what it sends.
|
|
54
54
|
Well, the Pi receives 4 bytes from itself and 8 bytes from the driver. So the Pi receives a total of 12 bytes and only the last 8 are the reply, of which only 4 are data bytes.
|
|
55
55
|
|
|
56
|
-
The
|
|
56
|
+
The documentation of the TMC2209 can be found here:
|
|
57
57
|
[TMC2209 - Datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/TMC2209_datasheet_rev1.09.pdf)
|
|
58
58
|
|
|
59
59
|
The code is also available on [PyPI](https://pypi.org/project/PyTmcStepper).
|
|
@@ -72,6 +72,13 @@ pip3 install PyTmcStepper
|
|
|
72
72
|
|
|
73
73
|
```shell
|
|
74
74
|
git clone https://github.com/Chr157i4n/PyTmcStepper
|
|
75
|
+
cd PyTmcStepper
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- (optional) install the lib to get proper syntax highlighting and start the demo scripts from every path
|
|
79
|
+
|
|
80
|
+
```shell
|
|
81
|
+
pip3 install -e .
|
|
75
82
|
```
|
|
76
83
|
|
|
77
84
|
- install the required modules
|
|
@@ -88,20 +95,20 @@ pip3 install PyTmcStepper
|
|
|
88
95
|
|
|
89
96
|
### Board Support
|
|
90
97
|
|
|
91
|
-
The following table shows the supported boards and which libraries for GPIO access is
|
|
98
|
+
The following table shows the supported boards and which libraries for GPIO access is being used for that board.
|
|
92
99
|
|
|
93
100
|
Library | Installation Parameter | Boards
|
|
94
101
|
----------- | ------------------------- | -----------
|
|
95
102
|
RPi.GPIO | RASPBERRY_PI | Pi4, Pi3 etc.
|
|
96
103
|
gpiozero | RASPBERRY_PI5 | Pi5
|
|
97
104
|
Jetson.GPIO | NVIDIA_JETSON | Nvidia Jetson
|
|
98
|
-
|
|
105
|
+
periphery | LUCKFOX_PICO | Luckfox Pico
|
|
99
106
|
OPi.GPIO | ORANGE_PI | Orange Pi
|
|
100
107
|
pyftdi | - | Windows/Linux
|
|
101
108
|
machine | - | Pico, Pico2, ESP32, etc.
|
|
102
109
|
|
|
103
110
|
Those libraries are needed for this library to work. You can either install the correct library yourself.
|
|
104
|
-
You can also install the needed GPIO library by
|
|
111
|
+
You can also install the needed GPIO library by specifying the Installation Parameter while installing this library:
|
|
105
112
|
|
|
106
113
|
```shell
|
|
107
114
|
pip3 install PyTmcStepper[RASPBERRY_PI]
|
|
@@ -120,7 +127,7 @@ TMC5160 | SPI/UART
|
|
|
120
127
|
|
|
121
128
|
## Submodules
|
|
122
129
|
|
|
123
|
-
with V0.7 the code for enabling the motor current output and the code for
|
|
130
|
+
with V0.7 the code for enabling the motor current output and the code for controlling the motion of the drivers
|
|
124
131
|
is split into their own classes to be able to support the diverse methods.
|
|
125
132
|
|
|
126
133
|
### EnableControl
|
|
@@ -159,7 +166,7 @@ SPI over FT232H | [TmcComSpiFtdi](src/tmc_driver/com/_tmc_com_spi_ftdi.py) | TM
|
|
|
159
166
|
|
|
160
167
|
## Wiring
|
|
161
168
|
|
|
162
|
-

|
|
163
170
|
|
|
164
171
|
Pin TMC | Color | connect to | Function
|
|
165
172
|
-- | -- | -- | --
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
\
|
|
9
9
|
\
|
|
10
|
-
This is a Python
|
|
10
|
+
This is a Python library to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
|
|
11
11
|
|
|
12
|
-
This code is still experimental, so use it
|
|
12
|
+
This code is still experimental, so use it at your own risk.
|
|
13
13
|
|
|
14
14
|
This library is programmed in pure Python. The performance of Python is not good enough to drive the motor with high speed.
|
|
15
15
|
So if you move the motor with high speed using this library the motor will lose steps.
|
|
@@ -17,13 +17,13 @@ So if you move the motor with high speed using this library the motor will lose
|
|
|
17
17
|
Tested on a [Bigtreetech TMC2209 V1.2](https://github.com/bigtreetech/BIGTREETECH-Stepper-Motor-Driver/tree/master/TMC2209/V1.2) and [Bigtreetech TMC2209 V1.3](https://github.com/bigtreetech/BIGTREETECH-Stepper-Motor-Driver/tree/master/TMC2209/V1.3).
|
|
18
18
|
|
|
19
19
|
It has a rSense of 110 mOhm and it uses one Pin (PDN_UART) for UART RX and TX.
|
|
20
|
-
So the PDN_UART-Pin needs to be connected to the
|
|
20
|
+
So the PDN_UART-Pin needs to be connected to the Raspberry Pis RX-Pin directly and to the TX-Pin with an 1kOhm resistor.
|
|
21
21
|
You can read more about this in the datasheet from Trinamic.
|
|
22
22
|
|
|
23
23
|
Because the TMC2209 uses one shared pin for transmit and receive in the UART communication line, the Raspberry Pi also receives what it sends.
|
|
24
24
|
Well, the Pi receives 4 bytes from itself and 8 bytes from the driver. So the Pi receives a total of 12 bytes and only the last 8 are the reply, of which only 4 are data bytes.
|
|
25
25
|
|
|
26
|
-
The
|
|
26
|
+
The documentation of the TMC2209 can be found here:
|
|
27
27
|
[TMC2209 - Datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/TMC2209_datasheet_rev1.09.pdf)
|
|
28
28
|
|
|
29
29
|
The code is also available on [PyPI](https://pypi.org/project/PyTmcStepper).
|
|
@@ -42,6 +42,13 @@ pip3 install PyTmcStepper
|
|
|
42
42
|
|
|
43
43
|
```shell
|
|
44
44
|
git clone https://github.com/Chr157i4n/PyTmcStepper
|
|
45
|
+
cd PyTmcStepper
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- (optional) install the lib to get proper syntax highlighting and start the demo scripts from every path
|
|
49
|
+
|
|
50
|
+
```shell
|
|
51
|
+
pip3 install -e .
|
|
45
52
|
```
|
|
46
53
|
|
|
47
54
|
- install the required modules
|
|
@@ -58,20 +65,20 @@ pip3 install PyTmcStepper
|
|
|
58
65
|
|
|
59
66
|
### Board Support
|
|
60
67
|
|
|
61
|
-
The following table shows the supported boards and which libraries for GPIO access is
|
|
68
|
+
The following table shows the supported boards and which libraries for GPIO access is being used for that board.
|
|
62
69
|
|
|
63
70
|
Library | Installation Parameter | Boards
|
|
64
71
|
----------- | ------------------------- | -----------
|
|
65
72
|
RPi.GPIO | RASPBERRY_PI | Pi4, Pi3 etc.
|
|
66
73
|
gpiozero | RASPBERRY_PI5 | Pi5
|
|
67
74
|
Jetson.GPIO | NVIDIA_JETSON | Nvidia Jetson
|
|
68
|
-
|
|
75
|
+
periphery | LUCKFOX_PICO | Luckfox Pico
|
|
69
76
|
OPi.GPIO | ORANGE_PI | Orange Pi
|
|
70
77
|
pyftdi | - | Windows/Linux
|
|
71
78
|
machine | - | Pico, Pico2, ESP32, etc.
|
|
72
79
|
|
|
73
80
|
Those libraries are needed for this library to work. You can either install the correct library yourself.
|
|
74
|
-
You can also install the needed GPIO library by
|
|
81
|
+
You can also install the needed GPIO library by specifying the Installation Parameter while installing this library:
|
|
75
82
|
|
|
76
83
|
```shell
|
|
77
84
|
pip3 install PyTmcStepper[RASPBERRY_PI]
|
|
@@ -90,7 +97,7 @@ TMC5160 | SPI/UART
|
|
|
90
97
|
|
|
91
98
|
## Submodules
|
|
92
99
|
|
|
93
|
-
with V0.7 the code for enabling the motor current output and the code for
|
|
100
|
+
with V0.7 the code for enabling the motor current output and the code for controlling the motion of the drivers
|
|
94
101
|
is split into their own classes to be able to support the diverse methods.
|
|
95
102
|
|
|
96
103
|
### EnableControl
|
|
@@ -129,7 +136,7 @@ SPI over FT232H | [TmcComSpiFtdi](src/tmc_driver/com/_tmc_com_spi_ftdi.py) | TM
|
|
|
129
136
|
|
|
130
137
|
## Wiring
|
|
131
138
|
|
|
132
|
-

|
|
133
140
|
|
|
134
141
|
Pin TMC | Color | connect to | Function
|
|
135
142
|
-- | -- | -- | --
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "PyTmcStepper"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.13.0"
|
|
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"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyTmcStepper
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
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
|
|
@@ -37,9 +37,9 @@ Dynamic: license-file
|
|
|
37
37
|
|
|
38
38
|
\
|
|
39
39
|
\
|
|
40
|
-
This is a Python
|
|
40
|
+
This is a Python library to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
|
|
41
41
|
|
|
42
|
-
This code is still experimental, so use it
|
|
42
|
+
This code is still experimental, so use it at your own risk.
|
|
43
43
|
|
|
44
44
|
This library is programmed in pure Python. The performance of Python is not good enough to drive the motor with high speed.
|
|
45
45
|
So if you move the motor with high speed using this library the motor will lose steps.
|
|
@@ -47,13 +47,13 @@ So if you move the motor with high speed using this library the motor will lose
|
|
|
47
47
|
Tested on a [Bigtreetech TMC2209 V1.2](https://github.com/bigtreetech/BIGTREETECH-Stepper-Motor-Driver/tree/master/TMC2209/V1.2) and [Bigtreetech TMC2209 V1.3](https://github.com/bigtreetech/BIGTREETECH-Stepper-Motor-Driver/tree/master/TMC2209/V1.3).
|
|
48
48
|
|
|
49
49
|
It has a rSense of 110 mOhm and it uses one Pin (PDN_UART) for UART RX and TX.
|
|
50
|
-
So the PDN_UART-Pin needs to be connected to the
|
|
50
|
+
So the PDN_UART-Pin needs to be connected to the Raspberry Pis RX-Pin directly and to the TX-Pin with an 1kOhm resistor.
|
|
51
51
|
You can read more about this in the datasheet from Trinamic.
|
|
52
52
|
|
|
53
53
|
Because the TMC2209 uses one shared pin for transmit and receive in the UART communication line, the Raspberry Pi also receives what it sends.
|
|
54
54
|
Well, the Pi receives 4 bytes from itself and 8 bytes from the driver. So the Pi receives a total of 12 bytes and only the last 8 are the reply, of which only 4 are data bytes.
|
|
55
55
|
|
|
56
|
-
The
|
|
56
|
+
The documentation of the TMC2209 can be found here:
|
|
57
57
|
[TMC2209 - Datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/TMC2209_datasheet_rev1.09.pdf)
|
|
58
58
|
|
|
59
59
|
The code is also available on [PyPI](https://pypi.org/project/PyTmcStepper).
|
|
@@ -72,6 +72,13 @@ pip3 install PyTmcStepper
|
|
|
72
72
|
|
|
73
73
|
```shell
|
|
74
74
|
git clone https://github.com/Chr157i4n/PyTmcStepper
|
|
75
|
+
cd PyTmcStepper
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- (optional) install the lib to get proper syntax highlighting and start the demo scripts from every path
|
|
79
|
+
|
|
80
|
+
```shell
|
|
81
|
+
pip3 install -e .
|
|
75
82
|
```
|
|
76
83
|
|
|
77
84
|
- install the required modules
|
|
@@ -88,20 +95,20 @@ pip3 install PyTmcStepper
|
|
|
88
95
|
|
|
89
96
|
### Board Support
|
|
90
97
|
|
|
91
|
-
The following table shows the supported boards and which libraries for GPIO access is
|
|
98
|
+
The following table shows the supported boards and which libraries for GPIO access is being used for that board.
|
|
92
99
|
|
|
93
100
|
Library | Installation Parameter | Boards
|
|
94
101
|
----------- | ------------------------- | -----------
|
|
95
102
|
RPi.GPIO | RASPBERRY_PI | Pi4, Pi3 etc.
|
|
96
103
|
gpiozero | RASPBERRY_PI5 | Pi5
|
|
97
104
|
Jetson.GPIO | NVIDIA_JETSON | Nvidia Jetson
|
|
98
|
-
|
|
105
|
+
periphery | LUCKFOX_PICO | Luckfox Pico
|
|
99
106
|
OPi.GPIO | ORANGE_PI | Orange Pi
|
|
100
107
|
pyftdi | - | Windows/Linux
|
|
101
108
|
machine | - | Pico, Pico2, ESP32, etc.
|
|
102
109
|
|
|
103
110
|
Those libraries are needed for this library to work. You can either install the correct library yourself.
|
|
104
|
-
You can also install the needed GPIO library by
|
|
111
|
+
You can also install the needed GPIO library by specifying the Installation Parameter while installing this library:
|
|
105
112
|
|
|
106
113
|
```shell
|
|
107
114
|
pip3 install PyTmcStepper[RASPBERRY_PI]
|
|
@@ -120,7 +127,7 @@ TMC5160 | SPI/UART
|
|
|
120
127
|
|
|
121
128
|
## Submodules
|
|
122
129
|
|
|
123
|
-
with V0.7 the code for enabling the motor current output and the code for
|
|
130
|
+
with V0.7 the code for enabling the motor current output and the code for controlling the motion of the drivers
|
|
124
131
|
is split into their own classes to be able to support the diverse methods.
|
|
125
132
|
|
|
126
133
|
### EnableControl
|
|
@@ -159,7 +166,7 @@ SPI over FT232H | [TmcComSpiFtdi](src/tmc_driver/com/_tmc_com_spi_ftdi.py) | TM
|
|
|
159
166
|
|
|
160
167
|
## Wiring
|
|
161
168
|
|
|
162
|
-

|
|
163
170
|
|
|
164
171
|
Pin TMC | Color | connect to | Function
|
|
165
172
|
-- | -- | -- | --
|
|
@@ -44,6 +44,17 @@ class StallGuard:
|
|
|
44
44
|
tcoolthrs: tmc_shared_regs.TCoolThrs
|
|
45
45
|
drvstatus: tmc_shared_regs.DrvStatus
|
|
46
46
|
|
|
47
|
+
# Stub methods - implemented by the driver class (Tmc2209, Tmc2240, Tmc5160)
|
|
48
|
+
def set_spreadcycle(self, en: bool) -> None:
|
|
49
|
+
"""Set spreadcycle mode. Implemented by driver class."""
|
|
50
|
+
raise NotImplementedError("set_spreadcycle must be implemented by driver class")
|
|
51
|
+
|
|
52
|
+
def get_microstepping_resolution(self) -> int:
|
|
53
|
+
"""Get microstepping resolution. Implemented by driver class."""
|
|
54
|
+
raise NotImplementedError(
|
|
55
|
+
"get_microstepping_resolution must be implemented by driver class"
|
|
56
|
+
)
|
|
57
|
+
|
|
47
58
|
@property
|
|
48
59
|
def sg_callback(self):
|
|
49
60
|
"""stallguard callback function"""
|
|
@@ -70,10 +81,7 @@ class StallGuard:
|
|
|
70
81
|
|
|
71
82
|
def deinit(self):
|
|
72
83
|
"""destructor"""
|
|
73
|
-
if (
|
|
74
|
-
getattr(self, "_pin_stallguard", None) is not None
|
|
75
|
-
and self._pin_stallguard is not None
|
|
76
|
-
):
|
|
84
|
+
if hasattr(self, "_pin_stallguard") and self._pin_stallguard is not None:
|
|
77
85
|
tmc_gpio.tmc_gpio.gpio_remove_event_detect(self._pin_stallguard)
|
|
78
86
|
tmc_gpio.tmc_gpio.gpio_cleanup(self._pin_stallguard)
|
|
79
87
|
self._pin_stallguard = None
|
|
@@ -99,10 +107,8 @@ class StallGuard:
|
|
|
99
107
|
Loglevel.INFO,
|
|
100
108
|
)
|
|
101
109
|
|
|
102
|
-
self.
|
|
103
|
-
|
|
104
|
-
tmc_math.steps_to_tstep(min_speed, self.get_microstepping_resolution())
|
|
105
|
-
)
|
|
110
|
+
self.stallguard_setup(threshold, min_speed)
|
|
111
|
+
|
|
106
112
|
self._sg_callback = callback
|
|
107
113
|
self._pin_stallguard = pin_stallguard
|
|
108
114
|
|
|
@@ -183,6 +189,24 @@ class StallGuard:
|
|
|
183
189
|
raise TmcMotionControlException("tmc_mc is None; cannot reset current pos")
|
|
184
190
|
self.tmc_mc.current_pos = 0
|
|
185
191
|
|
|
192
|
+
def stallguard_setup(
|
|
193
|
+
self,
|
|
194
|
+
threshold: int,
|
|
195
|
+
min_speed: int,
|
|
196
|
+
):
|
|
197
|
+
"""internal setup for stallguard
|
|
198
|
+
Args:
|
|
199
|
+
threshold (int): value for SGTHRS
|
|
200
|
+
min_speed (int): min speed [steps/s] for StallGuard
|
|
201
|
+
"""
|
|
202
|
+
self.tmc_logger.log(f"Stallguard threshold: {threshold}", Loglevel.DEBUG)
|
|
203
|
+
|
|
204
|
+
self.set_spreadcycle(False)
|
|
205
|
+
self._set_stallguard_threshold(threshold)
|
|
206
|
+
self._set_coolstep_threshold(
|
|
207
|
+
tmc_math.steps_to_tstep(min_speed, self.get_microstepping_resolution())
|
|
208
|
+
)
|
|
209
|
+
|
|
186
210
|
def do_homing(
|
|
187
211
|
self,
|
|
188
212
|
diag_pin: int,
|
|
@@ -212,8 +236,6 @@ class StallGuard:
|
|
|
212
236
|
if self.tmc_mc is None:
|
|
213
237
|
raise TmcMotionControlException("tmc_mc is None; cannot do homing")
|
|
214
238
|
|
|
215
|
-
self.tmc_logger.log(f"Stallguard threshold: {threshold}", Loglevel.DEBUG)
|
|
216
|
-
|
|
217
239
|
if max_speed is None:
|
|
218
240
|
max_speed = self.tmc_mc.max_speed_homing
|
|
219
241
|
if cb_success is _CB_SENTINEL:
|
|
@@ -222,8 +244,6 @@ class StallGuard:
|
|
|
222
244
|
self.tmc_logger.log("---", Loglevel.INFO)
|
|
223
245
|
self.tmc_logger.log("homing", Loglevel.INFO)
|
|
224
246
|
|
|
225
|
-
self.set_spreadcycle(0)
|
|
226
|
-
|
|
227
247
|
self.set_stallguard_callback(
|
|
228
248
|
diag_pin,
|
|
229
249
|
threshold,
|
|
@@ -239,11 +259,11 @@ class StallGuard:
|
|
|
239
259
|
|
|
240
260
|
if homing_succeeded:
|
|
241
261
|
self.tmc_logger.log("homing successful", Loglevel.INFO)
|
|
242
|
-
if cb_success is not None:
|
|
262
|
+
if cb_success is not None and callable(cb_success):
|
|
243
263
|
cb_success()
|
|
244
264
|
else:
|
|
245
265
|
self.tmc_logger.log("homing failed", Loglevel.INFO)
|
|
246
|
-
if cb_failure is not None:
|
|
266
|
+
if cb_failure is not None and callable(cb_failure):
|
|
247
267
|
cb_failure()
|
|
248
268
|
|
|
249
269
|
return homing_succeeded
|
|
@@ -91,16 +91,13 @@ class TmcStepperDriver:
|
|
|
91
91
|
|
|
92
92
|
def deinit(self):
|
|
93
93
|
"""destructor"""
|
|
94
|
-
if
|
|
94
|
+
if hasattr(self, "tmc_ec") and self.tmc_ec is not None:
|
|
95
95
|
self.tmc_ec.deinit()
|
|
96
96
|
self.tmc_ec = None
|
|
97
|
-
if
|
|
97
|
+
if hasattr(self, "tmc_mc") and self.tmc_mc is not None:
|
|
98
98
|
self.tmc_mc.deinit()
|
|
99
99
|
self.tmc_mc = None
|
|
100
|
-
if (
|
|
101
|
-
getattr(self, "tmc_logger", None) is not None
|
|
102
|
-
and self.tmc_logger is not None
|
|
103
|
-
):
|
|
100
|
+
if hasattr(self, "tmc_logger") and self.tmc_logger is not None:
|
|
104
101
|
self.tmc_logger.deinit()
|
|
105
102
|
del self.tmc_logger
|
|
106
103
|
|
|
@@ -114,103 +111,105 @@ class TmcStepperDriver:
|
|
|
114
111
|
# TmcMotionControl Wrapper
|
|
115
112
|
# ----------------------------
|
|
116
113
|
@property
|
|
117
|
-
def current_pos(self):
|
|
114
|
+
def current_pos(self) -> int:
|
|
118
115
|
"""_current_pos property"""
|
|
119
|
-
if self.tmc_mc is
|
|
120
|
-
|
|
121
|
-
return
|
|
116
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
117
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
118
|
+
return self.tmc_mc.current_pos
|
|
122
119
|
|
|
123
120
|
@current_pos.setter
|
|
124
121
|
def current_pos(self, current_pos: int):
|
|
125
122
|
"""_current_pos setter"""
|
|
126
|
-
if self.tmc_mc is
|
|
127
|
-
|
|
123
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
124
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
125
|
+
self.tmc_mc.current_pos = current_pos
|
|
128
126
|
|
|
129
127
|
@property
|
|
130
|
-
def current_pos_fullstep(self):
|
|
128
|
+
def current_pos_fullstep(self) -> int:
|
|
131
129
|
"""_current_pos as fullstep property"""
|
|
132
|
-
if self.current_pos is None or self.mres is None:
|
|
133
|
-
return None
|
|
134
130
|
return self.current_pos // self.mres
|
|
135
131
|
|
|
136
132
|
@current_pos_fullstep.setter
|
|
137
133
|
def current_pos_fullstep(self, current_pos: int):
|
|
138
134
|
"""_current_pos as fullstep setter"""
|
|
139
|
-
|
|
140
|
-
self.current_pos = current_pos * self.mres
|
|
135
|
+
self.current_pos = current_pos * self.mres
|
|
141
136
|
|
|
142
137
|
@property
|
|
143
|
-
def mres(self):
|
|
138
|
+
def mres(self) -> int:
|
|
144
139
|
"""_mres property"""
|
|
145
|
-
if self.tmc_mc is
|
|
146
|
-
|
|
147
|
-
return
|
|
140
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
141
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
142
|
+
return self.tmc_mc.mres
|
|
148
143
|
|
|
149
144
|
@mres.setter
|
|
150
145
|
def mres(self, mres: int):
|
|
151
146
|
"""_mres setter"""
|
|
152
|
-
if self.tmc_mc is
|
|
153
|
-
|
|
147
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
148
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
149
|
+
self.tmc_mc.mres = mres
|
|
154
150
|
|
|
155
151
|
@property
|
|
156
|
-
def steps_per_rev(self):
|
|
152
|
+
def steps_per_rev(self) -> int:
|
|
157
153
|
"""_steps_per_rev property"""
|
|
158
|
-
if self.tmc_mc is
|
|
159
|
-
|
|
160
|
-
return
|
|
154
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
155
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
156
|
+
return self.tmc_mc.steps_per_rev
|
|
161
157
|
|
|
162
158
|
@property
|
|
163
|
-
def fullsteps_per_rev(self):
|
|
159
|
+
def fullsteps_per_rev(self) -> int:
|
|
164
160
|
"""_fullsteps_per_rev property"""
|
|
165
|
-
if self.tmc_mc is
|
|
166
|
-
|
|
167
|
-
return
|
|
161
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
162
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
163
|
+
return self.tmc_mc.fullsteps_per_rev
|
|
168
164
|
|
|
169
165
|
@fullsteps_per_rev.setter
|
|
170
166
|
def fullsteps_per_rev(self, fullsteps_per_rev: int):
|
|
171
167
|
"""_fullsteps_per_rev setter"""
|
|
172
|
-
if self.tmc_mc is
|
|
173
|
-
|
|
168
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
169
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
170
|
+
self.tmc_mc.fullsteps_per_rev = fullsteps_per_rev
|
|
174
171
|
|
|
175
172
|
@property
|
|
176
|
-
def movement_abs_rel(self):
|
|
173
|
+
def movement_abs_rel(self) -> MovementAbsRel:
|
|
177
174
|
"""_movement_abs_rel property"""
|
|
178
|
-
if self.tmc_mc is
|
|
179
|
-
|
|
180
|
-
return
|
|
175
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
176
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
177
|
+
return self.tmc_mc.movement_abs_rel
|
|
181
178
|
|
|
182
179
|
@movement_abs_rel.setter
|
|
183
180
|
def movement_abs_rel(self, movement_abs_rel: MovementAbsRel):
|
|
184
181
|
"""_movement_abs_rel setter"""
|
|
185
|
-
if self.tmc_mc is
|
|
186
|
-
|
|
182
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
183
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
184
|
+
self.tmc_mc.movement_abs_rel = movement_abs_rel
|
|
187
185
|
|
|
188
186
|
@property
|
|
189
|
-
def movement_phase(self):
|
|
187
|
+
def movement_phase(self) -> MovementPhase:
|
|
190
188
|
"""_movement_phase property"""
|
|
191
|
-
if self.tmc_mc is
|
|
192
|
-
|
|
193
|
-
return
|
|
189
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
190
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
191
|
+
return self.tmc_mc.movement_phase
|
|
194
192
|
|
|
195
193
|
@property
|
|
196
|
-
def speed(self):
|
|
194
|
+
def speed(self) -> float:
|
|
197
195
|
"""_speed property"""
|
|
198
|
-
if self.tmc_mc is
|
|
199
|
-
|
|
200
|
-
return
|
|
196
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
197
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
198
|
+
return self.tmc_mc.speed
|
|
201
199
|
|
|
202
200
|
@speed.setter
|
|
203
201
|
def speed(self, speed: int):
|
|
204
202
|
"""_speed setter"""
|
|
205
|
-
if self.tmc_mc is
|
|
206
|
-
|
|
203
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
204
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
205
|
+
self.tmc_mc.speed = speed
|
|
207
206
|
|
|
208
207
|
@property
|
|
209
|
-
def max_speed(self):
|
|
208
|
+
def max_speed(self) -> int:
|
|
210
209
|
"""_max_speed property"""
|
|
211
|
-
if self.tmc_mc is
|
|
212
|
-
|
|
213
|
-
return
|
|
210
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
211
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
212
|
+
return self.tmc_mc.max_speed
|
|
214
213
|
|
|
215
214
|
@max_speed.setter
|
|
216
215
|
def max_speed(self, speed: int):
|
|
@@ -219,50 +218,53 @@ class TmcStepperDriver:
|
|
|
219
218
|
self.tmc_mc.max_speed = speed
|
|
220
219
|
|
|
221
220
|
@property
|
|
222
|
-
def max_speed_fullstep(self):
|
|
221
|
+
def max_speed_fullstep(self) -> int:
|
|
223
222
|
"""_max_speed_fullstep property"""
|
|
224
|
-
if self.tmc_mc is
|
|
225
|
-
|
|
226
|
-
return
|
|
223
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
224
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
225
|
+
return self.tmc_mc.max_speed_fullstep
|
|
227
226
|
|
|
228
227
|
@max_speed_fullstep.setter
|
|
229
228
|
def max_speed_fullstep(self, max_speed_fullstep: int):
|
|
230
229
|
"""_max_speed_fullstep setter"""
|
|
231
|
-
if self.tmc_mc is
|
|
232
|
-
|
|
230
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
231
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
232
|
+
self.tmc_mc.max_speed_fullstep = max_speed_fullstep
|
|
233
233
|
|
|
234
234
|
@property
|
|
235
|
-
def acceleration(self):
|
|
235
|
+
def acceleration(self) -> int:
|
|
236
236
|
"""_acceleration property"""
|
|
237
|
-
if self.tmc_mc is
|
|
238
|
-
|
|
239
|
-
return
|
|
237
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
238
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
239
|
+
return self.tmc_mc.acceleration
|
|
240
240
|
|
|
241
241
|
@acceleration.setter
|
|
242
242
|
def acceleration(self, acceleration: int):
|
|
243
243
|
"""_acceleration setter"""
|
|
244
|
-
if self.tmc_mc is
|
|
245
|
-
|
|
244
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
245
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
246
|
+
self.tmc_mc.acceleration = acceleration
|
|
246
247
|
|
|
247
248
|
@property
|
|
248
|
-
def acceleration_fullstep(self):
|
|
249
|
+
def acceleration_fullstep(self) -> int:
|
|
249
250
|
"""_acceleration_fullstep property"""
|
|
250
|
-
if self.tmc_mc is
|
|
251
|
-
|
|
252
|
-
return
|
|
251
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
252
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
253
|
+
return self.tmc_mc.acceleration_fullstep
|
|
253
254
|
|
|
254
255
|
@acceleration_fullstep.setter
|
|
255
256
|
def acceleration_fullstep(self, acceleration_fullstep: int):
|
|
256
257
|
"""_acceleration_fullstep setter"""
|
|
257
|
-
if self.tmc_mc is
|
|
258
|
-
|
|
258
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
259
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
260
|
+
self.tmc_mc.acceleration_fullstep = acceleration_fullstep
|
|
259
261
|
|
|
260
262
|
def run_to_position_steps(
|
|
261
263
|
self, steps, movement_abs_rel: MovementAbsRel | None = None
|
|
262
264
|
) -> StopMode:
|
|
263
265
|
"""motioncontrol wrapper"""
|
|
264
|
-
if self.tmc_mc is None:
|
|
265
|
-
|
|
266
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
267
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
266
268
|
return self.tmc_mc.run_to_position_steps(steps, movement_abs_rel)
|
|
267
269
|
|
|
268
270
|
def run_to_position_fullsteps(
|
|
@@ -277,12 +279,16 @@ class TmcStepperDriver:
|
|
|
277
279
|
"""motioncontrol wrapper"""
|
|
278
280
|
return self.run_to_position_steps(revs * self.steps_per_rev, movement_abs_rel)
|
|
279
281
|
|
|
280
|
-
|
|
282
|
+
def reset_position(self):
|
|
283
|
+
"""resets the current position to 0"""
|
|
284
|
+
self.current_pos_fullstep = 0
|
|
285
|
+
|
|
286
|
+
# Test Methods
|
|
281
287
|
# ----------------------------
|
|
282
288
|
def test_step(self):
|
|
283
289
|
"""test method"""
|
|
284
|
-
if self.tmc_mc is None:
|
|
285
|
-
|
|
290
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
291
|
+
raise AttributeError("TmcMotionControl is not set")
|
|
286
292
|
for _ in range(100):
|
|
287
293
|
self.tmc_mc.set_direction(Direction.CW)
|
|
288
294
|
self.tmc_mc.make_a_step()
|