Coordinated Stepper Movement and Acceleration

Hi all,

I am working on a project hanging plotter project. I need to control stepper motors such that they accelerate and move in tandem at different speeds. I have found two solutions that approach this functionality differently.

The first is from iforce2d, who uses interrupts to allow processes to happen at the same time. They made a video about it which has links to their progression of files: Coordinated stepper motor control (arduino) - YouTube

The second is from Robin on this forum, who controls multiple motors on a clock timing at the common multiple of all motors' step intervals for a given set of desired total steps. This was well documented in their post here: Co-ordinated stepper movements using AccelStepper - Programming Questions - Arduino Forum

I appreciate iforce2d's interrupt method due to the ability to insert an e-stop into the interrupts. Robin's method seems easier to understand and allows for transitioning between speeds rather than going to zero between coordinated motions. Both of these methods are from 2017, so I wouldn't be surprised if people have more suggestions for getting this functionality now. I was wondering if there is now a better method through a new library or something. Or, if not, have people added to one of these methods since they were introduced to make it easier to adapt into a custom system?

Thanks!
Eric

ebergqu:
The second is from Robin on this forum,

Thanks for the link. I had completely forgotten about that Thread and I had not bookmarked it as I usually do.

I wrote a Reply in another Thread yesterday or the day before in which I said

It is not all that difficult to write your own code to make the motors move in sync. The way I have done it is, for a particular move, calculate the interval between steps for each motor, then find the highest common factor for the two time values. For example, suppose the slow motor needs a step every 130 millisecs and the fast motor needs a step every 38 millisecs then the HCF is 2 (I think). So set up a timer (using micros) that triggers every 2 millisecs and every 19th tick move the fast motor and every 65th tick move the slow motor.

This Simple acceleration code illustrates how acceleration can be applied.

As I said earlier I had forgotten about my Thread using AccelStepper so I don't really know which (if either) approach is better. The big limitation of the AccelStepper library is its relatively low maximum step rate - IIRC it's about 4000 steps per second on a 16MHz Arduino.

...R