TM2130 packwge

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
PacoB
Posts: 2
Joined: Sun Nov 24, 2019 12:34 pm

TM2130 packwge

Post by PacoB » Sun Nov 24, 2019 12:36 pm

Hi! I'm a newbie oin ucPython. I'm changing from Arduino to python, because I start using it on several projects.
Is there any TMC package/example to control TMC stepper drivers?
Thanks in advance!

OutoftheBOTS_
Posts: 847
Joined: Mon Nov 20, 2017 10:18 am

Re: TM2130 packwge

Post by OutoftheBOTS_ » Sun Nov 24, 2019 8:03 pm

No there isn't a stepper driver package yet.

Python has advantages and disadvantages over C (ardunio being C with some libraries on top). I of the biggest thing python is bad at is it takes a little time to start up a function. Creating stepper motor step pules requires very fast calling of an interrupt call back so python is poor at this. 1 of the big advantages is python is that it is a scripting language that sits on top of C so it allows you to have the best of both worlds by combining C and Python. What is needed here is for the low level functionality to be written in C then wrapped up so that it can be called from python then you can write your high level application in python.

I have wrote code in python to turn 1 stepper at a time but it can only turn 1 stepper and is blocking while it turns see https://www.youtube.com/watch?v=sD4bG8hPYLQ&t=194s with code here https://github.com/OutOfTheBots/5x5x5_c ... stepper.py

I am working on C code for STM32F4 to be able to run multiple steppers in a non blocking way. At some point in the future I would like to wrap this up to be able to be called from python. The developers of MP are currently working on tools to wrap up compiled C code in to a .mpy file that can be called by python at runtime.

PacoB
Posts: 2
Joined: Sun Nov 24, 2019 12:34 pm

Re: TM2130 packwge

Post by PacoB » Mon Nov 25, 2019 7:37 am

Thanks for the info!!!

pidou46
Posts: 101
Joined: Sat May 28, 2016 7:01 pm

Re: TM2130 packwge

Post by pidou46 » Mon Nov 25, 2019 1:47 pm

I have made some experiments with Timer with a step / dir driver (like TM2130)

https://github.com/pidou46/ustepper/blo ... stepper.py

The general idea is to setup a PWM output and stop it with a Timer.

You just need to compute the Timer delay to achieve the desired stroke.

This solution is quite efficient, you can run the stepper at high speed (esp32 PWM can run at 40Mhz)

The code is non-blocking, so you can drive several steppers concurrently.

There are some drawbacks:

The position precision depends on Timer precision, I have found that delay of the Timer (in fact the callback function) is quite consistent to about 1300_us.
As the Timer can't be set in _us but only in _ms, you can compensate this delay by removing 1_ms to the Timer, the time precision would be around 300_us (the angular precision will depends of the stepper and the speed)

To achieve smooth rotation and high speed, it could be necessary to implement a speed ramp up (limited acceleration)
I do it by changing the microstepping setup on the fly.

I haven't made precision / repeatability test as of now, but it's in my todo list...

Hope this can help
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

likith1268
Posts: 15
Joined: Thu Aug 04, 2022 10:46 am

Re: TM2130 packwge

Post by likith1268 » Tue Aug 16, 2022 9:49 am

HI,

I'm working on stepper motor, I have three same kind of stepper motor connected to "pico". I need to merge all these individual codes into one single code and run the motor simultaneously.

Post Reply