Multiaxis stepper motors using RMT
Re: Multiaxis stepper motors using RMT
What about using some Trinamic 5160 drivers over spi/uart? Instead of step/dir.
- OlivierLenoir
- Posts: 126
- Joined: Fri Dec 13, 2019 7:10 pm
- Location: Picardie, FR
Re: Multiaxis stepper motors using RMT
TMC5160-EVAL seem to be an excellent product. Thanks for this information. I'll keep this in mind for another project.
For this project, it's out of budget. One TMC5160-EVAL costs 100 € where a lot of five DRV8825 cost 15 €. But agreed with you TMC5160-EVAL and DRV8825 are totally different in term of functions and power.
Olivier Lenoir
https://gitlab.com/olivierlenoir
https://gitlab.com/olivierlenoir
Re: Multiaxis stepper motors using RMT
How high voltage do you wnt to run? Check out the 5160 stepstick. Super cheap. And there is also the 5160 bob. If you dont have super high power check out trinamic 5161. 5161 have fets included.
-
- Posts: 3
- Joined: Mon Oct 04, 2021 4:34 am
Re: Multiaxis stepper motors using RMT
Hi, Guys.
Do you think this would actually work:
https://github.com/micropython/micropyt ... -933131381
Do you think this would actually work:
https://github.com/micropython/micropyt ... -933131381
Code: Select all
to accelerate/decelerate a stepper motor, RMT.write_pulses() would re-use same static pulse pattern,
by making this pattern fractal/self-similar, up to a clock frequency scale factor
and then update clock scale between RMT.write_pulses() invocations
by using rmt_set_clk_div()
- OlivierLenoir
- Posts: 126
- Joined: Fri Dec 13, 2019 7:10 pm
- Location: Picardie, FR
Re: Multiaxis stepper motors using RMT
On one axis, this seem to be doable, but this will depend on the number of acceleration and deceleration steps, because we are limited in memory.
Regarding multi-axis method, this will not work as it has been wrote today.
I plan to create g01() without acceleration / deceleration and an other one g01a() managing acceleration / deceleration.
Regarding multi-axis method, this will not work as it has been wrote today.
I plan to create g01() without acceleration / deceleration and an other one g01a() managing acceleration / deceleration.
Olivier Lenoir
https://gitlab.com/olivierlenoir
https://gitlab.com/olivierlenoir
-
- Posts: 3
- Joined: Mon Oct 04, 2021 4:34 am
Re: Multiaxis stepper motors using RMT
Here is a working experimental implementation:
https://gist.github.com/Andrei-Pozoloti ... 4de9c67267
Basic approach is:
* use piecewise interpolation for stepper motor pulse profile
* persist interpolation segments once, inside esp32.RMT.items store
* start sending pulses from items store with rmt.h | rmt_set_clk_div() and rmt.h | rmt_write_items()
* continue sending by switching between pulse patterns with rmt.h | rmt_register_tx_end_callback() system ISR
https://gist.github.com/Andrei-Pozoloti ... 4de9c67267
Basic approach is:
* use piecewise interpolation for stepper motor pulse profile
* persist interpolation segments once, inside esp32.RMT.items store
* start sending pulses from items store with rmt.h | rmt_set_clk_div() and rmt.h | rmt_write_items()
* continue sending by switching between pulse patterns with rmt.h | rmt_register_tx_end_callback() system ISR
-
- Posts: 3
- Joined: Sun Jul 03, 2022 11:37 am
Re: Multiaxis stepper motors using RMT
Hi OlivierLenoir,OlivierLenoir wrote: ↑Mon Oct 04, 2021 6:55 pmother one g01a() managing acceleration / deceleration.
I tested your library with a stepper motor, and it seems to have some software bottleneck. Namely this line:
https://gitlab.com/olivierlenoir/microp ... xis.py#L71
Code: Select all
def steps(self, steps, period=4, p_size=100):
"""Many 'steps' with position increment"""
self.set_dir(steps)
_d, _m = divmod(abs(steps), p_size)
pulse = (DRV8825_MP, max(DRV8825_MP, min(32767, period - DRV8825_MP)))
_wp = self._wp
loops = range(_d)
for _ in loops: # <-- here
_wp(pulse * p_size)
if _m:
_wp(pulse * _m)
self.pos += steps
I rotated a motor for 515.6 turns, and its quite audible when some of the loop begins (it is an audible glitch)
here is my testcode:
Code: Select all
rmt_step_pin = RMT(4, pin=Pin(4), clock_div=80)
# microstepping! 200/16, (4,40) @ clockdiv=80 is the minimum!
a = (4,500)*20 + (4,200)*20 + (4,100)*20 + (4,80)*20 + (4,60)*20 + (4,50)*20 + (4,40)*20 + (4,35)*20 + (4,34)*20 + (4,33)*20
v = (4,33)*200
def test(acceleration, velocity):
rmt_step_pin.write_pulses(acceleration)
loops = range(8250-1) # 16*515.6 - 1 , 515.6 turns (reduction gear ratio: 1:515.6)
for _ in loops:
rmt_step_pin.write_pulses(velocity)
test(a,v)
A clear step by step tutorial is required for me, I have never recompiled micropython itself.
- OlivierLenoir
- Posts: 126
- Joined: Fri Dec 13, 2019 7:10 pm
- Location: Picardie, FR
Re: Multiaxis stepper motors using RMT
Thanks for sharing your test.
As I mention in the README,
I will also improve acceleration / deceleration management using this document by implementing Taylor series approximation, because, currently acceleration / deceleration used in Multiaxis.g01() is not linear.
Until I finalize a new release, you can adjust the following Multiaxis attributes, Multiaxis.start_period, Multiaxis.period and Multiaxis.acceleration_rate.
As I mention in the README,
In branch bresenham, I'm implementing Bresenham's Algorithm to improve step frequency.- RMT, MutliAxis.g01(), manage start period (µs) (start frequency), target
period (µs) (target frequency) and acceleration / deceleration rate (µs per step)
/!\ still working on Axis.steps() acceleration / deceleration.
I will also improve acceleration / deceleration management using this document by implementing Taylor series approximation, because, currently acceleration / deceleration used in Multiaxis.g01() is not linear.
Until I finalize a new release, you can adjust the following Multiaxis attributes, Multiaxis.start_period, Multiaxis.period and Multiaxis.acceleration_rate.
Olivier Lenoir
https://gitlab.com/olivierlenoir
https://gitlab.com/olivierlenoir