Robotics & control

PID Controller Tuning Lab

Tunes a sampled PID controller on a tank level with a dead time or a mass on a spring, with an actuator limit and back-calculation anti-windup: 200 samples of the loop after a setpoint step and an optional load disturbance, the plant discretized exactly by the zero-order hold; the rise time, overshoot and 2% settling time, the final error, IAE, peak control, the share of samples at the limit and the control travel, the disturbance's peak error and recovery time; a comparison run with proportional action only, without the actuator limit, or with the quick (Ziegler-Nichols) or robust (SIMC) rule tuning; the loop's frequency response with the gain and phase margins found by a fixed bisection; and the frames for the response and control charts. Refuses inputs out of range plainly, warns when a run is unstable, unsettled or a rule is not available, and scores five challenges. For learning feedback control, PID tuning and stability margins.

Last updated

Calculator overview

Inputs and outputs

This summary comes from the calculator's published input and output contract.

Inputs

Plant gain K (required)
About this input

The plant gain K: the steady output per unit of command, in output units per command unit (both plants).

Unit out/cmd Default 1 Range 0.1 to 10
Plant (required)
About this input

The plant under control: Tank level (a first-order lag with a dead time) or Mass on a spring (an underdamped oscillator), chosen from the list.

Default Tank level Allowed Tank level, Mass on a spring
Your prediction (challenge 1) (required)
About this input

Your prediction for challenge 1: Not yet predicted, More than 10% or 10% or less. Not used outside challenge 1.

Default Not yet predicted Allowed Not yet predicted, More than 10%, 10% or less
Integral gain Ki (required)
About this input

The integral gain Ki per second: the command added per unit of error per second; it removes a steady offset.

Unit cmd/(out s) Default 0.5 Range 0 to 50
Natural frequency (spring) (required) Conditional
About this input

The spring natural frequency wn in rad/s. Shown and used for the spring only.

Unit rad/s Default 2 Range 0.5 to 5
Proportional gain Kp (required)
About this input

The proportional gain Kp in command units per output unit: the command added per unit of error.

Unit cmd/out Default 2 Range 0 to 50
Time constant (tank) (required) Conditional
About this input

The tank time constant tau in s: how fast the level follows the command. Shown and used for the tank only.

Unit s Default 4 Range 0.5 to 20
Tracking time (0 = automatic) (required)
About this input

The anti-windup tracking time Tt in s; 0 means automatic (the square root of Ti Td with a derivative, Ti without); at least h is used.

Unit s Default 0 Range 0 to 100
Step time (required)
About this input

When the setpoint steps, in s; it acts from the first sample at or after this time.

Unit s Default 1 Range 0 to 200
Sample time (required)
About this input

The sample time h in s: the controller reads the output and sets the command every h seconds; the run is 200 samples long.

Unit s Default 0.1 Range 0.02 to 1
Setpoint step (required)
About this input

The setpoint after the step, R, in output units (the setpoint is 0 before the step).

Unit out Default 1 Range -10 to 10
Challenge number (required)
About this input

Selects a challenge: 0 for none, 1 to 5 for a predefined challenge whose settings replace the inputs it fixes.

Default 0 Range 0 to 5
Compare with (required)
About this input

The comparison run shown beside the main run: None, Proportional only, No actuator limit, Quick rule tuning or Robust rule tuning (the rules need the tank with a dead time of at least one sample).

Default Proportional only Allowed None, Proportional only, No actuator limit, Quick rule tuning, Robust rule tuning
Anti-windup (required)
About this input

On: while the actuator is at a limit the integral is pulled back with the tracking time (back-calculation); Off: the integral keeps collecting error.

Default On Allowed On, Off
Actuator maximum (required)
About this input

The highest command the actuator can deliver, uMax, in command units.

Unit cmd Default 10 Range 0.5 to 100
Actuator minimum (required)
About this input

The lowest command the actuator can deliver, uMin, in command units.

Unit cmd Default -10 Range -100 to 0
Damping ratio (spring) (required) Conditional
About this input

The spring damping ratio zeta, from 0.05 (lightly damped) to 0.9. Shown and used for the spring only.

