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);
}
}