Skip to main content

Python TMCL client library

Latest Comit Travis PyPI version pyversions

Clone of NativeDesign/python-tmcl

Python wrapper around Trinamic's TMCL serial interface for controlling TMCM stepper modules via a serial-to-rs485 converter.

Installation

Install using pip

> pip install pytmcl

Install without pip

> git clone https://github.com/LukeSkywalker92/pyTMCL.git
> cd pyTMCL
> python setup.py install

Usage

Use an RS485-to-serial adapter to connect your PC to one or more TMCM modules. Before starting you should check the modules' serial-address and baud-rate is a known value. Out of the box (warning: anecdotal) modules usually have an address of 1 and a baud-rate of 9600 but this is not guarenteed. The easiest way to check these values is by using the TMCL IDE on a windows machine.

If using multiple TMCM modules attached to the same rs485 bus you must ensure that each module is set to a different serial-address so that they don't clash.

Example usage (single-axis modules)

from serial import Serial
from time import sleep
import pyTMCL

## serial-address as set on the TMCM module.
MODULE_ADDRESS = 1

## Open the serial port presented by your rs485 adapter
serial_port = Serial("/dev/tty.usbmodem1241")

## Create a Bus instance using the open serial port
bus = pyTMCL.connect(serial_port)

## Get the motor
motor = bus.get_motor(MODULE_ADDRESS)

## From this point you can start issuing TMCL commands
## to the motor as per the TMCL docs. This example will
## rotate the motor left at a speed of 1234 for 2 seconds
motor.rotate_left(1234)
sleep(2)
motor.stop()

Example usage (multi-axis modules)

from serial import Serial
import pyTMCL

## Open the serial port presented by your rs485 adapter
serial_port = Serial("/dev/tty.usbmodem1241")

## Create a Bus instance using the open serial port
bus = pyTMCL.connect(serial_port)

## Get the motor on axis 0 of module with address 1
module = bus.get_module( 1 )

a0 = module.get_motor(0)
a1 = module.get_motor(1)
a2 = module.get_motor(2)

Example usage (callbacks)

from serial import Serial
from time import sleep
import pyTMCL

# serial-address as set on the TMCM module.
MODULE_ADDRESS = 0

# Open the serial port presented by your rs485 adapter
serial_port = Serial("COM4")

# Create a Bus instance using the open serial port
bus = pyTMCL.connect(serial_port)

# Get the motor
motor = bus.get_motor(MODULE_ADDRESS)
motor.axis.max_positioning_speed = 200
# From this point you can start issuing pyTMCL commands
# to the motor as per the pyTMCL docs. This example will
# rotate the motor left at a speed of 1234 for 2 seconds


def angle_to_steps(angle):
    return int(angle * 256 / 1.8)

def callback(arg1, arg2):
	print("Argument 1: " + str(arg1) + "  Argument2: " + str(arg2))

motor.move_relative(angle_to_steps(360), callback=callback, args=("Finished Moving", "Turned 360 Degree"))

API Overview

class Motor (bus, address, axis)

move_absolute (position, callback=None, args=(), kwargs={})

Move the motor to the specified absolute position. Call callback function with *args and **kwargs when position is reached. (callback is optional).

move_relative (offset, callback=None, args=(), kwargs={})

Move the motor by the specified offset relative to current position. Call callback function with *args and **kwargs when position is reached. (callback is optional).

reference_search (rfs_type)

Start a reference search routine to locate limit switches.

rotate_left (velocity)

Rotate the motor left-wards at the specified velocity.

rotate_right (velocity)

Rotate the motor right-wards at the specified velocity.

run_command (cmd)

Execute a predefined user subroutine written to TMCM module firmware

send (cmd, type, motorbank, value)

Send a raw TMCL command to the motor.

stop ()

Stop the motor

Metadata

Release files for pyTMCL 1.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyTMCL 1.0.10
File Size Uploaded Provenance Actions
pyTMCL-1.0.10.tar.gz 7.2 kB Without provenance Details for pyTMCL-1.0.10.tar.gz

Release files / pyTMCL-1.0.10.tar.gz

Download URL pyTMCL-1.0.10.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fde9aee35dee54b3db80964a0d0a91873faa5979c33d4ae146c2002f17d87d0c
BLAKE2b-256 checksum
How to use checksums
eac23d569a3a978d415d20d27b6622ab3ab973068951227588ddefc06918ecd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

Security for pyTMCL 1.0.10

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page