Trapezoidal Velocity Profiles for Smooth Motion

A trapezoidal velocity profile moves a robot axis by accelerating at a constant rate, cruising at a set top speed, then decelerating at the same rate.

Reference
RE-4115
Published
Read
7 min

About the author · Editorial & verification standards

Laptop showing a step response plot beside a single-joint servo test rig with a weight

A trapezoidal velocity profile moves a robot axis by accelerating at a constant rate, cruising at a set top speed, then decelerating at the same rate. The acceleration time is v / a and each ramp covers v squared over 2a of distance, so the whole move can be planned with a few lines of arithmetic.

Key takeaways

  • A trapezoidal profile has three phases: constant acceleration, constant speed, constant deceleration.
  • Acceleration time is t = v / a and acceleration distance is d = v^2 / (2a).
  • If the move is shorter than v^2 / a, the profile becomes a triangle and the top speed is never reached.
  • Total time for a normal move is D / v + v / a, where D is the move distance.

Accelerate, Cruise, Decelerate

A trapezoidal velocity profile is a speed-versus-time shape with a sloping start, a flat top and a sloping end. Plot speed against time and it looks like a trapezoid, which gives the profile its name.

MECHATRONICS CLOSED-LOOP CONTROL ARCHITECTURESensor StageEncoder · IMU · Load CellControllerMCU / PLC / Motion LoopDriver StageMOSFET / Servo DriveActuatorMotor / AxisFeedback & Safety Interlock: Fault Monitoring · E-Stop · Isolated PowerDeterministic Control Loop · Star Ground Reference
Figure: Mechatronics closed-loop control architecture linking sensor feedback, controller, power driver stage, and mechanical actuator.

Why not jump straight to full speed? A motor cannot change speed instantly, and a sudden change makes wheels slip, loads slide and steppers lose steps. Ramping the speed keeps the force needed within what the motor can supply. The force needed is mass times acceleration, so a lower acceleration asks less of the motor, as discussed in the related reading on motor selection.

Acceleration Time Formula

Acceleration time is the time needed to reach top speed at a constant acceleration. From the definition of acceleration, a = v / t, so:

t_acc = v_max / a

The deceleration time is the same if you use the same magnitude of acceleration. Units must agree: if speed is in metres per second and acceleration in metres per second squared, time comes out in seconds. For a stepper, you can work in steps per second and steps per second squared instead, and the formulas do not change. The stepper step frequency calculator helps convert between speed and step rate.

Distance Covered in Each Phase

The distance in the acceleration phase is the average speed times the time. Speed rises evenly from 0 to v_max, so the average is v_max / 2:

d_acc = (v_max / 2) * t_acc = v_max^2 / (2 * a)
d_dec = d_acc
d_cruise = D - 2 * d_acc
t_cruise = d_cruise / v_max

Total time is t_total = 2 * t_acc + t_cruise. You can also write this as D / v_max + v_max / a, which is quicker to type into a calculator. The cycle time of a repeating task is built from sums like this, as described in the robot cycle time calculation guide.

Worked Example for a 1 m Move

Assumptions: move distance D = 1.0 m, top speed v_max = 0.5 m/s, acceleration a = 1.0 m/s^2.

  1. Acceleration time: t_acc = 0.5 / 1.0 = 0.5 s
  2. Acceleration distance: d_acc = 0.5^2 / (2 * 1.0) = 0.25 / 2 = 0.125 m
  3. Deceleration distance: also 0.125 m, so the two ramps cover 0.25 m
  4. Cruise distance: 1.0 - 0.25 = 0.75 m
  5. Cruise time: 0.75 / 0.5 = 1.5 s
  6. Total time: 0.5 + 1.5 + 0.5 = 2.5 s

Check with the shortcut formula: D / v_max + v_max / a = 1.0 / 0.5 + 0.5 / 1.0 = 2.0 + 0.5 = 2.5 s. Both agree.

PhaseTime (s)Distance (m)Speed (m/s)
Accelerate0.50.1250 to 0.5
Cruise1.50.7500.5
Decelerate0.50.1250.5 to 0
Total2.51.000

For a build that does straight moves with feedback, see the straight-line encoder robot project.

Coding the Profile

Coding the profile means writing a function that returns the wanted speed at any time since the move started. The sketch below is a plain C++ style function that works on an Arduino. It is untested, so check it against your own numbers before relying on it.

