PyTmcStepper 0.21.2__tar.gz → 0.21.4__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.21.2 → pytmcstepper-0.21.4}/PKG-INFO +1 -1
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/pyproject.toml +1 -1
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/PyTmcStepper.egg-info/PKG-INFO +1 -1
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/PyTmcStepper.egg-info/SOURCES.txt +1 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com.py +1 -1
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com_uart.py +3 -5
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com_uart_base.py +31 -20
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py +12 -2
- pytmcstepper-0.21.4/tests/test_tmc_move_stepdir_stop.py +136 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/LICENSE +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/README.md +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/setup.cfg +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/PyTmcStepper.egg-info/dependency_links.txt +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/PyTmcStepper.egg-info/requires.txt +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/PyTmcStepper.egg-info/top_level.txt +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/__init__.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/_tmc_exceptions.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/_tmc_math.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/_tmc_stallguard.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/_tmc_stepperdriver.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/_tmc_validation.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/_tmc_xxxx.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/__init__.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com_spi.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com_spi_base.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com_spi_circuitpython.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com_spi_ftdi.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com_spi_micropython.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com_uart_circuitpython.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com_uart_micropython.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/enable_control/__init__.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/enable_control/_tmc_ec.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/enable_control/_tmc_ec_pin.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/enable_control/_tmc_ec_toff.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/__init__.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_int_ramp_generator.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_pio.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_pio_base.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_pio_circuitpython.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_pio_micropython.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_vactual.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/platform_utils.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/reg/__init__.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/reg/_tmc2209_reg.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/reg/_tmc220x_reg.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/reg/_tmc224x_reg.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/reg/_tmc5160_reg.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/reg/_tmc_reg.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/reg/_tmc_shared_regs.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_2208.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_2209.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_220x.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_2240.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_5160.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/__init__.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_base.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_circuitpython.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_ftdi.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_periphery.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_logger/__init__.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_logger/_tmc_logger_base.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_logger/_tmc_logger_cpython.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_logger/_tmc_logger_micropython.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_gpiozero.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc2209.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc2240.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_com_spi.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_com_uart.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_ec_pin.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_imports.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_math.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_modules.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_move_intramp.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_move_stepdir.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_move_steppwmdir.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_move_stepreg.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_move_vactual.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_set_current.py +0 -0
- {pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/tests/test_tmc_stallguard.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyTmcStepper
|
|
3
|
-
Version: 0.21.
|
|
3
|
+
Version: 0.21.4
|
|
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.21.
|
|
7
|
+
version = "0.21.4"
|
|
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.21.
|
|
3
|
+
Version: 0.21.4
|
|
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
|
|
@@ -75,6 +75,7 @@ tests/test_tmc_math.py
|
|
|
75
75
|
tests/test_tmc_modules.py
|
|
76
76
|
tests/test_tmc_move_intramp.py
|
|
77
77
|
tests/test_tmc_move_stepdir.py
|
|
78
|
+
tests/test_tmc_move_stepdir_stop.py
|
|
78
79
|
tests/test_tmc_move_steppwmdir.py
|
|
79
80
|
tests/test_tmc_move_stepreg.py
|
|
80
81
|
tests/test_tmc_move_vactual.py
|
|
@@ -41,7 +41,7 @@ class TmcComUart(TmcComUartBase):
|
|
|
41
41
|
self._tmc_logger.log(f"SERIAL ERROR: {e}")
|
|
42
42
|
if errnum == 2:
|
|
43
43
|
self._tmc_logger.log(
|
|
44
|
-
f""""{self.ser.
|
|
44
|
+
f""""{self.ser.port} does not exist.
|
|
45
45
|
You need to activate the serial port with \"sudo raspi-config\"""",
|
|
46
46
|
Loglevel.ERROR,
|
|
47
47
|
)
|
|
@@ -62,7 +62,7 @@ class TmcComUart(TmcComUartBase):
|
|
|
62
62
|
raise TmcComException("Baudrate is not set")
|
|
63
63
|
|
|
64
64
|
# adjust per baud and hardware. Sequential reads without some delay fail.
|
|
65
|
-
self.communication_pause = 500
|
|
65
|
+
self.communication_pause = 500 / self.ser.baudrate
|
|
66
66
|
|
|
67
67
|
if self.ser is None:
|
|
68
68
|
return
|
|
@@ -70,9 +70,7 @@ class TmcComUart(TmcComUartBase):
|
|
|
70
70
|
self.ser.bytesize = serial.EIGHTBITS
|
|
71
71
|
self.ser.parity = serial.PARITY_NONE
|
|
72
72
|
self.ser.stopbits = serial.STOPBITS_ONE
|
|
73
|
-
|
|
74
|
-
# adjust per baud and hardware. Sequential reads without some delay fail.
|
|
75
|
-
self.ser.timeout = 20000 // self.ser.baudrate
|
|
73
|
+
self.ser.timeout = 1
|
|
76
74
|
|
|
77
75
|
self._uart_flush()
|
|
78
76
|
|
|
@@ -258,6 +258,17 @@ class TmcComUartBase(TmcCom):
|
|
|
258
258
|
if not self.ser.is_open:
|
|
259
259
|
raise TmcComException("Cannot test com, serial port is closed")
|
|
260
260
|
|
|
261
|
+
self._tmc_logger.log(f"Serialport: {self.ser.port}", Loglevel.DEBUG)
|
|
262
|
+
self._tmc_logger.log(f"Baudrate: {self.ser.baudrate}", Loglevel.DEBUG)
|
|
263
|
+
self._tmc_logger.log(
|
|
264
|
+
f"Timeout: {self.ser.timeout:.4f} s | {self.ser.timeout*1000:.2f} ms",
|
|
265
|
+
Loglevel.DEBUG,
|
|
266
|
+
)
|
|
267
|
+
self._tmc_logger.log(
|
|
268
|
+
f"Communication pause: {self.communication_pause:.4f} s | {self.communication_pause*1000:.2f} ms",
|
|
269
|
+
Loglevel.DEBUG,
|
|
270
|
+
)
|
|
271
|
+
|
|
261
272
|
if ioin is None:
|
|
262
273
|
ioin = tmc_shared_reg.Ioin(self)
|
|
263
274
|
setattr(ioin, "ADDR", 0x6) # Default IOIN address
|
|
@@ -279,44 +290,44 @@ class TmcComUartBase(TmcCom):
|
|
|
279
290
|
)
|
|
280
291
|
self._tmc_logger.log(f"hex: {rtn.hex()}", Loglevel.DEBUG)
|
|
281
292
|
|
|
282
|
-
self.
|
|
283
|
-
self.
|
|
293
|
+
self._tmc_logger.log(f"length snd: {len(snd)}", Loglevel.DEBUG)
|
|
294
|
+
self._tmc_logger.log(f"length rtn: {len(rtn)}", Loglevel.DEBUG)
|
|
284
295
|
|
|
285
|
-
self.
|
|
286
|
-
self.
|
|
287
|
-
self.
|
|
296
|
+
self._tmc_logger.log("complete messages:", Loglevel.DEBUG)
|
|
297
|
+
self._tmc_logger.log(str(snd.hex()), Loglevel.DEBUG)
|
|
298
|
+
self._tmc_logger.log(str(rtn.hex()), Loglevel.DEBUG)
|
|
288
299
|
|
|
289
|
-
self.
|
|
290
|
-
self.
|
|
291
|
-
self.
|
|
300
|
+
self._tmc_logger.log("just the first 4 bytes:", Loglevel.DEBUG)
|
|
301
|
+
self._tmc_logger.log(str(snd[0:4].hex()), Loglevel.DEBUG)
|
|
302
|
+
self._tmc_logger.log(str(rtn[0:4].hex()), Loglevel.DEBUG)
|
|
292
303
|
|
|
293
304
|
status = True
|
|
294
305
|
|
|
295
306
|
if len(rtn) == 12:
|
|
296
|
-
self.
|
|
307
|
+
self._tmc_logger.log(
|
|
297
308
|
"""The Raspberry Pi received the sent bytes and the answer from
|
|
298
309
|
the TMC.""",
|
|
299
310
|
Loglevel.DEBUG,
|
|
300
311
|
)
|
|
301
312
|
elif len(rtn) == 4:
|
|
302
|
-
self.
|
|
313
|
+
self._tmc_logger.log(
|
|
303
314
|
"the Raspberry Pi received only the sent bytes", Loglevel.ERROR
|
|
304
315
|
)
|
|
305
316
|
status = False
|
|
306
317
|
elif len(rtn) == 0:
|
|
307
|
-
self.
|
|
318
|
+
self._tmc_logger.log(
|
|
308
319
|
"the Raspberry Pi did not receive anything", Loglevel.ERROR
|
|
309
320
|
)
|
|
310
321
|
status = False
|
|
311
322
|
else:
|
|
312
|
-
self.
|
|
323
|
+
self._tmc_logger.log(
|
|
313
324
|
f"the Raspberry Pi received an unexpected amount of bytes: {len(rtn)}",
|
|
314
325
|
Loglevel.ERROR,
|
|
315
326
|
)
|
|
316
327
|
status = False
|
|
317
328
|
|
|
318
329
|
if snd[0:4] == rtn[0:4]:
|
|
319
|
-
self.
|
|
330
|
+
self._tmc_logger.log(
|
|
320
331
|
"""The Raspberry Pi received exactly the bytes it has send.
|
|
321
332
|
|
|
322
333
|
the first 4 bytes are the same
|
|
@@ -324,7 +335,7 @@ class TmcComUartBase(TmcCom):
|
|
|
324
335
|
Loglevel.DEBUG,
|
|
325
336
|
)
|
|
326
337
|
else:
|
|
327
|
-
self.
|
|
338
|
+
self._tmc_logger.log(
|
|
328
339
|
"""The Raspberry Pi did not received the bytes it has send.
|
|
329
340
|
|
|
330
341
|
the first 4 bytes are different
|
|
@@ -344,13 +355,13 @@ class TmcComUartBase(TmcCom):
|
|
|
344
355
|
)
|
|
345
356
|
status = False
|
|
346
357
|
|
|
347
|
-
self.
|
|
358
|
+
self._tmc_logger.log("---")
|
|
348
359
|
if status:
|
|
349
|
-
self.
|
|
360
|
+
self._tmc_logger.log("UART connection: OK", Loglevel.INFO)
|
|
350
361
|
else:
|
|
351
|
-
self.
|
|
362
|
+
self._tmc_logger.log("UART connection: not OK", Loglevel.ERROR)
|
|
352
363
|
|
|
353
|
-
self.
|
|
364
|
+
self._tmc_logger.log("---")
|
|
354
365
|
|
|
355
366
|
return status
|
|
356
367
|
|
|
@@ -374,7 +385,7 @@ class TmcComUartBase(TmcCom):
|
|
|
374
385
|
self.driver_address = address
|
|
375
386
|
if driver_ioin_regs is None:
|
|
376
387
|
if self.test_com():
|
|
377
|
-
self.
|
|
388
|
+
self._tmc_logger.log(
|
|
378
389
|
f"Found device at address {address}", Loglevel.INFO
|
|
379
390
|
)
|
|
380
391
|
found_devices.append((address, None))
|
|
@@ -384,7 +395,7 @@ class TmcComUartBase(TmcCom):
|
|
|
384
395
|
if self.test_com(ioin):
|
|
385
396
|
# Get driver name from DRIVER_NAME attribute if available
|
|
386
397
|
driver_name = getattr(driver_ioin_reg, "DRIVER_NAME", None)
|
|
387
|
-
self.
|
|
398
|
+
self._tmc_logger.log(
|
|
388
399
|
f"Found device at address {address}: {driver_name}",
|
|
389
400
|
Loglevel.INFO,
|
|
390
401
|
)
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_dir.py
RENAMED
|
@@ -302,7 +302,12 @@ class TmcMotionControlStepDir(TmcMotionControl):
|
|
|
302
302
|
self._movement_phase = MovementPhase.DECELERATING
|
|
303
303
|
elif self._n < 0:
|
|
304
304
|
# Currently decelerating, need to accel again?
|
|
305
|
-
|
|
305
|
+
# Never re-accelerate while a soft stop is pending
|
|
306
|
+
if (
|
|
307
|
+
(steps_to_stop < distance_to)
|
|
308
|
+
and self._direction == Direction.CW
|
|
309
|
+
and self._stop != StopMode.SOFTSTOP
|
|
310
|
+
):
|
|
306
311
|
self._n = -self._n # Start acceleration
|
|
307
312
|
self._movement_phase = MovementPhase.ACCELERATING
|
|
308
313
|
elif distance_to < 0:
|
|
@@ -319,7 +324,12 @@ class TmcMotionControlStepDir(TmcMotionControl):
|
|
|
319
324
|
self._movement_phase = MovementPhase.DECELERATING
|
|
320
325
|
elif self._n < 0:
|
|
321
326
|
# Currently decelerating, need to accel again?
|
|
322
|
-
|
|
327
|
+
# Never re-accelerate while a soft stop is pending
|
|
328
|
+
if (
|
|
329
|
+
(steps_to_stop < -distance_to)
|
|
330
|
+
and self._direction == Direction.CCW
|
|
331
|
+
and self._stop != StopMode.SOFTSTOP
|
|
332
|
+
):
|
|
323
333
|
self._n = -self._n # Start acceleration
|
|
324
334
|
self._movement_phase = MovementPhase.ACCELERATING
|
|
325
335
|
# Need to accelerate or decelerate
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""
|
|
2
|
+
test for stopping a movement (StopMode) of _tmc_mc_step_dir.py
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import time
|
|
6
|
+
import unittest
|
|
7
|
+
from src.tmc_driver.tmc_2209 import *
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TestTMCMoveStop(unittest.TestCase):
|
|
11
|
+
"""TestTMCMoveStop"""
|
|
12
|
+
|
|
13
|
+
# with mres = 2: max speed = 2000 steps/s, acceleration = 4000 steps/s^2
|
|
14
|
+
# => distance needed to stop from max speed: v^2 / (2a) = 500 steps
|
|
15
|
+
MAX_SPEED_FULLSTEP = 1000
|
|
16
|
+
ACCELERATION_FULLSTEP = 2000
|
|
17
|
+
STOP_DISTANCE = 500
|
|
18
|
+
TOLERANCE = 25
|
|
19
|
+
|
|
20
|
+
TARGET = 5000
|
|
21
|
+
|
|
22
|
+
def setUp(self):
|
|
23
|
+
"""setUp"""
|
|
24
|
+
self.tmc = Tmc2209(None, TmcMotionControlStepDir(16, 20))
|
|
25
|
+
|
|
26
|
+
# these values are normally set by reading the driver
|
|
27
|
+
self.tmc.mres = 2
|
|
28
|
+
|
|
29
|
+
self.tmc.acceleration_fullstep = self.ACCELERATION_FULLSTEP
|
|
30
|
+
self.tmc.max_speed_fullstep = self.MAX_SPEED_FULLSTEP
|
|
31
|
+
self.tmc.movement_abs_rel = MovementAbsRel.ABSOLUTE
|
|
32
|
+
|
|
33
|
+
def tearDown(self):
|
|
34
|
+
"""tearDown"""
|
|
35
|
+
# make sure no movement thread outlives a failed test
|
|
36
|
+
self.tmc.tmc_mc.stop(StopMode.HARDSTOP)
|
|
37
|
+
thread = self.tmc.tmc_mc._movement_thread
|
|
38
|
+
if thread is not None:
|
|
39
|
+
thread.join(timeout=10)
|
|
40
|
+
|
|
41
|
+
def _wait_until_distance(self, distance, timeout=5):
|
|
42
|
+
"""block until the motor has travelled at least 'distance' steps
|
|
43
|
+
(absolute value) from position 0"""
|
|
44
|
+
start = time.time()
|
|
45
|
+
while abs(self.tmc.tmc_mc.current_pos) < distance:
|
|
46
|
+
self.assertLess(
|
|
47
|
+
time.time() - start,
|
|
48
|
+
timeout,
|
|
49
|
+
f"motor did not reach {distance} steps within {timeout}s",
|
|
50
|
+
)
|
|
51
|
+
time.sleep(0.001)
|
|
52
|
+
|
|
53
|
+
def _start_and_stop(self, target, stop_after, stop_mode):
|
|
54
|
+
"""start a threaded movement to 'target' and stop it with 'stop_mode'
|
|
55
|
+
once 'stop_after' steps are travelled
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
(position when stopped, final position, returned StopMode)
|
|
59
|
+
"""
|
|
60
|
+
self.tmc.tmc_mc.run_to_position_steps_threaded(target, MovementAbsRel.RELATIVE)
|
|
61
|
+
self._wait_until_distance(stop_after)
|
|
62
|
+
self.tmc.tmc_mc.stop(stop_mode)
|
|
63
|
+
pos_stop = self.tmc.tmc_mc.current_pos
|
|
64
|
+
result = self.tmc.tmc_mc.wait_for_movement_finished_threaded()
|
|
65
|
+
pos_end = self.tmc.tmc_mc.current_pos
|
|
66
|
+
return pos_stop, pos_end, result
|
|
67
|
+
|
|
68
|
+
def _assert_softstop_at_max_speed(self, target):
|
|
69
|
+
"""softstop while running at max speed must decelerate
|
|
70
|
+
over v^2 / (2a) steps and not run to the target"""
|
|
71
|
+
# the acceleration phase is 500 steps long,
|
|
72
|
+
# so after 1000 steps the motor runs at max speed
|
|
73
|
+
pos_stop, pos_end, result = self._start_and_stop(
|
|
74
|
+
target, 1000, StopMode.SOFTSTOP
|
|
75
|
+
)
|
|
76
|
+
travelled = abs(pos_end - pos_stop)
|
|
77
|
+
|
|
78
|
+
self.assertEqual(result, StopMode.SOFTSTOP)
|
|
79
|
+
self.assertNotEqual(
|
|
80
|
+
pos_end, target, "softstop had no effect, motor ran to the target"
|
|
81
|
+
)
|
|
82
|
+
self.assertAlmostEqual(
|
|
83
|
+
travelled,
|
|
84
|
+
self.STOP_DISTANCE,
|
|
85
|
+
delta=self.TOLERANCE,
|
|
86
|
+
msg=f"stopped at {pos_stop}, ended at {pos_end}: "
|
|
87
|
+
f"travelled {travelled} steps, expected about {self.STOP_DISTANCE}",
|
|
88
|
+
)
|
|
89
|
+
self.assertEqual(self.tmc.tmc_mc.movement_phase, MovementPhase.STANDSTILL)
|
|
90
|
+
|
|
91
|
+
def test_softstop_cw(self):
|
|
92
|
+
"""test_softstop_cw"""
|
|
93
|
+
self._assert_softstop_at_max_speed(self.TARGET)
|
|
94
|
+
|
|
95
|
+
def test_softstop_ccw(self):
|
|
96
|
+
"""test_softstop_ccw"""
|
|
97
|
+
self._assert_softstop_at_max_speed(-self.TARGET)
|
|
98
|
+
|
|
99
|
+
def test_softstop_during_acceleration(self):
|
|
100
|
+
"""softstop during acceleration must stop sooner than from max speed"""
|
|
101
|
+
pos_stop, pos_end, result = self._start_and_stop(
|
|
102
|
+
self.TARGET, 100, StopMode.SOFTSTOP
|
|
103
|
+
)
|
|
104
|
+
travelled = pos_end - pos_stop
|
|
105
|
+
|
|
106
|
+
self.assertEqual(result, StopMode.SOFTSTOP)
|
|
107
|
+
self.assertGreaterEqual(travelled, 0)
|
|
108
|
+
self.assertLess(
|
|
109
|
+
travelled,
|
|
110
|
+
self.STOP_DISTANCE,
|
|
111
|
+
f"stopped at {pos_stop}, ended at {pos_end}: travelled {travelled} steps",
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
def test_hardstop(self):
|
|
115
|
+
"""hardstop must stop (almost) immediately"""
|
|
116
|
+
pos_stop, pos_end, result = self._start_and_stop(
|
|
117
|
+
self.TARGET, 1000, StopMode.HARDSTOP
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
self.assertEqual(result, StopMode.HARDSTOP)
|
|
121
|
+
self.assertLessEqual(
|
|
122
|
+
abs(pos_end - pos_stop), 2, f"stopped at {pos_stop}, ended at {pos_end}"
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
def test_move_after_softstop(self):
|
|
126
|
+
"""a movement after a softstop must run normally to its target"""
|
|
127
|
+
self._start_and_stop(self.TARGET, 1000, StopMode.SOFTSTOP)
|
|
128
|
+
|
|
129
|
+
result = self.tmc.run_to_position_steps(0)
|
|
130
|
+
pos = self.tmc.tmc_mc.current_pos
|
|
131
|
+
self.assertEqual(result, StopMode.NO)
|
|
132
|
+
self.assertEqual(pos, 0, f"actual position: {pos}, expected position: 0")
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
if __name__ == "__main__":
|
|
136
|
+
unittest.main()
|
|
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
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com_spi_circuitpython.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/com/_tmc_com_uart_circuitpython.py
RENAMED
|
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
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_pio.py
RENAMED
|
File without changes
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_pio_base.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py
RENAMED
|
File without changes
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_step_reg.py
RENAMED
|
File without changes
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/motion_control/_tmc_mc_vactual.py
RENAMED
|
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
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_circuitpython.py
RENAMED
|
File without changes
|
|
File without changes
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py
RENAMED
|
File without changes
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py
RENAMED
|
File without changes
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_periphery.py
RENAMED
|
File without changes
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_logger/_tmc_logger_cpython.py
RENAMED
|
File without changes
|
{pytmcstepper-0.21.2 → pytmcstepper-0.21.4}/src/tmc_driver/tmc_logger/_tmc_logger_micropython.py
RENAMED
|
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
|