Skip to content
Tactiverge
← Robotics Expedition

Level 4 · Systems Engineer · Advanced high school, AP or pre-university. Strong algebra, trigonometry and programming; developing calculus. · about 45 min

Fast, stable, accurate: pick two?

Transient response, the P/PI/PID trade-offs, and what sampling does to a control loop.

You'll be able to

  • Quantify a step response with overshoot, peak time, settling time and steady-state error.
  • Derive the closed-loop damping ratio and natural frequency of a P-controlled second-order joint.
  • Explain, with evidence from the lab, what integral and derivative action each buy and cost.
  • Write a sampled control loop as a discrete-time update and find the gain at which it becomes unstable.

01The problem

The arm from Level 3 now has a springy, lightly damped elbow: its gearbox and the cable to the gripper flex a little. The team wants the hand on target quickly, so they raise the proportional gain. The response gets faster, but the hand now swings past the target by more than half the move and rings for seconds. They add integral action to remove the remaining error, and the swing gets worse. A colleague suggests running the controller less often to save processor time, and at one setting the arm starts shaking itself apart.

Speed, stability and accuracy seem to fight each other. Is that a law of nature, or a sign the controller is badly designed? To decide, you need numbers that describe a response, models that predict those numbers, and an understanding of what each part of a PID controller, and the sampling rate itself, does to them.

02The idea

Describing a response with numbers

When a joint is told to move to a new angle (a step), its response is summarised by a few standard measures:

  • Overshoot: how far the peak goes past the final value, as a percentage of the final value.
  • Peak time: when that peak happens.
  • Settling time: when the output enters a ±2 % band around its final value and stays there.
  • Steady-state error: target minus final value.

These are what "fast", "stable" and "accurate" mean in practice. Fast is short rise and settling times; stable means it settles at all, with little overshoot; accurate is small steady-state error.

Second-order joints ring

A joint with springiness and inertia behaves like a second-order system:

τ²·θ'' + 2ζτ·θ' + θ = K·u

where ζ (the damping ratio) sets how much it rings. Below ζ = 1 the response overshoots, and the smaller ζ, the bigger the overshoot. Put a P controller around it and the algebra in the maths section shows something uncomfortable: the natural frequency rises with √(1 + K·Kp), but the damping ratio falls by the same factor. More gain means faster, more accurate and less damped, all at once. That is the trade-off the team saw.

What I and D buy, and what they cost

Integral action adds a term proportional to the accumulated error. As long as any error remains, the integral keeps growing and pushing, so it drives the steady-state error to zero, even against a constant load. The cost is that the integral has momentum: it keeps pushing after the error has crossed zero, which adds overshoot, and a large integral gain can make the loop unstable.

Derivative action adds a term proportional to how fast the output is changing, opposing rapid motion like a shock absorber. It adds damping, so overshoot falls and settling is quicker. The cost is sensitivity to sensor noise, because differentiating a noisy signal amplifies the noise; real controllers filter it, as the lab does.

So "pick two" is not a law. With P alone you can't have all three. PI buys accuracy, PID buys back the damping, and the remaining limits come from the actuator, the noise and the sampling.

Sampling turns a smooth loop into steps

A digital controller reads its sensor, computes a command and holds that command until the next sample. Between samples it is acting on old information. For a first-order plant, holding the command for one sample period T lets you write the loop exactly as a discrete-time update:

y[k+1] = p · y[k] + (input terms)

Whether the loop is stable depends only on the multiplier p: if |p| < 1, errors shrink every sample; if |p| > 1, they grow. Raising the gain pushes p downwards, through zero (where the error alternates sign every sample) and eventually below −1, where the loop oscillates with growing amplitude. Slower sampling makes that happen at much lower gains. Even at the lab's 100 samples per second, the hold adds a small delay that shows up as slightly more overshoot than the continuous-time formula predicts.

Recap