Default 0.2 Range 0.05 to 0.9
Load disturbance (required)
About this input

A load step W added to the plant input, in command units (0 for none).

Unit cmd Default 0 Range -10 to 10
Disturbance time (required)
About this input

When the load step starts, in s; it acts from the first sample at or after this time.

Unit s Default 10 Range 0 to 200
Derivative gain Kd (required)
About this input

The derivative gain Kd in s: the command added against the rate of change of the measured output (no setpoint kick).

Unit cmd s/out Default 0 Range 0 to 20
Dead time (tank) (required) Conditional
About this input

The tank dead time theta in s: how long the command takes to start acting; rounded to a whole number of samples. Shown and used for the tank only.

Unit s Default 0.5 Range 0 to 5
Derivative filter divisor N (required)
About this input

The derivative filter divisor N: the derivative is filtered with time constant Kd/(N Kp).

Default 10 Range 2 to 50

Outputs

Phase crossover frequency
About this output

The frequency where the loop phase crosses -180 degrees, in rad/s. Blank while challenge 1 awaits a prediction.

Unit rad/s
Peak control effort
About this output

The largest command magnitude over the run, in command units. Blank while challenge 1 awaits a prediction.

Unit cmd
Overshoot
About this output

The largest excess of the output over the setpoint, as a percent of the step (0 when it never passes it); measured up to a disturbance that comes after the step. Blank while challenge 1 awaits a prediction.

Unit %
Phase margin
About this output

How much extra phase lag the linear loop could take before instability, in degrees, read at the gain crossover; blank when the magnitude does not cross 0 dB on the grid. Blank while challenge 1 awaits a prediction.

Unit deg
Proportional gain Kp used
About this output

