pootle / tripipy

Simple python driver for Trinamic tmc5130 connected to Raspberry Pi
The Unlicense
37 stars 14 forks source link
python3 raspberry-pi stepper-motor stepper-motor-driver trinamic

tripipy

Python driver for Trinamic tmc5130 connected to Raspberry Pi

The Trinamic stepper control chips (like the tmc5130 and tmc5160) are FAR more sophisticated than the older stepper chips like the A4988. They are more expensive (around £15 mounted on a breakput board), but the added functionality dramtically reduces the compexity of the software needed to control the stepper, with goto and ramping available.

I have used the SPI interface to control the chip as this enables control of at least a couple of motors with minimal effort - 2 tmc5130s can be mounted on an adafruit prototyping hat making a nice compact controller.

This driver is far easier to install and run than the example code on the trinamic website. Their example code requres installation of both bcm2835 drivers and wiringpi, neither of which are standard on raspbian lite, and require local compilation.

I've run this with 2 motors on the base Raspiberry Pi SPI interface

Software Dependencies

This package is Python3, and requires pigpio to be running, it also uses guizero to provide a simple testing interface. The testing interface requires raspbian or raspbian-full.

sudo apt-get install python3-pigpio

sudo pip3 install guizero

Hardware dependencies

The driver uses 1 SPI channel per motor control chip, and 3 gpio pins: You should use the Raspberry pi gpio harware clock (GPIO 4) This can be shared if you have more than 1 motor controller. The other 2 pins (output stage enable and vcc-io / reset) can potentially be any ordinary gpio pin. The gpio pins and SPI settings are settable on the contructor interface for trinamicDriver.TrinamicDriver.

You will need a stepper motor and a suitable power supply.

Overview

There are 5 python files:

Installation

demo use

start the pigpio daemon if it is not already running I use sudo gpiod -c 256 or sudo pigpio

At the moment the gpio pins have defaults defined in the trinamicDriver module around line 36. These can be changed in the chipdrive module when it instantiates the class around line 133.

run the app:

tripipy-example

Select the mode to use:

goto target the chip drives the motor to reach the target - set a target posn before ppressing ACTION!

run forward the chip drives the motor at constant speed forwards

run reverse the chip drives the motor at constant speed in reverse

select the speed to use:

max rpm Runs at the maximum speed defined for the motor