GithubHelp home page GithubHelp logo

thalesfsp / tripipy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pootle/tripipy

0.0 1.0 0.0 80 KB

Simple python driver for Trinamic tmc5130 connected to Raspberry Pi

License: The Unlicense

Python 100.00%

tripipy's Introduction

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:

  • TrinamicDriver.py: (480 lines) This sets up and drives the SPI interface as well as the 3 straight gpio pins required by the tmc5130. I have tested this on the primary SPI interface using both available channels. It may not work on the Aux SPI interface as this may not support mode 3 SPI. It provides methods to read and write the chip's registers as well as chip reset and enabling the output stage.
  • tmc5130regs.py: (170 lines) This contains mappings for all the register names and some of the bit flag registers defined as IntFlags to make usage more readable. Each of the chip's registers is defined as an instance of a register class.
  • chipdrive.py: (250 lines) This contains a class tmc5130, each instance can control a single motor. There is a sample app (motors3.py) that can drive the motor displaying live status as the motor runs
  • treedict.py: a utility class that provides simple access to the chip register classes
  • motor2.py: a sample app, built using guizero to provide a simple gui to control the chip / motor.

Installation

  • install python3-pigpio:
sudo apt install python3-pigpio
  • git clone this repository or download the zip file and unzip it.
  • install it:
cd /<path_to_tripipy>/
sudo ./setup.py install

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

tripipy's People

Contributors

pootle avatar mag-seasony avatar gautamjain avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.