PyTmcStepper 0.7__tar.gz → 0.7.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.
Files changed (45) hide show
  1. {pytmcstepper-0.7/src/PyTmcStepper.egg-info → pytmcstepper-0.7.2}/PKG-INFO +26 -24
  2. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/README.md +25 -23
  3. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/setup.cfg +1 -1
  4. {pytmcstepper-0.7 → pytmcstepper-0.7.2/src/PyTmcStepper.egg-info}/PKG-INFO +26 -24
  5. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/PyTmcStepper.egg-info/SOURCES.txt +1 -0
  6. pytmcstepper-0.7.2/src/tmc_driver/_tmc_stallguard.py +139 -0
  7. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/_tmc_stepperdriver.py +7 -6
  8. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py +2 -2
  9. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/motion_control/_tmc_mc_vactual.py +3 -3
  10. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/reg/_tmc224x_reg.py +5 -5
  11. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/reg/_tmc_reg.py +2 -2
  12. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/tmc_2209.py +20 -135
  13. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/tmc_220x.py +4 -0
  14. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/tmc_2240.py +30 -128
  15. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/LICENSE +0 -0
  16. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/pyproject.toml +0 -0
  17. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/PyTmcStepper.egg-info/dependency_links.txt +0 -0
  18. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/PyTmcStepper.egg-info/requires.txt +0 -0
  19. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/PyTmcStepper.egg-info/top_level.txt +0 -0
  20. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/__init__.py +0 -0
  21. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/_tmc_gpio_board.py +0 -0
  22. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/_tmc_logger.py +0 -0
  23. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/_tmc_math.py +0 -0
  24. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/com/__init__.py +0 -0
  25. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/com/_tmc_com.py +0 -0
  26. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/com/_tmc_com_spi.py +0 -0
  27. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/com/_tmc_com_uart.py +0 -0
  28. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/enable_control/__init__.py +0 -0
  29. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/enable_control/_tmc_ec.py +0 -0
  30. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/enable_control/_tmc_ec_pin.py +0 -0
  31. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/enable_control/_tmc_ec_toff.py +0 -0
  32. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/motion_control/__init__.py +0 -0
  33. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/motion_control/_tmc_mc.py +0 -0
  34. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py +0 -0
  35. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/reg/__init__.py +0 -0
  36. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/reg/_tmc2209_reg.py +0 -0
  37. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/reg/_tmc220x_reg.py +0 -0
  38. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/src/tmc_driver/tmc_2208.py +0 -0
  39. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/tests/test_tmc2209.py +0 -0
  40. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/tests/test_tmc2240.py +0 -0
  41. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/tests/test_tmc_com_spi.py +0 -0
  42. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/tests/test_tmc_com_uart.py +0 -0
  43. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/tests/test_tmc_ec_pin.py +0 -0
  44. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/tests/test_tmc_math.py +0 -0
  45. {pytmcstepper-0.7 → pytmcstepper-0.7.2}/tests/test_tmc_move.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PyTmcStepper
3
- Version: 0.7
3
+ Version: 0.7.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
  Home-page: https://github.com/Chr157i4n/PyTmcStepper
6
6
  Author: Christian Köhlke
@@ -28,16 +28,16 @@ Requires-Dist: python-periphery; extra == "luckfox-pico"
28
28
  Provides-Extra: orange-pi
29
29
  Requires-Dist: OPi.GPIO; extra == "orange-pi"
30
30
 
31
- # TMC_2209_Raspberry_Pi
31
+ # PyTmcStepper
32
32
 
