How to describe speed of stepper motor in RPM

hello,
how can i describe RPM of stepper motor if i have delay time and step angle?
this is my code

const int stepPin=3;
const int dirPin=4;

void setup() {
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
}
void loop() {
  digitalWrite(dirPin,HIGH);

  for(int x=0; x < 2000000; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
  }
  delay(1000);

  digitalWrite(dirPin,LOW);

  for(int x = 0; x < 400; x++) {
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(1000);

i want to describe 5 or 10 RPM how can i do this?
thank you

From that code and absence of technical data it's impossible tell.
Read the topic "How to get the best out of this forum".

Maths. Simple at that.

delay time is the reciprocal of frequency

delay time 10 ms -> frequency is 100 Hz. 100 steps per second

step angle is fraction of circle

step angle 10 degrees, 360 / 10 is 36 steps per revokution.

So 100 steps / rev divided by 36 is 2.77 revolutions per second

is 2.77 x 60 or 167 RPM.

Use your own constants which you must know or can deduce from the code.

HTH

Yes, @n_regev1 might well have stated the steps per unit of time as well as the step angle of the motor. So I just guessed the delay between steps and the angle stepped. As a for examl,e.

a7

delay time is 500 ms according the code and the step angle is 1.8 degree

No, the delay is not 500ms (milliseconds) it is 500microseconds.

(or twice that?)

No. The time for one complete step is 500 + 500 microseconds.

Thank you Railroader, I was editing my post when you corrected me.

how can i know the time for step?
if i know that the step angle is 1.8 degree i need to do 200 steps for one cycle.


Here's one thought:

500 + 500 is 1000. 1000 microseconds is 1 millisecond is 0.001 seconds.

Beyond that, it's simple mathematics.

Give it a try.

a7

@alto777 No problem with a master degree. Just didn't feel like rewarding the poor post of OP with a complete course covering all possible steppers.

1 Like

More like no problem after Year 8 or 9. :expressionless:

a7

Haha. I agree but all members wouldn't....

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.