# When I try to spin my stepper motor faster then 1000 pps, it vibrates and doesn't move

Im trying to get my stepper to spin faster then 1000 pps, and my torque curve on my stepper's datasheet is showing it being capable of that(https://www.omc-stepperonline.com/download/17HS19-2004S1_Torque_Curve.pdf) but when i try to spin it faster then 1000 pps, it vibrates violently and does't move.

I'm giving a drv8825 24V 2A max as the datasheet specifies, and the DRV8825 max pulses is 250 khz, which is significantly more then 1000 pps, so I think its a code problem.

My code:

int main() {

xEN = 0;
yEN = 0;
xDIR = 1;
yDIR= 0;

for(int i = 0; i < 1000; i++){
xSTP = 1;
wait(0.001);
xSTP = 0;
wait(0.001);

}

}


I've read stepper motors need to be accelerated towards higher RPM, but im not sure how to do that. Like, how would I achieve 3000 pps?

EDIT: This seems to spin incredibly quickly and loudly but anything in the middle of this seems to just vibrate violently

int main() {

xEN = 0;
yEN = 0;
xDIR = 1;
yDIR= 0;

for(int i = 0; i < 1000; i++){
xSTP = 1;
wait(0.0005);
xSTP = 0;
wait(0.0005);

}

}


Although I am not an expert on this, I have some experience with coding stepper motors.

Regarding the code (if you are using Arduino as I am guessing), the use of the wait function blocks any code execution for approximately 0.001 [s] and then resumes. However, that does not guarantee that the execution of the next step is at exactly every 0.001.

A better way to work with pulses like that is to use the timer interrupts. They can provide a much more precise and dependable pulse. There are plenty of examples on the internet, depending on the platform (arduinos has slightly different implementations of timers) you are using.

Additionally, another thing that you can try, is try to change the input voltage. In some cases (usually older drivers though) increasing the voltage, improves the torque, and as a result there is a more steady movement.

Additionally, the DRV8826 has a nominal amperage of 1.5 A, and a maximum voltage of 2.2 A. You should monitor the amps to see if the DRV8825 is overheating or if its able to perform continuously under those conditions.

• Hello, Its defiantly not voltage because I'm using the voltage in the datasheet. I'm also using MBED and reprogramming a LPC1768 chip on a 3d printing board for motor wheel movement. I'll look up timer interrupts though. EDIT: I'm planning on getting a higher amperage stepper driver later, but I want to figure out why I can only get my stepper to drive slow for these so I can know what to look for in my next set of drivers. Feb 26, 2021 at 21:17

Welp, it appears NMech above this is right about using the chip's clock as the basis for the pulses. I don't quite fully understand the code yet, but using code from https://www.exploreembedded.com/wiki/LPC1768:_Timers for prescalar microsecond code and https://www.electronicshub.org/how-to-use-timer-in-lpc1768/ for the rest.

I set the prescalar to be based on microseconds and used the second link's Tim0 code to make a timer that stops once it reaches the specified amount of microseconds and now I can pulse past 1000 pps

int main() {

xEN = 0;
xDIR = 1;

Timer0_init(); //<---code for this in second link
while(1){
xSTP = 1;
delayus(333); //code for prescalar in first link
xSTP = 0;
delayus(333);
}
}