0
$\begingroup$

my program controls a stepper motor. The API of the motor allows me to set the maximum speed, maximum acceleration, maximum deceleration and the jerk. I would like to pre-calculate the duration of a movement. e.g. Max Speed = 10m/s, Max Acceleration/Deceleration = 500m/s², Jerk = 1000m/s³, distance to new location = 0.5m, duration = ?. Initial speed and acceleration are 0.

To be honest, I didn't know about the jerk before and I used the naive calculation time = distance / speed. I know that even without the jerk this calculation is wrong as I ignore the non-constant acceleration.

I find a lot of posts in the internet (e.g. https://en.wikipedia.org/wiki/Fourth,_fifth,_and_sixth_derivatives_of_position) but nothing that takes into account a max speed and max acceleration.

$\endgroup$

1 Answer 1

1
$\begingroup$

Let's suppose the movement should traverse the distance as fast as possible. It will accelerate for the first part, then reverse the signs and decelerate for the second part. While in progress you want it moving as fast as possible (either because it hits the speed limit, or because it reaches the midway point before hitting the speed limit). To hit the highest speed, you accelerate as hard as possible (again, subject to the acceleration limit). To accelerate as fast as possible, you apply the max jerk for as long as possible (subject to etc etc).

The wikipedia page for Jerk shows how to compute the distance traveled, as a cubic function of time, with the jerk as a parameter. I would start by plugging in your values, assuming max jerk, to see what happens. If that travels the distance without exceeding your max acceleration or velocity, you have the easy solution. If instead it hits a limit, it's still a piecewise solution, just with more than two pieces.

Apply max jerk to accelerate as hard as you can. If it's going to hit the speed limit first, you need to reduce the acceleration to become zero just as it hits the speed limit, so apply negative jerk as late as possible. If it's going to hit the acceleration limit first, just stop jerking when you get there. Then keep an eye on the speed as before.

In all cases, the maximum jerk is applied for as long as possible, as early/late as possible.

As an aside, it's perfectly plausible for a real system to accelerate harder than it can decelerate. Electrical power accelerating the system imparts a bunch of kinetic energy. Unless the controller has regenerative braking, the only place for the K.E. to go is to become heat dissipated in the motor windings or brake, and we hate that smoke. Similarly, pushing the system to be as fast as possible ignores other considerations such as wear, noise, or vibration.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.