Overshoot, settling time and steady-state error turn "good control" into numbers. For a second-order joint, P gain trades damping for speed and accuracy. Integral action removes steady-state error at the cost of overshoot; derivative action restores damping at the cost of noise sensitivity. Sampling adds delay, and every sampled loop has a gain limit you can compute.

03See it move

Predict before you experiment

On this springy second-order plant, what happens as you raise Kp from 1 to 8?

04The maths

P control of a second-order joint

Plant and controller:

τ²·θ'' + 2ζτ·θ' + θ = K·u
u = Kp·(r − θ)

Substitute and collect terms:

τ²·θ'' + 2ζτ·θ' + (1 + K·Kp)·θ = K·Kp·r

Compare with the standard form θ'' + 2ζcl·ωn·θ' + ωn²·θ = ωn²·θss:

ωn  = √(1 + K·Kp) / τ
ζcl = ζ / √(1 + K·Kp)
θss = r · K·Kp / (1 + K·Kp)

For ζcl < 1 the standard results are:

overshoot  = 100 · exp(−ζcl·π / √(1 − ζcl²))  %
peak time  = π / (ωn · √(1 − ζcl²))
settling  ≈ 4 / (ζcl · ωn)          (2 % band, rule of thumb)

Note that ζcl·ωn = ζ/τ does not depend on Kp: on this plant, P gain alone can't make the oscillation die out faster.

The sampled first-order loop

Take τ·y' = −y + K·u with u held constant for one sample period T. Solving exactly over one period:

y[k+1] = a·y[k] + K·(1 − a)·u[k],   a = e^(−T/τ)

With u[k] = Kp·(r − y[k]):

y[k+1] = (a − K·Kp·(1 − a))·y[k] + K·Kp·(1 − a)·r

The multiplier p = a − K·Kp·(1 − a) must satisfy |p| < 1. It falls as Kp rises and reaches −1 when

Kp_max = (1 + a) / (K·(1 − a))

A short script checks this for T = 0.2 s, τ = 1 s, K = 1:

import math

T, tau, K = 0.2, 1.0, 1.0      # sample time (s), time constant (s), plant gain
a = math.exp(-T / tau)

for kp in (5, 10, 10.5):
    p = a - K * kp * (1 - a)
    print(kp, round(p, 3), "stable" if abs(p) < 1 else "unstable")
print("limit", round((1 + a) / (K * (1 - a)), 2))
5 -0.088 stable
10 -0.994 stable
10.5 -1.085 unstable
limit 10.03

For small T, Kp_max ≈ 2τ ÷ (K·T): halving the sample rate roughly halves the gain you can use.

05Worked example

A springy joint has τ = 0.5 s, ζ = 0.4 and K = 1, under P control with Kp = 3 and a step command r = 1. Predict the final value, closed-loop damping ratio, natural frequency, overshoot, peak time and settling time, and compare with the lab.

Show the worked solution

Final value. θss = 3 ÷ (1 + 3) = 0.75, a steady-state error of 0.25.

Natural frequency. ωn = √4 ÷ 0.5 = 4 rad/s.

Damping. ζcl = 0.4 ÷ √4 = 0.2. The bare joint had ζ = 0.4; feedback has halved its damping.

Overshoot. 100 · exp(−0.2π ÷ √0.96) = 100 · exp(−0.641) ≈ 52.7 %. The peak is about 0.75 × 1.527 ≈ 1.15, above the target of 1 even though the final value is below it.

Peak time. π ÷ (4 × √0.96) ≈ 0.80 s.

Settling time. 4 ÷ (0.2 × 4) = 5 s.

Lab comparison. The lab reports a final value of 0.75, a peak at about 0.80 s, settling at about 5.0 s, and an overshoot of about 54 %. The extra 1.3 points of overshoot are the sampling effect: the lab's controller updates every 0.01 s and holds its command in between, which acts like a small delay and removes a little damping. Simulating the same loop with a 0.001 s update gives about 52.8 %, matching the formula.

