TMCM-Lib – Trinamic Motion Control Module Library for Python
This project aims to offer a clean high-level interface to the TMCM stepper motor controllers by Trinamic with TMCL firmware.
It currently only supports the module TMCM-3110 but others should be fairly easy to integrate.
Features
- Object-oriented design
- Documented public elements via type hints and docstrings
- Signaling errors via exceptions
- Blocking and non-blocking moving
- Expressing currents, velocities, and accelerations in physical units
- Reverting of motor direction per motor
- Setting, getting, and moving to coordinates
- Sending heartbeat messages automatically
Installing
pip install TMCM-Lib
Importing
import tmcm_lib
Examples
Configuring
from tmcm_lib import Port, Module
# Constructs the port to which the module is connected.
port = Port('COM1')
# Constructs the module connected to the port.
module = Module.construct(port)
# Enables the pull-up resistors of the limit switches of the module.
module.switch_limit_pullup_enabled = True
# Sets the activity of the limit switches of the module (True = high, False = low).
module.switch_limit_activity = True
# Gets the first motor of the module.
motor = module.motors[0]
# Sets the moving current of the motor in units of milliamperes.
motor.current_moving = 1_000
# Sets the standby current of the motor in units of milliamperes.
motor.current_standby = 100
# Sets the microstep resolution of the motor.
motor.microstep_resolution = 256
# Sets the velocity for moving the motor in units of fullsteps per second.
motor.velocity_moving = 800
# Sets the acceleration for moving the motor in units of fullsteps per square second.
motor.acceleration_moving = 400
# Enables the left limit switch of the motor.
motor.switch_limit_left.enabled = True
# Enables the right limit switch of the motor.
motor.switch_limit_right.enabled = True
Identifying
# Prints the model number of the module (e.g. "3110" for TMCM-3110).
print(module.model_number)
# Prints the firmware version of the module (e.g. "(1, 14)" for 1.14).
print(module.firmware_version)
Moving (Blocking)
Blocking moving waits while the motor is moving.
# Moves the motor relatively by the given distance in units of microsteps.
motor.move_by(512_000)
# Moves the motor absolutely to the given position in units of microsteps.
motor.move_to(0)
# Moves the motor in right direction until stopped (by a limit switch).
motor.move_right()
Moving (Non-blocking)
Non-blocking moving returns immediately after starting the moving.
# Starts moving the motor relatively by the given distance in units of microsteps.
motor.move_by(512_000, False)
# Waits while the motor is moving.
motor.wait_while_moving()
# Starts moving the motor absolutely to the given position in units of microsteps.
motor.move_to(0, False)
# Waits while the motor is moving.
while motor.moving :
...
# Starts moving the motor in right direction until stopped (by a limit switch or stop).
motor.move_right(False)
...
# Stops the motor.
motor.stop()
Motor union
A motor union is a set of motors that move simultaneously. Motors can move synchronously (i.e. they stop at the same time) or asynchronously.
from tmcl_lib import MotorUnion
# Constructs a motor union of the first and second motor of the module.
motor_union = MotorUnion(module, [0, 1])
# Moves the motor union synchronously absolutely to the given position in units of microsteps
# (i.e. first motor to first component; second motor to second component).
motor_union.move_to((512_000, 256_000))
Metadata
Release files for TMCM-Lib 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| TMCM-Lib-1.0.0.tar.gz | 17.6 kB | Without provenance | Details for TMCM-Lib-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| TMCM_Lib-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for TMCM_Lib-1.0.0-py3-none-any.whl |
Total release size: 37.9 kB
Release files / TMCM-Lib-1.0.0.tar.gz
| Download URL | TMCM-Lib-1.0.0.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8c64f69d25f1c30d48d9a5680f64219c69604b3314ca11516ae83a4905db00a
|
|
BLAKE2b-256 checksum How to use checksums |
e8ea2bbae99682e7c6d25f65bfb5f9b56ceff153a122c9fc458f180bed2717a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Release files / TMCM_Lib-1.0.0-py3-none-any.whl
| Download URL | TMCM_Lib-1.0.0-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
537202a0f910cc3f6101221211f5ea67f17fab5ce4f92c2b906276b21e34e9ef
|
|
BLAKE2b-256 checksum How to use checksums |
842cd46f68aeb1d44376fb6a729a627308683fe194b3c6b378e86a3e0016a961
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Security for TMCM-Lib 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.