Stepper Motor Maximum Frequency

Does anyone know the maximum frequency of a nema 17 stepper motor on microstep mode? The motor does not want to go faster than 10000 pulse/sec. It could be a problem in the code, but the code works at lower frequencies.

// Givens
long ta = 3e5;     // acceleration time (microsec)
long td = 3e5;     // deceleration time (microsec)
long Vm = 3200;    // steady state velocity (pulse/sec)
long Pt = 3200;    // total number of pulses for move (1600 steps per rev)

// Other variables
long dly;           // stepper pulse delay (microsec)
long t = td/9;      // current time (microsec)  -  You need to seed the initial time with something > 0 so you don't calculate too long of a delay
long t12 = 1e6 - ta - td;           // time during constant velocity (microsec)

int count = 0;
int loopcount = 0;
int dircount = 0;

const int loopdelay = 1;

#define dirPin 4   //red=dirPin, white=stepPin, black=digitalGND
#define stepPin 3


void setup() {

 Serial.begin(9600);
  
 pinMode(dirPin, OUTPUT);
 pinMode(stepPin, OUTPUT);
 
}


void loop() {

  loopcount++;

  //Serial.println(loopcount);
  
if (t>=(ta+t12+td)){

  dircount++;

  t=td/9;
  
  if ((dircount % 2) == 0){
    digitalWrite(dirPin,LOW);
    Serial.println("HIGH");
  }
  else {
    digitalWrite(dirPin,HIGH);
    Serial.println("LOW");
  }
}

else{
  
 // Decide which part of the velocity curve your at
 if (t<ta){                                        // Acceleration
   dly = (ta)/(2*(Vm/1e6)*t);
   //Serial.println("Acceleration");
 } 
 else if (t>=ta && t<(ta+t12)){                    // Constant velocity
   dly = 1/(2*(Vm/1e6));
   //Serial.println("Constant Velocity");
 }
 else if (t>=(ta+t12) && t<(ta+t12+td)){           // Slow down
   dly = 1/(2*((Vm/1e6)-(Vm/(1e6*td))*(t-ta-t12)));
   //Serial.println("Deceleration");
 }
 
 t = t+2*dly; // update the current time
 //Serial.println(dly);
 
 // Move stepper one pulse using delay just calculated
 digitalWrite(stepPin, HIGH);
 delayMicroseconds(dly);
 digitalWrite(stepPin, LOW);
 delayMicroseconds(dly);
 count ++;

 // The move is finished
 if (t>=(ta+t12+td)){
  
   loopcount=0;
   count=0;
   
   Serial.println("reset");
 
   delay (loopdelay);
 }
}
}
```

There are a wide variety of NEMA 17 stepper motors of different sizes and electrical specifications. You might try to find a datasheet for your particular motor to see if they provide a pull-out torque curve, which will give you a general idea of the maximum speed. There are many factors in a system that will affect the maximum speed, but the torque available from a stepper motor generally decreases as the rotation speed increases.

-Nathan

The stepper motor does get up to speed but only after a large jump. Because the stepper motor jumps are limited, requesting higher frequencies will cause the motor to stall. The amount of torque should not be a problem when it gets up to the high speed because the load is not too heavy. We need the motor to do 128kHz on microstep mode. Please do not criticize this as I realize that it is an insanely high frequency to be running on microstep mode. This degree of precision, however, will be needed later on. The problem is most likely in the equations, but am not quite sure. Do you have any suggestions on how to check them? Thanks

This is the motor: https://www.pololu.com/product/2298
This is the motor datasheet: https://www.pololu.com/file/download/SS242x.pdf?file_id=0J611

// Givens
long ta = 3e5;     // acceleration time (microsec)
long td = 3e5;     // deceleration time (microsec)
long Vm = 3200;    // steady state velocity (pulse/sec)
long Pt = 3200;    // total number of pulses for move (1600 steps per rev)

// Other variables
long dly;           // stepper pulse delay (microsec)
long t = td/9;      // current time (microsec)  -  You need to seed the initial time with something > 0 so you don't calculate too long of a delay
long t12 = 1e6 - ta - td;           // time during constant velocity (microsec)

int count = 0;
int loopcount = 0;
int dircount = 0;

const int loopdelay = 1;

#define dirPin 4   //red=dirPin, white=stepPin, black=digitalGND
#define stepPin 3


void setup() {

 Serial.begin(9600);
  
 pinMode(dirPin, OUTPUT);
 pinMode(stepPin, OUTPUT);
 
}


void loop() {

  loopcount++;

  //Serial.println(loopcount);
  
if (t>=(ta+t12+td)){

  dircount++;

  t=td/9;
  
  if ((dircount % 2) == 0){
    digitalWrite(dirPin,LOW);
    Serial.println("HIGH") ;
  }
  else {
    digitalWrite(dirPin,HIGH);
    Serial.println("LOW");
  }
}

else{
  
 // Decide which part of the velocity curve your at
 if (t<ta){                                        // Acceleration
   dly = (ta)/(2*(Vm/1e6)*t);
   //Serial.println("Acceleration");
 } 
 else if (t>=ta && t<(ta+t12)){                    // Constant velocity
   dly = 1/(2*(Vm/1e6));
   //Serial.println("Constant Velocity");
 }
 else if (t>=(ta+t12) && t<(ta+t12+td)){           // Slow down
   dly = 1/(2*((Vm/1e6)-(Vm/(1e6*td))*(t-ta-t12)));
   //Serial.println("Deceleration");
 }
 
 t = t+2*dly; // update the current time
 Serial.println(t);
 
 // Move stepper one pulse using delay just calculated
 digitalWrite(stepPin, HIGH);
 delayMicroseconds(dly);
 digitalWrite(stepPin, LOW);
 delayMicroseconds(dly);
 count ++;

 // The move is finished
 if (t>=(ta+t12+td)){
  
   loopcount=0;
   count=0;
   
   Serial.println("reset");
 
   delay (loopdelay);
 }
}
}
```

It is unclear what you are talking about when you say “the stepper motor jumps are limited”. It sounds like you are trying to run that motor at about 2400 rpm (if your 128khz is 1/16 microstep mode), which is not likely to be practical with the motor. This thread on our forum, where someone is trying to achieve high speed operation with a similar Sanyo pancake motor, might be helpful for you:

To check your code, you might use something like an oscilloscope or a multimeter with a frequency measurement setting to verify the STEP pin is being pulsed at the frequency you intend.

-Nathan

1 Like