D33 of 10
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

D3 · Lesson 3 · PID control and tuning

The proportional, integral and derivative terms and what each does, a drone holding altitude as a mass under PD control with its natural frequency and damping, overshoot and settling, the integral term that removes steady droop, and Ziegler–Nichols tuning

More than nine in ten industrial control loops are PID controllers: three terms, three knobs. The proportional term pushes in proportion to the error, the integral term keeps pushing harder for as long as any error remains, and the derivative term brakes when the error is changing fast. A quadcopter holding its altitude is a good place to see them work, because the drone is a mass with almost no friction: thrust accelerates it, and without the derivative term it would bounce up and down forever around its setpoint.

  • A 1.2 kg drone told to climb 1 m. Its altitude controller adds thrust Kpe−Kdh˙ to the hover thrust: proportional to the height error, minus a damping term proportional to the climb rate.
  • The drone behaves as a mass on a spring (Kp) with a damper (Kd): natural frequency ωn=Kp/m, damping ratio ζ=Kd/(2Kpm).
  • Too little Kd and it overshoots and bounces; too much and it creeps up slowly. ζ around 0.7 is a common compromise.

Predict

With Kp = 4.8 N/m and Kd = 2.4 N·s/m, the 1.2 kg drone has ζ = 0.5. By how much does it overshoot a 1 m climb?

Name it

The three terms

u(t)=Kpe(t)+Ki∫0tedτ+Kddedt
  • Proportional: reacts to the present error. More Kp responds faster but, on a plant like the drone, oscillates more.
  • Integral: reacts to accumulated past error, so it keeps growing until the error is zero. It removes steady-state error (lesson 2) but adds overshoot and can wind up when the actuator saturates.
  • Derivative: reacts to the error's rate of change, a prediction of where it's heading, which adds damping. It amplifies sensor noise, so it's filtered, and it's often applied to the measurement instead of the error to avoid a jolt when the setpoint jumps.

The drone

With mass m, PD control on the altitude gives mh¨+Kdh˙+Kph=Kphref, a second-order system with

ωn=Kp/m,ζ=Kd2Kpm

overshoot e−πζ/1−ζ2 and a 2% settling time of about 4/(ζωn).

A constant disturbance force Fd, such as thrust lost as the battery sags, leaves a steady altitude error of Fd/Kp under PD control. Adding the integral term drives it to zero.

Ziegler–Nichols tuning

Raise Kp alone until the loop oscillates steadily. That ultimate gain Ku and the oscillation's period Pu give a starting point:

Kp=0.6Ku,Ti=Pu/2,Td=Pu/8

with Ki=Kp/Ti and Kd=KpTd. The result is aggressive, with about 25% overshoot, and is usually softened by hand.

Worked example

The drone's battery sags and it loses 0.24 N of thrust. Under PD control with Kp = 4.8 N/m, how far does it sink? What fixes it?

Show the solution
  1. How far it sinks. Fd/Kp=0.24/4.8=0.05m
  2. The fix. An integral term keeps adding thrust while any error remains, so it settles back at the setpoint.

Answer it sinks 0.05 m, and an integral term brings it back to the setpoint.

Worked example

A loop oscillates steadily at Ku = 10 with period 2 s. What PID gains does Ziegler–Nichols suggest?

Show the solution
  1. Proportional gain. Kp=6
  2. Integral gain. Ti=1s so Ki=6 s⁻¹.
  3. Derivative gain. Td=0.25s so Kd=1.5 s.

Answer Kp = 6, Ki = 6 s⁻¹ and Kd = 1.5 s.

Worked example

The sagging drone sits 0.05 m low when an integral term with Ki = 6 N/(m·s) is switched on. At first, how fast does the integral's force grow, and roughly how long until it makes up the lost 0.24 N?

Show the solution
  1. How fast the force grows. Kie=6×0.05=0.3N/s
  2. Time to make up 0.24 N. If the error stayed put: 0.24/0.3=0.8s
  3. What really happens. The drone rises as the force builds, the error shrinks, and the last of the correction comes more slowly.

Answer the integral's force grows at 0.3 N/s at first, so it makes up the 0.24 N in roughly 0.8 s.

Check

A 1.2 kg drone's altitude loop has Kp = 2 N/m. What's its natural frequency?

Write units the way you normally would: 1.5 rad/s and 1500 mrad/s are the same answer.

Check

The same drone (1.2 kg, Kp = 2 N/m) has Kd = 2.5 N·s/m. What's its damping ratio?

Check

A second-order loop has damping ratio 0.4. By what percentage does it overshoot a step?

Check

A disturbance force of 0.3 N acts on a drone under PD altitude control with Kp = 2 N/m. How far does it settle from its setpoint?

Write units the way you normally would: 1.5 cm, 15 mm and 0.015 m are the same answer.

Check

A loop oscillates steadily at an ultimate gain of 10 with period 0.5 s. What derivative gain Kd does Ziegler–Nichols suggest?

Write units the way you normally would: 1.5 s and 1500 ms are the same answer.

Check

A PD-controlled drone with Kp = 2 N/m loses 0.24 N of thrust; then an integral term with Ki = 6 N/(m·s) is added.

(a)

How far does it sink under PD alone?

Write units the way you normally would: 1.5 m, 1500 mm and 0.0015 km are the same answer.

(b)

At what rate does the integral's force grow at first?

Check

A loop oscillates steadily at gain 10 with period 0.5 s. Ziegler–Nichols PID sets Kp=0.6Ku, Ti=Tu/2 and Td=Tu/8.

(a)

What is Kp?

(b)

What is Ki=Kp/Ti?

(c)

What is Kd=KpTd?

Explain why

What does each term of a PID controller contribute?

Practice

Keep practicing

10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.