PyTmcStepper 0.7.3__tar.gz → 0.7.5__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.7.3/src/PyTmcStepper.egg-info → pytmcstepper-0.7.5}/PKG-INFO +9 -5
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/README.md +6 -3
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/setup.cfg +1 -1
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5/src/PyTmcStepper.egg-info}/PKG-INFO +9 -5
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/PyTmcStepper.egg-info/SOURCES.txt +2 -0
- pytmcstepper-0.7.5/src/tmc_driver/_tmc_exceptions.py +16 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/_tmc_gpio_board.py +78 -6
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/_tmc_stepperdriver.py +1 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/com/_tmc_com_spi.py +5 -5
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/com/_tmc_com_uart.py +4 -2
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py +1 -0
- pytmcstepper-0.7.5/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py +96 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/motion_control/_tmc_mc_vactual.py +31 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/reg/_tmc2209_reg.py +1 -1
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/reg/_tmc220x_reg.py +24 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/reg/_tmc224x_reg.py +15 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/tmc_2209.py +1 -1
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/tmc_220x.py +14 -6
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/tmc_2240.py +4 -5
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/LICENSE +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/pyproject.toml +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/PyTmcStepper.egg-info/dependency_links.txt +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/PyTmcStepper.egg-info/requires.txt +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/PyTmcStepper.egg-info/top_level.txt +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/__init__.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/_tmc_logger.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/_tmc_math.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/_tmc_stallguard.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/com/__init__.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/com/_tmc_com.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/enable_control/__init__.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/enable_control/_tmc_ec.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/enable_control/_tmc_ec_pin.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/enable_control/_tmc_ec_toff.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/motion_control/__init__.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/motion_control/_tmc_mc.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/reg/__init__.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/reg/_tmc_reg.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/src/tmc_driver/tmc_2208.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/tests/test_tmc2209.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/tests/test_tmc2240.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/tests/test_tmc_com_spi.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/tests/test_tmc_com_uart.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/tests/test_tmc_ec_pin.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/tests/test_tmc_math.py +0 -0
- {pytmcstepper-0.7.3 → pytmcstepper-0.7.5}/tests/test_tmc_move.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: PyTmcStepper
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.5
|
|
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
|
|
@@ -27,6 +27,7 @@ Provides-Extra: luckfox-pico
|
|
|
27
27
|
Requires-Dist: python-periphery; extra == "luckfox-pico"
|
|
28
28
|
Provides-Extra: orange-pi
|
|
29
29
|
Requires-Dist: OPi.GPIO; extra == "orange-pi"
|
|
30
|
+
Dynamic: license-file
|
|
30
31
|
|
|
31
32
|
# PyTmcStepper
|
|
32
33
|
|
|
@@ -54,7 +55,7 @@ Because the TMC2209 uses one shared pin for transmit and receive in the UART com
|
|
|
54
55
|
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
56
|
|
|
56
57
|
The Documentation of the TMC2209 can be found here:
|
|
57
|
-
[TMC2209 -
|
|
58
|
+
[TMC2209 - Datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/TMC2209_datasheet_rev1.09.pdf)
|
|
58
59
|
|
|
59
60
|
The code is also available on [PyPI](https://pypi.org/project/PyTmcStepper).
|
|
60
61
|
|
|
@@ -138,6 +139,7 @@ MotionControl | Class | Driver | Notes
|
|
|
138
139
|
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
|
|
139
140
|
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.
|
|
140
141
|
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.
|
|
142
|
+
STEP_PWM/DIR | [TmcMotionControlStepPwmDir](src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py) | all | In contrast to STEP/DIR, the step pin is controlled by PWM. This reduces the load on the CPU, but does not allow precise positioning (similar to the VACTUAL).<br />STEP must be connected to a PWM-capable pin for this purpose
|
|
141
143
|
|
|
142
144
|
Further methods of controlling the motion of a motor could be:
|
|
143
145
|
|
|
@@ -249,6 +251,8 @@ So you don't need to connect anything to the Vio pin of the driver.
|
|
|
249
251
|
|
|
250
252
|
## Usage
|
|
251
253
|
|
|
254
|
+
The library currently uses functions to access the TMC registers, but Python properties for internal getters/setters.
|
|
255
|
+
|
|
252
256
|
```python
|
|
253
257
|
from tmc_driver.tmc_2209 import *
|
|
254
258
|
tmc = Tmc2209(TmcEnableControlPin(21), TmcMotionControlStepDir(16, 20), TmcComUart("/dev/serial0"))
|
|
@@ -260,8 +264,8 @@ tmc.set_spreadcycle(False)
|
|
|
260
264
|
tmc.set_microstepping_resolution(2)
|
|
261
265
|
tmc.set_internal_rsense(False)
|
|
262
266
|
|
|
263
|
-
tmc.
|
|
264
|
-
tmc.
|
|
267
|
+
tmc.acceleration_fullstep = 1000
|
|
268
|
+
tmc.max_speed_fullstep = 250
|
|
265
269
|
|
|
266
270
|
tmc.set_motor_enabled(True)
|
|
267
271
|
|
|
@@ -24,7 +24,7 @@ Because the TMC2209 uses one shared pin for transmit and receive in the UART com
|
|
|
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
26
|
The Documentation of the TMC2209 can be found here:
|
|
27
|
-
[TMC2209 -
|
|
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).
|
|
30
30
|
|
|
@@ -108,6 +108,7 @@ MotionControl | Class | Driver | Notes
|
|
|
108
108
|
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
|
|
109
109
|
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.
|
|
110
110
|
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.
|
|
111
|
+
STEP_PWM/DIR | [TmcMotionControlStepPwmDir](src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py) | all | In contrast to STEP/DIR, the step pin is controlled by PWM. This reduces the load on the CPU, but does not allow precise positioning (similar to the VACTUAL).<br />STEP must be connected to a PWM-capable pin for this purpose
|
|
111
112
|
|
|
112
113
|
Further methods of controlling the motion of a motor could be:
|
|
113
114
|
|
|
@@ -219,6 +220,8 @@ So you don't need to connect anything to the Vio pin of the driver.
|
|
|
219
220
|
|
|
220
221
|
## Usage
|
|
221
222
|
|
|
223
|
+
The library currently uses functions to access the TMC registers, but Python properties for internal getters/setters.
|
|
224
|
+
|
|
222
225
|
```python
|
|
223
226
|
from tmc_driver.tmc_2209 import *
|
|
224
227
|
tmc = Tmc2209(TmcEnableControlPin(21), TmcMotionControlStepDir(16, 20), TmcComUart("/dev/serial0"))
|
|
@@ -230,8 +233,8 @@ tmc.set_spreadcycle(False)
|
|
|
230
233
|
tmc.set_microstepping_resolution(2)
|
|
231
234
|
tmc.set_internal_rsense(False)
|
|
232
235
|
|
|
233
|
-
tmc.
|
|
234
|
-
tmc.
|
|
236
|
+
tmc.acceleration_fullstep = 1000
|
|
237
|
+
tmc.max_speed_fullstep = 250
|
|
235
238
|
|
|
236
239
|
tmc.set_motor_enabled(True)
|
|
237
240
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = PyTmcStepper
|
|
3
|
-
version = 0.7.
|
|
3
|
+
version = 0.7.5
|
|
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
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: PyTmcStepper
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.5
|
|
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
|
|
@@ -27,6 +27,7 @@ Provides-Extra: luckfox-pico
|
|
|
27
27
|
Requires-Dist: python-periphery; extra == "luckfox-pico"
|
|
28
28
|
Provides-Extra: orange-pi
|
|
29
29
|
Requires-Dist: OPi.GPIO; extra == "orange-pi"
|
|
30
|
+
Dynamic: license-file
|
|
30
31
|
|
|
31
32
|
# PyTmcStepper
|
|
32
33
|
|
|
@@ -54,7 +55,7 @@ Because the TMC2209 uses one shared pin for transmit and receive in the UART com
|
|
|
54
55
|
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
56
|
|
|
56
57
|
The Documentation of the TMC2209 can be found here:
|
|
57
|
-
[TMC2209 -
|
|
58
|
+
[TMC2209 - Datasheet](https://www.analog.com/media/en/technical-documentation/data-sheets/TMC2209_datasheet_rev1.09.pdf)
|
|
58
59
|
|
|
59
60
|
The code is also available on [PyPI](https://pypi.org/project/PyTmcStepper).
|
|
60
61
|
|
|
@@ -138,6 +139,7 @@ MotionControl | Class | Driver | Notes
|
|
|
138
139
|
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
|
|
139
140
|
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.
|
|
140
141
|
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.
|
|
142
|
+
STEP_PWM/DIR | [TmcMotionControlStepPwmDir](src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py) | all | In contrast to STEP/DIR, the step pin is controlled by PWM. This reduces the load on the CPU, but does not allow precise positioning (similar to the VACTUAL).<br />STEP must be connected to a PWM-capable pin for this purpose
|
|
141
143
|
|
|
142
144
|
Further methods of controlling the motion of a motor could be:
|
|
143
145
|
|
|
@@ -249,6 +251,8 @@ So you don't need to connect anything to the Vio pin of the driver.
|
|
|
249
251
|
|
|
250
252
|
## Usage
|
|
251
253
|
|
|
254
|
+
The library currently uses functions to access the TMC registers, but Python properties for internal getters/setters.
|
|
255
|
+
|
|
252
256
|
```python
|
|
253
257
|
from tmc_driver.tmc_2209 import *
|
|
254
258
|
tmc = Tmc2209(TmcEnableControlPin(21), TmcMotionControlStepDir(16, 20), TmcComUart("/dev/serial0"))
|
|
@@ -260,8 +264,8 @@ tmc.set_spreadcycle(False)
|
|
|
260
264
|
tmc.set_microstepping_resolution(2)
|
|
261
265
|
tmc.set_internal_rsense(False)
|
|
262
266
|
|
|
263
|
-
tmc.
|
|
264
|
-
tmc.
|
|
267
|
+
tmc.acceleration_fullstep = 1000
|
|
268
|
+
tmc.max_speed_fullstep = 250
|
|
265
269
|
|
|
266
270
|
tmc.set_motor_enabled(True)
|
|
267
271
|
|
|
@@ -8,6 +8,7 @@ src/PyTmcStepper.egg-info/dependency_links.txt
|
|
|
8
8
|
src/PyTmcStepper.egg-info/requires.txt
|
|
9
9
|
src/PyTmcStepper.egg-info/top_level.txt
|
|
10
10
|
src/tmc_driver/__init__.py
|
|
11
|
+
src/tmc_driver/_tmc_exceptions.py
|
|
11
12
|
src/tmc_driver/_tmc_gpio_board.py
|
|
12
13
|
src/tmc_driver/_tmc_logger.py
|
|
13
14
|
src/tmc_driver/_tmc_math.py
|
|
@@ -28,6 +29,7 @@ src/tmc_driver/enable_control/_tmc_ec_toff.py
|
|
|
28
29
|
src/tmc_driver/motion_control/__init__.py
|
|
29
30
|
src/tmc_driver/motion_control/_tmc_mc.py
|
|
30
31
|
src/tmc_driver/motion_control/_tmc_mc_step_dir.py
|
|
32
|
+
src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py
|
|
31
33
|
src/tmc_driver/motion_control/_tmc_mc_step_reg.py
|
|
32
34
|
src/tmc_driver/motion_control/_tmc_mc_vactual.py
|
|
33
35
|
src/tmc_driver/reg/__init__.py
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""Exceptions module"""
|
|
2
|
+
|
|
3
|
+
class TmcException(Exception):
|
|
4
|
+
"""Base class for all TMC exceptions"""
|
|
5
|
+
|
|
6
|
+
class TmcDriverException(TmcException):
|
|
7
|
+
"""Base class for all TMC driver exceptions"""
|
|
8
|
+
|
|
9
|
+
class TmcComException(TmcException):
|
|
10
|
+
"""Base class for all TMC communication exceptions"""
|
|
11
|
+
|
|
12
|
+
class TmcMotionControlException(TmcException):
|
|
13
|
+
"""Base class for all TMC motion control exceptions"""
|
|
14
|
+
|
|
15
|
+
class TmcEnableControlException(TmcException):
|
|
16
|
+
"""Base class for all TMC enable control exceptions"""
|
|
@@ -81,7 +81,7 @@ class BaseGPIOWrapper:
|
|
|
81
81
|
"""cleanup GPIO pin"""
|
|
82
82
|
raise NotImplementedError
|
|
83
83
|
|
|
84
|
-
def gpio_input(self, pin:int):
|
|
84
|
+
def gpio_input(self, pin:int) -> int:
|
|
85
85
|
"""read GPIO pin"""
|
|
86
86
|
raise NotImplementedError
|
|
87
87
|
|
|
@@ -89,6 +89,23 @@ class BaseGPIOWrapper:
|
|
|
89
89
|
"""write GPIO pin"""
|
|
90
90
|
raise NotImplementedError
|
|
91
91
|
|
|
92
|
+
def gpio_pwm_setup(self, pin:int, frequency:int = 10, duty_cycle:int = 0):
|
|
93
|
+
"""setup PWM"""
|
|
94
|
+
raise NotImplementedError
|
|
95
|
+
|
|
96
|
+
def gpio_pwm_set_frequency(self, pin:int, frequency:int):
|
|
97
|
+
"""set PWM frequency"""
|
|
98
|
+
raise NotImplementedError
|
|
99
|
+
|
|
100
|
+
def gpio_pwm_set_duty_cycle(self, pin:int, duty_cycle:int):
|
|
101
|
+
"""set PWM duty cycle
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
pin (int): pin number
|
|
105
|
+
duty_cycle (int): duty cycle in percent (0-100)
|
|
106
|
+
"""
|
|
107
|
+
raise NotImplementedError
|
|
108
|
+
|
|
92
109
|
def gpio_add_event_detect(self, pin:int, callback:types.FunctionType):
|
|
93
110
|
"""add event detect"""
|
|
94
111
|
raise NotImplementedError
|
|
@@ -100,6 +117,8 @@ class BaseGPIOWrapper:
|
|
|
100
117
|
class BaseRPiGPIOWrapper(BaseGPIOWrapper):
|
|
101
118
|
"""RPI.GPIO base wrapper"""
|
|
102
119
|
|
|
120
|
+
_gpios_pwm = [None] * 200
|
|
121
|
+
|
|
103
122
|
def init(self, gpio_mode=None):
|
|
104
123
|
"""initialize GPIO library"""
|
|
105
124
|
self.GPIO.setwarnings(False)
|
|
@@ -125,7 +144,7 @@ class BaseRPiGPIOWrapper(BaseGPIOWrapper):
|
|
|
125
144
|
"""cleanup GPIO pin"""
|
|
126
145
|
self.GPIO.cleanup(pin)
|
|
127
146
|
|
|
128
|
-
def gpio_input(self, pin:int):
|
|
147
|
+
def gpio_input(self, pin:int) -> int:
|
|
129
148
|
"""read GPIO pin"""
|
|
130
149
|
return self.GPIO.input(pin)
|
|
131
150
|
|
|
@@ -133,6 +152,25 @@ class BaseRPiGPIOWrapper(BaseGPIOWrapper):
|
|
|
133
152
|
"""write GPIO pin"""
|
|
134
153
|
self.GPIO.output(pin, value)
|
|
135
154
|
|
|
155
|
+
def gpio_pwm_setup(self, pin:int, frequency:int = 10, duty_cycle:int = 0):
|
|
156
|
+
"""setup PWM"""
|
|
157
|
+
self.GPIO.setup(pin, int(GpioMode.OUT), initial=int(Gpio.LOW))
|
|
158
|
+
self._gpios_pwm[pin] = self.GPIO.PWM(pin, frequency)
|
|
159
|
+
self._gpios_pwm[pin].start(duty_cycle)
|
|
160
|
+
|
|
161
|
+
def gpio_pwm_set_frequency(self, pin:int, frequency:int):
|
|
162
|
+
"""set PWM frequency"""
|
|
163
|
+
self._gpios_pwm[pin].ChangeFrequency(frequency)
|
|
164
|
+
|
|
165
|
+
def gpio_pwm_set_duty_cycle(self, pin:int, duty_cycle:int):
|
|
166
|
+
"""set PWM duty cycle
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
pin (int): pin number
|
|
170
|
+
duty_cycle (int): duty cycle in percent (0-100)
|
|
171
|
+
"""
|
|
172
|
+
self._gpios_pwm[pin].ChangeDutyCycle(duty_cycle)
|
|
173
|
+
|
|
136
174
|
def gpio_add_event_detect(self, pin:int, callback:types.FunctionType):
|
|
137
175
|
"""add event detect"""
|
|
138
176
|
self.GPIO.add_event_detect(pin, self.GPIO.RISING, callback=callback, bouncetime=300)
|
|
@@ -141,6 +179,7 @@ class BaseRPiGPIOWrapper(BaseGPIOWrapper):
|
|
|
141
179
|
"""remove event detect"""
|
|
142
180
|
self.GPIO.remove_event_detect(pin)
|
|
143
181
|
|
|
182
|
+
|
|
144
183
|
class MockGPIOWrapper(BaseRPiGPIOWrapper):
|
|
145
184
|
"""Mock.GPIO wrapper"""
|
|
146
185
|
|
|
@@ -176,11 +215,13 @@ class OPiGPIOWrapper(BaseRPiGPIOWrapper):
|
|
|
176
215
|
class GpiozeroWrapper(BaseGPIOWrapper):
|
|
177
216
|
"""gpiozero GPIO wrapper"""
|
|
178
217
|
|
|
218
|
+
_gpios = [None] * 200
|
|
219
|
+
_gpios_pwm = [None] * 200
|
|
220
|
+
|
|
179
221
|
def __init__(self):
|
|
180
222
|
"""constructor, imports gpiozero"""
|
|
181
223
|
self.gpiozero = import_module('gpiozero')
|
|
182
224
|
dependencies_logger.log("using gpiozero for GPIO control", Loglevel.INFO)
|
|
183
|
-
self._gpios = [None] * 200
|
|
184
225
|
|
|
185
226
|
def init(self, gpio_mode=None):
|
|
186
227
|
"""initialize GPIO library. pass on gpiozero"""
|
|
@@ -199,9 +240,12 @@ class GpiozeroWrapper(BaseGPIOWrapper):
|
|
|
199
240
|
|
|
200
241
|
def gpio_cleanup(self, pin:int):
|
|
201
242
|
"""cleanup GPIO pin"""
|
|
202
|
-
self._gpios[pin]
|
|
243
|
+
if self._gpios[pin] is not None:
|
|
244
|
+
self._gpios[pin].close()
|
|
245
|
+
if self._gpios_pwm[pin] is not None:
|
|
246
|
+
self._gpios_pwm[pin].close()
|
|
203
247
|
|
|
204
|
-
def gpio_input(self, pin:int):
|
|
248
|
+
def gpio_input(self, pin:int) -> int:
|
|
205
249
|
"""read GPIO pin"""
|
|
206
250
|
return self._gpios[pin].value
|
|
207
251
|
|
|
@@ -209,6 +253,34 @@ class GpiozeroWrapper(BaseGPIOWrapper):
|
|
|
209
253
|
"""write GPIO pin"""
|
|
210
254
|
self._gpios[pin].value = value
|
|
211
255
|
|
|
256
|
+
def gpio_pwm_enable(self, pin:int, enable:bool):
|
|
257
|
+
"""switch to PWM"""
|
|
258
|
+
if enable:
|
|
259
|
+
if self._gpios[pin] is not None:
|
|
260
|
+
self._gpios[pin] = None
|
|
261
|
+
self._gpios_pwm[pin] = self.gpiozero.PWMOutputDevice(pin)
|
|
262
|
+
else:
|
|
263
|
+
if self._gpios_pwm[pin] is not None:
|
|
264
|
+
self._gpios_pwm[pin] = None
|
|
265
|
+
self._gpios[pin] = self.gpiozero.DigitalOutputDevice(pin)
|
|
266
|
+
|
|
267
|
+
def gpio_pwm_setup(self, pin:int, frequency:int = 10, duty_cycle:int = 0):
|
|
268
|
+
"""setup PWM"""
|
|
269
|
+
# self._gpios_pwm[pin] = self.gpiozero.PWMOutputDevice(pin)
|
|
270
|
+
|
|
271
|
+
def gpio_pwm_set_frequency(self, pin:int, frequency:int):
|
|
272
|
+
"""set PWM frequency"""
|
|
273
|
+
self._gpios_pwm[pin].frequency = frequency
|
|
274
|
+
|
|
275
|
+
def gpio_pwm_set_duty_cycle(self, pin:int, duty_cycle:int):
|
|
276
|
+
"""set PWM duty cycle
|
|
277
|
+
|
|
278
|
+
Args:
|
|
279
|
+
pin (int): pin number
|
|
280
|
+
duty_cycle (int): duty cycle in percent (0-100)
|
|
281
|
+
"""
|
|
282
|
+
self._gpios_pwm[pin].value = duty_cycle/100
|
|
283
|
+
|
|
212
284
|
def gpio_add_event_detect(self, pin:int, callback:types.FunctionType):
|
|
213
285
|
"""add event detect"""
|
|
214
286
|
self._gpios[pin].when_activated = callback
|
|
@@ -244,7 +316,7 @@ class peripheryWrapper(BaseGPIOWrapper):
|
|
|
244
316
|
"""cleanup GPIO pin"""
|
|
245
317
|
self._gpios[pin].close()
|
|
246
318
|
|
|
247
|
-
def gpio_input(self, pin:int):
|
|
319
|
+
def gpio_input(self, pin:int) -> int:
|
|
248
320
|
"""read GPIO pin"""
|
|
249
321
|
return self._gpios[pin].read()
|
|
250
322
|
|
|
@@ -16,6 +16,7 @@ from .motion_control._tmc_mc import TmcMotionControl, MovementAbsRel, MovementPh
|
|
|
16
16
|
from .enable_control._tmc_ec import TmcEnableControl
|
|
17
17
|
from .enable_control._tmc_ec_pin import TmcEnableControlPin
|
|
18
18
|
from .motion_control._tmc_mc_step_dir import TmcMotionControlStepDir
|
|
19
|
+
from .motion_control._tmc_mc_step_pwm_dir import TmcMotionControlStepPwmDir
|
|
19
20
|
from ._tmc_logger import TmcLogger, Loglevel
|
|
20
21
|
from . import _tmc_math as tmc_math
|
|
21
22
|
|
|
@@ -12,6 +12,7 @@ TmcComSpi stepper driver spi module
|
|
|
12
12
|
|
|
13
13
|
import spidev
|
|
14
14
|
from ._tmc_com import *
|
|
15
|
+
from .._tmc_exceptions import TmcComException, TmcDriverException
|
|
15
16
|
|
|
16
17
|
# class MockSpiDev:
|
|
17
18
|
# """MockSpiDev"""
|
|
@@ -111,9 +112,9 @@ class TmcComSpi(TmcCom):
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
if flags["reset_flag"]:
|
|
114
|
-
|
|
115
|
+
raise TmcDriverException("TMC224X: reset detected")
|
|
115
116
|
if flags["driver_error"]:
|
|
116
|
-
|
|
117
|
+
raise TmcDriverException("TMC224X: driver error detected")
|
|
117
118
|
if flags["sg2"]:
|
|
118
119
|
self._tmc_logger.log("TMC stallguard2 flag is set", Loglevel.MOVEMENT)
|
|
119
120
|
if flags["standstill"]:
|
|
@@ -182,9 +183,8 @@ class TmcComSpi(TmcCom):
|
|
|
182
183
|
self.error_handler_running = True
|
|
183
184
|
self._tmc_registers["gstat"].read()
|
|
184
185
|
self._tmc_registers["gstat"].log(self.tmc_logger)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
raise SystemExit
|
|
186
|
+
self._tmc_registers["gstat"].check()
|
|
187
|
+
raise TmcDriverException("TMC220X: unknown error detected")
|
|
188
188
|
|
|
189
189
|
|
|
190
190
|
def test_com(self, addr):
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
#pylint: disable=broad-exception-caught
|
|
3
3
|
#pylint: disable=wildcard-import
|
|
4
4
|
#pylint: disable=unused-wildcard-import
|
|
5
|
+
#pylint: disable=unused-import
|
|
5
6
|
"""
|
|
6
7
|
TmcComUart stepper driver uart module
|
|
7
8
|
"""
|
|
8
9
|
|
|
9
10
|
import serial
|
|
10
11
|
from ._tmc_com import *
|
|
12
|
+
from .._tmc_exceptions import TmcComException, TmcDriverException
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
|
|
@@ -255,9 +257,9 @@ class TmcComUart(TmcCom):
|
|
|
255
257
|
self.error_handler_running = True
|
|
256
258
|
self._tmc_registers["gstat"].read()
|
|
257
259
|
self._tmc_registers["gstat"].log(self.tmc_logger)
|
|
260
|
+
self._tmc_registers["gstat"].check()
|
|
261
|
+
raise TmcDriverException("TMC220X: unknown error detected")
|
|
258
262
|
|
|
259
|
-
self._tmc_logger.log("EXITING!", Loglevel.INFO)
|
|
260
|
-
raise SystemExit
|
|
261
263
|
|
|
262
264
|
|
|
263
265
|
def test_com(self, addr):
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#pylint: disable=too-many-instance-attributes
|
|
2
|
+
#pylint: disable=too-many-arguments
|
|
3
|
+
#pylint: disable=too-many-branches
|
|
4
|
+
#pylint: disable=too-many-positional-arguments
|
|
5
|
+
"""
|
|
6
|
+
STEP_PWM/DIR Motion Control module
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from ._tmc_mc import MovementAbsRel, Direction, StopMode
|
|
10
|
+
from ._tmc_mc_step_dir import TmcMotionControlStepDir
|
|
11
|
+
from .._tmc_logger import TmcLogger, Loglevel
|
|
12
|
+
from .._tmc_gpio_board import tmc_gpio, GpiozeroWrapper
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TmcMotionControlStepPwmDir(TmcMotionControlStepDir):
|
|
16
|
+
"""STEP_PWM/DIR Motion Control class"""
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def speed(self):
|
|
20
|
+
"""_speed property"""
|
|
21
|
+
return self._speed
|
|
22
|
+
|
|
23
|
+
@speed.setter
|
|
24
|
+
def speed(self, speed:int):
|
|
25
|
+
"""_speed setter"""
|
|
26
|
+
self._speed = speed
|
|
27
|
+
tmc_gpio.gpio_pwm_set_frequency(self._pin_step, self._speed)
|
|
28
|
+
self._tmc_logger.log(f"Speed: {self._speed} µsteps/s", Loglevel.DEBUG)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def init(self, tmc_logger:TmcLogger):
|
|
32
|
+
"""init: called by the Tmc class"""
|
|
33
|
+
super().init(tmc_logger)
|
|
34
|
+
tmc_gpio.gpio_pwm_setup(self._pin_step, 1, 0)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def stop(self, stop_mode = StopMode.HARDSTOP):
|
|
38
|
+
"""stop the current movement
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
stop_mode (enum): whether the movement should be stopped immediately or softly
|
|
42
|
+
(Default value = StopMode.HARDSTOP)
|
|
43
|
+
"""
|
|
44
|
+
super().stop(stop_mode)
|
|
45
|
+
tmc_gpio.gpio_pwm_set_duty_cycle(self._pin_step, 0)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def run_to_position_steps(self, steps, movement_abs_rel:MovementAbsRel = None) -> StopMode:
|
|
49
|
+
"""runs the motor to a specific position
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
steps (int): position in µsteps
|
|
53
|
+
movement_abs_rel (enum, optional): whether the movement is absolute or relative
|
|
54
|
+
(Default value = None)
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
StopMode: the stop mode
|
|
58
|
+
"""
|
|
59
|
+
if isinstance(tmc_gpio, GpiozeroWrapper):
|
|
60
|
+
tmc_gpio.gpio_pwm_enable(self._pin_step, False)
|
|
61
|
+
|
|
62
|
+
return super().run_to_position_steps(steps, movement_abs_rel)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def run_speed_pwm(self, speed:int = None):
|
|
66
|
+
"""runs the motor
|
|
67
|
+
does not block the code
|
|
68
|
+
"""
|
|
69
|
+
if speed is None:
|
|
70
|
+
speed = self.max_speed
|
|
71
|
+
|
|
72
|
+
if isinstance(tmc_gpio, GpiozeroWrapper):
|
|
73
|
+
tmc_gpio.gpio_pwm_enable(self._pin_step, True)
|
|
74
|
+
|
|
75
|
+
if speed == 0:
|
|
76
|
+
# stop movement
|
|
77
|
+
tmc_gpio.gpio_pwm_set_duty_cycle(self._pin_step, 0)
|
|
78
|
+
else:
|
|
79
|
+
if speed < 0:
|
|
80
|
+
self.set_direction(Direction.CCW)
|
|
81
|
+
speed = -speed
|
|
82
|
+
else:
|
|
83
|
+
self.set_direction(Direction.CW)
|
|
84
|
+
|
|
85
|
+
# change pwm frequency
|
|
86
|
+
self.speed = speed
|
|
87
|
+
tmc_gpio.gpio_pwm_set_duty_cycle(self._pin_step, 50)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def run_speed_pwm_fullstep(self, speed:int = None):
|
|
91
|
+
"""runs the motor
|
|
92
|
+
does not block the code
|
|
93
|
+
"""
|
|
94
|
+
if speed is None:
|
|
95
|
+
speed = self.max_speed_fullstep
|
|
96
|
+
self.run_speed_pwm(speed * self.mres)
|
|
@@ -40,6 +40,17 @@ class TmcMotionControlVActual(TmcMotionControl):
|
|
|
40
40
|
raise NotImplementedError
|
|
41
41
|
|
|
42
42
|
|
|
43
|
+
def stop(self, stop_mode = StopMode.HARDSTOP):
|
|
44
|
+
"""stop the current movement
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
stop_mode (enum): whether the movement should be stopped immediately or softly
|
|
48
|
+
(Default value = StopMode.HARDSTOP)
|
|
49
|
+
"""
|
|
50
|
+
super().stop(stop_mode)
|
|
51
|
+
self.set_vactual(0)
|
|
52
|
+
|
|
53
|
+
|
|
43
54
|
def run_to_position_steps(self, steps, movement_abs_rel:MovementAbsRel = None):
|
|
44
55
|
"""runs the motor to the given position.
|
|
45
56
|
with acceleration and deceleration
|
|
@@ -177,3 +188,23 @@ class TmcMotionControlVActual(TmcMotionControl):
|
|
|
177
188
|
stop (enum): how the movement was finished
|
|
178
189
|
"""
|
|
179
190
|
return self.set_vactual_rps(rpm/60, duration, revolutions, acceleration)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def run_speed(self, speed:int):
|
|
194
|
+
"""runs the motor
|
|
195
|
+
does not block the code
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
speed (int): speed in µsteps per second
|
|
199
|
+
"""
|
|
200
|
+
self.set_vactual(speed/0.715)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def run_speed_fullstep(self, speed:int):
|
|
204
|
+
"""runs the motor
|
|
205
|
+
does not block the code
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
speed (int): speed in fullsteps per second
|
|
209
|
+
"""
|
|
210
|
+
self.run_speed(speed * self.mres)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#pylint: disable=unused-wildcard-import
|
|
3
3
|
#pylint: disable=unused-import
|
|
4
4
|
#pylint: disable=attribute-defined-outside-init
|
|
5
|
+
#pylint: disable=no-member
|
|
5
6
|
"""
|
|
6
7
|
Register module
|
|
7
8
|
"""
|
|
@@ -9,7 +10,6 @@ Register module
|
|
|
9
10
|
from ._tmc220x_reg import *
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
|
|
13
13
|
class TCoolThrs(TmcReg):
|
|
14
14
|
"""TCOOLTHRS register class"""
|
|
15
15
|
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
#pylint: disable=unused-wildcard-import
|
|
3
3
|
#pylint: disable=unused-import
|
|
4
4
|
#pylint: disable=attribute-defined-outside-init
|
|
5
|
+
#pylint: disable=no-member
|
|
5
6
|
"""
|
|
6
7
|
Register module
|
|
7
8
|
"""
|
|
8
9
|
|
|
9
10
|
import math
|
|
10
11
|
from ._tmc_reg import *
|
|
12
|
+
from .._tmc_exceptions import TmcDriverException
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
class GConf(TmcReg):
|
|
@@ -44,6 +46,16 @@ class GStat(TmcReg):
|
|
|
44
46
|
]
|
|
45
47
|
super().__init__(0x1, "GSTAT", tmc_com, reg_map)
|
|
46
48
|
|
|
49
|
+
def check(self):
|
|
50
|
+
"""check if the driver is ok"""
|
|
51
|
+
self.read()
|
|
52
|
+
if self.reset:
|
|
53
|
+
raise TmcDriverException("TMC220X: reset detected")
|
|
54
|
+
if self.uv_cp:
|
|
55
|
+
raise TmcDriverException("TMC220X: undervoltage detected")
|
|
56
|
+
if self.drv_err:
|
|
57
|
+
raise TmcDriverException("TMC220X: driver error detected")
|
|
58
|
+
|
|
47
59
|
|
|
48
60
|
class IfCnt(TmcReg):
|
|
49
61
|
"""IFCNT register class"""
|
|
@@ -113,6 +125,18 @@ class TStep(TmcReg):
|
|
|
113
125
|
super().__init__(0x12, "TSTEP", tmc_com, reg_map)
|
|
114
126
|
|
|
115
127
|
|
|
128
|
+
class TPwmThrs(TmcReg):
|
|
129
|
+
"""TPWMTHRS register class"""
|
|
130
|
+
|
|
131
|
+
def __init__(self, tmc_com: TmcCom):
|
|
132
|
+
"""constructor"""
|
|
133
|
+
|
|
134
|
+
reg_map = [
|
|
135
|
+
["tpwmthrs", 0, 0xFFFFF, int, None, ""]
|
|
136
|
+
]
|
|
137
|
+
super().__init__(0x13, "TPWMTHRS", tmc_com, reg_map)
|
|
138
|
+
|
|
139
|
+
|
|
116
140
|
class VActual(TmcReg):
|
|
117
141
|
"""VACTUAL register class"""
|
|
118
142
|
|
|
@@ -9,6 +9,7 @@ Register module
|
|
|
9
9
|
|
|
10
10
|
import math
|
|
11
11
|
from ._tmc_reg import *
|
|
12
|
+
from .._tmc_exceptions import TmcDriverException
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class GConf(TmcReg):
|
|
@@ -52,6 +53,20 @@ class GStat(TmcReg):
|
|
|
52
53
|
]
|
|
53
54
|
super().__init__(0x1, "GSTAT", tmc_com, reg_map)
|
|
54
55
|
|
|
56
|
+
def check(self):
|
|
57
|
+
"""check if the driver is ok"""
|
|
58
|
+
self.read()
|
|
59
|
+
if self.vm_uvlo:
|
|
60
|
+
raise TmcDriverException("TMC224X: Vmotor undervoltage detected")
|
|
61
|
+
if self.register_reset:
|
|
62
|
+
raise TmcDriverException("TMC224X: register reset detected")
|
|
63
|
+
if self.uv_cp:
|
|
64
|
+
raise TmcDriverException("TMC224X: Charge Pump undervoltage detected")
|
|
65
|
+
if self.drv_err:
|
|
66
|
+
raise TmcDriverException("TMC224X: driver error detected")
|
|
67
|
+
if self.reset:
|
|
68
|
+
raise TmcDriverException("TMC224X: reset detected")
|
|
69
|
+
|
|
55
70
|
|
|
56
71
|
class IfCnt(TmcReg):
|
|
57
72
|
"""IFCNT register class"""
|
|
@@ -117,8 +117,8 @@ class Tmc2209(Tmc220x, StallGuard):
|
|
|
117
117
|
self.set_spreadcycle(0)
|
|
118
118
|
|
|
119
119
|
mc_homing = TmcMotionControlVActual()
|
|
120
|
+
mc_homing.init(self.tmc_logger)
|
|
120
121
|
mc_homing.tmc_com = self.tmc_com
|
|
121
|
-
mc_homing.tmc_logger = self.tmc_logger
|
|
122
122
|
|
|
123
123
|
self.set_stallguard_callback(diag_pin, threshold, mc_homing.stop,
|
|
124
124
|
0.5*tmc_math.rps_to_steps(speed_rpm/60, self.tmc_mc.steps_per_rev))
|
|
@@ -22,13 +22,13 @@ import typing
|
|
|
22
22
|
from ._tmc_stepperdriver import *
|
|
23
23
|
from .com._tmc_com import TmcCom
|
|
24
24
|
from .com._tmc_com_uart import TmcComUart
|
|
25
|
-
from .com._tmc_com_spi import TmcComSpi
|
|
26
25
|
from .motion_control._tmc_mc_step_reg import TmcMotionControlStepReg
|
|
27
26
|
from .enable_control._tmc_ec_toff import TmcEnableControlToff
|
|
28
27
|
from .motion_control._tmc_mc_vactual import TmcMotionControlVActual
|
|
29
28
|
from ._tmc_logger import TmcLogger, Loglevel
|
|
30
29
|
from .reg._tmc220x_reg import *
|
|
31
30
|
from . import _tmc_math as tmc_math
|
|
31
|
+
from ._tmc_exceptions import TmcException, TmcComException, TmcMotionControlException, TmcEnableControlException, TmcDriverException
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
|
|
@@ -101,6 +101,7 @@ class Tmc220x(TmcStepperDriver):
|
|
|
101
101
|
IHoldIRun,
|
|
102
102
|
TPowerDown,
|
|
103
103
|
TStep,
|
|
104
|
+
TPwmThrs,
|
|
104
105
|
VActual,
|
|
105
106
|
MsCnt,
|
|
106
107
|
ChopConf,
|
|
@@ -126,9 +127,9 @@ class Tmc220x(TmcStepperDriver):
|
|
|
126
127
|
# Setup Registers
|
|
127
128
|
self.tmc_com.tmc_registers = self.tmc_registers
|
|
128
129
|
|
|
130
|
+
self.clear_gstat()
|
|
129
131
|
if self.tmc_mc is not None:
|
|
130
132
|
self.read_steps_per_rev()
|
|
131
|
-
self.clear_gstat()
|
|
132
133
|
self.tmc_com.flush_serial_buffer()
|
|
133
134
|
|
|
134
135
|
|
|
@@ -206,11 +207,9 @@ class Tmc220x(TmcStepperDriver):
|
|
|
206
207
|
def clear_gstat(self):
|
|
207
208
|
"""clears the "GSTAT" register"""
|
|
208
209
|
self.tmc_logger.log("clearing GSTAT", Loglevel.INFO)
|
|
209
|
-
self.gstat.read()
|
|
210
210
|
|
|
211
|
-
self.gstat.
|
|
212
|
-
|
|
213
|
-
self.gstat.uv_cp = True
|
|
211
|
+
for reg in self.gstat.reg_map:
|
|
212
|
+
setattr(self.gstat, reg[0], True)
|
|
214
213
|
|
|
215
214
|
self.gstat.write_check()
|
|
216
215
|
|
|
@@ -580,6 +579,15 @@ class Tmc220x(TmcStepperDriver):
|
|
|
580
579
|
return self.chopconf.tstep
|
|
581
580
|
|
|
582
581
|
|
|
582
|
+
def set_tpwmthrs(self, tpwmthrs: int):
|
|
583
|
+
"""sets the current tpwmthrs
|
|
584
|
+
|
|
585
|
+
Args:
|
|
586
|
+
tpwmthrs (int): value for tpwmthrs
|
|
587
|
+
"""
|
|
588
|
+
self.tpwmthrs.tpwmthrs = tpwmthrs
|
|
589
|
+
self.tpwmthrs.write_check()
|
|
590
|
+
|
|
583
591
|
|
|
584
592
|
def set_vactual(self, vactual:int):
|
|
585
593
|
"""sets the register bit "VACTUAL" to to a given value
|
|
@@ -30,6 +30,7 @@ from ._tmc_stallguard import StallGuard
|
|
|
30
30
|
from ._tmc_logger import TmcLogger, Loglevel
|
|
31
31
|
from .reg._tmc224x_reg import *
|
|
32
32
|
from . import _tmc_math as tmc_math
|
|
33
|
+
from ._tmc_exceptions import TmcException, TmcComException, TmcMotionControlException, TmcEnableControlException, TmcDriverException
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
|
|
@@ -139,9 +140,9 @@ class Tmc2240(TmcStepperDriver, StallGuard):
|
|
|
139
140
|
# Setup Registers
|
|
140
141
|
self.tmc_com.tmc_registers = self.tmc_registers
|
|
141
142
|
|
|
143
|
+
self.clear_gstat()
|
|
142
144
|
if self.tmc_mc is not None:
|
|
143
145
|
self.read_steps_per_rev()
|
|
144
|
-
self.clear_gstat()
|
|
145
146
|
self.tmc_com.flush_serial_buffer()
|
|
146
147
|
|
|
147
148
|
|
|
@@ -219,11 +220,9 @@ class Tmc2240(TmcStepperDriver, StallGuard):
|
|
|
219
220
|
def clear_gstat(self):
|
|
220
221
|
"""clears the "GSTAT" register"""
|
|
221
222
|
self.tmc_logger.log("clearing GSTAT", Loglevel.INFO)
|
|
222
|
-
self.gstat.read()
|
|
223
223
|
|
|
224
|
-
self.gstat.
|
|
225
|
-
|
|
226
|
-
self.gstat.uv_cp = True
|
|
224
|
+
for reg in self.gstat.reg_map:
|
|
225
|
+
setattr(self.gstat, reg[0], True)
|
|
227
226
|
|
|
228
227
|
self.gstat.write_check()
|
|
229
228
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|