Understanding the relationship of Pulse and Stepper RPM

arduinodriverpulsestepper motor

I have a pretty simple script that I'm using to control the RPM of my stepper motor:

void loop(){ 
  digitalWrite(PIN, HIGH);
  delayMicroseconds(wait);
  digitalWrite(PIN, LOW);
}

as you can see it's just producing a pretty standard pulse, I have my Arduino connected to a driver that manages the motor. The wait variable comes from a second order equation I derived from measuring the RPM with a Tachometer and tweaking the value.

// From data RPM = 31729/x + 17.327 thus x = 31729/(RPM-17.527)
wait = M/(RPM-C);

It works pretty well, I get readings consistently within only 1 – 2 rotations off. But the slope and intercept seem completely arbitrary to me. Is there a chance it has to do with the clock speed of the Arduino? I'm using an Uno and from playing around with the numbers I can't seem to find a relationship. From what I can tell, the driver looks hardwired so I don't think it has much to do with the equation.

Any idea what these values, the slope/intercept mean?

Equation: RPM =
31729/wait + 17.327

Best Answer

The slope is related to the number of steps it takes your motor to make 1 revolution.

For example, common steppers I've worked with take 200 steps per revolution. If you want to rotate at 100 RPM, then you have to give (100 * 200) steps every minute, or 333.33 steps per second. If you want 50 RPM, then its (50 * 200)/60 = 166.7 steps per second.

The number of steps per second is controlled by your [wait] time. The longer you wait, the fewer steps per second you get.

I'm not sure why you got the offset value you did. That implies that if your wait was infinite, (0 steps per second) your stepper would still be turning 17 RPM. That clearly can't be true. I suspect some measurement error.

I recommend looking at the data sheet for your stepper driver. It should specify minimum and maximum pulse widths and dwell time for the step signal. With the tight loop you have, there's a chance you're violating those specs and the behavior of the driver is unpredictable.