PID step response simulator

Choose a plant and the PID gains Kp, Ki and Kd to see how the output responds when the setpoint steps from 0 to 1. The graphs show the steady-state error left by P alone, how I removes it, how too much gain causes oscillation, and the integral windup caused by an actuator limit.

Plant and controller

Results

Final value
–
Steady-state error (setpoint − final)
–
Overshoot
–
Rise time (10→90%)
–
Settling time (±2%)
–
Peak control effort (absolute)
–

In the upper graph the blue line is the output and the dashed line is the setpoint (1). In the lower graph the green line is the controller output; a dashed line marks the actuator limit when one is set.

What P, I and D each do

A PID controller adds three terms: P, proportional to the error e between setpoint and output; I, proportional to the integral of e over time; and D, proportional to how fast e is changing. A larger P responds faster, but on a first-order plant an error remains. In the "P control only" example (K = 1, Kp = 4) the final value is K·Kp/(1 + K·Kp) = 0.8, leaving a steady-state error of 0.2. Adding I keeps increasing the control effort while any error remains, so the steady-state error disappears. D acts on the trend of the error and reduces overshoot and oscillation, but it amplifies noise, so it is normally used with a filter.

Overshoot and damping ratio

In a second-order system, the smaller the damping ratio ζ, the larger the overshoot; the peak overshoot of the step response is exp(−πζ/√(1 − ζ²)). In the "second-order plant" example the closed-loop ζ is about 0.14 and the overshoot is about 64%. As a guide, ζ = 0.5 gives about 16% and ζ = 0.7 about 5%. In the motor-position example, P control of an integrating plant gives a closed loop with ζ = 0.5 and about 16% overshoot. Because the plant contains an integrator, P control alone leaves no steady-state error for a step input.

Dead time and too much gain

Dead time is the delay between acting and seeing any effect at the output, caused for example by transport through pipes or by measurement and communication delays. With dead time, the controller acts on an output that is already out of date, so too much gain makes the loop oscillate and even more makes it diverge. In the "too much gain" example the output diverges at Kp = 20. Tuning rules such as Ziegler–Nichols give starting gains from the dead time and time constant, but on real equipment it is safer to start with modest gains and adjust while watching the response.

Integral windup and anti-windup

Real actuators have limits, such as a motor voltage or a valve opening. While the actuator is saturated and the output cannot keep up, the integrator keeps accumulating error. Once the setpoint is reached, the control effort stays high until that accumulated integral is worked off, which causes a large overshoot: integral windup. In the windup example a limit of 1.5 gives about 35% overshoot, and anti-windup reduces it to about 7%. This tool's anti-windup stops integrating while the actuator is saturated and the error would push it further into the limit. Another common method feeds the difference between the requested and limited output back into the integrator (back-calculation).

Practice control engineering questions

A step is applied to a second-order system (standard form without zeros) with a damping ratio ζ = 0.5. Which of the following is closest to the overshoot (the maximum excursion beyond the final value, as a fraction of the final value)?

  1. AAbout 16%
  2. BAbout 21%
  3. C50%
Show answer and explanation

Answer: A. About 16%

The overshoot of a standard second-order system is exp(−πζ/√(1 − ζ²)) and does not depend on the natural angular frequency ωn. For ζ = 0.5 it is exp(−π × 0.5/√0.75) ≈ exp(−1.81) ≈ 0.163, about 16%. For ζ ≈ 0.707 (1/√2) it is about 4.3%, a value often used as a guideline for a response with little overshoot. The overshoot peaks at the time π/ωd, where ωd = ωn√(1 − ζ²).

In a unity-feedback system the forward transfer function is G(s) = 9/(1 + 2s). Which of the following is the steady-state error for a step setpoint of size 1?

  1. A0
  2. B0.1
  3. CAbout 0.11
Show answer and explanation

Answer: B. 0.1

For a unity-feedback system, the steady-state error to a step is 1/(1 + Kp), where Kp = G(0) is called the position error constant. Here Kp = 9, so the steady-state error is 1/(1 + 9) = 0.1. In a system whose forward path has no integrator (a type 0 system), raising the gain makes the error smaller but not zero. To bring the error to zero, an integrator is added, for example with PI control.

A plant that contains no integrator (a type 0 system) is under proportional (P) control. Which of the following correctly describes the general change when the proportional gain Kp is increased?

  1. AThe steady-state error becomes smaller but not zero, and too large a gain makes the response oscillatory or unstable
  2. BThe steady-state error becomes exactly zero, and the response always stays stable without any oscillation, however large the gain is made
  3. CThe speed of response does not change, and only the steady-state error grows
Show answer and explanation

Answer: A. The steady-state error becomes smaller but not zero, and too large a gain makes the response oscillatory or unstable

