PyTmcStepper 0.11.0__tar.gz → 0.12.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.
Files changed (71) hide show
  1. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/PKG-INFO +17 -10
  2. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/README.md +16 -9
  3. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/pyproject.toml +1 -1
  4. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/PyTmcStepper.egg-info/PKG-INFO +17 -10
  5. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/_tmc_stallguard.py +14 -3
  6. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/_tmc_stepperdriver.py +74 -69
  7. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/_tmc_xxxx.py +24 -2
  8. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/enable_control/_tmc_ec_pin.py +3 -3
  9. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/motion_control/_tmc_mc.py +5 -0
  10. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py +23 -21
  11. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py +3 -1
  12. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/reg/_tmc_reg.py +11 -0
  13. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_220x.py +1 -4
  14. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_2240.py +1 -4
  15. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_5160.py +1 -4
  16. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_logger/_tmc_logger_base.py +2 -2
  17. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_logger/_tmc_logger_cpython.py +2 -1
  18. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/LICENSE +0 -0
  19. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/setup.cfg +0 -0
  20. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/PyTmcStepper.egg-info/SOURCES.txt +0 -0
  21. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/PyTmcStepper.egg-info/dependency_links.txt +0 -0
  22. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/PyTmcStepper.egg-info/requires.txt +0 -0
  23. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/PyTmcStepper.egg-info/top_level.txt +0 -0
  24. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/__init__.py +0 -0
  25. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/_tmc_exceptions.py +0 -0
  26. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/_tmc_math.py +0 -0
  27. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/_tmc_validation.py +0 -0
  28. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/com/__init__.py +0 -0
  29. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/com/_tmc_com.py +0 -0
  30. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/com/_tmc_com_spi.py +0 -0
  31. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/com/_tmc_com_spi_base.py +0 -0
  32. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/com/_tmc_com_spi_ftdi.py +0 -0
  33. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/com/_tmc_com_spi_micropython.py +0 -0
  34. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/com/_tmc_com_uart.py +0 -0
  35. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/com/_tmc_com_uart_base.py +0 -0
  36. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/com/_tmc_com_uart_micropython.py +0 -0
  37. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/enable_control/__init__.py +0 -0
  38. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/enable_control/_tmc_ec.py +0 -0
  39. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/enable_control/_tmc_ec_toff.py +0 -0
  40. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/motion_control/__init__.py +0 -0
  41. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/motion_control/_tmc_mc_int_ramp_generator.py +0 -0
  42. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py +0 -0
  43. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/motion_control/_tmc_mc_vactual.py +0 -0
  44. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/platform_utils.py +0 -0
  45. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/reg/__init__.py +0 -0
  46. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/reg/_tmc2209_reg.py +0 -0
  47. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/reg/_tmc220x_reg.py +0 -0
  48. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/reg/_tmc224x_reg.py +0 -0
  49. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/reg/_tmc5160_reg.py +0 -0
  50. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/reg/_tmc_shared_regs.py +0 -0
  51. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_2208.py +0 -0
  52. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_2209.py +0 -0
  53. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_gpio/__init__.py +0 -0
  54. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_base.py +0 -0
  55. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_ftdi.py +0 -0
  56. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py +0 -0
  57. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py +0 -0
  58. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_periphery.py +0 -0
  59. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py +0 -0
  60. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_logger/__init__.py +0 -0
  61. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/src/tmc_driver/tmc_logger/_tmc_logger_micropython.py +0 -0
  62. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/tests/test_tmc2209.py +0 -0
  63. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/tests/test_tmc2240.py +0 -0
  64. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/tests/test_tmc_com_spi.py +0 -0
  65. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/tests/test_tmc_com_uart.py +0 -0
  66. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/tests/test_tmc_ec_pin.py +0 -0
  67. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/tests/test_tmc_math.py +0 -0
  68. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/tests/test_tmc_modules.py +0 -0
  69. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/tests/test_tmc_move.py +0 -0
  70. {pytmcstepper-0.11.0 → pytmcstepper-0.12.0}/tests/test_tmc_set_current.py +0 -0
  71. {pytmcstepper-0.11.0 → pytmcstepper-0.12.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.11.0
3
+ Version: 0.12.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 libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
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 on your own risk.
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 Raspberrry Pis RX-Pin directly and to the TX-Pin with an 1kOhm resistor.
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 Documentation of the TMC2209 can be found here:
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 beeing used for that board.
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
- pheriphery | LUCKFOX_PICO | Luckfox Pico
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 specifing the Installation Parameter while installing this library:
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 controling the motion of the drivers
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
- ![wiring diagram](docs/images/wiring_diagram.png)
169
+ ![wiring diagram](docs/images/wiring_tmc2209_rpi4.png)
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 libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
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 on your own risk.
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 Raspberrry Pis RX-Pin directly and to the TX-Pin with an 1kOhm resistor.
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 Documentation of the TMC2209 can be found here:
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 beeing used for that board.
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
- pheriphery | LUCKFOX_PICO | Luckfox Pico
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 specifing the Installation Parameter while installing this library:
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 controling the motion of the drivers
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
- ![wiring diagram](docs/images/wiring_diagram.png)
139
+ ![wiring diagram](docs/images/wiring_tmc2209_rpi4.png)
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.11.0"
7
+ version = "0.12.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.11.0
3
+ Version: 0.12.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 libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi.
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 on your own risk.
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 Raspberrry Pis RX-Pin directly and to the TX-Pin with an 1kOhm resistor.
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 Documentation of the TMC2209 can be found here:
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 beeing used for that board.
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
- pheriphery | LUCKFOX_PICO | Luckfox Pico
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 specifing the Installation Parameter while installing this library:
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 controling the motion of the drivers
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
- ![wiring diagram](docs/images/wiring_diagram.png)
169
+ ![wiring diagram](docs/images/wiring_tmc2209_rpi4.png)
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"""
@@ -222,7 +233,7 @@ class StallGuard:
222
233
  self.tmc_logger.log("---", Loglevel.INFO)
223
234
  self.tmc_logger.log("homing", Loglevel.INFO)
224
235
 
225
- self.set_spreadcycle(0)
236
+ self.set_spreadcycle(False)
226
237
 
227
238
  self.set_stallguard_callback(
228
239
  diag_pin,
@@ -239,11 +250,11 @@ class StallGuard:
239
250
 
240
251
  if homing_succeeded:
241
252
  self.tmc_logger.log("homing successful", Loglevel.INFO)
242
- if cb_success is not None:
253
+ if cb_success is not None and callable(cb_success):
243
254
  cb_success()
244
255
  else:
245
256
  self.tmc_logger.log("homing failed", Loglevel.INFO)
246
- if cb_failure is not None:
257
+ if cb_failure is not None and callable(cb_failure):
247
258
  cb_failure()
248
259
 
249
260
  return homing_succeeded
@@ -114,103 +114,105 @@ class TmcStepperDriver:
114
114
  # TmcMotionControl Wrapper
115
115
  # ----------------------------
116
116
  @property
117
- def current_pos(self):
117
+ def current_pos(self) -> int:
118
118
  """_current_pos property"""
119
- if self.tmc_mc is not None:
120
- return self.tmc_mc.current_pos
121
- return None
119
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
120
+ raise AttributeError("TmcMotionControl is not set")
121
+ return self.tmc_mc.current_pos
122
122
 
123
123
  @current_pos.setter
124
124
  def current_pos(self, current_pos: int):
125
125
  """_current_pos setter"""
126
- if self.tmc_mc is not None:
127
- self.tmc_mc.current_pos = current_pos
126
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
127
+ raise AttributeError("TmcMotionControl is not set")
128
+ self.tmc_mc.current_pos = current_pos
128
129
 
129
130
  @property
130
- def current_pos_fullstep(self):
131
+ def current_pos_fullstep(self) -> int:
131
132
  """_current_pos as fullstep property"""
132
- if self.current_pos is None or self.mres is None:
133
- return None
134
133
  return self.current_pos // self.mres
135
134
 
136
135
  @current_pos_fullstep.setter
137
136
  def current_pos_fullstep(self, current_pos: int):
138
137
  """_current_pos as fullstep setter"""
139
- if self.mres is not None:
140
- self.current_pos = current_pos * self.mres
138
+ self.current_pos = current_pos * self.mres
141
139
 
142
140
  @property
143
- def mres(self):
141
+ def mres(self) -> int:
144
142
  """_mres property"""
145
- if self.tmc_mc is not None:
146
- return self.tmc_mc.mres
147
- return None
143
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
144
+ raise AttributeError("TmcMotionControl is not set")
145
+ return self.tmc_mc.mres
148
146
 
149
147
  @mres.setter
150
148
  def mres(self, mres: int):
151
149
  """_mres setter"""
152
- if self.tmc_mc is not None:
153
- self.tmc_mc.mres = mres
150
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
151
+ raise AttributeError("TmcMotionControl is not set")
152
+ self.tmc_mc.mres = mres
154
153
 
155
154
  @property
156
- def steps_per_rev(self):
155
+ def steps_per_rev(self) -> int:
157
156
  """_steps_per_rev property"""
158
- if self.tmc_mc is not None:
159
- return self.tmc_mc.steps_per_rev
160
- return None
157
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
158
+ raise AttributeError("TmcMotionControl is not set")
159
+ return self.tmc_mc.steps_per_rev
161
160
 
162
161
  @property
163
- def fullsteps_per_rev(self):
162
+ def fullsteps_per_rev(self) -> int:
164
163
  """_fullsteps_per_rev property"""
165
- if self.tmc_mc is not None:
166
- return self.tmc_mc.fullsteps_per_rev
167
- return None
164
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
165
+ raise AttributeError("TmcMotionControl is not set")
166
+ return self.tmc_mc.fullsteps_per_rev
168
167
 
169
168
  @fullsteps_per_rev.setter
170
169
  def fullsteps_per_rev(self, fullsteps_per_rev: int):
171
170
  """_fullsteps_per_rev setter"""
172
- if self.tmc_mc is not None:
173
- self.tmc_mc.fullsteps_per_rev = fullsteps_per_rev
171
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
172
+ raise AttributeError("TmcMotionControl is not set")
173
+ self.tmc_mc.fullsteps_per_rev = fullsteps_per_rev
174
174
 
175
175
  @property
176
- def movement_abs_rel(self):
176
+ def movement_abs_rel(self) -> MovementAbsRel:
177
177
  """_movement_abs_rel property"""
178
- if self.tmc_mc is not None:
179
- return self.tmc_mc.movement_abs_rel
180
- return None
178
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
179
+ raise AttributeError("TmcMotionControl is not set")
180
+ return self.tmc_mc.movement_abs_rel
181
181
 
182
182
  @movement_abs_rel.setter
183
183
  def movement_abs_rel(self, movement_abs_rel: MovementAbsRel):
184
184
  """_movement_abs_rel setter"""
185
- if self.tmc_mc is not None:
186
- self.tmc_mc.movement_abs_rel = movement_abs_rel
185
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
186
+ raise AttributeError("TmcMotionControl is not set")
187
+ self.tmc_mc.movement_abs_rel = movement_abs_rel
187
188
 
188
189
  @property
189
- def movement_phase(self):
190
+ def movement_phase(self) -> MovementPhase:
190
191
  """_movement_phase property"""
191
- if self.tmc_mc is not None:
192
- return self.tmc_mc.movement_phase
193
- return None
192
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
193
+ raise AttributeError("TmcMotionControl is not set")
194
+ return self.tmc_mc.movement_phase
194
195
 
195
196
  @property
196
- def speed(self):
197
+ def speed(self) -> float:
197
198
  """_speed property"""
198
- if self.tmc_mc is not None:
199
- return self.tmc_mc.speed
200
- return None
199
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
200
+ raise AttributeError("TmcMotionControl is not set")
201
+ return self.tmc_mc.speed
201
202
 
202
203
  @speed.setter
203
204
  def speed(self, speed: int):
204
205
  """_speed setter"""
205
- if self.tmc_mc is not None:
206
- self.tmc_mc.speed = speed
206
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
207
+ raise AttributeError("TmcMotionControl is not set")
208
+ self.tmc_mc.speed = speed
207
209
 
208
210
  @property
209
- def max_speed(self):
211
+ def max_speed(self) -> int:
210
212
  """_max_speed property"""
211
- if self.tmc_mc is not None:
212
- return self.tmc_mc.max_speed
213
- return None
213
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
214
+ raise AttributeError("TmcMotionControl is not set")
215
+ return self.tmc_mc.max_speed
214
216
 
215
217
  @max_speed.setter
216
218
  def max_speed(self, speed: int):
@@ -219,50 +221,53 @@ class TmcStepperDriver:
219
221
  self.tmc_mc.max_speed = speed
220
222
 
221
223
  @property
222
- def max_speed_fullstep(self):
224
+ def max_speed_fullstep(self) -> int:
223
225
  """_max_speed_fullstep property"""
224
- if self.tmc_mc is not None:
225
- return self.tmc_mc.max_speed_fullstep
226
- return None
226
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
227
+ raise AttributeError("TmcMotionControl is not set")
228
+ return self.tmc_mc.max_speed_fullstep
227
229
 
228
230
  @max_speed_fullstep.setter
229
231
  def max_speed_fullstep(self, max_speed_fullstep: int):
230
232
  """_max_speed_fullstep setter"""
231
- if self.tmc_mc is not None:
232
- self.tmc_mc.max_speed_fullstep = max_speed_fullstep
233
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
234
+ raise AttributeError("TmcMotionControl is not set")
235
+ self.tmc_mc.max_speed_fullstep = max_speed_fullstep
233
236
 
234
237
  @property
235
- def acceleration(self):
238
+ def acceleration(self) -> int:
236
239
  """_acceleration property"""
237
- if self.tmc_mc is not None:
238
- return self.tmc_mc.acceleration
239
- return None
240
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
241
+ raise AttributeError("TmcMotionControl is not set")
242
+ return self.tmc_mc.acceleration
240
243
 
241
244
  @acceleration.setter
242
245
  def acceleration(self, acceleration: int):
243
246
  """_acceleration setter"""
244
- if self.tmc_mc is not None:
245
- self.tmc_mc.acceleration = acceleration
247
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
248
+ raise AttributeError("TmcMotionControl is not set")
249
+ self.tmc_mc.acceleration = acceleration
246
250
 
247
251
  @property
248
- def acceleration_fullstep(self):
252
+ def acceleration_fullstep(self) -> int:
249
253
  """_acceleration_fullstep property"""
250
- if self.tmc_mc is not None:
251
- return self.tmc_mc.acceleration_fullstep
252
- return None
254
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
255
+ raise AttributeError("TmcMotionControl is not set")
256
+ return self.tmc_mc.acceleration_fullstep
253
257
 
254
258
  @acceleration_fullstep.setter
255
259
  def acceleration_fullstep(self, acceleration_fullstep: int):
256
260
  """_acceleration_fullstep setter"""
257
- if self.tmc_mc is not None:
258
- self.tmc_mc.acceleration_fullstep = acceleration_fullstep
261
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
262
+ raise AttributeError("TmcMotionControl is not set")
263
+ self.tmc_mc.acceleration_fullstep = acceleration_fullstep
259
264
 
260
265
  def run_to_position_steps(
261
266
  self, steps, movement_abs_rel: MovementAbsRel | None = None
262
267
  ) -> StopMode:
263
268
  """motioncontrol wrapper"""
264
- if self.tmc_mc is None:
265
- return StopMode.NO
269
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
270
+ raise AttributeError("TmcMotionControl is not set")
266
271
  return self.tmc_mc.run_to_position_steps(steps, movement_abs_rel)
267
272
 
268
273
  def run_to_position_fullsteps(
@@ -281,8 +286,8 @@ class TmcStepperDriver:
281
286
  # ----------------------------
282
287
  def test_step(self):
283
288
  """test method"""
284
- if self.tmc_mc is None:
285
- return
289
+ if getattr(self, "tmc_mc", None) is None or self.tmc_mc is None:
290
+ raise AttributeError("TmcMotionControl is not set")
286
291
  for _ in range(100):
287
292
  self.tmc_mc.set_direction(Direction.CW)
288
293
  self.tmc_mc.make_a_step()
@@ -106,8 +106,17 @@ class TmcXXXX(TmcStepperDriver):
106
106
  if self.tmc_ec is not None:
107
107
  self.tmc_ec.set_get_register_callback(self._get_register)
108
108
 
109
- self.max_speed_fullstep = 100
110
- self.acceleration_fullstep = 100
109
+ if getattr(self, "tmc_mc", None) is not None:
110
+ self.max_speed_fullstep = 100
111
+ self.acceleration_fullstep = 100
112
+
113
+ def _init(self):
114
+ """initialization after registers are created"""
115
+ if self.tmc_com is not None:
116
+ self.clear_gstat_verify()
117
+ if self.tmc_mc is not None:
118
+ self.read_steps_per_rev()
119
+ self.tmc_com.flush_com_buffer()
111
120
 
112
121
  def __del__(self):
113
122
  self.deinit()
@@ -121,6 +130,19 @@ class TmcXXXX(TmcStepperDriver):
121
130
 
122
131
  # Register Access
123
132
  # ----------------------------
133
+ def clear_gstat_verify(self):
134
+ """clears the GSTAT register and verifies that it was cleared"""
135
+ tries = 5
136
+ while True:
137
+ try:
138
+ self.gstat.clear_verify()
139
+ break
140
+ except TmcDriverException:
141
+ time.sleep(0.1)
142
+ tries -= 1
143
+ if tries <= 0:
144
+ raise TmcDriverException("Could not clear GSTAT register")
145
+
124
146
  def read_steps_per_rev(self) -> int:
125
147
  """returns how many steps are needed for one revolution.
126
148
  this reads the value from the tmc driver.
@@ -33,9 +33,9 @@ class TmcEnableControlPin(TmcEnableControl):
33
33
  def deinit(self):
34
34
  """destructor"""
35
35
  super().deinit()
36
- if self._pin_en is not None:
36
+ if getattr(self, "_pin_en", None) is not None:
37
37
  tmc_gpio.tmc_gpio.gpio_cleanup(self._pin_en)
38
- self._pin_en = None
38
+ del self._pin_en
39
39
 
40
40
  def set_motor_enabled(self, en):
41
41
  """enables or disables the motor current output
@@ -43,6 +43,6 @@ class TmcEnableControlPin(TmcEnableControl):
43
43
  Args:
44
44
  en (bool): whether the motor current output should be enabled
45
45
  """
46
- if self._pin_en is not None:
46
+ if getattr(self, "_pin_en", None) is not None:
47
47
  tmc_gpio.tmc_gpio.gpio_output(self._pin_en, not en)
48
48
  self._tmc_logger.log(f"Motor output active: {en}", Loglevel.INFO)
@@ -112,6 +112,11 @@ class TmcMotionControl:
112
112
  """_speed property"""
113
113
  return self._speed * self.mres
114
114
 
115
+ @speed_fullstep.setter
116
+ def speed_fullstep(self, speed_fullstep: int):
117
+ """_speed_fullstep setter"""
118
+ self._speed = speed_fullstep / self.mres
119
+
115
120
  @property
116
121
  def max_speed(self):
117
122
  """_max_speed property"""
@@ -20,6 +20,7 @@ from ..tmc_logger import TmcLogger, Loglevel
20
20
  from ..tmc_gpio import Gpio, GpioMode
21
21
  from .. import tmc_gpio
22
22
  from .. import _tmc_math as tmc_math
23
+ from .._tmc_exceptions import TmcMotionControlException
23
24
  from ..platform_utils import get_time_us
24
25
 
25
26
 
@@ -38,13 +39,13 @@ class TmcMotionControlStepDir(TmcMotionControl):
38
39
  if self._max_speed != speed:
39
40
  self._max_speed = speed
40
41
  if speed == 0.0:
41
- self._cmin = 0.0
42
+ self._cmin = 0
42
43
  else:
43
- self._cmin = 1000000.0 / speed
44
+ self._cmin = round(1000000.0 / speed)
44
45
  # Recompute _n from current speed and adjust speed if accelerating or cruising
45
46
  if self._n > 0:
46
- self._n = (self._speed * self._speed) / (
47
- 2.0 * self._acceleration
47
+ self._n = round(
48
+ (self._speed * self._speed) / (2.0 * self._acceleration)
48
49
  ) # Equation 16
49
50
  self.compute_new_speed()
50
51
 
@@ -61,9 +62,11 @@ class TmcMotionControlStepDir(TmcMotionControl):
61
62
  return
62
63
 
63
64
  # Recompute _n per Equation 17
64
- self._n = self._n * (self._acceleration / acceleration)
65
+ self._n = round(self._n * (self._acceleration / acceleration))
65
66
  # New c0 per Equation 7, with correction per Equation 15
66
- self._c0 = 0.676 * math.sqrt(2.0 / acceleration) * 1000000.0 # Equation 15
67
+ self._c0 = round(
68
+ 0.676 * math.sqrt(2.0 / acceleration) * 1000000.0
69
+ ) # Equation 15
67
70
  self._acceleration = acceleration
68
71
  self.compute_new_speed()
69
72
 
@@ -81,13 +84,8 @@ class TmcMotionControlStepDir(TmcMotionControl):
81
84
  if speed == 0.0:
82
85
  self._step_interval = 0
83
86
  else:
84
- self._step_interval = abs(1000000.0 / speed)
85
- if speed > 0:
86
- tmc_gpio.tmc_gpio.gpio_output(self._pin_dir, Gpio.HIGH)
87
- self._tmc_logger.log("going CW", Loglevel.MOVEMENT)
88
- else:
89
- tmc_gpio.tmc_gpio.gpio_output(self._pin_dir, Gpio.LOW)
90
- self._tmc_logger.log("going CCW", Loglevel.MOVEMENT)
87
+ self._step_interval = round(abs(1000000.0 / speed))
88
+ self.set_direction(Direction.CW if speed > 0 else Direction.CCW)
91
89
 
92
90
  self._speed = speed
93
91
 
@@ -142,12 +140,12 @@ class TmcMotionControlStepDir(TmcMotionControl):
142
140
 
143
141
  def deinit(self):
144
142
  """destructor"""
145
- if self._pin_step is not None:
143
+ if getattr(self, "_pin_step", None) is not None:
146
144
  tmc_gpio.tmc_gpio.gpio_cleanup(self._pin_step)
147
- self._pin_step = None
148
- if self._pin_dir is not None:
145
+ del self._pin_step
146
+ if getattr(self, "_pin_dir", None) is not None and self._pin_dir is not None:
149
147
  tmc_gpio.tmc_gpio.gpio_cleanup(self._pin_dir)
150
- self._pin_dir = None
148
+ del self._pin_dir
151
149
 
152
150
  def make_a_step(self):
153
151
  """method that makes on step
@@ -171,6 +169,8 @@ class TmcMotionControlStepDir(TmcMotionControl):
171
169
  Args:
172
170
  direction (bool): motor shaft direction: False = CCW; True = CW
173
171
  """
172
+ if self._pin_dir is None:
173
+ return
174
174
  super().set_direction(direction)
175
175
  tmc_gpio.tmc_gpio.gpio_output(self._pin_dir, int(direction))
176
176
 
@@ -284,6 +284,8 @@ class TmcMotionControlStepDir(TmcMotionControl):
284
284
  Returns:
285
285
  enum: how the movement was finished
286
286
  """
287
+ if self._movement_thread is None:
288
+ raise TmcMotionControlException("No movement thread running.")
287
289
  self._movement_thread.join()
288
290
  return self._stop
289
291
 
@@ -312,8 +314,8 @@ class TmcMotionControlStepDir(TmcMotionControl):
312
314
  https://web.archive.org/web/20140705143928/http://fab.cba.mit.edu/classes/MIT/961.09/projects/i0/Stepper_Motor_Speed_Profile.pdf
313
315
  """
314
316
  distance_to = self.distance_to_go() # +ve is clockwise from current location
315
- steps_to_stop = (self._speed * self._speed) / (
316
- 2.0 * self._acceleration
317
+ steps_to_stop = round(
318
+ (self._speed * self._speed) / (2.0 * self._acceleration)
317
319
  ) # Equation 16
318
320
  if (distance_to == 0 and steps_to_stop <= 2) or (
319
321
  self._stop == StopMode.SOFTSTOP and steps_to_stop <= 1
@@ -373,8 +375,8 @@ class TmcMotionControlStepDir(TmcMotionControl):
373
375
  self._movement_phase = MovementPhase.ACCELERATING
374
376
  else:
375
377
  # Subsequent step. Works for accel (n is +_ve) and decel (n is -ve).
376
- self._cn = self._cn - (
377
- (2.0 * self._cn) / ((4.0 * self._n) + 1)
378
+ self._cn = round(
379
+ self._cn - ((2.0 * self._cn) / ((4.0 * self._n) + 1))
378
380
  ) # Equation 13
379
381
  self._cn = max(self._cn, self._cmin)
380
382
  if self._cn == self._cmin:
@@ -44,7 +44,7 @@ class TmcMotionControlStepPwmDir(TmcMotionControlStepDir):
44
44
  tmc_gpio.tmc_gpio.gpio_pwm_set_duty_cycle(self._pin_step, 0)
45
45
 
46
46
  def run_to_position_steps(
47
- self, steps, movement_abs_rel: MovementAbsRel = None
47
+ self, steps, movement_abs_rel: MovementAbsRel | None = None
48
48
  ) -> StopMode:
49
49
  """runs the motor to a specific position
50
50
 
@@ -58,6 +58,7 @@ class TmcMotionControlStepPwmDir(TmcMotionControlStepDir):
58
58
  """
59
59
  if tmc_gpio.tmc_gpio.__class__.__name__ == "GpiozeroWrapper":
60
60
  tmc_gpio.tmc_gpio.gpio_pwm_enable(self._pin_step, False)
61
+ # TODO: check for a better solution for gpiozero
61
62
 
62
63
  return super().run_to_position_steps(steps, movement_abs_rel)
63
64
 
@@ -75,6 +76,7 @@ class TmcMotionControlStepPwmDir(TmcMotionControlStepDir):
75
76
 
76
77
  if tmc_gpio.tmc_gpio.__class__.__name__ == "GpiozeroWrapper":
77
78
  tmc_gpio.tmc_gpio.gpio_pwm_enable(self._pin_step, True)
79
+ # TODO: check for a better solution for gpiozero
78
80
 
79
81
  if speed == 0:
80
82
  # stop movement
@@ -157,3 +157,14 @@ class TmcReg:
157
157
  if reg.clear_value is not None:
158
158
  setattr(self, reg.name, reg.reg_class(reg.clear_value))
159
159
  self.write_check()
160
+
161
+ def clear_verify(self) -> bool:
162
+ """clear this register and verify that it was cleared"""
163
+ self.clear()
164
+ self.read()
165
+ for reg in self._REG_MAP:
166
+ if reg.clear_value is not None:
167
+ value = getattr(self, reg.name)
168
+ if int(value) != reg.reg_class(0):
169
+ return False
170
+ return True
@@ -106,10 +106,7 @@ class Tmc220x(TmcXXXX):
106
106
  self.pwmconf: PwmConf = PwmConf(self.tmc_com)
107
107
  self.drvstatus: DrvStatus = DrvStatus(self.tmc_com)
108
108
 
109
- self.gstat.clear()
110
- if self.tmc_mc is not None:
111
- self.read_steps_per_rev()
112
- self.tmc_com.flush_com_buffer()
109
+ super()._init()
113
110
 
114
111
  # Register Access
115
112
  # ----------------------------
@@ -115,10 +115,7 @@ class Tmc2240(TmcXXXX, StallGuard):
115
115
  self.sgresult: SgResult = SgResult(self.tmc_com)
116
116
  self.sgind: SgInd = SgInd(self.tmc_com)
117
117
 
118
- self.gstat.clear()
119
- if self.tmc_mc is not None:
120
- self.read_steps_per_rev()
121
- self.tmc_com.flush_com_buffer()
118
+ super()._init()
122
119
 
123
120
  def deinit(self):
124
121
  """destructor"""
@@ -129,10 +129,7 @@ class Tmc5160(TmcXXXX, StallGuard):
129
129
  self.tcoolthrs: TCoolThrs = TCoolThrs(self.tmc_com)
130
130
  self.loststeps: LostSteps = LostSteps(self.tmc_com)
131
131
 
132
- self.gstat.clear()
133
- if self.tmc_mc is not None:
134
- self.read_steps_per_rev()
135
- self.tmc_com.flush_com_buffer()
132
+ super()._init()
136
133
 
137
134
  def deinit(self):
138
135
  """destructor"""
@@ -56,8 +56,8 @@ class TmcLoggerBase:
56
56
  loglevel (enum): level for which to log
57
57
  logprefix (string): new logprefix (name of the logger) (default: "TMCXXXX")
58
58
  """
59
- self._logprefix = logprefix
60
- self._loglevel = loglevel
59
+ self.logprefix = logprefix
60
+ self.loglevel = loglevel
61
61
 
62
62
  def __del__(self):
63
63
  """destructor"""
@@ -50,7 +50,6 @@ class TmcLogger(TmcLoggerBase):
50
50
  handlers (list): list of logging handlers, see logging.handlers (default: None)
51
51
  formatter (logging.Formatter): formatter for the log messages (default: None)
52
52
  """
53
- super().__init__(loglevel, logprefix)
54
53
 
55
54
  # Add our custom log levels to the logger
56
55
  for level in [Loglevel.ALL, Loglevel.MOVEMENT, Loglevel.NONE]:
@@ -74,6 +73,8 @@ class TmcLogger(TmcLoggerBase):
74
73
 
75
74
  self.logger.propagate = True
76
75
 
76
+ super().__init__(loglevel, logprefix)
77
+
77
78
  def __del__(self):
78
79
  """destructor"""
79
80
  self.deinit()
File without changes
File without changes