The proportional gain used, command units per output unit (the challenge's when a challenge fixes it).

Unit cmd/out
Plant used
About this output

The plant used (the challenge's when a challenge fixes it).

No unit declared
Plant gain K used
About this output

The plant gain used, output units per command unit (the challenge's when a challenge fixes it).

Unit out/cmd
Loop frames: 201 samples of the setpoint, the output, the control and its P, I and D terms, the saturated flag, and the comparison run's output and control
About this output

The loop frames: 201 rows, one per sample k = 0 to 200, each with the time in s, the setpoint, the output, the command, the P, I and D terms, 1 when the actuator is at a limit, and the comparison run's output and command (blank without a comparison run). A stopped run is blank from its first uncomputed sample. Rows 1 to 200 are withheld while challenge 1 awaits a prediction.

No unit declared
Integral gain Ki used
About this output

The integral gain used, per second (the challenge's when a challenge fixes it).

Unit cmd/(out s)
Integral of absolute error (IAE)
About this output

The integral of the absolute error over the run, h times the sum of |e| over samples 0 to 199, in output units times s. Blank while challenge 1 awaits a prediction.

Unit out s
Model Status
About this output

NOT VALID with the reason when an input cannot be used; CHECK when the results are shown but the step or load comes after the run, a run grew past the blow-up limit, a rule comparison is not available, the output does not settle within 2%, or the dead time was rounded by more than 1%; otherwise OK.

No unit declared
Natural frequency (spring) used
About this output

The natural frequency used, rad/s (the challenge's when a challenge fixes it). Blank for the tank.

Unit rad/s
Formula module versions
About this output

The formula modules the model is built from, with their versions.

No unit declared
Model version
About this output

The model version.

No unit declared
Recovery time after the disturbance
About this output

The time from the load step to the sample from which the error stays within 2% of K W, in s; blank when it does not recover within the run. Blank while challenge 1 awaits a prediction.

Unit s
Setpoint step used
About this output

The setpoint step used, output units (the challenge's when a challenge fixes it).

Unit out
Share of samples at the actuator limit
About this output

The share of the 201 samples where the controller asked for more than the actuator can deliver, in percent. Blank while challenge 1 awaits a prediction.

Unit %
Sample time used
About this output

The sample time used, s (the challenge's when a challenge fixes it).

Unit s
Settling time (2%)
About this output

The time after the step from which the output stays within 2% of the setpoint, in s; blank when it does not settle before the run ends or a later disturbance arrives. Blank while challenge 1 awaits a prediction.

Unit s
Tracking time used
About this output

The anti-windup tracking time used, in s; blank without an integral or with anti-windup off.

Unit s
Time constant (tank) used
About this output

The time constant used, s (the challenge's when a challenge fixes it). Blank for the spring.

Unit s
Step time used
About this output

The time of the first sample at or after the entered step time, in s.

Unit s
Rise time (10% to 90%)
About this output

The time the output takes to go from 10% to 90% of the step, in s, by linear interpolation between samples; blank when it never reaches 90% before a later disturbance or the end of the run. Blank while challenge 1 awaits a prediction.

Unit s
Response plot minimum
About this output

The lower bound of the response chart: the smallest of 0, the setpoint, the output over the shown samples and the comparison run's output (when it runs to the end), less 10% of the span.

Unit out
Response plot maximum
About this output

The upper bound of the response chart: the largest of 0, the setpoint, the output over the shown samples and the comparison run's output (when it runs to the end), plus 10% of the span.

Unit out
Rule derivative gain
About this output

The rule tuning's Kd = Kp Td (quick: Td = theta/2; robust: 0), in s.

Unit cmd s/out
Run length
About this output

The length of the run, 200 samples times h, in s.

Unit s
Rule proportional gain
About this output

The rule tuning's Kp (quick: 1.2 tau/(K theta); robust: tau/(2 K theta)), with the dead time used; blank unless a rule is compared and available.

Unit cmd/out
Rule integral gain
About this output

The rule tuning's Ki = Kp/Ti (quick: Ti = 2 theta; robust: Ti = the smaller of tau and 8 theta), per second.

Unit cmd/(out s)
Gain margin
About this output

How much the loop gain could rise before the linear loop (no actuator limit) becomes unstable, in dB, read at the phase crossover; blank when the phase does not cross -180 degrees on the grid. Blank while challenge 1 awaits a prediction.

Unit dB
Comparison IAE
About this output

The comparison run's integral of the absolute error, in output units times s. Blank while challenge 1 awaits a prediction.

Unit out s
Comparison final error
About this output

The comparison run's error at the last sample, in output units. Blank while challenge 1 awaits a prediction.

Unit out
Challenge result
About this output

No challenge selected, MET or NOT MET.

No unit declared
Comparison overshoot
About this output

The comparison run's overshoot, in percent. Blank while challenge 1 awaits a prediction.

Unit %
Comparison settling time
About this output

The comparison run's 2% settling time after the step, in s. Blank while challenge 1 awaits a prediction.

Unit s
Comparison rise time
About this output

The comparison run's rise time from 10% to 90% of the step, in s. Blank while challenge 1 awaits a prediction.

Unit s
Comparison peak control effort
About this output

The comparison run's largest command magnitude, in command units. Blank while challenge 1 awaits a prediction.

Unit cmd
Anti-windup used
About this output

The anti-windup setting used (the challenge's when a challenge fixes it).

No unit declared
Actuator minimum used
About this output

The actuator minimum used, command units (the challenge's when a challenge fixes it).

Unit cmd
Actuator maximum used
About this output

The actuator maximum used, command units (the challenge's when a challenge fixes it).

Unit cmd
Challenge feedback
About this output

Feedback on the selected challenge: the prediction prompt, the met text or the not-met hint (blank with none).

No unit declared
Challenge score
About this output

The challenge score: 100 when met, else 0.

No unit declared
Challenge: the value scored
About this output

The value the selected challenge scores: the overshoot (1 and 4), the settling time (2), the disturbance peak error (3) or the IAE (5); blank when it is blank or withheld.

No unit declared
Challenge goal
About this output

The goal of the selected challenge (blank with none).

No unit declared
Comparison used
About this output

The comparison run used (the challenge's when a challenge fixes it).

No unit declared
Load disturbance used
About this output

The load disturbance used, command units (the challenge's when a challenge fixes it).

Unit cmd
Largest error after the disturbance
About this output

The largest |error| from the load step to the end of the run, in output units; blank without a load step in the run. Blank while challenge 1 awaits a prediction.

Unit out
Derivative gain Kd used
About this output

The derivative gain used, s (the challenge's when a challenge fixes it).

Unit cmd s/out
Disturbance time used
About this output

The time of the first sample at or after the entered disturbance time, in s.

Unit s
Gain crossover frequency
About this output

The frequency where the loop magnitude crosses 0 dB, in rad/s. Blank while challenge 1 awaits a prediction.

Unit rad/s
Loop frequency response: 40 frequencies over three decades up to 0.98 pi/h, the magnitude in dB, the phase in degrees and the crossover markers
About this output

The loop frequency response: 40 rows at frequencies over three decades up to 0.98 pi/h (13 a decade), each with the frequency in rad/s, the loop magnitude in dB, the continuous loop phase in degrees, and Gain crossover, Phase crossover or Both crossovers on the row that ends the first crossing of each kind. Blank when every gain is 0 or while challenge 1 awaits a prediction.

No unit declared
Final error
About this output

The error (setpoint minus output) at the last sample, in output units. Blank while challenge 1 awaits a prediction.

Unit out
Control travel
About this output

The total movement of the command, the sum of |u(k) - u(k-1)|, in command units. Blank while challenge 1 awaits a prediction.

Unit cmd
Control plot minimum
About this output

The lower bound of the control chart: the actuator minimum less 10% of the actuator range.

Unit cmd
Control plot maximum
About this output

The upper bound of the control chart: the actuator maximum plus 10% of the actuator range.

Unit cmd
Damping ratio (spring) used
About this output

The damping ratio used (the challenge's when a challenge fixes it). Blank for the tank.

No unit declared
Derivative filter divisor N used
About this output

The derivative filter divisor used (the challenge's when a challenge fixes it).

No unit declared
Derivative filter time
About this output

The derivative filter time Tf = Kd/(N Kp) (h when Kp = 0), in s; blank without a derivative.

Unit s
Dead time used
About this output

The dead time used, a whole number of samples times h, in s (tank only).

Unit s
This page is provided by LogicCommons for informational purposes only. Results are analysis outputs computed from the inputs you supply and are not professional advice. Verify all inputs and results independently.

LogicCommons is in beta. If a result, label, or reference looks wrong, tell us here; we read every message.

Methodology

Purpose and model boundary

This lab tunes a sampled PID controller on one feedback loop: a stable plant, the controller and an actuator with limits. The plant is a tank level (a first-order lag with a dead time) or a mass on a spring (an underdamped oscillator). You step the setpoint, may knock the plant with a load disturbance, and set the proportional, integral and derivative gains. The lab runs 200 samples of the loop, with the plant discretized exactly for a command held between samples, and returns the rise time, overshoot and 2% settling time, the final error, the integral of the absolute error (IAE), the peak control, the share of samples at the actuator limit and the control travel, and the disturbance's peak error and recovery time. A comparison run beside it shows the same loop with proportional action only, without the actuator limit, or with the quick (Ziegler-Nichols) or robust (SIMC) rule tuning. In Advanced it adds the loop's frequency response with the gain and phase margins. Five scored challenges use the same model.

It is a lab for learning feedback control: what each of the three terms does, why integral action removes an offset but can cause overshoot, why a dead time limits how hard you can push, what windup is and how anti-windup stops it, and what the stability margins say. It is not a tuning tool for a real process. The plants are linear and known exactly, the units are generic, and there is no measurement noise, actuator rate limit or quantisation.

The model is the calculation authority. The page sends the values you set to the model and draws only what it returns: the setpoint, output and control of both runs sample by sample, the P, I and D terms, the saturated samples, and the frequency response with its crossovers. The page computes no response, metric or margin itself.

Inputs and units

Output and command are in generic units ("out" and "cmd").

Input Meaning and unit
Plant Tank level or Mass on a spring (default Tank level).
Plant gain K From 0.1 to 10 out per cmd (default 1): the steady output per unit of command, for both plants.
Time constant (tank) τ, from 0.5 to 20 s (default 4 s). Tank only.
Dead time (tank) θ, from 0 to 5 s (default 0.5 s), rounded to a whole number of samples. Tank only.
Natural frequency (spring) ωn, from 0.5 to 5 rad/s (default 2 rad/s). Spring only.
Damping ratio (spring) ζ, from 0.05 to 0.9 (default 0.2). Spring only.
Proportional gain Kp From 0 to 50 cmd per out (default 2).
Integral gain Ki From 0 to 50 cmd per out per second (default 0.5).
Derivative gain Kd From 0 to 20 cmd s per out (default 0).
Setpoint step R, from -10 to 10 out (default 1); the setpoint is 0 before the step.
Step time From 0 to 200 s (default 1 s); the step acts from the first sample at or after it.
Load disturbance W, from -10 to 10 cmd (default 0, none), added to the plant input.
Disturbance time From 0 to 200 s (default 10 s); the load acts from the first sample at or after it.
Actuator minimum, maximum uMin from -100 to 0 and uMax from 0.5 to 100 cmd (defaults -10 and 10).
Anti-windup On or Off (default On).
Compare with None, Proportional only, No actuator limit, Quick rule tuning or Robust rule tuning (default Proportional only).
Sample time h, from 0.02 to 1 s (default 0.1 s); the run is 200 samples long.
Derivative filter divisor N From 2 to 50 (default 10).
Tracking time Tt, from 0 to 100 s (default 0, automatic).
Challenge number 0 for free exploration, or 1 to 5 to load a challenge.
Your prediction (challenge 1) Not yet predicted, More than 10% or 10% or less. Used only in challenge 1.

A plant parameter that does not belong to the chosen plant is not checked, not used and not shown: the time constant and dead time belong to the tank, the natural frequency and damping ratio to the spring.

Where each input is set:

  • On the canvas only: the plant and your prediction for challenge 1.
  • In the input panel: every other input. The markers on the response chart show the step and load times the model used; play the run, or click a chart to go to a sample.

Governing relationships

The plants. Tank: P(s) = K·e^(-θs) / (τs + 1). Spring: P(s) = K·ωn² / (s² + 2ζωn·s + ωn²).

Exact sampling (zero-order hold). Both plants are written as x[k+1] = Φ·x[k] + Γ·u_d[k], y = x₁, where u_d is the command held over the sample. Tank: Φ₁₁ = a = e^(-h/τ), Γ₁ = K·(1 - a). Spring, with σ = ζωn and ωd = ωn·√(1 - ζ²):

  • Φ₁₁ = e^(-σh)·(cos ωd·h + (σ/ωd)·sin ωd·h), Φ₁₂ = e^(-σh)·sin(ωd·h)/ωd,
  • Φ₂₁ = -e^(-σh)·(ωn²/ωd)·sin ωd·h, Φ₂₂ = e^(-σh)·(cos ωd·h - (σ/ωd)·sin ωd·h),
  • Γ₁ = K·(1 - Φ₁₁), Γ₂ = -K·Φ₂₁.

These are the exact solutions for a held input, so the plant is exact at the samples. The dead time is d = round(θ/h) samples, a half rounding up: the command reaches the plant d samples late, and the load W is added after the delay.

The controller (discrete parallel PID). With the error e = r - y:

  • P = Kp·e.
  • D is the derivative of the measurement (not of the error, so a setpoint step gives no kick), filtered with time constant Tf = Kd/(N·Kp) (h when Kp = 0): D[k] = cD·D[k-1] - gD·(y[k] - y[k-1]), with cD = Tf/(Tf + h) and gD = Kd/(Tf
    • h).
  • The command asked for is v = P + I + D, and the actuator delivers u = v clipped to [uMin, uMax]; a sample is saturated when v lies outside the limits.
  • The integral is a forward sum: I[k+1] = I[k] + Ki·h·e[k], plus, with anti-windup on, the back-calculation term (h/Tt)·(u[k] - v[k]), which pulls the integral back while the actuator is at a limit.
  • The tracking time used is Tt = max(h, entered Tt); with 0 entered it is automatic: √(Ti·Td) with a derivative and Ti without, where Ti = Kp/Ki and Td = Kd/Kp.

The run. The loop starts at rest at zero and runs samples k = 0 to 200 (200·h seconds). A run whose output passes 1,000 times the larger of 1, |R| and |W| is treated as unstable and stops there.

The comparison run. The same plant, setpoint, load, sample time, filter and anti-windup switch, with: Proportional only (Kp, 0, 0); No actuator limit (the same gains, u = v); or a rule tuning from the tank's τ, K and the dead time used θu = d·h (tank with at least one sample of dead time only):

  • quick rule (Ziegler-Nichols step response): Kp = 1.2·τ/(K·θu), Ti = 2·θu, Td = θu/2;
  • robust rule (SIMC with the closed-loop time constant equal to the dead time): Kp = τ/(2·K·θu), Ti = min(τ, 8·θu), Td = 0;

with Ki = Kp/Ti and Kd = Kp·Td.

Step metrics. Over the samples from the step to the end of the run, or to the sample before a later disturbance, with z = y/R:

  • overshoot = max(0, (largest z - 1)·100) %;
  • rise time = the time from z = 0.1 to z = 0.9, each crossing found by linear interpolation between samples;
  • settling time = the time from the step to the sample from which |y - R| stays within 2% of |R|.

Whole-run metrics. Final error = e at the last sample; IAE = h·(|e₀| + ... + |e₁₉₉|); peak control = the largest |u|; share at the limit = 100·(saturated samples) / 201; control travel = the sum of |u[k] - u[k-1]|. After a load step: the largest |e|, and the recovery time to the sample from which |e| stays within 2% of K·W, the load's uncorrected effect.

Frequency response and margins (Advanced). For the linear loop without the actuator limit, L(z) = C(z)·P(z)·z^(-d), evaluated at 40 frequencies over three decades up to 0.98·π/h, 13 a decade, as magnitude in dB and continuous phase in degrees. The gain crossover is where the magnitude first falls through 0 dB and the phase crossover where the phase first falls through -180 degrees. Each is refined by exactly 8 halvings of the grid interval that brackets it, then a linear interpolation. Phase margin = 180 + phase at the gain crossover; gain margin = -(magnitude in dB) at the phase crossover.

Calculation sequence

  1. Check the inputs that apply, in the order of the list under Errors and warnings.
  2. Take the values used: in a challenge, its own settings, except the inputs it leaves to you. The prediction is never replaced.
  3. Find the step, disturbance and dead-time sample counts, the plant matrices and the controller constants.
  4. Compute the comparison run's gains.
  5. Run the main loop and the comparison loop, row by row, until sample 200 or the blow-up stop.
  6. Compute the step, whole-run and disturbance metrics for both runs.
  7. Compute the frequency response, the crossovers and the margins, and the plot bounds.
  8. Set the status and, in a challenge, score it.

Outputs and interpretation

The main run: rise time (10% to 90%), overshoot (%) and settling time (2%) in s after the step; final error; IAE (out·s); peak control effort (cmd); share of samples at the actuator limit (%); control travel (cmd); and, with a load step, the largest error after the disturbance and the recovery time.

The comparison run: its rise time, overshoot, settling time, final error, IAE and peak control, and, for a rule tuning, the rule's proportional, integral and derivative gains.

The controller and plant: the derivative filter time, the tracking time used (blank without an integral or with anti-windup off), the dead time used, the step and disturbance times used (the samples they act from) and the run length.

Margins (Advanced): gain margin (dB) and phase crossover frequency, phase margin (degrees) and gain crossover frequency (rad/s), each blank when its crossing does not occur on the grid.

Tables: the loop frames (201 samples of the time, setpoint, output, command, the P, I and D terms, the saturated flag, and the comparison run's output and command) and the frequency response (frequency, magnitude, phase and the crossover markers).

Reading the canvas: the response chart plots the setpoint and both runs' outputs, with the step and load markers; the control chart plots both commands against the actuator limits, with the saturated samples marked; the three term traces show which part of the controller is doing the work at each moment. A large I term when the output first reaches the setpoint means overshoot is coming. In Advanced, a small gain or phase margin means the linear loop is close to instability.

Challenges

Every challenge uses the tank (K 1, τ 4 s), a 0.1 s sample time, N 10 and a setpoint step at 1 s, and fixes every input it is not about; the page names the inputs each challenge lets you change. The model scores each challenge MET (100 points) or NOT MET (0), shows the value it scored, and gives a one-line hint while it is not met. Every MET needs a run that reached the end without the blow-up stop.

  1. Overshoot or not? The tank has a 0.5 s dead time and the controller uses Kp 2 and Ki 1. Predict: will the level overshoot the new setpoint by more than 10%? It is met when your prediction matches the overshoot (the value scored).
  2. Tame the dead time. The tank now has a 1 s dead time. Tune the gains so the level overshoots by no more than 5% and settles within 2% of the setpoint within 6 s of the step. The value scored is the settling time.
  3. Reject the load. A load disturbance of 1 hits the tank at 10 s and the actuator is limited to plus or minus 2.5. Tune the gains so the error never passes 0.2 after the disturbance and is back within 2% of the disturbance's full effect within 5 s. The value scored is the largest error after the disturbance.
  4. Stop the windup. A step of 5 with the actuator limited to plus or minus 6: without anti-windup the level overshoots and has not settled by the end of the run. Make the overshoot 10% or less and let the level settle, without changing the gains. You choose anti-windup and the tracking time; the value scored is the overshoot.
  5. Beat the rule. Beat the robust rule tuning on the tank with a 1 s dead time: reach an IAE at least 10% lower than the rule's, with an overshoot of 10% or less and the level settled within 2% before the run ends. The value scored is the IAE.

Challenge 1 holds back the answer until you predict. While your prediction reads Not yet predicted, every response metric, the comparison metrics, the margins and the frequency response are blank, the frames after sample 0 are blank, and the status skips the warnings that would reveal how the run ends; the challenge reads NOT MET with a prompt to predict first. Your prediction changes nothing outside challenge 1.

What to take from the lab: proportional action alone leaves an offset, integral action removes it at the price of overshoot, derivative action damps the approach, a dead time forces gentler gains, and anti-windup keeps a saturated actuator from storing error it must later unwind.

Validation and status logic

The status reads the first match in the list under Errors and warnings. The NOT VALID checks run on the values you entered, also while a challenge is selected, and only on the inputs that apply to the chosen plant. The CHECK items run on the values used, also inside challenges. While challenge 1 awaits a prediction, the CHECK items for an unstable main run, an unstable comparison run and an unsettled output are skipped. A challenge number that is not a whole number from 0 to 5 counts as no challenge selected.

Assumptions and limitations

  • Linear, stable plants with known parameters; generic units. The load is a step at the plant input. No measurement noise, actuator rate limit or quantisation.
  • The plant is exact at the samples for a held command. The controller is discrete by definition, so sampling effects are part of the model.
  • The dead time is a whole number of samples; the step and the load act from the first sample at or after their times.
  • 200 samples per run: a slow loop may not settle, and a dead time longer than the run shows nothing.
  • The margins describe the linear loop without the actuator limit, on a 40-point grid; a crossing outside the grid, or one that enters and leaves within one grid interval, is not reported. After the refinement they are within about 0.01 degrees and 0.001 dB.
  • A run that passes the blow-up limit is treated as unstable; a very resonant stable loop could in principle pass it.
  • A value within 1×10⁻⁹ (relative) of a threshold may flip a status or a challenge.

Restrictions and non-computing states

Under NOT VALID every result, frame and frequency row is blank; a selected challenge reads NOT MET with a score of 0, and its goal and hint stay shown. A run that stops at the blow-up limit is blank from its first uncomputed sample, and its metrics are blank. The rule comparison is blank for the spring or a tank with no whole sample of dead time. The frequency response is blank when every gain is 0. In challenge 1, until you predict, the results are held back as described under Challenges.

Errors and warnings

The status messages, first match wins:

  • NOT VALID: choose a plant from the list
  • NOT VALID: the plant gain must be from 0.1 to 10, the time constant from 0.5 to 20 s, the dead time from 0 to 5 s, the natural frequency from 0.5 to 5 rad/s and the damping ratio from 0.05 to 0.9: only the parameters of the chosen plant are checked.
  • NOT VALID: the proportional gain must be from 0 to 50, the integral gain from 0 to 50 per second and the derivative gain from 0 to 20 s
  • NOT VALID: the setpoint step and the disturbance must each be from -10 to 10, and their times from 0 to 200 s
  • NOT VALID: the actuator minimum must be from -100 to 0 and the maximum from 0.5 to 100, and anti-windup and the comparison must be chosen from their lists
  • NOT VALID: the sample time must be from 0.02 to 1 s, the derivative filter from 2 to 50 and the tracking time from 0 to 100 s
  • NOT VALID: the challenge number must be a whole number from 0 to 5, and the overshoot prediction one of the listed choices
  • CHECK: the setpoint step or the disturbance comes after the end of the run (200 sample steps), so it has no effect; move it earlier or use a longer sample time
  • CHECK: the output grew past 1,000 times the larger of 1, the step size and the disturbance size, so the loop is treated as unstable and the frames stop there
  • CHECK: the rule tunings are defined for the tank with a dead time of at least one sample step, so no comparison run is shown
  • CHECK: the comparison run grew past 1,000 times the larger of 1, the step size and the disturbance size, so it is treated as unstable and its frames stop there
  • CHECK: the output does not settle within 2% of the setpoint step before the run ends or the disturbance arrives (a steady offset, a slow approach or a lasting oscillation)
  • CHECK: the dead time is not a whole number of sample steps, so it was rounded, and the dead time used differs from the entered value by more than 1%
  • OK: the inputs are valid and none of the above applies.

References

This laboratory is an educational model of a sampled PID control loop. The plant, a first-order lag with dead time or an underdamped second-order system, is discretized exactly for a command held between samples (the zero-order hold). The controller acts in parallel form on the error, with a filtered derivative of the measurement, an actuator limit and back-calculation anti-windup. Comparison tunings come from the Ziegler-Nichols step-response rule and from Skogestad's SIMC rule, and the gain and phase margins are read from the loop's frequency response.

Sources and further reading

  • The PID controller, its tuning by the Ziegler-Nichols rules and from a first-order-plus-dead-time model, integral windup and how to avoid it with tracking, and filtering the derivative: K. J. Åström and R. M. Murray, Feedback Systems: An Introduction for Scientists and Engineers, 2nd edition, Princeton University Press, chapter 11, PID Control. Feedback Systems wiki
  • Loop transfer functions, the Nyquist criterion and the gain and phase margins: K. J. Åström and R. M. Murray, Feedback Systems, 2nd edition, chapter 10, Frequency Domain Analysis. Feedback Systems wiki
  • The SIMC tuning rule for a first-order-plus-dead-time process: S. Skogestad, "Simple analytic rules for model reduction and PID controller tuning", Journal of Process Control 13(4), 2003, pages 291-309. doi:10.1016/S0959-1524(02)00062-8
  • The step-response (reaction curve) tuning rule: J. G. Ziegler and N. B. Nichols, "Optimum settings for automatic controllers", Transactions of the ASME 64, 1942, pages 759-768.
  • Sampling a continuous-time system with a zero-order hold, and the discrete implementation of a PID controller: K. J. Åström and B. Wittenmark, Computer-Controlled Systems: Theory and Design, 3rd edition, Prentice Hall, 1997.

No table or text from any of these publications is reproduced, and none of their authors or publishers has reviewed or endorses this laboratory.

This laboratory is for learning. Its results hold only within its stated ranges; the plants are linear and known exactly, with no noise or rate limits, so gains tuned here are not settings for a real process.

Links were current at build time. If one moves, search the document's title rather than reporting a broken link as a defect.

Results are informational and not professional advice. See our Terms of Use. Powered by SpreadsheetWeb · About · Privacy · Terms