06Your experiment

  1. In the feedback lab, open “More controls”, choose the 2nd-order plant, and set τ = 0.5 s and ζ = 0.40. Leave noise, disturbance and saturation off.
  2. Choose P with Kp = 3. Record overshoot, settling time and the final value, and compare them with the worked example.
  3. Switch to PI and set Ki = 4 (keep Kp = 3). Record overshoot, settling time and the final value.
  4. Switch to PID and set Kd = 0.30 (keep Kp = 3, Ki = 4). Record the same three numbers.
  5. Go back to PI and raise Ki to 8. Describe what happens.
  6. Optional: with PID, add a little sensor noise (σ = 0.02) and watch the control effort plot.

Record: Make a list with one line per controller (P, PI, PID, PI with Ki = 8): overshoot, settling time and final value. You should see roughly 54 % / 5.0 s / 0.75 for P; about 59 % with no settling inside 10 s for PI; about 35 % / 4.3 s / 1.00 for PID; and a growing oscillation for Ki = 8. Write two sentences on which controller you would choose for the arm and why.

07Guided practice

For the same joint (τ = 0.5 s, ζ = 0.4, K = 1), what closed-loop damping ratio and predicted overshoot does Kp = 8 give?

Hint

ζcl = ζ ÷ √(1 + K·Kp), then use the overshoot formula.

Answer

ζcl = 0.4 ÷ 3 ≈ 0.133, so overshoot ≈ 100 · exp(−0.133π ÷ √(1 − 0.0178)) ≈ 65.5 %. The lab, with its 0.01 s sampling, shows about 68 %.

A first-order loop (τ = 1 s, K = 1) is sampled every T = 0.2 s with Kp = 5. What is the discrete multiplier p, and is the loop stable?

Hint

p = a − K·Kp·(1 − a) with a = e^(−0.2).

Answer

a ≈ 0.8187, so p ≈ 0.8187 − 5 × 0.1813 ≈ −0.088. |p| < 1, so it is stable; the negative sign means any error alternates sign each sample, but it shrinks fast.

The lab runs its controller every 0.01 s on a first-order plant with τ = 1 s and K = 1. What is the largest stable P gain?

Hint

Use Kp_max = (1 + a) ÷ (1 − a) with a = e^(−0.01), or the small-T approximation 2τ ÷ T.

Answer

a ≈ 0.99005, so Kp_max ≈ 1.99005 ÷ 0.00995 ≈ 200. The approximation 2 × 1 ÷ 0.01 = 200 agrees, which is why the lab's slider (up to 20) can't destabilise this plant.

08Check your understanding

  1. 1For a P-controlled second-order joint, how does increasing Kp change the closed-loop damping ratio?
  2. 2In the lab, switching from P to PI on the springy joint removed the steady-state error but increased overshoot. Why?
  3. 3What is the main practical cost of adding derivative action?
  4. 4A sampled first-order loop has discrete multiplier p = −0.6. What does the error do from one sample to the next?
  5. 5Halving a control loop's sample rate, with everything else fixed, roughly does what to the largest stable P gain on a first-order plant?

09Technical challenge

A cheap joint controller runs a P loop on a first-order plant with τ = 1 s and K = 1, but only samples every T = 0.2 s and holds its command in between. Above what value of Kp does the loop become unstable? (Two decimal places.)

10Engineering & research

Every digital controller in a real robot faces these trade-offs: drone flight controllers, motor drives and the joint servos in robot arms all choose gains, filters and sample rates together. Engineers commonly measure step responses exactly as you did, then tune P, I and D against overshoot, settling and noise limits.

Tactiverge's proposed TV-01 study would put controllers like these inside a harder loop: two arms coupled through a soft object, with a camera that sometimes drops out. Every design choice in this lesson becomes a variable such a study would have to control or report: the sample rate of each sensor, the gains of each joint, and how much overshoot the object can tolerate before it is damaged. A careful study plan would fix the controllers in advance and change only the sensing condition being compared. TV-01 is a proposed study that has not yet been carried out, so it has no results to report.

Next, try the mission: Is It Really Better?

Original Tactiverge material, not yet externally reviewed by educators. CC BY 4.0.