help with mutiple steppers on arduino mega

Hello,

I was hoping to get some help on this project.

I have three stepper motors that I need to control independently. I would like to connect them to the ARDUINO MEGA direclty, is this possilble? to which pins?

is there a sample code i need to use? any libraries i need to download? want to simply make them sweep back and forth independently.

Regards,

karim.

So far as I know the Mega uses the same servo library as the Uno and you can use any pin.

http://arduino.cc/en/Reference/Servo#.Uy8PUYUVBrA

Steppers are not (rc-)servos. Stepper-motors do not sweep (on their own). Nor do servos make true steps. You would want to use a stepper motor driver (usually 1 for each), as the microcontroller pins cannot drive the stepper coils directly. Way too much current is required.

Please make sure you know what you are asking about, or show exactly what kind of motors you have.

Stepper tutorial:

https://www.sparkfun.com/tutorials/400

Example of (rc)servo use:

https://www.sparkfun.com/tutorials/304

Valen:
Steppers are not (rc-)servos.

The OP says steppers and yet I kept reading is as "servos". :o :oops:

I’d blame it on the MaiTais except that it was Sun AM when I answered, not Fri PM. :doh:

Ok, thank you.

But I am not connecting them directly to the Arduino, I am using an H-Bridge (SN754410) for each one!

On the other hand, I am using Sparkfun Steppers with 200 steps/rev. (product number 10848).

Would these help? I realize the three steppers will not work entirely by the Arduino, that is why I also got an external power supply outputting: 12 VCD, 3A.

I would appreciate your suggestion.

In that case, this should get you started.

http://www.hobbytronics.co.uk/stepper-motor-sn754410

I don’t know if the same pin numbers can be used on the Mega, though. Something you should look out for yourself…

Ok thank you I had written some code that I incorporated some lines from this link you provided to my code:

I connect the USB cable from Arduino to my PC but I cannot find the COM1 port there (not in Arduino MEga and not in Control Panel: Ports)!!

This is my setup (pictures attached - sorry for too many wirings and confusing background in advance).

This is the code I have used (very basic):

#include <Stepper.h>

#define STEPS 200

Stepper stepper1(STEPS, 0, 1, 2, 3);
Stepper stepper2(STEPS, 4, 5, 6, 7);
Stepper stepper3(STEPS, 8, 9, 10, 11);

void setup()
{
  stepper1.setSpeed(60);
  stepper2.setSpeed(60);
  stepper3.setSpeed(60);
  Serial.begin(9600);
}

void loop()
{
  
  Serial.println("CW");
  
  stepper1.step(STEPS);
  stepper2.step(STEPS);
  stepper3.step(STEPS);
  
  delay(500);
  
  Serial.println("CCW");
  
  stepper1.step(-STEPS);
  stepper2.step(-STEPS);
  stepper3.step(-STEPS);
  
  delay(500);
  
}

I would appreciate your help. Am I connecting to wrong pins to Arduino? Am I drawing too much current?? As you can see both the “ON” green and “L” yellow LEDs are lighting!! why is that?

Thank you,

Karim.

I’m sorry, but that is just too much of a bowl of spaghetti to make sense out of. Can you provide a drawing of which wire went into which pin-hole and for what function on the chips? It’s great that you did make the pictures though, unfortunately it’s to complicated to tell what goes on.

Also, does the Arduino work if you do not connect the motors to the drive chips? Or with just 1 connected? Have you tried to build it up in steps gradually? (testing in between) That may help identify the spot of a potentially improper connection. And reduce the amount of spaghetti. Once you get it to work, you can copy it for the other motors.

I would appreciate your help. Am I connecting to wrong pins to Arduino? Am I drawing too much current?? As you can see both the “ON” green and “L” yellow LEDs are lighting!! why is that?

I can make out that you connected a wire into pin 13. That is what the L-LED is connected to also. So if there is a high enough voltage on it then it will light up. The “ON” LED is ON when… well when the Mega is “on”! :wink: (to be more precise: when there is sufficient voltage on the 5v Vcc pin of it. which could be less than 5 volt and still light up)

As for drawing too much current, only a multimeter can tell you that. Make sure you have one among your tools, and start measuring.

Yes, sorry for that:

Here are the schematics I have used (attached).

Of course I have removed the 10k pot and i have added three steppers.

I am not sure what pins I am allowed to use then: you are correct, 13 is connected to the LED…where am i able to put the wires to then? which pins? for all three steppers? do I need to define pins for Arduino?

Yes I did this first for one motor, and it worked fine (of course with the pot) and then removed the pot and added the steppers.

Thank you.

I realize that drawing a picture of your own setup is a lot of work. But these images shown do not (likely) contain the problem. The problem is on your board. (breadboard most likely)

What if you build up the circuit surrounding the second driver chip and motor, but use the control wires (yellow in the last drawing) of the first motor section instead. As that pin -setup is known to work in your experience. Then you can isolate if the fault is in the 2nd driver circuitry/wires, or due to improper choice of the used pins or something else on the arduino side. I’m not familiar yet with the stepper library. So I can’t tell if it requires one of the pin to be able to do PWM. (then again, from the pcb silkscreen it looks like all pins can do PWM) But I doubt it, the circuit should do fine with normal digital level changes which are not automatic.

For what it’s worth. I bought a set of those kind of jumper wires recently. (not at SF though) And the first one I connected up happened to have had a broken wire out of the box. It was black, the custom color normaly chosen for ground, so my circuit wouldn’t work. Make sure you check for continuity on your wires with your multimeter.