Fixed time positioning trajectory calculation

For an application, I need to position a motor over a given distance in a given time, within limitations of maximum speed, max ramp. As long as ramp-up and ramp-down are equal and maximum speed is not reached, the speed profile is a triangle and calculation is simple (max speed is 2 x average, ramp-up half the time, ramp down for the rest of the time).

But if I end up with needing a trapezoid, things get more complicated and I have not found a nice solution yet. Searching for positioning, I only found calculations that use distance, ramp and max-speed with the actual time it takes as a result, not as an input.

Can anyone give me a pointer or link?

I would like to avoid iterative methods and look-up tables if possible.

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)

"Most people would like to be delivered from
 Click to see the full signature
Reply to
Stef
Loading thread data ...

That's because as soon as the v(t) has to become trapezoidal, you don't *have* two variables to control any more --- in other words, you'll be driving the motor at the fastest speed it can possibly go, with no options left. I.e. the time you get as the result from those formulae is not the time you wish for this move to take, but the minimum amount of time the machine needs to get that far.

Assuming you're in the trapezoid regime,

a_max := max ramp (acceleration and deceleration limit assumed equal) v_max := max speed t_max := v_max / a_max = time from rest to v_max, at a_max

Max_distance(t) = 2 * a_max / 2 * t_max^2 + v_max * (t - 2 * t_max) = v_max^2 / a_max + v_max * (t - 2 * v_max / amax) = v_max * t - v_max^2 / a_max = v_max * (t - t_max)

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

Repeat after me:

v = u+at s = ut + a*sqr(t) sqr(v) = (sqr(u) + 2*a*s s = (v+u)/2 * t

Work the combinations for your three segments (ramp up, steady, ramp down) to get your distance.

GCE physics 1967.

Paul Burke

Reply to
Paul Burke

You are now talking about a position that is not reachable in the given time. But between these two extremes there is trapezoidal solution that takes excactly the required time. There are 3 areas:

1) Short distance, ramps not at max, max speed not reached, triangle, target reached in time. 2) Medium distance, ramps not at max, max speed not reached, trapezoid, target reached in time. 3) Long distance, ramps at max, max speed reached, trapezoid, target not reached in time. 1) is an easy solution (if ramps are equal) 2) Have not found a solution yet 3) can not be remedied, we'll have to live with that.

Yes, this gives the maximum distance possible in the given time and marks the boundary between 2) and 3).

The problem:

Inputs: - MaxRampUp - MaxRampDown - MaxSpeed - MoveDistance - MoveTime

Outputs: - RampUp - RampDown - TopSpeed - BrakingPoint

The resulting move should complete in exactly MoveTime if possible and use the slowest possible ramps.

To complicate things, the max ramps are not equal and there is a starting velocity. But I'll handle those if I can handle the simple case. :-)

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)
Reply to
Stef

x(t) = x(0) + v(0)*t + 0.5*a*t^2

Highschool physics 1982 (?)

I already know my distance and the time it should take, now work out ramp-up, steady and ramp-down. This was not in my physics exam I'm affraid. Also notice the random sig below (Maybe fortune is not that random after all :-)

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)

Education is what survives when what has been learnt has been forgotten.
 Click to see the full signature
Reply to
Stef

[...]
[...]

Look up to your own quoted text: you yourself started speaking of "needing" a trapezoid. You only "need" a trapezoid if a triangular speed profile isn't workable, i.e. if the distance is larger than the maximum triangle-type move can give you. Once you're beyond that point, you do indeed lose one degree of freedom.

Ah! That requirement is new, isn't it? And do you want to keep ramp-up and ramp-down equally fast, or both the same ratio of their maximum allowed value. Or something else?

The formula still applies --- just drop the _max from a_max, and solve it for a.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

mail)

Can you adjust the ramp up and ramp down rates, in other words the acceleration? If you can then there is no need to worry about the flat top as you can get any timing within the limits of the machine by reducing the acceleration. If you need to hit your maximum speed and the graph has a flat top out then you don't have a solution, the machine can't possibly get there in time.

Work your way through this page then get back to your problem.

formatting link

Peter

Reply to
moocowmoo
[Helpfull info that I need to study in more detail]

I indeed did not mention it earlier, sorry. But even if I drop that requirement and, for instance, use fixed time ramps I still have trouble calculating the required topspeed to get to the target position in time.

But which a? That remains my problem: a? topspeed? I'll keep on it, but if anyone can come up with a clue I would be thankfull. I think I'm having a bad thinkingcapday. :-(

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)

PLUG IT IN!!!
Reply to
Stef

Yes, I can adjust the ramps. And is some cases there is a solution with a flat top at max speed, as long as acceleration is not over max. Or even a flat top at less then max speed is possible.

