Skip to content

Control Systems

How a trapezoidal motion profile works

A trapezoidal motion profile plans a move in three parts: accelerate at a fixed rate, cruise at a top speed, then decelerate at the same rate so the machine stops exactly on target. Plotted as speed against time, it's a trapezoid. The controller moves a setpoint along that plan and the position loops follow it, so the machine never feels a jolt bigger than the acceleration you chose.

Why not jump straight to the goal?

Set the target 1.5 m away in one step and the loops see a 1.5 m error at once. They floor it: a waiter robot hits 6 m/s², everything its wheels can give, and a full cup spills above about 1.5 m/s². A plain ramp, moving the setpoint at a steady 0.4 m/s, keeps the cup dry but takes 4 s. At 0.6 m/s it arrives in time, but the robot has to jump from standing to 0.6 m/s, a 1.6 m/s² jolt, and the coffee goes.

Plan the speed

Speed up at 1 m/s², cruise at 1 m/s, brake at 1 m/s². Every 10 ms the speed changes by 0.01 m/s and the setpoint moves by speed × 0.01 s. The cup never feels much more than 1 m/s², and the robot, following a moment behind its setpoint, reaches the table 1.5 m away in about 2.7 s.

When to brake

stopping distance = v² ÷ 2a

At 1 m/s and 1 m/s² that's 0.5 m. So on every pass, compare the stopping distance with the distance left, and once it has reached it, brake:

float left = goal - setpoint;
if (vel * vel / 2.0 >= left) vel = vel - 0.01;   // brake (a = 1 m/s²)
else if (vel < 1.0) vel = vel + 0.01;            // speed up
if (vel < 0) vel = 0;
setpoint = setpoint + vel * 0.01;
if (setpoint > goal) setpoint = goal;

Live experiment

Carry the coffee without a spill

A waiter robot carries a full cup 1.5 m, and the coffee spills above 1.5 m/s². Move the setpoint with a jump, a ramp at 0.4 or 0.6 m/s, or the trapezoid. The flag is the setpoint and the strip is the jolt: only the trapezoid is dry and at the table inside 3 s.

Try it yourself: free lesson

“Don't spill the coffee” is lesson 4 of 6 in Balance Bluffs, Control Systems World 3. Free with an account. Lessons unlock in order, so you’ll do the 17 before it first.

Short moves become triangles

If the move is too short to reach top speed, the braking rule fires before the cruise begins and the trapezoid loses its flat top: a triangle profile. With these settings that happens for any move under 1 m, and the same code handles it without a special case.

Smoother still: the S-curve

At each corner of a trapezoid the acceleration jumps, and that sudden change, the jerk, can be felt and can make a machine ring. An S-curve profile ramps the acceleration up and down too. Lifts use one so you hardly feel the start. A 3D printer has an acceleration setting, often 500 to 3000 mm/s², and limits the corners with "jerk" or "junction deviation".

Free lesson

Now build it yourself

Each lesson comes in three short parts: see the idea, try it on a live board, then build it yourself, with quick checks as you go.

Try it yourself: free lesson

“Don't spill the coffee” is lesson 4 of 6 in Balance Bluffs, Control Systems World 3. Free with an account. Lessons unlock in order, so you’ll do the 17 before it first.

Or start from the very first lesson, no account needed

Practice questions

Three quick questions from the lessons. Pick an answer to check it.

  1. Question 1 of 3vel is 0.8 m/s and 0.3 m is left. Stopping distance = vel² ÷ 2. Should the robot brake?
    Show the answer

    Answer: Yes: 0.8² ÷ 2 = 0.32 m, more than the 0.3 m left. It needs 0.32 m to stop and has 0.3. Brake now, and it stops just about on the mark.

    • Why not “No: keep speeding up”? Speeding up would make the stopping distance even longer than the 0.3 m left, and it would overshoot.
    • Why not “Only if it's late”? The rule doesn't watch the clock. Once the stopping distance reaches the distance left, it brakes.
    • Why not “No: cruise”? Cruising at 0.8 m/s still needs 0.32 m to stop, more than is left.
  2. Question 2 of 3A trapezoid profile…
    Show the answer

    Answer: Speeds up gently, cruises, and brakes just in time. Planned speed, three phases. The robot's loops follow it easily.

    • Why not “Brakes first”? It can't brake before it's moving. Braking comes at the end, once the stopping distance reaches what's left.
    • Why not “Moves at one fixed speed all the way”? One fixed speed is a plain ramp. It has to jump to that speed at the start and stop dead at the end.
    • Why not “Jumps straight to the goal”? Jumping to the goal is what a profile avoids: the loops see the whole error at once and floor it.
  3. Question 3 of 3In a cascade, the outer loop's output is…
    Show the answer

    Answer: The inner loop's target. The outer loop gives orders, the inner loop carries them out. Here the profile is one more loop of orders on the outside: it tells the robot's loops where to be.

    • Why not “The motor drive”? Only the innermost loop drives the motor. Each outer loop gives orders to the loop inside it.
    • Why not “The sensor reading”? Sensor readings are inputs to the loops, not what they put out.
    • Why not “The clamp”? A clamp can limit the outer loop's order, but it isn't what the loop produces.
Keep practising: free lesson

“Don't spill the coffee” is lesson 4 of 6 in Balance Bluffs, Control Systems World 3. Free with an account. Lessons unlock in order, so you’ll do the 17 before it first.

Questions people ask

What is a trapezoidal velocity profile?

A plan for a move in which the speed rises at a constant acceleration, holds at a top speed, then falls at a constant deceleration to zero at the target. Plotted against time the speed is a trapezoid, and its area is the distance moved.

How long does a trapezoidal move take?

Reaching top speed v at acceleration a takes v ÷ a and covers v² ÷ 2a; braking takes the same. The rest of the distance is at v. For 1.5 m at 1 m/s and 1 m/s²: 1 s up, 1 s down, and the middle 0.5 m at 1 m/s takes 0.5 s, so 2.5 s in all.

What is the difference between a trapezoidal and an S-curve profile?

A trapezoid changes acceleration instantly at each corner. An S-curve also limits how fast the acceleration changes, the jerk, so the corners are rounded. It takes a little longer but shakes the machine less, which suits lifts, precision tools and fragile loads.

Every topic