Package: pyTMCL
Python TMCL client libraryClone ofNativeDesign/python-tmclPython wrapper around Trinamic's TMCL serial interface for controlling TMCM stepper modules
via a serial-to-rs485 converter.InstallationInstall using pip>pipinstallpytmclInstall without pip>gitclonehttps://github.com/LukeSkywalker92/pyTMCL.git
>cdpyTMCL
>pythonsetup.pyinstallUsageUse 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
of1and a baud-rate of9600but this is not guarenteed. The easiest way to check
these values is by using theTMCL IDEon a windows machine.If using multiple TMCM modules attached to the same rs485 bus youmustensure that
each module is set to adifferentserial-address so that they don't clash.Example usage (single-axis modules)fromserialimportSerialfromtimeimportsleepimportpyTMCL## serial-address as set on the TMCM module.MODULE_ADDRESS=1## Open the serial port presented by your rs485 adapterserial_port=Serial("/dev/tty.usbmodem1241")## Create a Bus instance using the open serial portbus=pyTMCL.connect(serial_port)## Get the motormotor=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 secondsmotor.rotate_left(1234)sleep(2)motor.stop()Example usage (multi-axis modules)fromserialimportSerialimportpyTMCL## Open the serial port presented by your rs485 adapterserial_port=Serial("/dev/tty.usbmodem1241")## Create a Bus instance using the open serial portbus=pyTMCL.connect(serial_port)## Get the motor on axis 0 of module with address 1module=bus.get_module(1)a0=module.get_motor(0)a1=module.get_motor(1)a2=module.get_motor(2)Example usage (callbacks)fromserialimportSerialfromtimeimportsleepimportpyTMCL# serial-address as set on the TMCM module.MODULE_ADDRESS=0# Open the serial port presented by your rs485 adapterserial_port=Serial("COM4")# Create a Bus instance using the open serial portbus=pyTMCL.connect(serial_port)# Get the motormotor=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 secondsdefangle_to_steps(angle):returnint(angle*256/1.8)defcallback(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 Overviewclass Motor (bus, address, axis)move_absolute (position, callback=None, args=(), kwargs={})Move the motor to the specifiedabsoluteposition.
Call callback function with*argsand**kwargswhen position is reached. (callback is optional).move_relative (offset, callback=None, args=(), kwargs={})Move the motor by the specified offsetrelative to current position.
Call callback function with*argsand**kwargswhen 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 firmwaresend (cmd, type, motorbank, value)Send a raw TMCL command to the motor.stop ()Stop the motor