Products > Programming

Synchronize stepper motor movement

(1/3) > >>

meba:
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?

langwadt:
https://github.com/gnea/grbl/

DiTBho:

--- Quote from: langwadt on April 09, 2021, 07:40:36 pm ---https://github.com/gnea/grbl/

--- End quote ---

Good find!

beanflying:
Lots of options but all would be best resolved by treating them as separate drives. Also 'TIME' is not a good measure of amount of movement but 'Calibrated Step Count' is. Time to max speed and acceleration is controlled by a bunch of unspecified (by you) variables such as weight (mass of what is moving), direction (with or against gravity), resistance of that mass from the slides/bearings or whatever etc..... so time will never be truly accurate.

So Calibrated counting of steps relies on no skipped or missed steps (correctly sized stepper and adequate current and driver) then calibration for distance of travel against a known number of steps to get this value.

Have a look locally for a 3D Printer board and use a slightly tweaked version of the likely Marlin version of GRBL and it should already have built in a fixed move option. So all you need to do is change it to move all three as one.

Arduino Mega and a Ramps board and Stepper drivers. Now a bit old school but works well.

MKS (combined Arduino and Ramps board more or less) plenty on evilbay for not much.

So unless I have got your plan wrong  ;) (possible) look at these sorts of solutions and if nothing else play lots and learn as you go.

DiTBho:

--- Quote from: camila on April 10, 2021, 10:22:13 am ---Better to find something out from the arduino forum regarding the library or funtion of it

--- End quote ---

In my case I do not like Arduino, but I like to have examples, and I am willing to rewrite that code entirely, so it's a good "get started" material  :D

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod