I'm writing code for a microcontroller that will ramp up the speed of a stepper motor as quickly as possible, for a jig that I'm building, that moves a workpiece from one position to another along a linear rail.
This question is not about modifying the mechanical or electrical system around the stepper motor, but simply the rate at which the stepper motor is stepped.
Given a desired speed, it will ramp up the speed of a stepper motor (and so the speed of the workpiece) from stationary. (The stepper motor will not have any kind of feedback to the controller other than a switch at each end so it can periodically establish its position, and stop if it's lost/gained too many steps in one direction).
So, I'll need to implement/write a function which gives the optimal speed $s$ (revolutions per second) at time $t$ for maximum acceleration. (Where $s(t=0)=0$) which the microcontroller will use to determine how fast to accelerate the workpiece / stepper motor.
The function might look like this:
$$s = kt$$
Where $k$ is an optimized constant, $t$ is in seconds, $s$ is revolutions per second.
The maximum maximum acceleration will be specified by choosing a value of $k$. It will be determined by experiment rather than calculation.
What I want to know is:
- One (or more) formulas that I might use. I would then attempt various contants, varying them so I find values that result in good acceleration.
- A strategy for determining those constants.
E.g. using the above formula:
- start with some value of $k=k_0$
- Attempt #1: Run the motor with that value of $k$, starting from $t=0$. Record the speed at which the motor failed to accelerate.
- Attempt #2: Double $k_0$, call it $k_1$. Repeat step 2.
- Attempt #3: Use half of $k_0$ as $k_{-1}$. Repeat step 2.
- If $k_1$ gives the highest speed, double it as $k_2$.
- If $k_{-1}$ gives the highest speed, half it as $k_{-2}$.
- If $k_0$ gives the highest speed, followed by $k_1$, take the average as $k_{0.5}$
- If $k_0$ gives the highest speed, followed by $k_{-1}$, take the average as $k_{-0.5}$
- Repeat step 2.
- And so on
Further thoughts
I think the above formula might work well assuming there is the equivalent of a flywheel attached to the motor, and:
- there is zero friction
- the motor exerts constant torque at any speed
Is that correct?
Similarly assuming:
- the motor and system has zero mass / inertia
- the motor exerts constant torque at any speed
- the only resistance to movement is friction
Then the motor can still accelerate to full speed immediately. (So $k$ could be infinite). And if there is inertia, assuming friction forces are constant, (ie independent of speed), assuming I'm correct so far, then the formula is still good; $k$ will just be a lower value.
But that leaves questions:
- What is a typical relationship between stepper motor speed and torque? Clearly it tails off as speed increases, otherwise there would be no limit to its speed. So it clearly won't be taken into account by the above formula. I am investigating this link which goes into much detail, but perhaps there are factors which are more significant than others, or there are more basic models that give good approximations.
- What other factors could be significant that would can not be modeled within the above formula?