Stepper motor stops after few 2 seconds

Hi,

I have been driving my clay extruder stepper motor with arduino and motorshield for quite some time, but after I changed motor (same kind), it stops after 2 seconds, even though it should just keep going. Do you have an idea, what can be the problem? Attached you will find photos of the setup. I would be very greatful for advice! Caroline

PS: The script I use is this:

#include <TimerOne.h>
TimerOne t1;
int drehzahl = 0;
int aktDrehzahl = 0;

void timerSetzen(int aktDrehzahl);

void setup()
{

pinMode(12, OUTPUT);
//t1.initialize(100000); // Initialisiert den Timer mit 100000 microseconds
t1.attachInterrupt( timerIsr ); // Serviceroutine
t1.stop();

Serial.begin(115200);
while(!Serial);
Serial.println(“Hallo bin bereit!”);

}

void loop()
{
if (Serial.available() > 0)
{
drehzahl = Serial.parseInt();
if (drehzahl > 9 ) //Einstellige Werte stoppen den Motor
{
if(drehzahl < 70){ //Drehzahlen unter 70 verhindern
drehzahl = 70;
aktDrehzahl = 70;
timerSetzen(drehzahl);
Serial.print("Drehzahl aktuell: ");
Serial.println(aktDrehzahl);
}
if(drehzahl > 600){ //Drehzahlen bis 450 U/min begrenzen
drehzahl = 600;
}
while (drehzahl != aktDrehzahl){ //Motor beschleunigen (Drehpoti Simulation)
if (aktDrehzahl < 70)
{
aktDrehzahl = 70; //Wenn der Motor steht mit 70 U/min starten
timerSetzen(aktDrehzahl);
}
if ((drehzahl - aktDrehzahl) > 10){
aktDrehzahl += 10;
}else {
aktDrehzahl = drehzahl;
}
timerSetzen(aktDrehzahl);
Serial.print("Drehzahl aktuell: ");
Serial.println(aktDrehzahl);
}

}else
{
t1.stop();
aktDrehzahl = 0;
Serial.println(“Motor hält”);
}
}

}

/// --------------------------
/// Custom ISR Timer Routine
/// --------------------------
void timerIsr()
{
// Motor step impulse
digitalWrite( 12, digitalRead( 12 ) ^ 1 );
}

void timerSetzen(int drehzahl)
{
float tmp = 1 / ((float) drehzahl / 60 * 400) * 1000000ul;
t1.initialize(tmp);
if (drehzahl < 350) //Warten bis Motor Drehzahl erreicht hat
{
delay(30);
}else
{
delay(100);
}
}

Please post a link to the datasheet for your stepper motor.

Please also modify your post and use the code button </>

so your code 
looks like this

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

Your code is too long for me to study quickly without copying to my text editor.

And please make your images visible in your Post so we don’t have to download them. See this Simple Image Posting Guide

…R

Please identify all the hardware, datasheets if at all possible. Is that 5V supply driving the stepper controller, cause usually you need a higher voltage for that. It could be the controller is simply under-voltage.