NEMA17 & DRV8825 - HOW I CAN 1000RPM or HIGHER? I'M A BEGGINER

Hello everyone! I wanna get my NEMA17 stepper motor to 1000RPM or higher with DRV8825 module. I read this tutorial https://www.makerguides.com/drv8825-stepper-motor-driver-arduino-tutorial/ , but i don't know if i understand very good the code there. I use a 12V with 3A adapter for the driver power supply. I change the delay in that for statement to change the speed and try a code showed below to measure the RPM. I use an IR speed sensor based on LM393 ( A22 module) to read the number of interruptions. When i try to change delay at 300us it stucks.

ARDUINO CODE:

// CODE EXAMPLE TO HANDLE NEMA17 AND A22 SPEED SENSOR(BASED ON LM393) AT THE SAME TIME - SERIAL MONITOR
const int dirPin = 2;
const int stepPin = 3;
const int stepsPerRevolution = 200;

const int speedsensor = 11;
int value = 0;
int last_value = 0;
unsigned long start_time = 0;
unsigned long end_time =0;

void setup()
{
// Declare pins as Outputs
Serial.begin(9600);
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(speedsensor,INPUT);
digitalWrite(dirPin, HIGH);
}
void loop()
{
start_time = millis();
end_time = start_time+60000; // 60 sec
while(millis() < end_time) //do this untill end_time = 60 sec
{
for(int x = 0; x < stepsPerRevolution; x++)
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(400);
digitalWrite(stepPin, LOW);
delayMicroseconds(400);
if(digitalRead(speedsensor)&& value == last_value)
{
value++;
}
}
Serial.print("Value is: ");
Serial.println(value);
last_value = value;
}

Serial.println();
Serial.println("Turation is :");
Serial.print(value);
Serial.print(" RPM");
delay(10000); // delay for next measurement
}

The circuit is in the link. Thanks for help!

@heredea, your topic was movd to a more suitable location on the forum.

Can you please spend some time reading https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966; after that, please edit your post and add the code tags as described. Thank you.

I edit it i think. Sorry but i am running out of time with a project.

Please understand that motors need to be ACCELERATED to achieve a high rotation speed. They don't instantly go from 0 to 1000 RPM. I don't see any attempt to accelerate the motor.
Paul

And how i accelerate it?

You should use a libraray like MobaTools or AccelStepper to drive you stepper. These libraries can do the acceleration.

I will try! Thanks for advice!

If you’re going to use a stepper, you need to know how many steps per revolution that particular motor is designed for.

Then - to achieve 1000 rpm, you need to generate (step frequency = #steps x 1000).
In your code, you need a method to ramp the step frequency up or down to that target speed as needed,

What’s the application?
It may be a lot easier to use a DC motor, and use PWM to drive your motor.

My application doesn't need so much rpm, but I would like to try to see that it performs so many rotations and find a good method of speed control. My application is to design a peristaltic pump and that's why I would like to have a higher speed range, even if I don't use so many rotations.

You only talk here about the mounting plate (1.7 inch).
Leo..

At what speed will your pump become ineffective?
Paul