PyTmcStepper 0.12.0__tar.gz → 0.13.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/PKG-INFO +1 -1
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/pyproject.toml +1 -1
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/PyTmcStepper.egg-info/PKG-INFO +1 -1
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_math.py +2 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_stallguard.py +21 -12
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_stepperdriver.py +29 -28
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_xxxx.py +11 -1
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/enable_control/_tmc_ec_pin.py +2 -2
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_int_ramp_generator.py +48 -12
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py +2 -2
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py +1 -24
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_vactual.py +7 -8
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc220x_reg.py +1 -1
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc5160_reg.py +20 -20
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc_reg.py +34 -2
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_2240.py +10 -12
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_5160.py +50 -12
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_ftdi.py +0 -2
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py +43 -18
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_periphery.py +11 -4
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py +21 -5
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/LICENSE +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/README.md +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/setup.cfg +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/PyTmcStepper.egg-info/SOURCES.txt +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/PyTmcStepper.egg-info/dependency_links.txt +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/PyTmcStepper.egg-info/requires.txt +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/PyTmcStepper.egg-info/top_level.txt +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/__init__.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_exceptions.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/_tmc_validation.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/__init__.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_spi.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_spi_base.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_spi_ftdi.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_spi_micropython.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_uart.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_uart_base.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/com/_tmc_com_uart_micropython.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/enable_control/__init__.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/enable_control/_tmc_ec.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/enable_control/_tmc_ec_toff.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/__init__.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/platform_utils.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/__init__.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc2209_reg.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc224x_reg.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/reg/_tmc_shared_regs.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_2208.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_2209.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_220x.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/__init__.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_base.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_logger/__init__.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_logger/_tmc_logger_base.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_logger/_tmc_logger_cpython.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/tmc_logger/_tmc_logger_micropython.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/tests/test_tmc2209.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/tests/test_tmc2240.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/tests/test_tmc_com_spi.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/tests/test_tmc_com_uart.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/tests/test_tmc_ec_pin.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/tests/test_tmc_math.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/tests/test_tmc_modules.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/tests/test_tmc_move.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/tests/test_tmc_set_current.py +0 -0
- {pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/tests/test_tmc_stallguard.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyTmcStepper
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi
|
|
5
5
|
Author-email: Christian Köhlke <christian@koehlke.de>
|
|
6
6
|
License-Expression: GPL-3.0
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "PyTmcStepper"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.13.0"
|
|
8
8
|
authors = [{ name = "Christian Köhlke", email = "christian@koehlke.de" }]
|
|
9
9
|
description = "This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi"
|
|
10
10
|
readme = "README.md"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyTmcStepper
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.0
|
|
4
4
|
Summary: This is a Python libary to drive a stepper motor with a Trinamic stepper driver and a single board computer like a Raspberry Pi
|
|
5
5
|
Author-email: Christian Köhlke <christian@koehlke.de>
|
|
6
6
|
License-Expression: GPL-3.0
|
|
@@ -81,10 +81,7 @@ class StallGuard:
|
|
|
81
81
|
|
|
82
82
|
def deinit(self):
|
|
83
83
|
"""destructor"""
|
|
84
|
-
if (
|
|
85
|
-
getattr(self, "_pin_stallguard", None) is not None
|
|
86
|
-
and self._pin_stallguard is not None
|
|
87
|
-
):
|
|
84
|
+
if hasattr(self, "_pin_stallguard") and self._pin_stallguard is not None:
|
|
88
85
|
tmc_gpio.tmc_gpio.gpio_remove_event_detect(self._pin_stallguard)
|
|
89
86
|
tmc_gpio.tmc_gpio.gpio_cleanup(self._pin_stallguard)
|
|
90
87
|
self._pin_stallguard = None
|
|
@@ -110,10 +107,8 @@ class StallGuard:
|
|
|
110
107
|
Loglevel.INFO,
|
|
111
108
|
)
|
|
112
109
|
|
|
113
|
-
self.
|
|
114
|
-
|
|
115
|
-
tmc_math.steps_to_tstep(min_speed, self.get_microstepping_resolution())
|
|
116
|
-
)
|
|
110
|
+
self.stallguard_setup(threshold, min_speed)
|
|
111
|
+
|
|
117
112
|
self._sg_callback = callback
|
|
118
113
|
self._pin_stallguard = pin_stallguard
|
|
119
114
|
|
|
@@ -194,6 +189,24 @@ class StallGuard:
|
|
|
194
189
|
raise TmcMotionControlException("tmc_mc is None; cannot reset current pos")
|
|
195
190
|
self.tmc_mc.current_pos = 0
|
|
196
191
|
|
|
192
|
+
def stallguard_setup(
|
|
193
|
+
self,
|
|
194
|
+
threshold: int,
|
|
195
|
+
min_speed: int,
|
|
196
|
+
):
|
|
197
|
+
"""internal setup for stallguard
|
|
198
|
+
Args:
|
|
199
|
+
threshold (int): value for SGTHRS
|
|
200
|
+
min_speed (int): min speed [steps/s] for StallGuard
|
|
201
|
+
"""
|
|
202
|
+
self.tmc_logger.log(f"Stallguard threshold: {threshold}", Loglevel.DEBUG)
|
|
203
|
+
|
|
204
|
+
self.set_spreadcycle(False)
|
|
205
|
+
self._set_stallguard_threshold(threshold)
|
|
206
|
+
self._set_coolstep_threshold(
|
|
207
|
+
tmc_math.steps_to_tstep(min_speed, self.get_microstepping_resolution())
|
|
208
|
+
)
|
|
209
|
+
|
|
197
210
|
def do_homing(
|
|
198
211
|
self,
|
|
199
212
|
diag_pin: int,
|
|
@@ -223,8 +236,6 @@ class StallGuard:
|
|
|
223
236
|
if self.tmc_mc is None:
|
|
224
237
|
raise TmcMotionControlException("tmc_mc is None; cannot do homing")
|
|
225
238
|
|
|
226
|
-
self.tmc_logger.log(f"Stallguard threshold: {threshold}", Loglevel.DEBUG)
|
|
227
|
-
|
|
228
239
|
if max_speed is None:
|
|
229
240
|
max_speed = self.tmc_mc.max_speed_homing
|
|
230
241
|
if cb_success is _CB_SENTINEL:
|
|
@@ -233,8 +244,6 @@ class StallGuard:
|
|
|
233
244
|
self.tmc_logger.log("---", Loglevel.INFO)
|
|
234
245
|
self.tmc_logger.log("homing", Loglevel.INFO)
|
|
235
246
|
|
|
236
|
-
self.set_spreadcycle(False)
|
|
237
|
-
|
|
238
247
|
self.set_stallguard_callback(
|
|
239
248
|
diag_pin,
|
|
240
249
|
threshold,
|
|
@@ -91,16 +91,13 @@ class TmcStepperDriver:
|
|
|
91
91
|
|
|
92
92
|
def deinit(self):
|
|
93
93
|
"""destructor"""
|
|
94
|
-
if
|
|
94
|
+
if hasattr(self, "tmc_ec") and self.tmc_ec is not None:
|
|
95
95
|
self.tmc_ec.deinit()
|
|
96
96
|
self.tmc_ec = None
|
|
97
|
-
if
|
|
97
|
+
if hasattr(self, "tmc_mc") and self.tmc_mc is not None:
|
|
98
98
|
self.tmc_mc.deinit()
|
|
99
99
|
self.tmc_mc = None
|
|
100
|
-
if (
|
|
101
|
-
getattr(self, "tmc_logger", None) is not None
|
|
102
|
-
and self.tmc_logger is not None
|
|
103
|
-
):
|
|
100
|
+
if hasattr(self, "tmc_logger") and self.tmc_logger is not None:
|
|
104
101
|
self.tmc_logger.deinit()
|
|
105
102
|
del self.tmc_logger
|
|
106
103
|
|
|
@@ -116,14 +113,14 @@ class TmcStepperDriver:
|
|
|
116
113
|
@property
|
|
117
114
|
def current_pos(self) -> int:
|
|
118
115
|
"""_current_pos property"""
|
|
119
|
-
if
|
|
116
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
120
117
|
raise AttributeError("TmcMotionControl is not set")
|
|
121
118
|
return self.tmc_mc.current_pos
|
|
122
119
|
|
|
123
120
|
@current_pos.setter
|
|
124
121
|
def current_pos(self, current_pos: int):
|
|
125
122
|
"""_current_pos setter"""
|
|
126
|
-
if
|
|
123
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
127
124
|
raise AttributeError("TmcMotionControl is not set")
|
|
128
125
|
self.tmc_mc.current_pos = current_pos
|
|
129
126
|
|
|
@@ -140,77 +137,77 @@ class TmcStepperDriver:
|
|
|
140
137
|
@property
|
|
141
138
|
def mres(self) -> int:
|
|
142
139
|
"""_mres property"""
|
|
143
|
-
if
|
|
140
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
144
141
|
raise AttributeError("TmcMotionControl is not set")
|
|
145
142
|
return self.tmc_mc.mres
|
|
146
143
|
|
|
147
144
|
@mres.setter
|
|
148
145
|
def mres(self, mres: int):
|
|
149
146
|
"""_mres setter"""
|
|
150
|
-
if
|
|
147
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
151
148
|
raise AttributeError("TmcMotionControl is not set")
|
|
152
149
|
self.tmc_mc.mres = mres
|
|
153
150
|
|
|
154
151
|
@property
|
|
155
152
|
def steps_per_rev(self) -> int:
|
|
156
153
|
"""_steps_per_rev property"""
|
|
157
|
-
if
|
|
154
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
158
155
|
raise AttributeError("TmcMotionControl is not set")
|
|
159
156
|
return self.tmc_mc.steps_per_rev
|
|
160
157
|
|
|
161
158
|
@property
|
|
162
159
|
def fullsteps_per_rev(self) -> int:
|
|
163
160
|
"""_fullsteps_per_rev property"""
|
|
164
|
-
if
|
|
161
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
165
162
|
raise AttributeError("TmcMotionControl is not set")
|
|
166
163
|
return self.tmc_mc.fullsteps_per_rev
|
|
167
164
|
|
|
168
165
|
@fullsteps_per_rev.setter
|
|
169
166
|
def fullsteps_per_rev(self, fullsteps_per_rev: int):
|
|
170
167
|
"""_fullsteps_per_rev setter"""
|
|
171
|
-
if
|
|
168
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
172
169
|
raise AttributeError("TmcMotionControl is not set")
|
|
173
170
|
self.tmc_mc.fullsteps_per_rev = fullsteps_per_rev
|
|
174
171
|
|
|
175
172
|
@property
|
|
176
173
|
def movement_abs_rel(self) -> MovementAbsRel:
|
|
177
174
|
"""_movement_abs_rel property"""
|
|
178
|
-
if
|
|
175
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
179
176
|
raise AttributeError("TmcMotionControl is not set")
|
|
180
177
|
return self.tmc_mc.movement_abs_rel
|
|
181
178
|
|
|
182
179
|
@movement_abs_rel.setter
|
|
183
180
|
def movement_abs_rel(self, movement_abs_rel: MovementAbsRel):
|
|
184
181
|
"""_movement_abs_rel setter"""
|
|
185
|
-
if
|
|
182
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
186
183
|
raise AttributeError("TmcMotionControl is not set")
|
|
187
184
|
self.tmc_mc.movement_abs_rel = movement_abs_rel
|
|
188
185
|
|
|
189
186
|
@property
|
|
190
187
|
def movement_phase(self) -> MovementPhase:
|
|
191
188
|
"""_movement_phase property"""
|
|
192
|
-
if
|
|
189
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
193
190
|
raise AttributeError("TmcMotionControl is not set")
|
|
194
191
|
return self.tmc_mc.movement_phase
|
|
195
192
|
|
|
196
193
|
@property
|
|
197
194
|
def speed(self) -> float:
|
|
198
195
|
"""_speed property"""
|
|
199
|
-
if
|
|
196
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
200
197
|
raise AttributeError("TmcMotionControl is not set")
|
|
201
198
|
return self.tmc_mc.speed
|
|
202
199
|
|
|
203
200
|
@speed.setter
|
|
204
201
|
def speed(self, speed: int):
|
|
205
202
|
"""_speed setter"""
|
|
206
|
-
if
|
|
203
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
207
204
|
raise AttributeError("TmcMotionControl is not set")
|
|
208
205
|
self.tmc_mc.speed = speed
|
|
209
206
|
|
|
210
207
|
@property
|
|
211
208
|
def max_speed(self) -> int:
|
|
212
209
|
"""_max_speed property"""
|
|
213
|
-
if
|
|
210
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
214
211
|
raise AttributeError("TmcMotionControl is not set")
|
|
215
212
|
return self.tmc_mc.max_speed
|
|
216
213
|
|
|
@@ -223,42 +220,42 @@ class TmcStepperDriver:
|
|
|
223
220
|
@property
|
|
224
221
|
def max_speed_fullstep(self) -> int:
|
|
225
222
|
"""_max_speed_fullstep property"""
|
|
226
|
-
if
|
|
223
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
227
224
|
raise AttributeError("TmcMotionControl is not set")
|
|
228
225
|
return self.tmc_mc.max_speed_fullstep
|
|
229
226
|
|
|
230
227
|
@max_speed_fullstep.setter
|
|
231
228
|
def max_speed_fullstep(self, max_speed_fullstep: int):
|
|
232
229
|
"""_max_speed_fullstep setter"""
|
|
233
|
-
if
|
|
230
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
234
231
|
raise AttributeError("TmcMotionControl is not set")
|
|
235
232
|
self.tmc_mc.max_speed_fullstep = max_speed_fullstep
|
|
236
233
|
|
|
237
234
|
@property
|
|
238
235
|
def acceleration(self) -> int:
|
|
239
236
|
"""_acceleration property"""
|
|
240
|
-
if
|
|
237
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
241
238
|
raise AttributeError("TmcMotionControl is not set")
|
|
242
239
|
return self.tmc_mc.acceleration
|
|
243
240
|
|
|
244
241
|
@acceleration.setter
|
|
245
242
|
def acceleration(self, acceleration: int):
|
|
246
243
|
"""_acceleration setter"""
|
|
247
|
-
if
|
|
244
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
248
245
|
raise AttributeError("TmcMotionControl is not set")
|
|
249
246
|
self.tmc_mc.acceleration = acceleration
|
|
250
247
|
|
|
251
248
|
@property
|
|
252
249
|
def acceleration_fullstep(self) -> int:
|
|
253
250
|
"""_acceleration_fullstep property"""
|
|
254
|
-
if
|
|
251
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
255
252
|
raise AttributeError("TmcMotionControl is not set")
|
|
256
253
|
return self.tmc_mc.acceleration_fullstep
|
|
257
254
|
|
|
258
255
|
@acceleration_fullstep.setter
|
|
259
256
|
def acceleration_fullstep(self, acceleration_fullstep: int):
|
|
260
257
|
"""_acceleration_fullstep setter"""
|
|
261
|
-
if
|
|
258
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
262
259
|
raise AttributeError("TmcMotionControl is not set")
|
|
263
260
|
self.tmc_mc.acceleration_fullstep = acceleration_fullstep
|
|
264
261
|
|
|
@@ -266,7 +263,7 @@ class TmcStepperDriver:
|
|
|
266
263
|
self, steps, movement_abs_rel: MovementAbsRel | None = None
|
|
267
264
|
) -> StopMode:
|
|
268
265
|
"""motioncontrol wrapper"""
|
|
269
|
-
if
|
|
266
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
270
267
|
raise AttributeError("TmcMotionControl is not set")
|
|
271
268
|
return self.tmc_mc.run_to_position_steps(steps, movement_abs_rel)
|
|
272
269
|
|
|
@@ -282,11 +279,15 @@ class TmcStepperDriver:
|
|
|
282
279
|
"""motioncontrol wrapper"""
|
|
283
280
|
return self.run_to_position_steps(revs * self.steps_per_rev, movement_abs_rel)
|
|
284
281
|
|
|
285
|
-
|
|
282
|
+
def reset_position(self):
|
|
283
|
+
"""resets the current position to 0"""
|
|
284
|
+
self.current_pos_fullstep = 0
|
|
285
|
+
|
|
286
|
+
# Test Methods
|
|
286
287
|
# ----------------------------
|
|
287
288
|
def test_step(self):
|
|
288
289
|
"""test method"""
|
|
289
|
-
if
|
|
290
|
+
if not hasattr(self, "tmc_mc") or self.tmc_mc is None:
|
|
290
291
|
raise AttributeError("TmcMotionControl is not set")
|
|
291
292
|
for _ in range(100):
|
|
292
293
|
self.tmc_mc.set_direction(Direction.CW)
|
|
@@ -37,6 +37,7 @@ class TmcXXXX(TmcStepperDriver):
|
|
|
37
37
|
gconf: tmc_shared_regs.GConf
|
|
38
38
|
chopconf: tmc_shared_regs.ChopConf
|
|
39
39
|
mscnt: tmc_shared_regs.MsCnt
|
|
40
|
+
tpwmthrs: tmc_shared_regs.TPwmThrs
|
|
40
41
|
|
|
41
42
|
# Constructor/Destructor
|
|
42
43
|
# ----------------------------
|
|
@@ -106,7 +107,7 @@ class TmcXXXX(TmcStepperDriver):
|
|
|
106
107
|
if self.tmc_ec is not None:
|
|
107
108
|
self.tmc_ec.set_get_register_callback(self._get_register)
|
|
108
109
|
|
|
109
|
-
if
|
|
110
|
+
if hasattr(self, "tmc_mc") and self.tmc_mc is not None:
|
|
110
111
|
self.max_speed_fullstep = 100
|
|
111
112
|
self.acceleration_fullstep = 100
|
|
112
113
|
|
|
@@ -380,6 +381,15 @@ class TmcXXXX(TmcStepperDriver):
|
|
|
380
381
|
|
|
381
382
|
return reg, data, flags
|
|
382
383
|
|
|
384
|
+
def set_hybrid_threshold_speed(self, speed: int):
|
|
385
|
+
"""sets the hybrid threshold speed
|
|
386
|
+
|
|
387
|
+
Args:
|
|
388
|
+
speed (int): speed in steps per second
|
|
389
|
+
"""
|
|
390
|
+
tstep = tmc_math.steps_to_tstep(speed, self.get_microstepping_resolution())
|
|
391
|
+
self.tpwmthrs.modify("tpwmthrs", tstep)
|
|
392
|
+
|
|
383
393
|
# Test Methods
|
|
384
394
|
# ----------------------------
|
|
385
395
|
def test_pin(self, pin, ioin_reg_field_name: str) -> bool:
|
|
@@ -33,7 +33,7 @@ class TmcEnableControlPin(TmcEnableControl):
|
|
|
33
33
|
def deinit(self):
|
|
34
34
|
"""destructor"""
|
|
35
35
|
super().deinit()
|
|
36
|
-
if
|
|
36
|
+
if hasattr(self, "_pin_en"):
|
|
37
37
|
tmc_gpio.tmc_gpio.gpio_cleanup(self._pin_en)
|
|
38
38
|
del self._pin_en
|
|
39
39
|
|
|
@@ -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
|
|
46
|
+
if hasattr(self, "_pin_en"):
|
|
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)
|
|
@@ -43,17 +43,34 @@ class TmcMotionControlIntRampGenerator(TmcMotionControl):
|
|
|
43
43
|
def current_pos(self):
|
|
44
44
|
"""_current_pos property"""
|
|
45
45
|
xactual: tmc5160_reg.XActual = self.get_register("xactual")
|
|
46
|
+
xactual.read()
|
|
46
47
|
self._current_pos = xactual.xactual
|
|
47
48
|
return self._current_pos
|
|
48
49
|
|
|
49
50
|
@current_pos.setter
|
|
50
51
|
def current_pos(self, current_pos: int):
|
|
51
52
|
"""_current_pos setter"""
|
|
52
|
-
|
|
53
|
+
self._current_pos = current_pos
|
|
53
54
|
xactual: tmc5160_reg.XActual = self.get_register("xactual")
|
|
54
55
|
xactual.xactual = current_pos
|
|
55
56
|
xactual.write()
|
|
56
57
|
|
|
58
|
+
@property
|
|
59
|
+
def target_pos(self):
|
|
60
|
+
"""_target_pos property"""
|
|
61
|
+
xtarget: tmc5160_reg.XTarget = self.get_register("xtarget")
|
|
62
|
+
xtarget.read()
|
|
63
|
+
self._target_pos = xtarget.xtarget
|
|
64
|
+
return self._target_pos
|
|
65
|
+
|
|
66
|
+
@target_pos.setter
|
|
67
|
+
def target_pos(self, target_pos: int):
|
|
68
|
+
"""_target_pos setter"""
|
|
69
|
+
self._target_pos = target_pos
|
|
70
|
+
xtarget: tmc5160_reg.XTarget = self.get_register("xtarget")
|
|
71
|
+
xtarget.xtarget = target_pos
|
|
72
|
+
xtarget.write()
|
|
73
|
+
|
|
57
74
|
def __init__(self):
|
|
58
75
|
"""constructor"""
|
|
59
76
|
super().__init__()
|
|
@@ -139,10 +156,23 @@ class TmcMotionControlIntRampGenerator(TmcMotionControl):
|
|
|
139
156
|
"""blocks the code until the movement is finished or stopped from a different thread!"""
|
|
140
157
|
rampstat: tmc5160_reg.RampStat = self.get_register("rampstat")
|
|
141
158
|
while True:
|
|
159
|
+
# self._tmc_logger.log(f"current pos: {self.current_pos}", Loglevel.MOVEMENT)
|
|
142
160
|
rampstat.read()
|
|
143
161
|
if rampstat.position_reached:
|
|
144
162
|
self._tmc_logger.log("position reached", Loglevel.MOVEMENT)
|
|
145
163
|
return
|
|
164
|
+
if rampstat.event_stop_sg:
|
|
165
|
+
self._tmc_logger.log("stopped by stallguard", Loglevel.MOVEMENT)
|
|
166
|
+
self._stop = StopMode.HARDSTOP
|
|
167
|
+
return
|
|
168
|
+
if rampstat.event_stop_l:
|
|
169
|
+
self._tmc_logger.log("stopped by limit switch l", Loglevel.MOVEMENT)
|
|
170
|
+
self._stop = StopMode.HARDSTOP
|
|
171
|
+
return
|
|
172
|
+
if rampstat.event_stop_r:
|
|
173
|
+
self._tmc_logger.log("stopped by limit switch r", Loglevel.MOVEMENT)
|
|
174
|
+
self._stop = StopMode.HARDSTOP
|
|
175
|
+
return
|
|
146
176
|
time.sleep(0.01) # sleep 10ms to reduce CPU load
|
|
147
177
|
|
|
148
178
|
def run_to_position_steps(
|
|
@@ -162,27 +192,28 @@ class TmcMotionControlIntRampGenerator(TmcMotionControl):
|
|
|
162
192
|
Returns:
|
|
163
193
|
stop (enum): how the movement was finished
|
|
164
194
|
"""
|
|
165
|
-
#
|
|
195
|
+
self._current_pos = self.current_pos # sync current pos with register
|
|
196
|
+
|
|
197
|
+
self.set_ramp_mode(RampMode.POSITIONING_MODE)
|
|
198
|
+
self.set_motion_profile(self._max_speed, self._acceleration, self._acceleration)
|
|
199
|
+
|
|
200
|
+
self._stop = StopMode.NO
|
|
201
|
+
|
|
166
202
|
if movement_abs_rel is None:
|
|
167
203
|
movement_abs_rel = self._movement_abs_rel
|
|
168
204
|
|
|
169
205
|
if movement_abs_rel == MovementAbsRel.RELATIVE:
|
|
170
|
-
self.
|
|
206
|
+
self.target_pos = self._current_pos + steps
|
|
171
207
|
else:
|
|
172
|
-
self.
|
|
173
|
-
|
|
174
|
-
self.set_ramp_mode(RampMode.POSITIONING_MODE)
|
|
175
|
-
self.set_motion_profile(self._max_speed, self._acceleration, self._acceleration)
|
|
208
|
+
self.target_pos = steps
|
|
176
209
|
|
|
177
210
|
self._tmc_logger.log(
|
|
178
|
-
f"cur: {self._current_pos} | tar: {self._target_pos}",
|
|
211
|
+
f"Before movement cur: {self._current_pos} | tar: {self._target_pos}",
|
|
212
|
+
Loglevel.MOVEMENT,
|
|
179
213
|
)
|
|
180
214
|
|
|
181
|
-
xtarget: tmc5160_reg.XTarget = self.get_register("xtarget")
|
|
182
|
-
xtarget.xtarget = self._target_pos
|
|
183
|
-
xtarget.write()
|
|
184
|
-
|
|
185
215
|
self.wait_until_stop()
|
|
216
|
+
self.target_pos = self.current_pos
|
|
186
217
|
|
|
187
218
|
loststeps: tmc5160_reg.LostSteps = self.get_register("loststeps")
|
|
188
219
|
loststeps.read()
|
|
@@ -191,4 +222,9 @@ class TmcMotionControlIntRampGenerator(TmcMotionControl):
|
|
|
191
222
|
f"Lost steps detected: {loststeps.lost_steps}", Loglevel.MOVEMENT
|
|
192
223
|
)
|
|
193
224
|
|
|
225
|
+
self._tmc_logger.log(
|
|
226
|
+
f"After movement cur: {self.current_pos} | tar: {self._target_pos}",
|
|
227
|
+
Loglevel.MOVEMENT,
|
|
228
|
+
)
|
|
229
|
+
|
|
194
230
|
return self._stop
|
{pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py
RENAMED
|
@@ -140,10 +140,10 @@ class TmcMotionControlStepDir(TmcMotionControl):
|
|
|
140
140
|
|
|
141
141
|
def deinit(self):
|
|
142
142
|
"""destructor"""
|
|
143
|
-
if
|
|
143
|
+
if hasattr(self, "_pin_step"):
|
|
144
144
|
tmc_gpio.tmc_gpio.gpio_cleanup(self._pin_step)
|
|
145
145
|
del self._pin_step
|
|
146
|
-
if
|
|
146
|
+
if hasattr(self, "_pin_dir") and self._pin_dir is not None:
|
|
147
147
|
tmc_gpio.tmc_gpio.gpio_cleanup(self._pin_dir)
|
|
148
148
|
del self._pin_dir
|
|
149
149
|
|
{pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py
RENAMED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
STEP_PWM/DIR Motion Control module
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
from ._tmc_mc import
|
|
9
|
+
from ._tmc_mc import Direction, StopMode
|
|
10
10
|
from ._tmc_mc_step_dir import TmcMotionControlStepDir
|
|
11
11
|
from ..tmc_logger import TmcLogger, Loglevel
|
|
12
12
|
from .. import tmc_gpio
|
|
@@ -43,25 +43,6 @@ class TmcMotionControlStepPwmDir(TmcMotionControlStepDir):
|
|
|
43
43
|
super().stop(stop_mode)
|
|
44
44
|
tmc_gpio.tmc_gpio.gpio_pwm_set_duty_cycle(self._pin_step, 0)
|
|
45
45
|
|
|
46
|
-
def run_to_position_steps(
|
|
47
|
-
self, steps, movement_abs_rel: MovementAbsRel | None = None
|
|
48
|
-
) -> 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 tmc_gpio.tmc_gpio.__class__.__name__ == "GpiozeroWrapper":
|
|
60
|
-
tmc_gpio.tmc_gpio.gpio_pwm_enable(self._pin_step, False)
|
|
61
|
-
# TODO: check for a better solution for gpiozero
|
|
62
|
-
|
|
63
|
-
return super().run_to_position_steps(steps, movement_abs_rel)
|
|
64
|
-
|
|
65
46
|
def run_speed_pwm(self, speed: int | None = None):
|
|
66
47
|
"""runs the motor
|
|
67
48
|
does not block the code
|
|
@@ -74,10 +55,6 @@ class TmcMotionControlStepPwmDir(TmcMotionControlStepDir):
|
|
|
74
55
|
if speed is None:
|
|
75
56
|
speed = self.max_speed
|
|
76
57
|
|
|
77
|
-
if tmc_gpio.tmc_gpio.__class__.__name__ == "GpiozeroWrapper":
|
|
78
|
-
tmc_gpio.tmc_gpio.gpio_pwm_enable(self._pin_step, True)
|
|
79
|
-
# TODO: check for a better solution for gpiozero
|
|
80
|
-
|
|
81
58
|
if speed == 0:
|
|
82
59
|
# stop movement
|
|
83
60
|
tmc_gpio.tmc_gpio.gpio_pwm_set_duty_cycle(self._pin_step, 0)
|
{pytmcstepper-0.12.0 → pytmcstepper-0.13.0}/src/tmc_driver/motion_control/_tmc_mc_vactual.py
RENAMED
|
@@ -69,13 +69,12 @@ class TmcMotionControlVActual(TmcMotionControl):
|
|
|
69
69
|
self._tmc_logger.log(
|
|
70
70
|
f"cur: {self._current_pos} | tar: {self._target_pos}", Loglevel.MOVEMENT
|
|
71
71
|
)
|
|
72
|
-
# self._tmc_logger.log(f"mov: {movement_abs_rel}", Loglevel.MOVEMENT)
|
|
73
72
|
|
|
74
73
|
self._stop = StopMode.NO
|
|
75
|
-
if movement_abs_rel
|
|
76
|
-
movement_abs_rel
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
if movement_abs_rel is None:
|
|
75
|
+
movement_abs_rel = self._movement_abs_rel
|
|
76
|
+
|
|
77
|
+
if movement_abs_rel == MovementAbsRel.ABSOLUTE:
|
|
79
78
|
steps = steps - self.current_pos
|
|
80
79
|
|
|
81
80
|
rps = tmc_math.steps_to_rps(self.max_speed_fullstep, self.steps_per_rev)
|
|
@@ -141,16 +140,16 @@ class TmcMotionControlVActual(TmcMotionControl):
|
|
|
141
140
|
|
|
142
141
|
if duration == 0:
|
|
143
142
|
return self._stop
|
|
144
|
-
|
|
143
|
+
duration_us = duration * 1000 * 1000
|
|
145
144
|
|
|
146
145
|
self._starttime = get_time_us()
|
|
147
146
|
current_time = get_time_us()
|
|
148
|
-
while current_time < self._starttime +
|
|
147
|
+
while current_time < self._starttime + duration_us:
|
|
149
148
|
if self._stop == StopMode.HARDSTOP:
|
|
150
149
|
break
|
|
151
150
|
if acceleration != 0:
|
|
152
151
|
time_to_stop = (
|
|
153
|
-
self._starttime +
|
|
152
|
+
self._starttime + duration_us - abs(current_vactual / acceleration)
|
|
154
153
|
)
|
|
155
154
|
if self._stop == StopMode.SOFTSTOP:
|
|
156
155
|
time_to_stop = current_time - 1
|
|
@@ -143,7 +143,7 @@ class VActual(shared.VActual):
|
|
|
143
143
|
ADDR = 0x22
|
|
144
144
|
|
|
145
145
|
vactual: int
|
|
146
|
-
_REG_MAP = (TmcRegField("vactual", 0, 0xFFFFFF, int, None, ""),)
|
|
146
|
+
_REG_MAP = (TmcRegField("vactual", 0, 0xFFFFFF, int, None, "", signed=True),)
|
|
147
147
|
|
|
148
148
|
|
|
149
149
|
class MsCnt(shared.MsCnt):
|