33
- [![PyPI python version TMC-2209-Raspberry-Pi](https://badgen.net/pypi/python/TMC-2209-Raspberry-Pi)](https://pypi.org/project/TMC-2209-Raspberry-Pi)
34
- [![PyPI version TMC-2209-Raspberry-Pi](https://badgen.net/pypi/v/TMC-2209-Raspberry-Pi)](https://pypi.org/project/TMC-2209-Raspberry-Pi)
35
- [![PyPI downloads TMC-2209-Raspberry-Pi](https://img.shields.io/pypi/dm/TMC-2209-Raspberry-Pi)](https://pypi.org/project/TMC-2209-Raspberry-Pi)
36
- [![GitHub issues](https://img.shields.io/github/issues/Chr157i4n/TMC2209_Raspberry_Pi.svg)](https://GitHub.com/Chr157i4n/TMC2209_Raspberry_Pi/issues/)
33
+ [![PyPI python version PyTmcStepper](https://badgen.net/pypi/python/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
34
+ [![PyPI version PyTmcStepper](https://badgen.net/pypi/v/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
35
+ [![PyPI downloads PyTmcStepper](https://img.shields.io/pypi/dm/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
36
+ [![GitHub issues](https://img.shields.io/github/issues/Chr157i4n/PyTmcStepper.svg)](https://GitHub.com/Chr157i4n/PyTmcStepper/issues/)
37
37
 
38
38
  \
39
39
  \
40
- This is a library to drive a stepper motor with a TMC2209 stepper driver and a Raspberry Pi.
40
+ This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
41
41
 
42
42
  This code is still experimental, so use it on your own risk.
43
43
 
@@ -56,14 +56,14 @@ Well, the Pi receives 4 bytes from itself and 8 bytes from the driver. So the Pi
56
56
  The Documentation of the TMC2209 can be found here:
57
57
  [TMC2209 - Datsheet](https://www.analog.com/media/en/technical-documentation/data-sheets/TMC2209_datasheet_rev1.09.pdf)
58
58
 
59
- The code is also available on [PyPI](https://pypi.org/project/TMC-2209-Raspberry-Pi).
59
+ The code is also available on [PyPI](https://pypi.org/project/PyTmcStepper).
60
60
 
61
- ## Installation
61
+ ## Installation (on Raspberry Pi)
62
62
 
63
63
  ### Installation with PIP
64
64
 
65
65
  ```shell
66
- pip3 install TMC-2209-Raspberry-Pi
66
+ pip3 install PyTmcStepper
67
67
  ```
68
68
 
69
69
  ### Installation with GIT
@@ -71,7 +71,7 @@ pip3 install TMC-2209-Raspberry-Pi
71
71
  - clone this repo to your Raspberry Pi using
72
72
 
73
73
  ```shell
74
- git clone https://github.com/Chr157i4n/TMC2209_Raspberry_Pi
74
+ git clone https://github.com/Chr157i4n/PyTmcStepper
75
75
  ```
76
76
 
77
77
  - install the required modules
@@ -103,7 +103,7 @@ Those libraries are needed for this library to work. You can either install the
103
103
  You can also install the needed GPIO library by specifing the Installation Parameter while installing this library:
104
104
 
105
105
  ```shell
106
- pip3 install TMC-2209-Raspberry-Pi[RASPBERRY_PI]
106
+ pip3 install PyTmcStepper[RASPBERRY_PI]
107
107
  ```
108
108
 
109
109
  ## Driver Support
@@ -125,16 +125,16 @@ is split into their own classes to be able to support the diverse methods.
125
125
 
126
126
  EnableControl | Class | Driver | Notes
127
127
  -- | -- | -- | --
128
- Pin | TmcEnableControlPin | all | the EN Pin of the Driver needs to be connected to a GPIO of the Pi
129
- TOff | TmcEnableControlToff | all | the EN Pin needs to be connected to GND.<br />On the TMC2209 this enables current Output on Startup!<br />On the TMC2240 this works fine, because TOff is per default 0 (off).
128
+ Pin | [TmcEnableControlPin](src/tmc_driver/enable_control/_tmc_ec_pin.py) | all | the EN Pin of the Driver needs to be connected to a GPIO of the Pi
129
+ TOff | [TmcEnableControlToff](src/tmc_driver/enable_control/_tmc_ec_toff.py) | all | the EN Pin needs to be connected to GND.<br />On the TMC2209 this enables current Output on Startup!<br />On the TMC2240 this works fine, because TOff is per default 0 (off).
130
130
 
131
131
  ### MotionControl
132
132
 
133
133
  MotionControl | Class | Driver | Notes
134
134
  -- | -- | -- | --
135
- STEP/DIR | TmcMotionControlStepDir | all | the STEP and DIR pin of the driver must each be connected to a GPIO of the Pi
136
- STEP/REG | TmcMotionControlStepReg | all | only the STEP pin needs to be connected to a GPIO of the Pi.<br />The direction is controlled via the Register.
137
- VACTUAL | TmcMotionControlVActual | TMC220x | the Direction and Speed is controlled via Register. But VActual does only allow setting a speed and therefore cannot control positioning of the Motor.
135
+ STEP/DIR | [TmcMotionControlStepDir](src/tmc_driver/motion_control/_tmc_mc_step_dir.py) | all | the STEP and DIR pin of the driver must each be connected to a GPIO of the Pi
136
+ STEP/REG | [TmcMotionControlStepReg](src/tmc_driver/motion_control/_tmc_mc_step_reg.py) | all | only the STEP pin needs to be connected to a GPIO of the Pi.<br />The direction is controlled via the Register.
137
+ VACTUAL | [TmcMotionControlVActual](src/tmc_driver/motion_control/_tmc_mc_vactual.py) | TMC220x | the Direction and Speed is controlled via Register. But VActual does only allow setting a speed and therefore cannot control positioning of the Motor.
138
138
 
139
139
  Further methods of controlling a motor could be:
140
140
 
@@ -146,8 +146,8 @@ Further methods of controlling a motor could be:
146
146
 
147
147
  Com | Class | Driver | Notes
148
148
  -- | -- | -- | --
149
- UART | TmcComUart | all | Communication via UART (RX, TX). See [Wiring](#uart)<br />[pyserial](https://pypi.org/project/pyserial) needs to be installed
150
- SPI | TmcComSpi | TMC2240 | Communication via SPI (MOSI, MISO, CLK, CS). See [Wiring](#spi)<br />[spidev](https://pypi.org/project/spidev) needs to be installed
149
+ 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
150
+ 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
151
151
 
152
152
  ## Wiring
153
153
 
@@ -209,23 +209,25 @@ if not, check the connection of the pin.
209
209
 
210
210
  ### [demo_script_03_basic_movement.py](demo/demo_script_03_basic_movement.py)
211
211
 
212
- This script should move the motor 6 times, one revolution back and forth.
212
+ This script shows the different functions available to move the motors.
213
+ The motor is moved 4 times one revolution back and forth.
213
214
 
214
215
  ### [demo_script_04_stallguard.py](demo/demo_script_04_stallguard.py)
215
216
 
216
- In this script the stallguard feature of the TMC2209 is beeing setup.
217
+ In this script the stallguard feature of the TMC2209 is being setup.
217
218
  A funtion will be called, if the driver detects a stall. The function stops the current movement.
218
219
  The motor will be moved 10 revolutions. If the movement is finished unhindered, the script outputs ```Movement finished successfully```.
219
220
  If you block the motor with pliers or something similar, the the motor will stop and the script outputs ```StallGuard!``` and ```Movement was not completed```
220
221
 
221
222
  ### [demo_script_05_vactual.py](demo/demo_script_05_vactual.py)
222
223
 
223
- VACTUAL allows moving the motor by UART control. It gives the motor velocity in +-(2^23)-1 [μsteps / t]
224
+ VACTUAL enables the motor to be moved via the COM interface (UART) without additional GPIOs. The motor speed is transmitted as a value in +-(2^23)-1 [µsteps / t] via the COM interface.
224
225
 
225
226
  ### [demo_script_06_multiple_drivers.py](demo/demo_script_06_multiple_drivers.py)
226
227
 
227
228
  Multiple drivers can be addressed via UART by setting different addresses with the MS1 and MS2 pins.
228
229
  Simultaneous movement of multiple motors can be done with threaded movement.
230
+ When using SPI different Drivers are accessed via the Chip Select pin.
229
231
 
230
232
  ### [demo_script_07_threads.py](demo/demo_script_07_threads.py)
231
233
 
@@ -268,7 +270,7 @@ tmc.set_motor_enabled(False)
268
270
 
269
271
  ## Troubleshoot
270
272
 
271
- If you have questions please check out the [Wiki](https://github.com/Chr157i4n/TMC2209_Raspberry_Pi/wiki) and the other issues.
273
+ If you have questions please check out the [Wiki](https://github.com/Chr157i4n/PyTmcStepper/wiki) and the other issues.
272
274
 
273
275
  If you encounter any problems, feel free to open an issue (ENG/GER).
274
276
  Please don't send any E-Mails to me. Pls use Github, so that i don't need to answer the same question multiple times.
@@ -297,6 +299,6 @@ The main focus for this are Test setups, as Python is not fast enough for high m
297
299
 
298
300
  ## Feedback/Contributing
299
301
 
300
- If you encounter any problem, feel free to open an issue on the Github [issue page](https://github.com/Chr157i4n/TMC2209_Raspberry_Pi/issues).
302
+ If you encounter any problem, feel free to open an issue on the Github [issue page](https://github.com/Chr157i4n/PyTmcStepper/issues).
301
303
  Feedback will keep this project growing and I encourage all suggestions.
302
304
  Feel free to submit a pull request on the dev branch.
@@ -1,13 +1,13 @@
1
- # TMC_2209_Raspberry_Pi
1
+ # PyTmcStepper
2
2
 
3
- [![PyPI python version TMC-2209-Raspberry-Pi](https://badgen.net/pypi/python/TMC-2209-Raspberry-Pi)](https://pypi.org/project/TMC-2209-Raspberry-Pi)
4
- [![PyPI version TMC-2209-Raspberry-Pi](https://badgen.net/pypi/v/TMC-2209-Raspberry-Pi)](https://pypi.org/project/TMC-2209-Raspberry-Pi)
5
- [![PyPI downloads TMC-2209-Raspberry-Pi](https://img.shields.io/pypi/dm/TMC-2209-Raspberry-Pi)](https://pypi.org/project/TMC-2209-Raspberry-Pi)
6
- [![GitHub issues](https://img.shields.io/github/issues/Chr157i4n/TMC2209_Raspberry_Pi.svg)](https://GitHub.com/Chr157i4n/TMC2209_Raspberry_Pi/issues/)
3
+ [![PyPI python version PyTmcStepper](https://badgen.net/pypi/python/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
4
+ [![PyPI version PyTmcStepper](https://badgen.net/pypi/v/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
5
+ [![PyPI downloads PyTmcStepper](https://img.shields.io/pypi/dm/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
6
+ [![GitHub issues](https://img.shields.io/github/issues/Chr157i4n/PyTmcStepper.svg)](https://GitHub.com/Chr157i4n/PyTmcStepper/issues/)
7
7
 
8
8
  \
9
9
  \
10
- This is a library to drive a stepper motor with a TMC2209 stepper driver and a Raspberry Pi.
10
+ This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
11
11
 
12
12
  This code is still experimental, so use it on your own risk.
13
13
 
@@ -26,14 +26,14 @@ Well, the Pi receives 4 bytes from itself and 8 bytes from the driver. So the Pi
26
26
  The Documentation of the TMC2209 can be found here:
27
27
  [TMC2209 - Datsheet](https://www.analog.com/media/en/technical-documentation/data-sheets/TMC2209_datasheet_rev1.09.pdf)
28
28
 
29
- The code is also available on [PyPI](https://pypi.org/project/TMC-2209-Raspberry-Pi).
29
+ The code is also available on [PyPI](https://pypi.org/project/PyTmcStepper).
30
30
 
31
- ## Installation
31
+ ## Installation (on Raspberry Pi)
32
32
 
33
33
  ### Installation with PIP
34
34
 
35
35
  ```shell
36
- pip3 install TMC-2209-Raspberry-Pi
36
+ pip3 install PyTmcStepper
37
37
  ```
38
38
 
39
39
  ### Installation with GIT
@@ -41,7 +41,7 @@ pip3 install TMC-2209-Raspberry-Pi
41
41
  - clone this repo to your Raspberry Pi using
42
42
 
43
43
  ```shell
44
- git clone https://github.com/Chr157i4n/TMC2209_Raspberry_Pi
44
+ git clone https://github.com/Chr157i4n/PyTmcStepper
45
45
  ```
46
46
 
47
47
  - install the required modules
@@ -73,7 +73,7 @@ Those libraries are needed for this library to work. You can either install the
73
73
  You can also install the needed GPIO library by specifing the Installation Parameter while installing this library:
74
74
 
75
75
  ```shell
76
- pip3 install TMC-2209-Raspberry-Pi[RASPBERRY_PI]
76
+ pip3 install PyTmcStepper[RASPBERRY_PI]
77
77
  ```
78
78
 
79
79
  ## Driver Support
@@ -95,16 +95,16 @@ is split into their own classes to be able to support the diverse methods.
95
95
 
96
96
  EnableControl | Class | Driver | Notes
97
97
  -- | -- | -- | --
98
- Pin | TmcEnableControlPin | all | the EN Pin of the Driver needs to be connected to a GPIO of the Pi
99
- TOff | TmcEnableControlToff | all | the EN Pin needs to be connected to GND.<br />On the TMC2209 this enables current Output on Startup!<br />On the TMC2240 this works fine, because TOff is per default 0 (off).
98
+ Pin | [TmcEnableControlPin](src/tmc_driver/enable_control/_tmc_ec_pin.py) | all | the EN Pin of the Driver needs to be connected to a GPIO of the Pi
99
+ TOff | [TmcEnableControlToff](src/tmc_driver/enable_control/_tmc_ec_toff.py) | all | the EN Pin needs to be connected to GND.<br />On the TMC2209 this enables current Output on Startup!<br />On the TMC2240 this works fine, because TOff is per default 0 (off).
100
100
 
101
101
  ### MotionControl
102
102
 
103
103
  MotionControl | Class | Driver | Notes
104
104
  -- | -- | -- | --
105
- STEP/DIR | TmcMotionControlStepDir | all | the STEP and DIR pin of the driver must each be connected to a GPIO of the Pi
106
- STEP/REG | TmcMotionControlStepReg | all | only the STEP pin needs to be connected to a GPIO of the Pi.<br />The direction is controlled via the Register.
107
- VACTUAL | TmcMotionControlVActual | TMC220x | the Direction and Speed is controlled via Register. But VActual does only allow setting a speed and therefore cannot control positioning of the Motor.
105
+ STEP/DIR | [TmcMotionControlStepDir](src/tmc_driver/motion_control/_tmc_mc_step_dir.py) | all | the STEP and DIR pin of the driver must each be connected to a GPIO of the Pi
106
+ STEP/REG | [TmcMotionControlStepReg](src/tmc_driver/motion_control/_tmc_mc_step_reg.py) | all | only the STEP pin needs to be connected to a GPIO of the Pi.<br />The direction is controlled via the Register.
107
+ VACTUAL | [TmcMotionControlVActual](src/tmc_driver/motion_control/_tmc_mc_vactual.py) | TMC220x | the Direction and Speed is controlled via Register. But VActual does only allow setting a speed and therefore cannot control positioning of the Motor.
108
108
 
109
109
  Further methods of controlling a motor could be:
110
110
 
@@ -116,8 +116,8 @@ Further methods of controlling a motor could be:
116
116
 
117
117
  Com | Class | Driver | Notes
118
118
  -- | -- | -- | --
119
- UART | TmcComUart | all | Communication via UART (RX, TX). See [Wiring](#uart)<br />[pyserial](https://pypi.org/project/pyserial) needs to be installed
120
- SPI | TmcComSpi | TMC2240 | Communication via SPI (MOSI, MISO, CLK, CS). See [Wiring](#spi)<br />[spidev](https://pypi.org/project/spidev) needs to be installed
119
+ 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
120
+ 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
121
121
 
122
122
  ## Wiring
123
123
 
@@ -179,23 +179,25 @@ if not, check the connection of the pin.
179
179
 
180
180
  ### [demo_script_03_basic_movement.py](demo/demo_script_03_basic_movement.py)
181
181
 
182
- This script should move the motor 6 times, one revolution back and forth.
182
+ This script shows the different functions available to move the motors.
183
+ The motor is moved 4 times one revolution back and forth.
183
184
 
184
185
  ### [demo_script_04_stallguard.py](demo/demo_script_04_stallguard.py)
185
186
 
186
- In this script the stallguard feature of the TMC2209 is beeing setup.
187
+ In this script the stallguard feature of the TMC2209 is being setup.
187
188
  A funtion will be called, if the driver detects a stall. The function stops the current movement.
188
189
  The motor will be moved 10 revolutions. If the movement is finished unhindered, the script outputs ```Movement finished successfully```.
189
190
  If you block the motor with pliers or something similar, the the motor will stop and the script outputs ```StallGuard!``` and ```Movement was not completed```
190
191
 
191
192
  ### [demo_script_05_vactual.py](demo/demo_script_05_vactual.py)
192
193
 
193
- VACTUAL allows moving the motor by UART control. It gives the motor velocity in +-(2^23)-1 [μsteps / t]
194
+ VACTUAL enables the motor to be moved via the COM interface (UART) without additional GPIOs. The motor speed is transmitted as a value in +-(2^23)-1 [µsteps / t] via the COM interface.
194
195
 
195
196
  ### [demo_script_06_multiple_drivers.py](demo/demo_script_06_multiple_drivers.py)
196
197
 
197
198
  Multiple drivers can be addressed via UART by setting different addresses with the MS1 and MS2 pins.
198
199
  Simultaneous movement of multiple motors can be done with threaded movement.
200
+ When using SPI different Drivers are accessed via the Chip Select pin.
199
201
 
200
202
  ### [demo_script_07_threads.py](demo/demo_script_07_threads.py)
201
203
 
@@ -238,7 +240,7 @@ tmc.set_motor_enabled(False)
238
240
 
239
241
  ## Troubleshoot
240
242
 
241
- If you have questions please check out the [Wiki](https://github.com/Chr157i4n/TMC2209_Raspberry_Pi/wiki) and the other issues.
243
+ If you have questions please check out the [Wiki](https://github.com/Chr157i4n/PyTmcStepper/wiki) and the other issues.
242
244
 
243
245
  If you encounter any problems, feel free to open an issue (ENG/GER).
244
246
  Please don't send any E-Mails to me. Pls use Github, so that i don't need to answer the same question multiple times.
@@ -267,6 +269,6 @@ The main focus for this are Test setups, as Python is not fast enough for high m
267
269
 
268
270
  ## Feedback/Contributing
269
271
 
270
- If you encounter any problem, feel free to open an issue on the Github [issue page](https://github.com/Chr157i4n/TMC2209_Raspberry_Pi/issues).
272
+ If you encounter any problem, feel free to open an issue on the Github [issue page](https://github.com/Chr157i4n/PyTmcStepper/issues).
271
273
  Feedback will keep this project growing and I encourage all suggestions.
272
274
  Feel free to submit a pull request on the dev branch.
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = PyTmcStepper
3
- version = 0.7
3
+ version = 0.7.2
4
4
  author = Christian Köhlke
5
5
  author_email = christian@koehlke.de
6
6
  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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PyTmcStepper
3
- Version: 0.7
3
+ Version: 0.7.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
  Home-page: https://github.com/Chr157i4n/PyTmcStepper
6
6
  Author: Christian Köhlke
@@ -28,16 +28,16 @@ Requires-Dist: python-periphery; extra == "luckfox-pico"
28
28
  Provides-Extra: orange-pi
29
29
  Requires-Dist: OPi.GPIO; extra == "orange-pi"
30
30
 
31
- # TMC_2209_Raspberry_Pi
31
+ # PyTmcStepper
32
32
 
33
- [![PyPI python version TMC-2209-Raspberry-Pi](https://badgen.net/pypi/python/TMC-2209-Raspberry-Pi)](https://pypi.org/project/TMC-2209-Raspberry-Pi)
34
- [![PyPI version TMC-2209-Raspberry-Pi](https://badgen.net/pypi/v/TMC-2209-Raspberry-Pi)](https://pypi.org/project/TMC-2209-Raspberry-Pi)
35
- [![PyPI downloads TMC-2209-Raspberry-Pi](https://img.shields.io/pypi/dm/TMC-2209-Raspberry-Pi)](https://pypi.org/project/TMC-2209-Raspberry-Pi)
36
- [![GitHub issues](https://img.shields.io/github/issues/Chr157i4n/TMC2209_Raspberry_Pi.svg)](https://GitHub.com/Chr157i4n/TMC2209_Raspberry_Pi/issues/)
33
+ [![PyPI python version PyTmcStepper](https://badgen.net/pypi/python/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
34
+ [![PyPI version PyTmcStepper](https://badgen.net/pypi/v/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
35
+ [![PyPI downloads PyTmcStepper](https://img.shields.io/pypi/dm/PyTmcStepper)](https://pypi.org/project/PyTmcStepper)
36
+ [![GitHub issues](https://img.shields.io/github/issues/Chr157i4n/PyTmcStepper.svg)](https://GitHub.com/Chr157i4n/PyTmcStepper/issues/)
37
37
 
38
38
  \
39
39
  \
40
- This is a library to drive a stepper motor with a TMC2209 stepper driver and a Raspberry Pi.
40
+ This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
41
41
 
42
42
  This code is still experimental, so use it on your own risk.
43
43
 
@@ -56,14 +56,14 @@ Well, the Pi receives 4 bytes from itself and 8 bytes from the driver. So the Pi
56
56
  The Documentation of the TMC2209 can be found here:
57
57
  [TMC2209 - Datsheet](https://www.analog.com/media/en/technical-documentation/data-sheets/TMC2209_datasheet_rev1.09.pdf)
58
58
 
59
- The code is also available on [PyPI](https://pypi.org/project/TMC-2209-Raspberry-Pi).
59
+ The code is also available on [PyPI](https://pypi.org/project/PyTmcStepper).
60
60
 
61
- ## Installation
61
+ ## Installation (on Raspberry Pi)
62
62
 
63
63
  ### Installation with PIP
64
64
 
65
65
  ```shell
66
- pip3 install TMC-2209-Raspberry-Pi
66
+ pip3 install PyTmcStepper
67
67
  ```
68
68
 
69
69
  ### Installation with GIT
@@ -71,7 +71,7 @@ pip3 install TMC-2209-Raspberry-Pi
71
71
  - clone this repo to your Raspberry Pi using
72
72
 
73
73
  ```shell
74
- git clone https://github.com/Chr157i4n/TMC2209_Raspberry_Pi
74
+ git clone https://github.com/Chr157i4n/PyTmcStepper
75
75
  ```
76
76
 
77
77
  - install the required modules
@@ -103,7 +103,7 @@ Those libraries are needed for this library to work. You can either install the
103
103
  You can also install the needed GPIO library by specifing the Installation Parameter while installing this library:
104
104
 
105
105
  ```shell
106
- pip3 install TMC-2209-Raspberry-Pi[RASPBERRY_PI]
106
+ pip3 install PyTmcStepper[RASPBERRY_PI]
107
107
  ```
108
108
 
109
109
  ## Driver Support
@@ -125,16 +125,16 @@ is split into their own classes to be able to support the diverse methods.
125
125
 
126
126
  EnableControl | Class | Driver | Notes
127
127
  -- | -- | -- | --
128
- Pin | TmcEnableControlPin | all | the EN Pin of the Driver needs to be connected to a GPIO of the Pi
129
- TOff | TmcEnableControlToff | all | the EN Pin needs to be connected to GND.<br />On the TMC2209 this enables current Output on Startup!<br />On the TMC2240 this works fine, because TOff is per default 0 (off).
128
+ Pin | [TmcEnableControlPin](src/tmc_driver/enable_control/_tmc_ec_pin.py) | all | the EN Pin of the Driver needs to be connected to a GPIO of the Pi
129
+ TOff | [TmcEnableControlToff](src/tmc_driver/enable_control/_tmc_ec_toff.py) | all | the EN Pin needs to be connected to GND.<br />On the TMC2209 this enables current Output on Startup!<br />On the TMC2240 this works fine, because TOff is per default 0 (off).
130
130
 
131
131
  ### MotionControl
132
132
 
133
133
  MotionControl | Class | Driver | Notes
134
134
  -- | -- | -- | --
135
- STEP/DIR | TmcMotionControlStepDir | all | the STEP and DIR pin of the driver must each be connected to a GPIO of the Pi
136
- STEP/REG | TmcMotionControlStepReg | all | only the STEP pin needs to be connected to a GPIO of the Pi.<br />The direction is controlled via the Register.
137
- VACTUAL | TmcMotionControlVActual | TMC220x | the Direction and Speed is controlled via Register. But VActual does only allow setting a speed and therefore cannot control positioning of the Motor.
135
+ STEP/DIR | [TmcMotionControlStepDir](src/tmc_driver/motion_control/_tmc_mc_step_dir.py) | all | the STEP and DIR pin of the driver must each be connected to a GPIO of the Pi
136
+ STEP/REG | [TmcMotionControlStepReg](src/tmc_driver/motion_control/_tmc_mc_step_reg.py) | all | only the STEP pin needs to be connected to a GPIO of the Pi.<br />The direction is controlled via the Register.
137
+ VACTUAL | [TmcMotionControlVActual](src/tmc_driver/motion_control/_tmc_mc_vactual.py) | TMC220x | the Direction and Speed is controlled via Register. But VActual does only allow setting a speed and therefore cannot control positioning of the Motor.
138
138
 
139
139
  Further methods of controlling a motor could be:
140
140
 
@@ -146,8 +146,8 @@ Further methods of controlling a motor could be:
146
146
 
147
147
  Com | Class | Driver | Notes
148
148
  -- | -- | -- | --
149
- UART | TmcComUart | all | Communication via UART (RX, TX). See [Wiring](#uart)<br />[pyserial](https://pypi.org/project/pyserial) needs to be installed
150
- SPI | TmcComSpi | TMC2240 | Communication via SPI (MOSI, MISO, CLK, CS). See [Wiring](#spi)<br />[spidev](https://pypi.org/project/spidev) needs to be installed
149
+ 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
150
+ 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
151
151
 
152
152
  ## Wiring
153
153
 
@@ -209,23 +209,25 @@ if not, check the connection of the pin.
209
209
 
210
210
  ### [demo_script_03_basic_movement.py](demo/demo_script_03_basic_movement.py)
211
211
 
212
- This script should move the motor 6 times, one revolution back and forth.
212
+ This script shows the different functions available to move the motors.
213
+ The motor is moved 4 times one revolution back and forth.
213
214
 
214
215
  ### [demo_script_04_stallguard.py](demo/demo_script_04_stallguard.py)
215
216
 
216
- In this script the stallguard feature of the TMC2209 is beeing setup.
217
+ In this script the stallguard feature of the TMC2209 is being setup.
217
218
  A funtion will be called, if the driver detects a stall. The function stops the current movement.
218
219
  The motor will be moved 10 revolutions. If the movement is finished unhindered, the script outputs ```Movement finished successfully```.
219
220
  If you block the motor with pliers or something similar, the the motor will stop and the script outputs ```StallGuard!``` and ```Movement was not completed```
220
221
 
221
222
  ### [demo_script_05_vactual.py](demo/demo_script_05_vactual.py)
222
223
 
223
- VACTUAL allows moving the motor by UART control. It gives the motor velocity in +-(2^23)-1 [μsteps / t]
224
+ VACTUAL enables the motor to be moved via the COM interface (UART) without additional GPIOs. The motor speed is transmitted as a value in +-(2^23)-1 [µsteps / t] via the COM interface.
224
225
 
225
226
  ### [demo_script_06_multiple_drivers.py](demo/demo_script_06_multiple_drivers.py)
226
227
 
227
228
  Multiple drivers can be addressed via UART by setting different addresses with the MS1 and MS2 pins.
228
229
  Simultaneous movement of multiple motors can be done with threaded movement.
230
+ When using SPI different Drivers are accessed via the Chip Select pin.
229
231
 
230
232
  ### [demo_script_07_threads.py](demo/demo_script_07_threads.py)
231
233
 
@@ -268,7 +270,7 @@ tmc.set_motor_enabled(False)
268
270
 
269
271
  ## Troubleshoot
270
272
 
271
- If you have questions please check out the [Wiki](https://github.com/Chr157i4n/TMC2209_Raspberry_Pi/wiki) and the other issues.
273
+ If you have questions please check out the [Wiki](https://github.com/Chr157i4n/PyTmcStepper/wiki) and the other issues.
272
274
 
273
275
  If you encounter any problems, feel free to open an issue (ENG/GER).
274
276
  Please don't send any E-Mails to me. Pls use Github, so that i don't need to answer the same question multiple times.
@@ -297,6 +299,6 @@ The main focus for this are Test setups, as Python is not fast enough for high m
297
299
 
298
300
  ## Feedback/Contributing
299
301
 
300
- If you encounter any problem, feel free to open an issue on the Github [issue page](https://github.com/Chr157i4n/TMC2209_Raspberry_Pi/issues).
302
+ If you encounter any problem, feel free to open an issue on the Github [issue page](https://github.com/Chr157i4n/PyTmcStepper/issues).
301
303
  Feedback will keep this project growing and I encourage all suggestions.
302
304
  Feel free to submit a pull request on the dev branch.
@@ -11,6 +11,7 @@ src/tmc_driver/__init__.py
11
11
  src/tmc_driver/_tmc_gpio_board.py
12
12
  src/tmc_driver/_tmc_logger.py
13
13
  src/tmc_driver/_tmc_math.py
14
+ src/tmc_driver/_tmc_stallguard.py
14
15
  src/tmc_driver/_tmc_stepperdriver.py
15
16
  src/tmc_driver/tmc_2208.py
16
17
  src/tmc_driver/tmc_2209.py
@@ -0,0 +1,139 @@
1
+ #pylint: disable=too-many-arguments
2
+ #pylint: disable=too-many-public-methods
3
+ #pylint: disable=too-many-branches
4
+ #pylint: disable=too-many-instance-attributes
5
+ #pylint: disable=too-many-positional-arguments
6
+ #pylint: disable=bare-except
7
+ #pylint: disable=no-member
8
+ #pylint: disable=unused-import
9
+ #pylint: disable=wildcard-import
10
+ #pylint: disable=unused-wildcard-import
11
+ """StallGuard mixin
12
+ """
13
+
14
+ import types
15
+ from ._tmc_stepperdriver import *
16
+ from .com._tmc_com import TmcCom
17
+ from ._tmc_gpio_board import GpioPUD, GpioMode
18
+ from ._tmc_logger import Loglevel
19
+ from .reg._tmc224x_reg import *
20
+ from . import _tmc_math as tmc_math
21
+
22
+
23
+
24
+
25
+
26
+ class StallGuard():
27
+ """StallGuard
28
+
29
+ This class is used to control the stallguard feature of the TMC stepper driver.
30
+ The drivers class needs to inherit from this class to use the stallguard feature (mixin).
31
+ """
32
+ tmc_com:TmcCom = None
33
+
34
+ _pin_stallguard:int = None
35
+ _sg_callback:types.FunctionType = None
36
+
37
+
38
+
39
+ def set_stallguard_callback(self, pin_stallguard, threshold, callback,
40
+ min_speed = 100):
41
+ """set a function to call back, when the driver detects a stall
42
+ via stallguard
43
+ high value on the diag pin can also mean a driver error
44
+
45
+ Args:
46
+ pin_stallguard (int): pin needs to be connected to DIAG
47
+ threshold (int): value for SGTHRS
48
+ callback (func): will be called on StallGuard trigger
49
+ min_speed (int): min speed [steps/s] for StallGuard (Default value = 100)
50
+ """
51
+ self.tmc_logger.log(f"setup stallguard callback on GPIO {pin_stallguard}", Loglevel.INFO)
52
+ self.tmc_logger.log(f"StallGuard Threshold: {threshold} | minimum Speed: {min_speed}", Loglevel.INFO)
53
+
54
+ self._set_stallguard_threshold(threshold)
55
+ self._set_coolstep_threshold(tmc_math.steps_to_tstep(min_speed, self.get_microstepping_resolution()))
56
+ self._sg_callback = callback
57
+ self._pin_stallguard = pin_stallguard
58
+
59
+ tmc_gpio.gpio_setup(self._pin_stallguard, GpioMode.IN, pull_up_down=GpioPUD.PUD_DOWN)
60
+ # first remove existing events
61
+ tmc_gpio.gpio_remove_event_detect(self._pin_stallguard)
62
+ tmc_gpio.gpio_add_event_detect(self._pin_stallguard, self.stallguard_callback)
63
+
64
+
65
+
66
+ def stallguard_callback(self, gpio_pin):
67
+ """the callback function for StallGuard.
68
+ only checks whether the duration of the current movement is longer than
69
+ _sg_delay and then calls the actual callback
70
+
71
+ Args:
72
+ gpio_pin (int): pin number of the interrupt pin
73
+ """
74
+ del gpio_pin
75
+ if self._sg_callback is None:
76
+ self.tmc_logger.log("StallGuard callback is None", Loglevel.DEBUG)
77
+ return
78
+ self._sg_callback()
79
+
80
+
81
+
82
+ def enable_coolstep(self, semin_sg:int = 150, semax_sg:int = 200, seup:int = 1, sedn:int = 3, min_speed:int = 100):
83
+ """enables coolstep and sets the parameters for coolstep
84
+ The values for semin etc. can be tested with the test_stallguard_threshold function
85
+
86
+ Args:
87
+ semin_sg (int): lower threshold. Current will be increased if SG_Result goes below this
88
+ semax_sg (int): upper threshold. Current will be decreased if SG_Result goes above this
89
+ seup (int): current increment step
90
+ sedn (int): number of SG_Result readings for each current decrement
91
+ """
92
+ semax_sg = semax_sg - semin_sg
93
+
94
+ self.coolconf.read()
95
+ self.coolconf.semin = round(max(0, min(semin_sg/32, 15)))
96
+ self.coolconf.semax = round(max(0, min(semax_sg/32, 15)))
97
+ self.coolconf.seimin = 1 # scale down to until 1/4 of IRun (7 - 31)
98
+ self.coolconf.seup = seup
99
+ self.coolconf.sedn = sedn
100
+ self.coolconf.write_check()
101
+
102
+ self._set_coolstep_threshold(tmc_math.steps_to_tstep(min_speed, self.get_microstepping_resolution()))
103
+
104
+
105
+
106
+ def get_stallguard_result(self):
107
+ """return the current stallguard result
108
+ its will be calculated with every fullstep
109
+ higher values means a lower motor load
110
+
111
+ Returns:
112
+ sgresult (int): StallGuard Result
113
+ """
114
+ self.sgresult.read()
115
+ return self.sgresult.sgresult
116
+
117
+
118
+
119
+ def _set_stallguard_threshold(self, threshold):
120
+ """sets the register bit "SGTHRS" to to a given value
121
+ this is needed for the stallguard interrupt callback
122
+ SGRESULT becomes compared to the double of this threshold.
123
+ SGRESULT ≤ SGTHRS*2
124
+
125
+ Args:
126
+ threshold (int): value for SGTHRS
127
+ """
128
+ self.sgthrs.modify("sgthrs", threshold)
129
+
130
+
131
+
132
+ def _set_coolstep_threshold(self, threshold):
133
+ """This is the lower threshold velocity for switching
134
+ on smart energy CoolStep and StallGuard to DIAG output. (unsigned)
135
+
136
+ Args:
137
+ threshold (int): threshold velocity for coolstep
138
+ """
139
+ self.tcoolthrs.modify("tcoolthrs", threshold)
@@ -253,20 +253,21 @@ class TmcStepperDriver:
253
253
  self.tmc_mc.acceleration_fullstep = acceleration_fullstep
254
254
 
255
255
 
256
- def run_to_position_steps(self, steps, movement_abs_rel:MovementAbsRel = None):
256
+ def run_to_position_steps(self, steps, movement_abs_rel:MovementAbsRel = None) -> StopMode:
257
257
  """motioncontrol wrapper"""
258
258
  if self.tmc_mc is not None:
259
- self.tmc_mc.run_to_position_steps(steps, movement_abs_rel)
259
+ return self.tmc_mc.run_to_position_steps(steps, movement_abs_rel)
260
+ return None
260
261
 
261
262
 
262
- def run_to_position_fullsteps(self, steps, movement_abs_rel:MovementAbsRel = None):
263
+ def run_to_position_fullsteps(self, steps, movement_abs_rel:MovementAbsRel = None) -> StopMode:
263
264
  """motioncontrol wrapper"""
264
- self.run_to_position_steps(steps * self.mres, movement_abs_rel)
265
+ return self.run_to_position_steps(steps * self.mres, movement_abs_rel)
265
266
 
266
267
 
267
- def run_to_position_revolutions(self, revs, movement_abs_rel:MovementAbsRel = None):
268
+ def run_to_position_revolutions(self, revs, movement_abs_rel:MovementAbsRel = None) -> StopMode:
268
269
  """motioncontrol wrapper"""
269
- self.run_to_position_steps(revs * self.steps_per_rev, movement_abs_rel)
270
+ return self.run_to_position_steps(revs * self.steps_per_rev, movement_abs_rel)
270
271
 
271
272
 
272
273
  # StepperDriver methods
@@ -164,7 +164,7 @@ class TmcMotionControlStepDir(TmcMotionControl):
164
164
  tmc_gpio.gpio_output(self._pin_dir, direction.value)
165
165
 
166
166
 
167
- def run_to_position_steps(self, steps, movement_abs_rel:MovementAbsRel = None):
167
+ def run_to_position_steps(self, steps, movement_abs_rel:MovementAbsRel = None) -> StopMode:
168
168
  """runs the motor to the given position.
169
169
  with acceleration and deceleration
170
170
  blocks the code until finished or stopped from a different thread!
@@ -203,7 +203,7 @@ class TmcMotionControlStepDir(TmcMotionControl):
203
203
  return self._stop
204
204
 
205
205
 
206
- def run_to_position_revolutions(self, revolutions, movement_abs_rel:MovementAbsRel = None):
206
+ def run_to_position_revolutions(self, revolutions, movement_abs_rel:MovementAbsRel = None) -> StopMode:
207
207
  """runs the motor to the given position.
208
208
  with acceleration and deceleration
209
209
  blocks the code until finished!