Go Down

Topic: Uno Stepper Motors H bridges and power supplies (Read 1 time) previous topic - next topic

buycris

Apr 03, 2012, 05:12 pm Last Edit: Apr 03, 2012, 05:13 pm by buycris Reason: 1
Hi everyone,
so i want to be able to control multiple stepper motors - 5 actually in total but currently experimenting with 2. Each has an h-bridge, is bi-polar, 0.23Nm holding torque and draws 330mA. rated at 12v however runs fine with more than that - apparently that gives me more torque if required.

I have each of them wired up and if i run the code to control either of them to do the task that i need them for (pumping), they work great. However if i try and run them both they jutter and shake. I then adjusted my code to run one after the other and then the first one works fine, but the second then shakes.

My question: How do you write the code to run them both - if that's what's required, secondly why are they shaking and not spinning even when i run one after the other?
Lastly, my power supply is mains dv 12v however reading on internet, i could put that power supply in series with another one to get more voltage - seems to work fine, giving me a total output of 17v. however one of the power supplies is rated at 0.5amps, the other at 2amps. As far as i understand my max available current draw is still 0.5amps?

I just cant find a shop that will sell me variable voltage supply with a higher current rating...

Code: [Select]
#include <Stepper.h>
#define motorSteps 200     // change this depending on the number of steps
#define motor1Pin1 2
#define motor1Pin2 3
#define motor1Pin3 4
#define motor1Pin4 5
#define motor2Pin1 6
#define motor2Pin2 7
#define motor2Pin3 8
#define motor2Pin4 9

Stepper Stepper_1(motorSteps, motor1Pin1,motor1Pin2,motor1Pin3,motor1Pin4);
Stepper Stepper_2(motorSteps, motor2Pin1,motor2Pin2,motor2Pin3,motor2Pin4);
void setup()
{
    int i;
    int j = 0;
}
void loop()
{
  for (i=5;i<50;i++){
  Stepper_1.setSpeed(i);
  Stepper_1.step(2);
  }
  while (j<1000)
  {
      Stepper_1.step(1);
     j++;
  }
  delay(25);
  j=0;
for (i=5;i<50;i++){
  Stepper_2.setSpeed(i);
  Stepper_2.step(2);
  } 
   while (j<1000)
  {
      Stepper_2.step(1);
      j++;
  }
}

Grumpy_Mike

Quote
How do you write the code to run them both

You implement a processes like Bresenham algorithm http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm, where both motors are stepped together ( or not ) after the appropriate delay.

Quote
and draws 330mA

That is normally per coil so for two motors you have four coils and so 330 * 4 = 1.32 Amps. Your power supply can not supply this much current and that is why you are seeing the juddering.

Quote
i could put that power supply in series with another one to get more voltage

Yes.
Quote
As far as i understand my max available current draw is still 0.5amps?

Yes.

buycris

#2
Apr 03, 2012, 05:23 pm Last Edit: Apr 03, 2012, 05:25 pm by buycris Reason: 1
Thanks Grumpy_Mike,
and do you need to accelerate stepper motors as opposed to just asking them to run at full speed instantly?
And am i more likely to be succesful running with a 9v power supply that can handle 2amps rather than a 12v supply that can only handle 0.5 amps?
you don;t know of an example anywhere for running two steppers?

Grumpy_Mike

Quote
do you need to accelerate stepper motors as opposed to just asking them to run at full speed instantly?

If you accelerate and decelerate you can get a higher top speed.

Quote
am i more likely to be succesful running with a 9v power supply that can handle 2amps rather than a 12v supply that can only handle 0.5 amps?

Yes as your setup takes well over 0.5 Amps you can not run it at all on the lower capacity supply.

Quote
an example anywhere for running two steppers?

There are lots. Look at the RepRap project, or my own CNC conversion
http://www.thebox.myzen.co.uk/Hardware/CNC_Conversion.html
But these are likely to be several steps up on the sort of code level you are at currently.

buycris

how would you turn two on simultaneously with code more simple than yours? i.e do you do one step on one, then a step on the other etc etc to create the "illusion" they are running simultaneously or something????

Grumpy_Mike

Quote
how would you turn two on simultaneously

You do not turn on a motor, it is on all the time. You step it, that is you give it a pulse on the step pin or you change the control outputs.
So delay and step and delay. You can skip stepping one of the motors every other time if you want it to run at half the speed of the other.

What software are you using? The stepping motor library is not suited to driving more than one motor.

buycris

Yeah Im using Arduino 1.0 and Stepper.h
Is there a better library for this task?

Grumpy_Mike

Quote
Is there a better library for this task?

As far as I know there is no library that allows multiple motors to be driven simultaneously.

Go Up