PID Loop Tuning from Step Test Data
Operator: Abdulla Al Fahad. How tools are built and checked
A step test is the cheapest experiment in process control: move the controller output by a few percent, log the process variable until it settles, and you have what a model needs. The hard part comes after, when five tuning rules give five different gains and you have to say which one is safe. This page fits a dead-time model to the log, then shows every rule's settings together with the gain margin, phase margin and peak sensitivity of the resulting loop and a simulated set-point and load response.
Nothing here is tuned blind. Each rule's row carries its margins and its overshoot, so a Cohen-Coon PI with a phase margin of 24 degrees and 68% overshoot is visible as exactly that, next to an IMC PI with 61 degrees and 4%.
Key features
- Fits first-order, second-order and integrating models, each with dead time, by least squares, and reports R², RMSE, iterations and warnings about the data
- Ziegler-Nichols reaction-curve and ultimate-gain rules, Cohen-Coon, IMC or lambda tuning and Skogestad SIMC, for P, PI and PID
- Settings in ideal (ISA), parallel and series forms, with proportional band and repeats per time unit
- Gain margin, phase margin, Ms and Mt from the open-loop frequency response, with Bode magnitude and phase and a Nyquist plot
- Closed-loop simulation of a set-point step and an input load step, with overshoot, rise time, settling time and peak load deviation
- Manual model entry if you already have the parameters, and a CSV of the settings and of the simulated response
Test data, model forms and controller forms
The file needs three numeric columns, time, process variable and controller output, with at least 20 and at most 20,000 rows and a header that the page uses to guess the columns: time, pv or similar, co, mv, output or op. The time must increase on every row. Evenly spaced data is simulated exactly; unevenly spaced data is simulated with sub-steps and takes longer to fit.
Choose the model form yourself. First order plus dead time suits most self-regulating loops. Second order plus dead time adds a second lag for an S-shaped response with a slow start. The integrating model is for levels and other loops whose output ramps after a step, where the process variable is still moving at the end of the test.
How it works
The model is simulated against your controller-output column with the lags advanced exactly over each sample, the output held between samples and the dead time applied as a whole number of samples plus a fraction, so the fit is smooth in the dead time and can resolve it below one sample. A Nelder-Mead search on the logarithms of the lags and dead time, with the gain and the starting output free, minimises the squared error, and is restarted once from its best point.
The rules use the model directly. Ziegler-Nichols reaction curve gives Kc = τ/(Kθ) for P, 0.9τ/(Kθ) with Ti = 3.33θ for PI, and 1.2τ/(Kθ), 2θ and 0.5θ for PID. IMC gives Kc = τ/(K(λ+θ)) and Ti = τ for PI, with lambda set to the dead time unless you change it. Skogestad SIMC gives the same gain with Ti = min(τ, 4(τc+θ)), and uses the second lag as the derivative time for a second-order model. A second-order model is reduced to an equivalent first-order one by the half rule for the rules that need one.
Margins come from L(jω) = C(jω)G(jω) on a logarithmic grid, with a derivative filter of Td/10. The simulation uses the same controller with derivative on the measurement. The load step enters at the plant input halfway through the run, so it passes through the dead time like a real disturbance.
Common use cases
- A technician with a heating loop steps the output from 40% to 50%, fits K = 2.0 °C per %, τ = 10 min and θ = 3 min, and reads that the IMC PI settles within 2% in 18 minutes where the Ziegler-Nichols PI needs 33.
- A plant engineer wants a PID in series form for an older controller: the page converts Kc 2.00, Ti 6.00 and Td 1.50 minutes of the ideal form into series settings only when Ti is at least four times Td, and says so otherwise.
- A student compares SIMC with lambda equal to the dead time against a lambda of twice that: the gain margin rises from 3.14 to 4.71 and the settling time lengthens from 18.4 to 23.4 time units, with no overshoot.
- An operator gets a tank-level test whose output is still ramping at the end, and the page's warning points to the integrating model instead of a first-order fit.
How to use this tool
- Load the step test, or load the example, and check that the page picked the right time, process variable and controller output columns.
- Choose the model form and look at the fit: R², RMSE and any warnings about noise, saturation or an unsettled output.
- Choose P, PI or PID, and set lambda if you want something other than the dead time.
- Compare the rules by margins and overshoot, then open the one you prefer to see its Bode and Nyquist plots and the simulated responses.
- Copy the settings in the form your controller uses, or download the CSV.
Example
The page's example: a simulated step test with CO stepped from 40 to 50 at t = 10 and measurement noise, 401 samples at 0.25 s
Model: first order plus dead time. Controller: PI. Lambda: blank, so the fitted dead time is used.Fit and settings
Fit: K = 1.999, τ = 10.005, θ = 3.000, R² = 0.99995, RMSE 0.048 (the data were made with K 2, τ 10, θ 3)
SIMC PI: Kc 0.834, Ti 10.0, gain margin 3.14, phase margin 61.4°, Ms 1.59, overshoot 4.2%
Ziegler-Nichols PI: Kc 1.50, Ti 9.99, phase margin 38.4°, overshoot 40.5%
Cohen-Coon PI: Kc 1.54, Ti 6.18, phase margin 24.2°, overshoot 67.7%Tips for best results
- A bigger step improves the fit when there is noise. The page flags a response that is under ten times the noise level, and an unnoticed 1% step on a noisy signal gives a poor model.
- Start from SIMC or IMC with lambda equal to the dead time and move lambda up for a gentler loop; the margins in the table tell you how much room you bought.
- If the fit's R² is high but the loop oscillates in practice, suspect a nonlinear valve or a different operating point from the test, not the tuning rule.
Common pitfalls
A first-order model fitted to a higher-order response folds the extra lag into its time constant and dead time. If a second-order fit has an R² barely above the first-order one, the first is enough; if it is clearly higher, use the second-order model.
The ultimate-gain rule here uses the gain and period computed from the model, not from a trial on the plant. Its settings are as good as the model is.
Derivative action amplifies noise. The simulation filters it with Td/10 and has no measurement noise, so it looks better than the same PID on a noisy transmitter.
Controller output limits and anti-windup are not part of the fit or the margins. If the controller output sat at a limit during the test, the page warns, but it cannot repair the data.
Common errors and how to fix them
- Time must increase on every row (row 241).
- Sort the file by time and remove duplicate timestamps before loading it.
- The controller output never changes, so there is no step to identify a model from.
- Use a file in which the controller output moved; a log of closed-loop operation at steady state has nothing to fit.
- The response (0.231) is only 3.1 times the noise level; the fit will be poor.
- Repeat the test with a larger output step, or record a longer baseline so the noise is estimated better.
- The file has more than 20,000 rows. Thin it or cut it to the step.
- Keep every second or fifth row, or cut the file to the step and the settling that follows.
Best practices
- Run the test at the operating point you intend to control, with the loop in manual and the other loops in their normal modes.
- Record at least one dead time of flat baseline before the step and wait for the output to settle after it.
- Check settings on the plant at low gain first and raise them in steps, with limits and alarms active.
Frequently asked questions
What have the rules and margins been checked against?
Two exact cases are reproduced. With zero dead time, the IMC PI with lambda 3 on a gain of 2 and time constant of 10 gives a closed loop of 1 − exp(−t/3) to within 3.5e-4 in the simulation. For the first-order process with a delay, the ultimate gain from the phase condition ωθ + atan(ωτ) = π is 4.623 for K 1.5, τ 8 and θ 2, and the margin routine reports a gain margin of 4.62300 at Kc = 1. SIMC with lambda equal to the dead time on a lag-dominant process (τ 5, θ 1) gives a gain margin of 3.14, phase margin 61.35° and Ms 1.59.
Why do SIMC and IMC give identical PI settings in the example?
With lambda equal to the dead time of 3 and a time constant of 10, SIMC's integral time min(τ, 4(τc+θ)) is min(10, 24), which is τ. IMC's is τ always. For a larger time constant relative to the dead time they differ only when 4(τc+θ) falls below τ.
Why is there no derivative term for SIMC on a first-order model?
Skogestad's rule gives derivative time equal to the second lag, which is zero for a first-order model, so the PID row equals the PI row. Fit a second-order model to get a derivative action from SIMC.
Can the settings be used in a controller that wants a gain in percent proportional band?
Yes, the table shows the proportional band as 100 divided by Kc and the integral action as repeats per time unit, which is 1/Ti.