Need Help with programming NEMA 17 Stepper Motor with a TB6600 Stepper Driver

Hello all,

I recently purchased a TB6600 Stepper Motor driver to use for my Arduino to power a NEMA 17 Stepper motor. https://www.amazon.com/MYSWEETY-TB6600-Stepper-Driver-Controller/dp/B01MYMK1G9

My questions concern a little more about the programming. I used a video course and the internet to help me create this particular sketch to run the motor.

For this motor, it is running the maximum speed that I am setting it to, but I need it to run for a total of 48 revolutions. In this script, I declared 6400 pulses/rev in my for statement, but I need it to run (640048) times even though it exceeds the overflow limit when I upload the script to the Arduino. Can anyone help me with how to solve this problem or if anyone has knowledge with this particular driver who could help at all?
This is what I need to achieve: for (unsigned int i=0; __i<(6400
48)__; i++)

In other words, I want the stepper motor to run 48 full revolutions at a rate of 6400 pulse/rev.

int PUL=6; //define Pulse pin
int DIR=5; //define Direction pin
int ENA=7; //define Enable Pin
void setup() {
  pinMode (PUL, OUTPUT);
  pinMode (DIR, OUTPUT);
  pinMode (ENA, OUTPUT);

}

void loop() {
  for (unsigned int i=0; i<(6400); i++)      {
    digitalWrite(DIR,LOW);
    digitalWrite(ENA,HIGH);
    digitalWrite(PUL,HIGH);
    delayMicroseconds(3);
    digitalWrite(PUL,LOW);
    delayMicroseconds(3);
    
  }
   delay(1000);
  for (unsigned int i=0; i<6400; i++)   
  {
    digitalWrite(DIR,HIGH);
    digitalWrite(ENA,HIGH);
    digitalWrite(PUL,HIGH);
    delayMicroseconds(3);
    digitalWrite(PUL,LOW);
    delayMicroseconds(3);
  }
    delay(1000);
    while(1);
}

You’re sending a step pulse every 6 uS, that’s 166667 per second, a 200 step per rev motor would try to run 50000 RPM if it were possible. Try a sane speed:

for (unsigned long i=0; i<(307200); i++)      { // 48 * 6400
    digitalWrite(DIR,LOW);
    digitalWrite(ENA,HIGH);
    digitalWrite(PUL,HIGH);
    delayMicroseconds(10);
    digitalWrite(PUL,LOW);
    delayMicroseconds(3000);

A simple solution may be to change from unsigned int to unsigned long as that will remove the overflow limitation

...R
Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library

OOPS! Fixed, guess he's trying to using 32 microstep.