Skip to main content

Read/Write to Trinamic motion controller TMC5160 via the uart interface

Project description

A python package to read/write to registers to TMC motion controllers via the uart. This package includes register addresses for the TMC5160 as specified here:

https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC5160A_Datasheet_Rev1.14.pdf

Other TMC controllers could be adapted by providing the register include file with its specific register addresses.

There are some test scripts in the ./bin directory. Tested on both Windows and Raspberry PI with a USB/RS485 adapter to a custom board with a TMC5160 chip with uart pins broken out.

There are two read functions. read_int() and read_reg(). The first returns a 32 bit value and second returns a 4 byte object.

Repository can be found:

https://github.com/troxel/TMC_UART

Synopsis

from tmc_uart import TMC5160_UART
from tmc_uart import tmc5160_reg as reg

drvconf = { 'comm_dev':'/dev/ttyUSB0', 'baud':500000 }
drv = TMC5160_UART(drvconf)

mtr_id = 0

ifcnt0 =  drv.read_int(0, reg.IFCNT)
drv.write_reg(mtr_id,reg.GCONF,0x0000000C)
ifcnt1 =  drv.read_int(0, reg.IFCNT)
print("IFCNT before and after: {} {}".format(ifcnt0,ifcnt1))

gconf = drv.read_reg(mtr_id, reg.GCONF)
print("GONF = ",gconf)

xactual = drv.read_int(mtr_id,reg.XACTUAL)
print("XACTUAL = ",xactual)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tmc_uart-0.1.3.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

tmc_uart-0.1.3-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page