Two axis interpolation + acceleration

1,996 views
Skip to first unread message

Sergi Valls

unread,
May 24, 2013, 4:45:11 PM5/24/13
to accels...@googlegroups.com
Hi all,

I have been testing accelstepper together with two friends, very good piece of software.
We are writing (or at least trying) a library for accelstepper to draw arcs, circles and interpolation lines with two axis.

My configuration is this:
- Two 4Nm motors
- Two 9A Drivers with 10x microstepping
- Accelstepper with two pins: direction and pulse

I will like to do partial circles and linear interpolation but with acceleration/deceleration.
For example that will be a test program:
- Convex 60º arc radius 10 mm.
- 30º straight line
- Concave 30º arc radius 4 mm.

Any suggestions will be greatly appreciated.

Sandy Noble

unread,
May 24, 2013, 4:59:39 PM5/24/13
to accels...@googlegroups.com
Hi Sergi, accelstepper probably isn't the right tool for the job because it does acceleration based on a target position on only one axis.  To draw a curves or arcs, or even straight line with a cartesian bot of some sort, your acceleration needs to be coordinated between two motors - the speed curve needs to be planned differently, and I don't think accelstepper has the features to help with that.

It's not a straightforward task, but if you want smooth movement and acceleration, there's a few things out there that does it already - have a look at GRBL to start with, it is ace.


sn

Carlos Salgado Garcés

unread,
May 24, 2013, 5:04:42 PM5/24/13
to accels...@googlegroups.com
Hi Sergi,
Here's is Carlos, from Madrid. Don't you need real time feedback to control microstepping?
Good luck with your project.


2013/5/24 Sergi Valls <serg...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Sergi Valls

unread,
May 25, 2013, 5:52:26 PM5/25/13
to accels...@googlegroups.com
Hi Sandy,

First thing, my goal it is to do all this without the need of any external computer or preloaded "G code". And users can input (for example with a LCD) what the motors have to do, so we don't know previously what movements will the motors do.
Having that in mind, I can't use software like GRBL, because it is a G-code interpreter, however I can have a look at the software to see how do they do it, although I think it will not be easy...

Based on your answer, without having test it deep enough, then I think I can simulate acceleration regulating the call to "run". For example: If I set a target position for "X" and "Y" axis, then I can call "run" first at 0,1 s. interval and then more often until I reach the desired speed.
Thing is this software must balance the call to "X" and "Y" axis to do the desired movement.

The idea is to use the accelstepper facility to control the motors, and implement a software layer, so I can say to the software when programming the Arduino:
moveArc(1000,60,20,X,Y);
Where: moveArc is move in an arc shape, 1000 is the arc radious in mm, 60 is the amount of degrees to move from the 360º possible of a complete Arc, 20 is the start angle, and X Y the axis to interpolate.


El divendres 24 de maig de 2013 22:59:39 UTC+2, Sandy Noble va escriure:

Sergi Valls

unread,
May 25, 2013, 5:58:10 PM5/25/13
to accels...@googlegroups.com
Hi Carlos,

I'm from Barcelona, nice to meet you.
It is supposed that all the axis will move when we send the pulses, normally there is no delay: the motors move or not.
It is possible also to implement a simple feedback system, but only as a way for safety: this way we implement an encoder (via an encoder connected to the stepper or directly with a servo) and when the Nr. of pulses and efective movement of the motor doesn't match, the driver gives an error which the Arduino reads.
Of course there are more complex system with compensation and linear encoders, however this is not the object of this project, and anyway to do such a complex task then it is better to buy a Fanuc or Fagor CNC.

El divendres 24 de maig de 2013 23:04:42 UTC+2, Carlos Salgado Garcés va escriure:

Sandy Noble

unread,
May 25, 2013, 7:03:18 PM5/25/13
to accels...@googlegroups.com
Right I see what you mean.  But I'd still have a look at GRBL - regardless what format you get the command into the machine (G code or an internal command), it still boils down to planning a series of moves to a series of coordinates, and the acceleration curve has to take the full length of the arc into account, not just each individual segment.

