Motor RPM Calculation

I was wondering how changing the delaymircoseconds corresponds to motor rpm. How would you calculate it. Formula. Motor Spec: Nema 17: 200 steps/rev 1.8° per step Bis easy drive, default mode

I timed the below code, @ delayMicroseconds(1000); it was around 9 rpm approximately

long Distance = 0;  // Record the number of steps we have taken

void setup() {
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
}

void loop()  {
  digitalWrite(9, HIGH);
  delayMicroseconds(1000);
  digitalWrite(9, LOW);
  delayMicroseconds(1000);
  Distance = Distance + 1;  //record the step
  // Check to see if we are at the end of our move
  
  if  (Distance == 256000)
  {
    // We are! Reverse direction (invert DIR signal)
    if (digitalRead(8) == LOW)
    {
      digitalWrite(8, HIGH);
    }
    else
    {
      digitalWrite(8, LOW);
    }
    
    Distance = 0;
    
    delay(2000);
  }
  
}

You have 200 steps pre revoloution, if each step takes N seconds it takes 200 * N seconds per revoloution. You have to divide 60 by that number to get RPM. Note for 1mS delay the value of N will be 0.002 because you have two delays per step.

That dose not match what you were getting, it looks like your stepping motor driver might be on 16 micro steps per step.

I don't quite understand.

So it would be 200*16*N/60?

At 1000 microseconds = .001 seconds, need to multiply by 2 because 2 delays per coil.

Therefore, 200*16*.002/60= 0.1 rpm?

That does not seem correct from what I saw when I ran the motor at 1000 microseconds. It was completing one revolution in about 6.5 seconds, or 9 rpm.

Never mind I got it. Thanks

200*16*.002= 6.4 s/rev

60/6.4= 9.4 rpm :)