All very basic highschool physics that I do know (or at least should :-) but I'll study it to make sure. Thanks for that link.

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)

GIVE:	Support the helpless victims of computer error.
Reply to
Stef

Sorry, my typo. Look, it's all quite easy. You have max speed Vm, and acceleration a. So time to accelerate (= time to decelerate) = Vm/a. Distance covered in acceleration and deceleration = Vm*Vm/a.

The run distance is the remaining distance after acc/dec = S-Vm^2/a. The time taken = distance/speed = S/Vm - Vm/a.

So total time = 2*Vm/a + S/Vm - Vm/a = S/Vm+Vm/a.

So Vm^2 -Vm*a*t +a*S = 0. Al Khwarismi will get your Vm for you (as well as tell you if it's possible)

Paul Burke

Reply to
Paul Burke

Indeed. And in those cases, *you* have to make a decision which kind of profile you prefer. You have 3 parameters in a trapezoidal pattern: the actual ramp rates, and the flat top speed. You have only

2 parametric requirements: total time (--> base width of the trapezoid), and total distance (area of the trapezoid).

Which means your system is under-constrained, and will usually have an infinitude of possible solutions. You have to impose one more restriction to get a well-defined solution.

I still think that if you "need" a trapezoidal pattern, that automatically means you don't have any choice but to max out both the the ramps and the top speed, and the problem doesn't actually arise.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

Yes, if 'a' is known... So I'll have to estimate the a's (they are not equal) and from there get Vm. Probably not optimal, but usable if the sqrts don't take too long.

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)

One good reason why computers can do more work than people is that they
 Click to see the full signature
Reply to
Stef

This restriction would ideally be "the lowest possible acceleration" but that again needs to be found. So upto now I have not found an easy solution.

No: Maxing out both can lead to reaching the destination before the required time.

I think I'll work on an acceleration aproximation and from there, using a modified version of paul's equation, get Vmax etc. This might not give an 'optimum' but will probably work OK.

One more constraint: The calcualtions should not take more than a few ms on a 30MHz 16-bit dsp. I thought I covered this in my first post by asking for "no iterations" but it now looks like I'll be needing square-roots, i'll see how long those take.

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)

"By the time they had diminished from 50 to 8, the other dwarves began
 Click to see the full signature
Reply to
Stef

mail)

Let S be the distance to go. Let T be the time you want to get there in. Let A be the maximum acceleration permitted. Let V be the maximum speed permitted. Let a be the actual acceleration required and t be the time for acceleration (= time to slow too).

(1) Then try a triangle a = 4S/T^2 and v = a*(T/2) = 2S/T. If a

Reply to
Peter Dickerson
[...]

Not only that: you have two accelerations, which you appear to want to control separately. So what does "lowest possible" actually mean, then? How do you plan to control two competing parameters by a single minimization criterion?

Lacking that information, I'll assume the two accelerations to be always the same (but of different sign), i.e. a symmetrical situation.

Let's go back to the v(t) diagram. You want to construct a trapezoid (or a triangle, which is included as a degenerate trapezoid with zero-length upper parallel edge), with given base line (time to go) and area (distance to cover). Contraints are on the angles in the two bottom corners (--> max acceleration and deceleration), and on the height of the trapezoid.

If you think about it for a while, and make some sketches, I hope you can agree find that for minimal angles, only two cases can happen:

1) triagonal pattern (because if you lower the accelerations any more, you'll still have a triangular, but of smaller area). 2) a trapezoid of maxed-out height (because if there's still room above the upper edge, you could always rotate the diagonals down a bit, and compensate to keep the area fixed, by moving the upper edge up a bit).

In a nutshell: if your movement needs an average velocity (v) of less than v_max / 2, use a triangular pattern that only goes up to 2*v, and immediately down again. If you need v > v_max/2, use a trapezoidal pattern going all the way up to v_max. Use the equation poster earlier, solved for the acceleration, to find out what acceleration you need.

--
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
Reply to
Hans-Bernhard Broeker

"Stef" wrote

The usual technique is to start with a constant jerk specification. There will also be limits on acceleration and velocity set by the motors, mechanics and motor drive. Figure that going in you need jerk, acceleration and velocity specs. Then you need the distance to travel. Four variables going in.

The profile is then composed of four jerks: one at the beginning and one at the end of acceleration and another two for the deceleration.

For a full move you need to calculate the jerk magnitude, the jerk time (all 4 are of equal time), the interjerk time (the period of constant acceleration), and the interacceleration time (the period of constant velocity). Four variables going out: no sweat.

It is all highschool physics. It is not that hard. It is a bit tedious. There are three cases of moves to consider:

jerk jerk jerk accel jerk jerk deaccel jerk jerk accel jerk constvelocity jerk deaccel jerk

