Increasing the speed of a stepper motor?

I’m using a Nema 23 stepper and a microstepping driver.

This is the simple code I’m using to get it to just turn:

#include <EEPROM.h>

const int pul =  2;  //set pulse at pin 2 
const int dir =  3;  //set direction at pin 3
const int ena =  4;  //set direction at pin 4
int motorSpeed = 1000; //set motor delay

void setup(){
  pinMode(pul, OUTPUT); 
  pinMode(dir, OUTPUT);
  pinMode(ena, OUTPUT);  
  digitalWrite(dir, LOW);
  digitalWrite(pul, LOW);  

void loop(){
     digitalWrite(pul, LOW);
     digitalWrite(pul, HIGH);


I can’t set a lower motorDelay than 1000 (1 milisecond) does this mean thats the fastest my motor will turn? If its any help this is the manual for the driver:

High, the manual says something like:

The maximum pulse rate is 100KHz compatible with Mach 3 motion control software.

With Arduino, you would need to use delayMicroseconds() See:

I am using that, but when I go below 1000 delay it just make a screeching noise. I've set it to maximum microsteps. Any ideas?

What are you using (what voltage) for a motor supply now? The PDF says it accepts 20V to 50V; you need to move to a higher voltage to get more speed.

Stepper motors can't accelerate instantly to full speed or anything like it, you need to ramp-up the step-rate or you lose lock and they mis-step and stall (that screeching noise). The AccelStepper library is the first requirement - and eventually to go faster you have to overcome back-EMF which means a chopper-drive IC and a higher voltage power supply - gets more complex then.

Also mechanical resonances can cause lose-of-lock too - mechanical damping can help but micro-stepping is a really good at combating the severity of resonance.

Thanks Mark, had no idea you had to ramp it up. I'll try that out. @Chagin, I'm using an old laptop PSU which I think is something like 19v but need to check the label.

Hi Chems,

Take a look at: Which is a stepper library that will let you ramp up speed. Many people have found this greatly increases their maximum speed.

Remember you need to ramp DOWN too; or lose steps...

I can’t quite see how to integrate the examples from AccelStepper with my code. Are there any examples out there showing how to use AccelStepper with code similar to mine shown in the first post?