I've done something similar in my polargraph code, for drawing segmented lines using a hanging-v plotter.  I didn't use the built-in acceleration features of accelstepper, but instead I stole the old acceleration routine (desiredSpeed()) from accelstepper, and used it to work out and set a speed for each segment in the line.  So each line gets chopped into 100 pieces (for example), and I run each piece at a speed calculated using desiredSpeed().  It's a pretty crude way of doing it, but it works for simple stuff, albeit with a lot less finesse than accelstepper itself.  My code is https://github.com/euphy/polargraph_server_mega/blob/master/exec.ino drawBetweenPoints() and desiredSpeed().

sn




--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Sandy Noble

Sergi Valls

unread,
May 26, 2013, 5:33:08 AM5/26/13
to accels...@googlegroups.com
Hi Sandy,

Thanks a lot for your answer.
I was looking at GRBL code, and it is very well though... and extremely complex for my poor mathematic skills!
I found an image which ilustrates very well what we plan to do:

Imatge en línia 1
It is a saw shape movement. To do it we need to interpolate only two axis X and Y, but we need more axis which goes freely, for example the indexer, lets call it A axis.
The program will ask the user for positions Nr. 1 up to 6, and will repeat this shape hundreds of times, until user changes one of the 6 variables.
The problem is that I want to run 2 axis... or 10, but always interpolating only two of them, and programs like GRBL are very focused on 3 axis machining.
I thought accelstepper was a very good strating point, because I will only need to care about the movement formulas/mechanics, but when interpolating comes into play I have two problems:
- Mathematics
- Acceleration as a whole, not as a part of a movement.

I found two interesting info's:
- The Bresenham algorithm
- The smoothstep


2013/5/26 Sandy Noble <sandy...@gmail.com>
image.jpeg

Anteneh Mekonnen

unread,
Apr 6, 2018, 2:25:23 PM4/6/18
to accelstepper
Hi Sergi,

Did you succeed in your project to draw arcs and curves without using GRBL? I have started a kind of project for which I am writing a code to run two stepper motors to draw a curve with speed control. Please  help me?

jeff leonard

unread,
Apr 9, 2018, 12:32:46 PM4/9/18
to accels...@googlegroups.com
Hi Anteneh,
How's your code coming along? I am using accelstepper to draw circles, arcs, ovals and Bézier curves. 
--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Сергей Петруня

unread,
Nov 20, 2018, 6:49:20 PM11/20/18
to accelstepper
Hi  JL, 

if you have code to share, I would be glad to have one. 
Currently, I am working on a project, where I should implement a drawing machine with 3 steppers. Firstly  I need to draw a square. Have some ideas about, but maybe you have something that already works.

BR 

понедельник, 9 апреля 2018 г., 18:32:46 UTC+2 пользователь JL написал:

Tyler Gerritsen

unread,
Nov 21, 2018, 12:32:24 PM11/21/18
to accelstepper
Hi Sergi,

I'm new to this group but recently did some modifications to AccelStepper and MultiStepper to interpolate multiple axis with acceleration.  It's based on Bresenham's Algorithm and is very efficient.  Only light modifications were made to AccelStepper (making a few variables public) and I added the new functions to MultiStepper.

Let me know if you are interested and I can share.  Right now the modifications aren't very clean, I need to fix that.

One of the problems with CNC machines is they can make LOTS of small lines to make a complex shape.  AccelStepper doesn't look forward, so it will stop at the end of each tiny line.  GRBL does look forward and won't stop at the end of a small line if there is another one ahead.

Tyler

Сергей Петруня

unread,
Nov 22, 2018, 6:33:19 AM11/22/18
to accelstepper
Hi Tyler,
yes, I`m interested. It would be helpful in to see another solution. I can also send you later my solution if you are interested in. 


it would be nice to have yo
среда, 21 ноября 2018 г., 18:32:24 UTC+1 пользователь Tyler Gerritsen написал:

luk

unread,
Mar 16, 2020, 12:33:43 PM3/16/20
to accelstepper
Hi Tyler

Can you send me your library with acceleration?

Carlos Suarez Gonzalez

unread,
Aug 10, 2023, 9:08:32 PM8/10/23
to accelstepper
Hi Tyler, I'm in a project for my woodworking shop and I need to do the same, i need to move two axis with acceleration, please can you send me your library,, i really will appreciate that.

Ralph Hulslander

unread,
Aug 11, 2023, 11:50:47 AM8/11/23
to accels...@googlegroups.com
Tyler, I also would like a copy of your code.

Ralph

Reply all
Reply to author
Forward
0 new messages