I am trying to create a project of a small turret which incorporates object detection(this part is irrelevant I only wanted to give some clarity)
I searched for several forums but couldn't find a definitive answer:
My main objective is to use the turret in x and y axises with each having a nema17 step motor individually. I need to be able to find the fastest way possible for the turret the aim which means:
x for x axis length , y for y axis length, c(x,y) for the final point.
x(t) for the time to finish the distance of x from current point . (same for y(t) c(t))
Now what I am trying to accomplish is to reach the point c in the fastest way possible, which happens to be the longest duration between x(t) and y(t) (because the slower one would already be at its final point by the time the longer one gets there)
So if x > y --> x(t) > y(t) thus:
c(t) = x(t)
To be able to do that, i need to use both stepper motors simultaneously in different steps and I don't know if I'm able to to dat with an arduino uno.
I do not want to make it "seem" like the stepper motors are working simultaneously via moving each motor in small increments beacuse that would still actually be smaller than my goal.
I do have an option to use two arduinos (1 for each stepper motor) but I am asking if there is a more efficient option, if not, please give me some advice on my journey
I am sorry for not depicting a code but the code is not really written yet. I want to specify this detail first and then start coding.
I apologise if my description is too explanatory and long but I saw too many forums with the same question that lead to nowhere so that's why.
Note: Arduino's only objective is to move the turret and shoot, so other calculations and commands are done by a raspberry pi 4
You can absolutely control the motors in small steps one after the other. This is roughly the way most "Multitasking" in Industrial Controllers work. The Arduino should work fast enough, so it is not noticable to humans.
A 3D Printer has at least 4 Axis and a single core controller is perfectly fine.
You can move multiple steppers with synchronized motion:
The trick for coordinated motion is the Bresenham line drawing algorithm, where you step the fast axis at speed, and step the slow axis or not as needed by keeping track of the ratio between the slower stepping and the faster stepping.
AccelStepper has a multi-stepper option, but speed is limited.
Wouldn't using this method mean that the total time for turret to get to his location would equal to total time spent on getting to the x axis + total time spent on getting to the y axis?
I believe he means that x&y will be stepping as fast as possible, but the shorter axis motion will reach its setting first. It doesn't go directly, but goes diagonally at maxX & maxY travel speed until it reaches Y(X) and then continues stepping at maxX (maxY) speed along X (Y) until it reaches the destination.
Turret-wise, it starts turning both as fast as possible, and if it reaches azimuth or elevation first, it stops stepping along that axis, but continues at full speed along the other adjustment.
I am completely and utterly thrilled.
This is the most compact G-code interpreter I've ever seen.
Of course, I don't earn my money from internet research doing this hundreds of hours
but I spent dozens of hours researching to find a good implementation of the Bresenham algorithm
You won't find much and then it's either highly complicated and/or incomplete in the sense of entering G-code as a character string
==> code generates the step pulses coordinated for two axes
Thanks but it’s the MarginallyCleverRobots guy who wrote the code. I just implemented it on wokwi
It’s missing a few things as compared to more practical implementations: non-blocking, acceleration, and motion planning, but it is amazing with the parsing, axis sorting, and bresenham coordinated motion.