// UNTESTED sketch: speed at time t for a trapezoidal move.
// D = distance, vmax = top speed, a = acceleration (all positive).
float profileSpeed(float t, float D, float vmax, float a) {
  float tAcc = vmax / a;
  float dAcc = 0.5f * a * tAcc * tAcc;      // = vmax*vmax/(2a)
  if (2.0f * dAcc > D) {                    // short move: triangle
    vmax = sqrtf(a * D);                    // lower peak speed
    tAcc = vmax / a;
    dAcc = 0.5f * D;
  }
  float tCruise = (D - 2.0f * dAcc) / vmax;
  float tTotal  = 2.0f * tAcc + tCruise;
  if (t < 0.0f || t >= tTotal) return 0.0f;     // not moving
  if (t < tAcc) return a * t;                    // accelerate
  if (t < tAcc + tCruise) return vmax;           // cruise
  return a * (tTotal - t);                       // decelerate
}

Call it from a timed loop, for example every 10 ms, and send the result to your speed controller or step generator. A closed loop on the wheel or joint still needs tuning, covered in the PID tuning for robot motion post. For a stepper axis, the A4988 stepper driver datasheet lists the maximum step rate it accepts. More background is in the Learn hub.

When the Move Is Too Short

A move is too short when the distance is less than v_max^2 / a, because there is no room to reach top speed before braking must start. The profile then becomes a triangle with a lower peak speed:

v_peak = sqrt(a * D)
t_total = 2 * sqrt(D / a)

With the numbers above, the limit is 0.5^2 / 1.0 = 0.25 m. Try D = 0.16 m. Since 0.16 is less than 0.25, the profile is a triangle. v_peak = sqrt(1.0 * 0.16) = 0.4 m/s, which is below the 0.5 m/s limit. Time is 2 * sqrt(0.16 / 1.0) = 2 * 0.4 = 0.8 s. Check: each ramp lasts 0.4 / 1.0 = 0.4 s and covers 0.4^2 / 2 = 0.08 m, so two ramps cover 0.16 m. Correct.

How to check this yourself

  1. Pick your own D, v_max and a. Compute v_max^2 / a first to see whether the move is a trapezoid or a triangle.
  2. Compute the three phase times and add them. Compare with D / v_max + v_max / a.
  3. Print profileSpeed() over time in the serial monitor and confirm the ramps and the flat top.
  4. Add up speed times the time step across the whole profile. The sum should be close to D.
  5. Run the move on the real axis with a safe margin, and compare the actual travel time, measured with a stopwatch or the controller clock, to the plan.

Common mistakes

  • Setting acceleration higher than the motor torque can deliver, so a stepper stalls or a wheel slips.
  • Forgetting the short-move case and getting a negative cruise time.
  • Mixing units, such as millimetres in distance and metres per second in speed.
  • Using the same acceleration for heavy and light loads without checking the motor’s torque curve.

Quick checklist

  • Compute v_max^2 / a and compare it with the move distance.
  • Keep units consistent throughout.
  • Choose acceleration within motor torque limits.
  • Verify the plan by summing speed over time.
  • Start with a low acceleration and increase it gradually.

Frequently asked questions

What is a trapezoidal velocity profile?

It is a motion plan in which speed rises at a constant rate, stays constant, then falls at a constant rate. The speed graph looks like a trapezoid. It is common in stepper and servo control because it limits acceleration, which protects motors and loads while keeping the move time short.

How do I calculate the time for a trapezoidal move?

Use total time equals distance divided by top speed, plus top speed divided by acceleration. For 1 m at 0.5 m/s and 1 m/s squared, that is 2.0 plus 0.5, or 2.5 seconds. This works only if the distance is at least top speed squared divided by acceleration.

Why does my stepper motor miss steps when it starts?

Starting at high step rate asks for more torque than the motor can supply at that speed, and the rotor falls out of step. Ramping the step rate up gradually, as in a trapezoidal profile, keeps the torque needed within the motor’s curve. Check your motor and driver datasheets for limits.

About the author and how this is kept accurate

Written, checked and maintained by Jignesh Panchal of Jaadu Digital. Figures in worked examples come from the stated assumptions, not from a bench test of our own. Read the editorial standard, follow the author on LinkedIn, or send a correction. Last reviewed: November 2026.

Pass it onWhatsAppLinkedIn

Keep reading

Continue learning

Free: the final-year project pack

A shortlist with BOMs, a report outline that matches the usual chapter scheme, a costing sheet and 40 viva questions. Built for the February–April submission season.

The Build Note

One short email when something is worth your bench time.

A new build sheet, a part price that moved, or a mistake worth avoiding. No daily drip, no recycled news.

One short email when a build or a price is worth your time. Unsubscribe in one click.