Trouble controlling two stepper motors at the same time

Hi,

I literally searched the whole internet for 2 days but I can't find any answer to my problem. In my current project I am trying to build a balancing robot. I wasn't statisfied using geared motors, so now I am trying with Stepper motors instead.

I am using following compontents:

  • Arduino Mega
  • Bipolar Stepper motor (2x)
  • DRV8825 driver (2x)
  • toggle switch
  • wires
  • LiPo Battery (11,1V & 3000mAh)

Here's my problem:
If i just run one motor everything works fine BUT the other motor and other driver board have to be fully disconnected!.
As soon as I connect the second motor (don't run it, just connecting the driver to the arduino and power supply and the motor to the driver) the first motor stops working.
To sum it up driving one motor works, but when connecting the second with the exact same wiring, motor 1 stops working (code stays the same).

What I did already:

  • I already checked the voltage at the driver board
  • Also checked all the wires
  • Switched the driver boards
  • Checked and switched all pins
  • Tried a Step Down Converter to 5DC to connect the driver boards to the battery instead of using Arduino 5V pins
  • tried different codes
  • decreased and increased the current using the potentiometer

Code I used:

I am really confused about this. I thought it's supposed to be pretty straight forward using two motors. As an mechanical engineer I am at the end of my knowledge now. I would be really happy if somebody could help me out with this.

Thanks in advance!

Sorry, forgot to specify the parts. I think this is helpful:

Motor data:
Rated Current (Single Phase): DC 1.5A. Rated Voltage: DC 3.6V.

Phase resistance(20°):2.4 X (1±15%)Ω/phase.

Phase Inductance(1KHz): 3.7 X (1±20%)mH/phase.

I think it's widely know but also the data from the motor driver:

drv8825:

@highfish1's wiring.PNG:

highfish1:
If i just run one motor everything works fine BUT the other motor and other driver board have to be fully disconnected!.
As soon as I connect the second motor (don't run it, just connecting the driver to the arduino and power supply and the motor to the driver) the first motor stops working.
To sum it up driving one motor works, but when connecting the second with the exact same wiring, motor 1 stops working (code stays the same).

What happens if you connect motor 2 only, without motor 1 connected?

The code you mention refers to a single motor not two !
Please include YOUR sketch inside code tags ( </> )

Could you also take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.

highfish1:
I would be really happy if somebody could help me out with this.

You need to post the program.

...R

Thank you for the replies.

Here is the code I am using to drive motor1:

#define dirPin 3                              //using Motor1
#define stepPin 2                            //using Motor1
//#define dirPin 13                              //using Motor2
//#define stepPin 12                            //using Motor2
#define stepsPerRevolution 200

void setup() {
  // Declare pins as output:
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}

void loop() {
  // Set the spinning direction clockwise:
  digitalWrite(dirPin, HIGH);
  // Spin the stepper motor 1 revolution slowly:
  for (int i = 0; i < stepsPerRevolution; i++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(2000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(2000);
  }
  delay(1000);
}

@pert

What happens if you connect motor 2 only, without motor 1 connected?

Motor 2 is running without any problems (changing dir and step pin in the program for motor 2) --> commenting pins from motor 1 out.

But then the same thing happens. As soon as I plug in the other driver board. None of them are working anymore.

@ballscrewbob

The code you mention refers to a single motor not two !

I am aware of that. But first I want to make one motor running while both driver boards are connected. Afterwards I can try to make them run at the same time.

But for now I can't run one motor while the other one is connected. It only works if the other one is disconnected.

highfish1:
Here is the code I am using:

That program only exercises a single motor. You need to post the program that has problems with two motors.

When posting code please use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor See How to use the forum

...R
Stepper Motor Basics
Simple Stepper Code

@Robin2

That program only exercises a single motor. You need to post the program that has problems with two motors.

As I tried to explain. I am aware that the code only runs one motor.

Example a:

  • Motor 1 and driver board 1 : connected
  • Motor 2 and driver borad 2 : disconnected

--> Motor 1 perfectly works, using the code above

Example b:

  • Motor 1 and driver board 1 : connected
  • Motor 2 and driver borad 2 : connected

--> Motor 1 doesn't work anymore, using the same code

First I have to fix this problem before I can run them at the same time

Edit: I found this guy using two motors with the same exact wiring. It looks like it works for him. This is why I am confused. Even his power supply is less powerful.
http://www.brokking.net/images/yabr/yabr-schematic_robot.pdf

This is likely to be a power problem - as LiPo's can usually produce huge currents without trouble I suspect
that your wiring is too thin or the switch is inadequate. If you have a multimeter monitor the voltage from
the battery when the second motor+driver are added to the circuit - it shouldn't drop very much, a fraction
of a volt.

Then monitor the voltage at the driver boards - this should be very close to the battery voltage.

By the way its a very good idea to use fuses with high current batteries, since otherwise a short circuit might
set the wiring on fire which is a "bad outcome".

Hi, thanks MarkT!

If you have a multimeter monitor the voltage from
the battery when the second motor+driver are added to the circuit - it shouldn't drop very much, a fraction
of a volt.

I already monitored the battery voltage with a multimeter (10,8V at the poles).
Then I monitored the voltage at each motor driver when both are connected. --> both got constant ~10,78V without any drops or something like that.

Then I disconnected the battery and tried with a power supply instead of a battery. Same thing. So my conclusion is, that the needed current can't be the problem.

@highfish1, please make a simple pencil drawing showing how you have everything connected and post a photo of the drawing.

It is too easy to misunderstand Fritzing diagrams and, also, it is impossible to read the pin labels.

...R

@Robin2

I just drawed the two scenarios. For both scenarios I use the same code:

#define dirPin 3                              //using Motor1
#define stepPin 2                            //using Motor1
#define stepsPerRevolution 200

void setup() {
  // Declare pins as output:
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}

void loop() {
  // Set the spinning direction clockwise:
  digitalWrite(dirPin, HIGH);
  // Spin the stepper motor 1 revolution slowly:
  for (int i = 0; i < stepsPerRevolution; i++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(2000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(2000);
  }
  delay(1000);
}

Scenario One: Motor 1 does work
Scenario Two: Motor 1 doesn't work

Now I want to figure out why Motor 1 stops working as soon as I connect the second motor. Even if I do not programming any actions for the motor 2.

If I got that going I want to add the second motor to the code. (Doing that later)

(MOD EDIT)

Thank's for the much clearer diagrams.

I confess I can't see anything wrong except that you don't have 100 microfarad capacitors across Vmot and GND at the DRV8825s. See the diagram on the Pololu DRV8825 web page.

Do you have the same problem if you switch the code to drive the other DRV8825?

I presume you have tested both motors and drivers separately.

What happens if you disconnect the 5v step down and just power the Mega using the USB cable?

...R

@Robin2

Thank you for helping out.
Already thought about the capacitor but I don't have any around.

Do you have the same problem if you switch the code to drive the other DRV8825?

Yes, same Problem.

I presume you have tested both motors and drivers separately.

Yes, if I use them separately everything works fine.

What happens if you disconnect the 5v step down and just power the Mega using the USB cable?

Without the step down and powering Arduino via. USB was my first setup.
Friend of mine then told me to use the step down and do not power the Arduino via USB, so that the Arduino and DRV8825 got the same ground.

But didn't work either.

Also tried different codes in the meantime (also libraries). But none of them are working either, so no need to post them.

ARE you using a plastic breadboard and jumper wires anywhere in the project?

Paul

Also are both DRV8825's setup for the correct current and each tested working with a motor?

highfish1:
Friend of mine then told me to use the step down and do not power the Arduino via USB, so that the Arduino and DRV8825 got the same ground.

But didn't work either.

When you are powering the Arduino through the USB connection you still need the 5v and GND connections between the Arduino and the DRV8825.

Just to clarify, my suggestion is to take the step-down device out of the system completely - at least for testing. The logic side of the DRV8825 uses very little current and can easily be powered from the Arduino 5v pin.

...R

@Paul_KD7HB

No I am using no plastic breadboard but I am using a few jumper wires.
Just because I didn't know if I will have to modify something.

@MarkT
Yes, I adjusted the potentiometer from low to high. Just because I thought that could be a problem.
Afterwards I set the current while measuring a winding in series with a multimeter.

I am pretty sure that the setup is right because they work when they are connected sperately.

@Robin2
Will try it right away!

@Robin2

When you are powering the Arduino through the USB connection you still need the 5v and GND connections between the Arduino and the DRV8825.

Just to clarify, my suggestion is to take the step-down device out of the system completely - at least for testing. The logic side of the DRV8825 uses very little current and can easily be powered from the Arduino 5v pin.

Tried it but unfortunately it didn't make a difference. Same problem still there :confused:

highfish1:
Tried it but unfortunately it didn't make a difference. Same problem still there :confused:

Very strange.

The behaviour you describe would be typical of a short circuit somewhere.

All I can think of is to undo all the connections and create them again from scratch in case there is an error.

...R