Proportional control is the most basic control, producing a manipulated variable proportional to the error. Increasing Kp makes the response faster and reduces the steady-state error to a step, 1/(1 + Kp·K) where K is the steady-state gain of the plant, but with no error the manipulated variable would also be zero, so the error does not reach zero (offset). Raising the gain also reduces the phase margin and increases the overshoot, and a plant with a large lag becomes unstable. Integral action is added to remove the steady-state error.

Which of the following is the correct pair of the main purpose of adding integral (I) action in PI control and its side effect?

  1. AThe purpose is to remove high-frequency noise, and the side effect is a larger steady-state error
  2. BThe purpose is to remove the steady-state error to a constant setpoint or disturbance, and the side effect is a phase lag that makes the loop more prone to oscillation
  3. CThe purpose is to anticipate changes in the error, speeding up the response and suppressing overshoot, and the side effect is strong amplification of high-frequency noise
Show answer and explanation

Answer: B. The purpose is to remove the steady-state error to a constant setpoint or disturbance, and the side effect is a phase lag that makes the loop more prone to oscillation

Integral action accumulates the error over time into the manipulated variable, so it keeps changing the manipulated variable as long as any error remains and finally brings the steady-state error to zero. On the other hand, an integrator delays the phase by 90°, which reduces the phase margin and makes overshoot and oscillation more likely. The integral time Ti is therefore tuned so that it is not too short. Speeding up the response, suppressing overshoot and tending to amplify noise are features of derivative action.

Which of the following correctly describes integral windup?

  1. AA phenomenon in which the derivative term amplifies noise and the manipulated variable keeps oscillating finely; it is prevented by adding a low-pass filter to the derivative
  2. BA phenomenon in which a steady-state error persists because the sampling period in the integral calculation was made too long
  3. CA phenomenon in which the integral term keeps accumulating the error while the manipulated variable is stuck at its upper limit, so the manipulated variable does not come down for a while even after the error changes sign, causing a large overshoot
Show answer and explanation

Answer: C. A phenomenon in which the integral term keeps accumulating the error while the manipulated variable is stuck at its upper limit, so the manipulated variable does not come down for a while even after the error changes sign, causing a large overshoot

Manipulated variables such as a motor voltage or a valve opening have upper and lower limits. When a large error continues and the manipulated variable saturates at its upper limit, the manipulated variable cannot increase any further, yet the integral term keeps accumulating the error and grows large. Even after the controlled variable passes the setpoint and the error changes sign, the manipulated variable stays at its upper limit until the accumulated integral comes down, which causes a large overshoot and a long oscillation. As a countermeasure, anti-windup is used, which stops integrating or limits the integral while the output is saturated.

Positional PI control is implemented on a microcontroller, with the duty cycle of a PWM signal (0 to 100%) as the manipulated variable. Which of the following is a correct countermeasure against integral windup?

  1. AWhile the output is saturated, increase the proportional gain to get out of saturation sooner
  2. BIf the integral term is calculated in floating point no overflow occurs, so no special measure is needed
  3. CWhile the output is saturated, stop integrating if the error would deepen the saturation, or feed the difference from the limited value back into the integrator, to hold down the integral
Show answer and explanation

Answer: C. While the output is saturated, stop integrating if the error would deepen the saturation, or feed the difference from the limited value back into the integrator, to hold down the integral

The first method is conditional integration (clamping): while the output is saturated and the error would deepen the saturation, the integral is not updated. The second is back-calculation: the difference between the value calculated before limiting and the value actually output is multiplied by a coefficient and fed back into the integrator to pull the integral back. In the velocity form of PID control, which calculates the change in the manipulated variable, simply limiting the output makes windup unlikely. When calculating in integer fixed point, overflow of the integral variable itself must also be guarded against, for example with saturating arithmetic.

FAQ

How should I choose PID gains?

A basic approach is to raise P alone to just below the point where the response starts to oscillate, add I to remove the steady-state error, and add D if the overshoot is too large. If you know the dead time and time constant, tuning rules such as Ziegler–Nichols give starting values. On real equipment, also allow for actuator limits and noise, and start with modest gains.

Why does P control alone leave a steady-state error?

With P control the output of the controller is proportional to the error, so some error must remain to keep producing control effort. For a first-order plant K/(Ts+1) the final value is K·Kp/(1 + K·Kp) and the error is 1/(1 + K·Kp). Adding I, or a plant that contains an integrator, removes the steady-state error for a step input.

Why is the derivative term filtered?

The derivative amplifies fast changes, so it amplifies measurement noise, and a sudden setpoint change makes the control effort spike. A first-order low-pass filter limits the high-frequency gain. In this tool the filter time constant is Kd/(N·Kp); a smaller N means stronger filtering.

Related terms

PID control Integral windup Overshoot Settling time Steady-state error First-order system Second-order system Time constant

Related comparisons

Related calculators

Semiconductor, Electronics and Computing Calculators →