The output of the profile is either a set of way points for a position control servo or a set of step times for a stepper motor. If you are using a stepper you have the additional requirement of having to be accelerating in the resonance zone, this may add two more cases to the profiles if the max velocity is > resonance speed.

This is from memory, so take with grain of salt.

I seem to remember an article on this in some freebie journal (ISJ?), aimed at stepper motors IIRC.

--
Nicholas O. Lindan, Cleveland, Ohio
Consulting Engineer:  Electronics; Informatics; Photonics.
 Click to see the full signature
Reply to
Nicholas O. Lindan

I can see from your comments that you've been thinking about all this.

You mentioned that you divide the problem up into three conditions:

There are these two controlling math expressions: ('d' is the distance and 't' is the time, each as specified)

(A) Compare t with [2*sqrt(d/max_ramp)], which examines if you have exceeded your acceleration limit using the triangular approach, and; (B) Compare t with [2*d/max_speed], which examines if you have exceeded your velocity limit using the triangular approach.

If t >= [2*sqrt(d/max_ramp)] and t >= [2*d/max_speed], in other words the time is long enough so that neither max speed nor max ramp is exceeded, then your first case is satisfied and a triangular profile makes sense. In this case, your actual acceleration is easily computed as [4*d/t^2] and your peak velocity as [2*d/t].

I agree with you that a trapezoidal profile will be used in some cases where the specified time is met and you still don't exceed either max speed or max ramp. This case takes place where t >= [2*sqrt(d/max_ramp)] and t < [2*d/max_speed] and yet t >= [max_speed/max_ramp - d/max_speed]. So long as these are true, the trapezoid should be used, with an acceleration of [max_speed/(t-d/max_speed)].

In the case where t >= [2*sqrt(d/max_ramp)] and t < [2*d/max_speed] but instead now t < [max_speed/max_ramp - d/max_speed], then your acceleration limit would have to be exceeded so the acceleration is instead set to max_ramp and your time will be exceeded by the trapezoid, with a computed value for 't' being simply [max_speed/max_ramp - d/max_speed].

But what about the case where t < [2*sqrt(d/max_ramp)] and t >= [2*d/max_speed]? In other words, where your max speed isn't exceeded but your max ramp is? In this case, you need to accelerate at max ramp, instead. But following a more gentle slope will most certainly force you to take longer, however you will NOT need or require a trapezoid -- as the triangular shape is still optimal, but just longer. This is a case where your narrow triangular profile is forced into a squatter triangular profile by the acceleration limits, yet the area needs to be the same, thus forcing a longer 't' or base. But it is not a trapezoid, yet you fail your time limit. Here, the new time is [2*sqrt(d/max_ramp)].

In other words, there is another condition you haven't accounted.

It's more like:

A \ V \------------------------------------+------------------------------------+ | T R I A N G U L A R | +- - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - -+ | neither max speed nor max ramp is | max ramp is exceeded, but not max | | exceeded, so a triangular profile | speed; so use max ramp as accel | | value -- or, it may not. This | | | becomes two cases, where 't' may | | | be met, or not. See comment above. | | +------------------------------------+------------------------------------+

The above table is based on my conditions (A) and (B), above.

I may have misunderstood, though. So correct me, as you see appropriate.

Jon

Reply to
Jonathan Kirwan

"lowest possible" means as low as possible while still completing the move in time. If you decrease the accelleration too much, the move can not be completed in time.

As I already mentioned somewhere in this thread, the accelerations are not equal.

Yes you are right on this. There is in some cases the posibility of a trapeziod that not has the maxed out height. But, as you write above, this can always be changed to a maxed out one. That does make the problem a little easier. And this does in fact result in the "lowest possible acceleration" solution. :-)

Yes I'll try this using equal accelerations and zero startspeed for now. I already wrote a small C program to test the equations and show me the resulting move. If this works OK, I'll try to move on to non-zero start speed and asymetrical acceleration.

Thanks for your help.

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)

The chief cause of problems is solutions.
 Click to see the full signature
Reply to
Stef

That is exectly my problem. This is the usual technique and examples can be found on the internet. But I have failed to find a technique for making the move in a specific time, not nesceseraly the shortest possible time.

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)
Reply to
Stef

Not completely done yet. The solution can still be triangular but requiring more time then asked for. So we need some means to calculate the topspeed reached in the trajectory. I've now made a quick hack that assumes only accelerating for half of the _requested_ time. Which is far from optimal as the move will take longer if shorter time is requested. I'll solve this later.

[snip excellent formulas]

I've implemented your solution in my simple simulator and it works perfectly, thanks.

All that is now left to do is take unequal accellleration and decelleration into account. Which may not be that trivial as most simplifications in the formulas are because they are equal. And there is also the matter of the initial speed step that is now in there to prevent the motor from stalling. But I'll try to get this working now.

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)
Reply to
Stef

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.