Time to geek out about motor technology a bit. As a starting point an excerpt from FDL-2 non-plus firmware:
void StepRange(int stepperPin, double startDelay, double endDelay, double steps){Okay, we've all heard the usual runaround about open-loop stepper drives for feeding darts in nerf guns. The one about too much torque decay at high speeds to run reliably at higher ROF and all that. Well, this function above is right at the core of the matter, and no offense, there's a pretty big and apparently very common blunder in it. Angular acceleration of a synchronous motor can be expressed as commutations per second squared. Steps per second per second; or if dealing with the period of a signal, delay change per second. Not per step - per second. The motor commutation frequency is increasing, so "delay change per step" doesn't generate anything resembling a linear velocity/constant acceleration profile. Rather, it gives linearly increasing acceleration, and quadratically increasing velocity.
double delayChangePerStep = (endDelay - startDelay) / steps;
double loopDelay = startDelay;
for (int index = 0 ; index < steps ; index += 1) {
digitalWrite(stepperPin, HIGH);
delayMicroseconds(loopDelay / 2);
digitalWrite(stepperPin, LOW);
delayMicroseconds(loopDelay / 2);
loopDelay += delayChangePerStep;
}
}
That is the very LAST thing we want for actually driving something, to accelerate harder as speed climbs and the torque curve drops off.
How about a graphic long timescale example of what this is doing:
https://www.youtube.com/watch?v=25XOH7JPU5w (Check the code in the description!)
