PID Control Tuner

Tune a PID controller and see how the output follows a step setpoint through a first-order plant.

Loading interactive simulation...

on a first-order plant the D term has nothing to damp 🖖

The proportional term reacts to the present error and the integral term removes the offset it leaves behind. Watch P alone do it: at kp = 1.2 the output parks at 0.5455 and stays there, short by exactly kp/(1 + kp) for ever. Adding ki closes that gap. The derivative term is the odd one out on this plant, because kd·de/dt feeds back the output's own rate: the loop becomes (τ + k·kd)ẏ = −y + k(kpe + ki∫e), so it enlarges the time constant rather than damping anything. With integral action present a slower loop winds up further, and raising kd from 0 to 0.6 at kp = 1.3, ki = 2.5 takes the overshoot from 6.6% to 14.6%. Derivative action earns its keep on systems with inertia to oppose. This one has none.

controlling by the gap, not the goal 🖖

The controller never sees the setpoint as a direct command โ€” it only ever knows the error, the gap between where the output is now and where you want it. Every push it sends is a reaction to that gap, working to shrink it toward zero. Watch the step response: the setpoint jumps, the error is large, so the controller pushes hard and eases off as the output catches up. Good control comes from reacting to the mistake, not from knowing the perfect move in advance.

born from watching a battleship's helmsman 🖖

The three-term recipe wasn't derived from equations first. In 1922 Nicolas Minorsky worked out PID control by watching an experienced helmsman steer the battleship USS New Mexico. He noticed the sailor corrected not just for how far off course the ship was (proportional), but for how long it had drifted (integral) and how fast the heading was changing (derivative). Automatic steering copied a human's instinct before the theory caught up.

Problems solved in full

  1. Where a controller with nothing but proportional gain actually settles 5 steps

    A controller with nothing but proportional gain is asked to hold an output at 1. Find where it actually settles, and find why the rise-time row says the target was never reached. This is P only: Kp = 1.2, Ki = 0, Kd = 0, plant time constant ฯ„ = 1 s, plant gain K = 1, setpoint r = 1.

    1. Three facts close the loop into one equation. The controller pushes with Kp times the error, the plant drifts toward K times whatever it is pushed with, and the error is what the setpoint has left over after the output. Substituting the last two into the first leaves y talking only to itself.

    2. Settled means the derivative is 0, and that turns the differential equation into arithmetic you can do in your head. The gain appears twice โ€” once in the numerator and once in the sum below it โ€” and that is the whole shape of the answer.

    3. Subtract to get the error that is left, and watch r cancel out of the fraction. The offset is a fraction of whatever you asked for, not a fixed amount: ask for 100 and you miss by 45.45, ask for 1 and you miss by 0.4545. It is a property of the loop, not of the request.

    4. Why the loop cannot do better takes one line, and it is the point of the whole problem. The controller's only output is Kp times the error. A zero error commands zero push, and zero push holds the plant at zero. The controller needs a permanent error to generate the permanent push that keeps y up โ€” check it: the settled command is 0.5455, which is exactly the output it is holding. The offset is not bad tuning, it is the mechanism.

    5. That also explains the empty row. Rise time is the first instant y reaches 0.9r, and y can never climb past its own ceiling of 0.5455. So the reading is not telling you the loop is slow โ€” it is telling you the target is above the ceiling. Solve for the gain that lifts the ceiling to 0.9 and you get 9, so every Kp below 9 produces that same blank.

    Answer

    The tool prints y(10 s) = 0.55 and a steady-state error of 0.455, with rise time and settling time both unreached. Now the sting. The factor 1 + KยทKp = 2.2 that divides the error also divides the plant's time constant, so this loop reaches its wrong answer in 0.4545 s instead of the plant's own 1 s. Speed and accuracy are the same knob, and the knob is expensive: squeezing the error down to 1% needs Kp โ‰ฅ 99, and at t = 0 the error is the full setpoint, so the controller opens by demanding 99 times the output it is trying to produce. Proportional gain never removes the offset โ€” it only makes it small enough to ignore, and charges you a violent first move for it. Removing it needs a term that keeps pushing after the error has stopped changing.

  2. How much offset survives an integrator after 10 s 5 steps

    An integrator is supposed to make the offset disappear. Find how much of it survives after 10 s, and find the gain at which this loop would start to ring instead. This is PI: Kp = 1, Ki = 0.6, Kd = 0, ฯ„ = 1 s, K = 1, r = 1.

    1. That the offset goes is an argument, not a calculation. Suppose the loop settles with a constant error that is not 0. Then its running integral grows without limit, so the command grows without limit, so the output grows without limit โ€” which is not settling. The only constant error a settled PI loop can have is 0, whatever the gains are.

    2. Knowing it gets there says nothing about when. Differentiate the loop equation once to kill the integral sign, and notice what has happened to the order: a first-order plant under PI control is a second-order system, with all the behaviour that implies.

    3. The error obeys the same equation with the setpoint drive removed, so it is a sum of exponentials whose rates are the roots. Here the discriminant is positive, both roots are real and negative, and there is nothing left to oscillate with โ€” which is why the overshoot row reads 0.0% rather than some small percentage.

    4. Two starting conditions fix the two weights. At t = 0 nothing has moved, so the error is the whole setpoint; and the plant's opening slope is KยทKpยทr/ฯ„ = 1, so the error's opening slope is -1. Solve the pair and both weights come out at exactly 0.5, which is a coincidence of these gains and not a general result.

    5. At 10 s the fast root is long dead โ€” its term is down to 4ร—10โปโธ โ€” so the slow one is the whole answer, and it has had only 3.7 of its own time constants to work in. Nothing has gone wrong; the loop is simply still on its way.

    Answer

    The tool prints y(10 s) = 0.99 and a residual error of 0.013. The offset is leaving, but at the end of the window it is still 1.3%, and that is the honest price of integral action: it removes the error in principle and takes its time in practice. Reaching 0.1% needs ln(500)/0.3675 = 16.9 s, off the right-hand edge of the plot, so this window cannot show you a finished PI loop at these gains. Raise Ki to hurry it and you run into a wall โ€” the discriminant goes negative at Ki = 1, past which the roots are complex and the response rings. The deeper difference is worth more than either number. The proportional offset was r/(1 + KยทKp), which contains the plant gain, so a valve that fouls or a motor that weakens moves the answer: halve K and the P-only miss grows from 0.455 to 0.625. The PI settling point contains no K at all. That is why industrial loops carry an integrator โ€” not because it is more accurate today, but because it stays accurate when the plant changes underneath it.

References (1)

Example problems

  • P only - kp = 1.2 alone parks the output at 0.5455 and leaves it there. The 45.5% shortfall is exactly kp/(1 + kp) - proportional control cannot close the last gap.
  • PI - The same plant with ki = 0.6 added reaches 0.9873 by ten seconds and is still closing. Integral action is what removes the offset P alone leaves behind.
  • with derivative - kd = 0.2 on top of kp = 1.3 and ki = 0.5, and it barely moves anything: 0.9663 at ten seconds against PI's 0.9873. On a first-order plant the D term adds lag rather than damping.