stepper stops working

hi

I am driving a Nema 17, with the motor shield v2 from adafruit with the following sketch:

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h"

Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 

Adafruit_StepperMotor *myMotor = AFMS.getStepper(1, 2);


void setup() {
  AFMS.begin();
  myMotor->setSpeed(1);   
}

void loop() {
  myMotor->step(1, FORWARD, MICROSTEP); 
  }

I am powering directly to the shield with 12v 3000mah power supply.

Sometimes, when I plug the power supply, the stepper doesnt start turning, and sometimes, after some time of working correctly, it stops turning.

Any idea?
Where to start troubleshooting?

thanks.-

You need to post a link to the datasheet for your stepper motor. if it is a low impedance motor the motor shield won't be suitable.

...R
Stepper Motor Basics
Simple Stepper Code

It is the one adafruit offer together with the shield

the stepper gets pretty warm as well.-

That should work OK with the shield. It is normal for stepper motors to get hot - uncomfortable to touch.

Are you powering the Arduino separately from the motor?

...R

no, I have just one power supply, as described, connected to the shield.

camilozk:
no, I have just one power supply, as described, connected to the shield.

See what happens if you power the Arduino separately - with the USB cable, for example.

...R

Now I am powering the system through the dc barrel from the arduino. The first difference is that every time I connect the power, the system starts running, and this was not the case when connecting the power directly to the shield.

Now I have it turning to see if at any given point it stops working...

Does this mean is a shield problem?

camilozk:
Now I am powering the system through the dc barrel from the arduino.

I did not suggest that you "power the system".

I suggested that you power the Arduino with one power supply (a USB cable from your PC) and power the shield with the 12v supply.

...R

yes, I know what you suggested, but I didnt follow your suggestion, and I am anyway powering everything from the arduino´s dc barrel. Is that bad practice? (connecting power to the dc barrel, not not following your suggestion).

I didnt follow your suggestion,

Try following the suggestion.

It would be really nice, instead of simply following the suggestion, to be able to discuss what are the differences between powering the system through the dc barrel of the arduino, and powering the system from both the dc barrel of the arduino and the Vin of the shield with different power supplies.

I imagine that this is the way we are all going to learn more about why and how we do things, instead of simply following suggestions.

btw, I tried both methods by now, and both work.-

Motors often generate very large electrical disturbances in the power lines, which can reset the Arduino, cause it to malfunction, or even destroy it.

That is why we normally suggest that the Arduino be powered separately from the motor (with grounds connected), or to use power supply decoupling techniques to reduce the electrical noise getting to the Arduino.

camilozk:
It would be really nice, instead of simply following the suggestion,

The purpose of my suggestion was to get you to gather some useful diagnostic data. I don't have your hardware so I cannot do it on your behalf.

...R

Thank you very much guys for the valuable information!