Go Down

Topic: Moving 2 steppers at the same time different distance (Read 204 times) previous topic - next topic

javosegurag

I want to move 2 steppers, axis x and y at the same time but diferent distance, for example x axis to move 1000 steps and y axis move 500 steps.
I'm not using any stepper libary, do I need to use one?
Does any one know how to move independently both stppers at the same time?

Delta_G

I'm not using any stepper libary, do I need to use one?
You don't have to.  You could write the code yourself.  But it would certainly be easier to use code that's already known to work. 


Quote
Does any one know how to move independently both stppers at the same time?
Yes.  How you ask?  Well that depends on the rest of the code which you aren't showing. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

groundFungus


Paul_KD7HB

I want to move 2 steppers, axis x and y at the same time but diferent distance, for example x axis to move 1000 steps and y axis move 500 steps.
I'm not using any stepper libary, do I need to use one?
Does any one know how to move independently both stppers at the same time?

Moving two steppers different distances at the same time means one will have to move faster than the other. Is this what you want?

Paul

TomGeorge

Hi,
What are you using to drive the stepper motors?

Can you post link to data/spec of the Stepper and the driver.

Thanks... Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

Robin2

Note that the MultiStepper library does not use acceleration.

If you want to have coordinated movement with acceleration you will need to write your own code. It is not very difficult. The code in this link should help get you started.

I do the coordination by figuring out the time needed for the motor with move that takes the longest time. That will require (say) 533 steps in 8000 millisecs. Suppose a second motor is to do 284 steps in the same 8000 millisecs. Multiply the steps 533 * 284 = 151372 "ticks" or 1 tick per 53 microsecs. If you set up code to increment a counter every 53 microsecs then move motorA one step every 284 ticks and motorB every 533 ticks.

...R
Stepper Motor Basics
Simple Stepper Code
Two or three hours spent thinking and reading documentation solves most programming problems.

MarkT

Perhaps this is an xyproblem, and what is needed in a link to GRBL? https://github.com/grbl/grbl
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

javosegurag

Moving two steppers different distances at the same time means one will have to move faster than the other. Is this what you want?

Paul
Not necessarily, I just need to move to the wanted coordinates. If X has to move a smaller distance to then Y, X could stop when it reaches its distance and wait for Y.

Robin2

Not necessarily, I just need to move to the wanted coordinates. If X has to move a smaller distance to then Y, X could stop when it reaches its distance and wait for Y.
That is the simplest case and the AccelStepper library will easily deal with it.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

javosegurag

Hi,
What are you using to drive the stepper motors?

Can you post link to data/spec of the Stepper and the driver.

Thanks... Tom... :)
I'm using the A4988 stepper driver

javosegurag

You don't have to.  You could write the code yourself.  But it would certainly be easier to use code that's already known to work.  


Yes.  How you ask?  Well that depends on the rest of the code which you aren't showing.  
I actually have no code, because I try it with FOR but it has to move first the X axis and when it finish it passes to the second FOR and moves the Y axis, but I want it to move at the same time to make it a faster move

TomGeorge

I actually have no code, because I try it with FOR but it has to move first the X axis and when it finish it passes to the second FOR and moves the Y axis, but I want it to move at the same time to make it a faster move
Well how can we help you, what is FOR?
Can you tell us your electronics, programming, arduino, hardware experience?


If you want someone to write arduino code for you, then I suggest the "Gigs and Collaboration" section of this forum.


Thanks.. Tom.... :)
Everything runs on smoke, let the smoke out, it stops running....

javosegurag

Well how can we help you, what is FOR?
Can you tell us your electronics, programming, arduino, hardware experience?


If you want someone to write arduino code for you, then I suggest the "Gigs and Collaboration" section of this forum.


Thanks.. Tom.... :)
I use the FOR so that the steppers move the desire amount, but there is 2 problems with this method, 1. they move the same distance and then I have to use another FOR to move the extra amount the axis that has to go further, 2. (Most important problem) It seems like both steppers are moving at the same time, but is not true, it is moving one stepper 1 step and then 1 step to the other stepper, so they are moving at half the speed they were supposed to go.

Can I make a digitalWrite to 2 pins (variables) at the same time in the same line?

Code: [Select]

for(int x = 0; x < 200; x++)  // 1 rev is 200 steps
 {  
   digitalWrite(stepX,HIGH);
   delay(1);
   digitalWrite(stepX,LOW);
   delay(1);

   digitalWrite(stepY1,HIGH);
   delay(1);
   digitalWrite(stepY1,LOW);
   delay(1);
 }



Robin2

Can I make a digitalWrite to 2 pins (variables) at the same time in the same line?

Code: [Select]

for(int x = 0; x < 200; x++)  // 1 rev is 200 steps
 {   
   digitalWrite(stepX,HIGH);
   delay(1);
   digitalWrite(stepX,LOW);
   delay(1);

   digitalWrite(stepY1,HIGH);
   delay(1);
   digitalWrite(stepY1,LOW);
   delay(1);
 }



That should work. However having an interval between steps of 1 millisec (the second delay() ) implies a step rate of 1000 per second which is very fast without using acceleration. In fact, as you have 4 delay(1) calls in loop() the step rate will be about 250 per sec.

Look at the second example in this Simple Stepper Code to see how to control the stepper without using delay()

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up