Hi,

I am using the AccelStepper Library to control three motors. Now I want to synchronize the movement of these stepper motors.

All of the motors have a fixed acceleration and a maximum speed. The distance they have to travel is always different. Now I want to make sure that all the motors start and stop their movement at the same time. Therefor I want to calculate the time how long each of the motors would need to reach their destination. In the next step I want to increase / decrease the maximum speed of motor 2 and motor 3, so they need the same time to reach their destination as motor 1 does.

At the moment I am ignoring the acceleration and just assume that it moves with a constant velocity, but this is just a rough approximation and causes the motors to stop at a slightly different time.

My idea would be, that I need to calculate how long the motors take to reach their maximum speed, calculate how far they move during the acceleration process, then do the same with the deceleration. Now I can check how much distance is left, where the motor will move with a constant velocity, and calculate this time as well. Now I can compare the times and have a more precise time estimation. However, since this is no linear function, I can not simply use a multiplicator to increase / decrease the speed of the other axes. So this seems like a really inefficient solution with a lot of trial and error to get the desired result.

Is there another solution to my problem? A library or maybe a function I am not aware of?