This may be a better question for the Physics StackExchange so tell me if I should move the question.
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
M:31729
and C:17.327
digitalWrite(PIN, LOW);