PID Controller Tuning Simulator
Tune a filtered PID controller on process and DC motor models. Compare step response, actuator saturation, Bode margins and a root locus with SIMC or Ziegler–Nichols settings.
This PID tuning simulator helps engineers and students see how controller settings change a feedback loop. Use it for a first pass at process-control settings, a laboratory exercise, or a comparison between a process model and a DC motor speed model. The default example is a first-order plant with a one-second delay and a SIMC PI controller, so the response and stability margins can be compared with published results.
Choose first order plus dead time when a step test suggests one dominant lag. Enter the normalized process gain, time constant and transport delay. For an oscillatory plant, choose the second-order model and enter its natural angular frequency and damping ratio. The DC motor model uses rotor inertia, viscous friction, resistance, inductance, torque constant and back EMF constant. Its mechanical-unit selector accepts SI or US customary data. Voltage and speed bases define what one per-unit command and output mean.
For the first-order model, choose SIMC PI, Ziegler–Nichols reaction-curve PID, or manual parallel gains. SIMC uses a desired response time: increasing it usually trades speed for gentler action. Ziegler–Nichols requires a positive delay and can give aggressive settings. The other plant models use manual gains. The derivative acts on the measured output through a first-order filter, avoiding a derivative kick at the setpoint change.
Set the actuator limits and try a disturbance at the plant input. Compare the commanded actuator signal and the integral contribution with conditional anti-windup enabled and disabled. A warning identifies targets that the actuator cannot hold. Press play to move the schematic marker through the precomputed transient; playback does not rerun the simulation.
The response charts show setpoint tracking and the plant's separate open-loop response to the same numerical input step. Rise time uses the 10–90% thresholds, and settling time uses a 2% band around the requested target. When a disturbance is enabled, these two timing metrics and overshoot use only the interval before it; the absolute error integral uses the entire simulation.
Use the Bode plot calculator to inspect the continuous loop magnitude, phase and margins over the selected frequency range. These plots include exact transport delay and exclude saturation. Choose a phase-margin or gain-margin detail view for readable crossover markers, or select the full unwrapped range. The reported limiting margins include their frequencies and consider every odd-180° crossing in both directions within the search range. The root locus scales all three controller gains together; with delay it uses a first-order Padé approximation. It is a guide to pole movement, not an exact delay-system stability proof.
Before transferring PID controller calculator settings to equipment, check the model, controller convention, signal scaling and sample period. The interval count sets the simulated controller sample period, equal to duration divided by intervals. Doubling the count changes that controller period and checks convergence toward continuous control; it is not merely a finer plant integration mesh. The tool omits measurement noise, quantization, actuator rate limits, backlash, motor current limits and parameter changes.
How it is calculated
The process models use . For first order, and . For second order, and . The DC motor follows Newton's and Kirchhoff's laws: . The voltage and speed bases convert this to a normalized gain. The motor equations and sample constants follow CTMS; the equations are also derived directly here.
The parallel feedback controller is . In the time simulation, derivative acts on output, so . A backward-Euler derivative filter and trapezoidal error integration run once per controller sample. Saturation clips the command. Conditional anti-windup rejects an integral increment only when its error direction would push a saturated command farther into its limit. It resumes integration when the error reverses. The input disturbance is added after saturation and before the transport delay.
Plant state transitions under each held input are evaluated analytically. A fractional delay splits a sample into two exact held-input transitions. This treats the delay exactly for the simulated sampled command; controller sampling still requires a convergence check. Initial states are zero. The time normalization of 1 s keeps mixed numerical coefficient vectors dimensionless without concealing physical units.
SIMC PI for a first-order model uses , , , (Skogestad 2003, Eqs. 23–24, attached PDF p. 6). Ziegler–Nichols reaction-curve PID uses , , , with and (Åström–Murray, Table 11.1a). Filtering changes the ideal Ziegler–Nichols response.
The continuous frequency response includes exact transport delay. Phase is calculated as the controller's analytic atan2 phase minus the stable plant-denominator phase and , anchored to the model's low-frequency branch. It therefore does not depend on the sweep's starting frequency. The unity-gain frequencies come from the real polynomial in obtained from .
For gain margin, zeros of the analytic phase derivative partition frequency into monotonic intervals. Every negative-real-axis level is checked in both directions within the selected range. Each crossing is refined by 34 log-frequency bisections. The signed gain margin closest to 0 dB and signed phase margin closest to 0° are returned with their crossover frequencies, following the MathWorks margin definition. Phase margin is the signed angular distance to the nearest odd-180° branch. These scalar margins do not establish internal stability. An absent crossing is reported as unavailable in the selected range. A range containing 1000 or more phase-crossing candidates is rejected rather than reporting a partial search. Peak sensitivity still uses the 601-point frequency grid.
The phase-view selector provides phase-crossover detail, gain-crossover detail, and the full unwrapped range. Focused views restrict the neighborhood of the selected crossover, including no more than roughly 180° of transport-delay phase variation, and draw the crossover markers and phase-margin arrow against the appropriate odd-180° guide. A crossover outside the displayed neighborhood remains reported in the header.
The simulated controller sample period is . Changing the interval count or duration changes the actual sampled-controller model, not just a plant integration mesh. The plant transition between commands is analytical. Resolution warnings check plant poles, the derivative filter, and , where the control frequency scale is the largest unity-gain crossover (including outside the plot) or largest rational closed-loop pole magnitude. This last threshold is a conservative numerical-resolution guideline for comparison with a continuous design, not a sampled-loop stability theorem.
Root locus solves for 61 multipliers from 0 to 10, keeping the filter time fixed and scaling every gain. A first-order Padé factor approximates delay only for this pole analysis. Uncancelled modes are retained. Dots show all sampled roots without implying branch connectivity; rings mark the current gain, and grey rings mark open-loop poles. Roots outside the chosen square are omitted.
Assumptions
Signals are deviations from a zero operating point. Plant gains and setpoints are positive; feedback is unity and negative. All process signals use per-unit scaling. For the motor, actual voltage equals command × voltage base, and actual speed equals output × speed base. Motor back EMF and torque constants are independently entered in SI units. Radians are dimensionless in the mechanical equations.
The models are linear and time invariant. The only actuator nonlinearity included is command saturation. The disturbance has the same units as normalized command and represents an additive plant-input load, not a motor shaft-torque load. There is no derivative action on setpoint. Anti-windup is conditional integration, with no hidden back-calculation gain.
Only first-order plants receive automatic tuning. Second-order and DC motor choices use the visible manual gains. The controller is parallel; SIMC is PI here, so no series-to-parallel PID conversion is needed. Time is always in seconds, angular frequency in rad/s; the motor mechanical-unit selector converts compound SI and US units explicitly. Other compatible fields use the catalog's normal unit display.
Where it applies
Use positive, stable first- or second-order self-regulating plants and the stated rigid-rotor DC motor model. This does not model integrating plants, unstable plants, inverse response, current-limited drives or cascaded control loops.
Continuous Bode margins and Padé poles describe the unsaturated continuous controller. The sampled, saturated transient can behave differently. Positive displayed margins alone do not certify stability or robustness to unmodeled dynamics. First-order Padé poles can be inaccurate near delay-dominated instability; use exact-delay frequency analysis and the sampled response together. No-crossing messages apply only to the chosen frequency range. Peak sensitivity may miss a very narrow peak.
Resolve the fastest plant, controller and closed-loop time scales, as well as the derivative filter. Warnings request a smaller controller sample period. Increasing the interval count or shortening the duration changes that sample period and therefore changes the simulated controller. Repeat with twice as many intervals when checking convergence toward the continuous design. A sample-and-hold command is assumed, with zero-order-hold plant evolution; continuous-controller reference values differ slightly at finite sampling. The simulation stops filling new dynamic states if the output exceeds 10⁸ p.u., and explicitly warns before that display limit.
Overshoot, rise and settling are measured relative to the requested step, not the observed final value. A −1 s timing value in the calculation details means the threshold or settling criterion was not achieved within the observation interval. Metrics before a disturbance cannot show later disturbance rejection. The final error and IAE cover the whole run.
The CTMS university mirror labels inertia with an erroneous /s² in one list. This tool uses kg·m², consistent with inertia dimensions and the source's MATLAB model. Settings are starting points for model studies and commissioning analysis; validate against the actual plant and controller implementation.
The exact-model scalar margin search is limited to 999 phase-crossing candidates per selected frequency range; narrow the range if prompted. Positive scalar margins may coexist with an unstable feedback loop, especially with multiple crossings. No Nyquist winding count or disk-margin analysis is performed. The full phase plot can span many delay rotations; choose a crossover-detail view to inspect a particular margin.
References
- Skogestad, S. (2003), Simple analytic rules for model reduction and PID controller tuning, Journal of Process Control 13, 291–309. DOI: https://doi.org/10.1016/S0959-1524(02)00062-8. Author manuscript: https://skoge.folk.ntnu.no/publications/2003/tuningPID/finalpaper.pdf
- Åström, K. J. and Murray, R. M., Feedback Systems, PID Control chapter, Table 11.1 (author-hosted 2019 chapter): https://www.cds.caltech.edu/~murray/books/AM05/pdf/fbs-pid_01Jan19.pdf
- Control Tutorials for MATLAB and Simulink, DC Motor Speed Modeling, university mirror: https://www.ece.ualberta.ca/~tchen/ctm/examples/motor/motor.html ; current tutorial: https://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SystemModeling
- MathWorks, margin: negative-real-axis crossings modulo 360° and selection of gain and phase margins closest to zero. https://www.mathworks.com/help/control/ref/dynamicsystem.margin.html
Inputs
| Input | Symbol | Unit | Default |
|---|---|---|---|
| Plant model | model | First order plus dead time | |
| Process DC gain Output per input, both normalized. | K_proc | 1 | |
| Process time constant | T_proc | s | 4 |
| Natural angular frequency | w_n | rad/s | 2 |
| Damping ratio | zeta_p | 0.5 | |
| Transport delay Use zero for a delay-free model. Applied to the plant input. | theta_d | s | 1 |
| Motor mechanical units | motor_units | SI: kg·m² and N·m·s | |
| Rotor inertia | J_rot | kg*m^2 | 0.01 |
| Viscous friction | b_rot | N*m*s | 0.1 |
| Rotor inertia (US) | J_us | lbm*ft^2 | 0.237304 |
| Viscous friction (US) | b_us | lbf*ft*s | 0.07375621493 |
| Torque constant | K_t | N*m/A | 0.01 |
| Back EMF constant | K_e | V*s | 0.01 |
| Armature resistance | R_arm | ohm | 1 |
| Armature inductance | L_arm | H | 0.5 |
| Voltage for 1 p.u. command Actuator limits multiply this voltage. | V_base | V | 12 |
| Speed for 1 p.u. output Setpoint and output multiply this speed. | W_base | rad/s | 1 |
| Tuning method | tuning | SIMC PI (Skogestad 2003) | |
| SIMC response time Larger values give gentler control; start at the transport delay. | lambda_c | s | 1 |
| Proportional gain Parallel form: u = Kp e + Ki integral(e) − Kd filtered dy/dt. | Kp_manual | 2 | |
| Integral gain Parallel form: u = Kp e + Ki integral(e) − Kd filtered dy/dt. | Ki_manual | 1/s | 0.5 |
| Derivative gain Parallel form: u = Kp e + Ki integral(e) − Kd filtered dy/dt. | Kd_manual | s | 0.1 |
| Derivative filter time First-order filter; derivative acts on measurement, avoiding setpoint kick. | T_filter | s | 0.1 |
| Conditional integral anti-windup Freeze integration only when saturation and error would drive it farther into saturation. | antiwindup | true | |
| Minimum command | u_min | p.u. | -3 |
| Maximum command | u_max | p.u. | 3 |
| Setpoint step Applied at t = 0; initial plant and controller states are zero. | r_step | p.u. | 1 |
| Plant-input disturbance step Added after actuator saturation, before transport delay. | d_step | p.u. | 0 |
| Disturbance time | t_load | s | 15 |
| Simulation duration At a fixed interval count, changing duration also changes the controller sample period. | T_span | s | 30 |
| Phase view Detail views keep the delay phase readable near a selected crossover. The full view retains every delay rotation. | phase_view | Phase-margin crossover detail | |
| Controller sample intervals Sample period = duration / intervals. Changing this count changes the simulated controller sample period. Double it to check convergence toward the continuous design. | N_samples | 1500 | |
| Bode start frequency | w_low | rad/s | 0.001 |
| Bode end frequency | w_high | rad/s | 100 |
| Root locus axis half-span Poles outside this square are omitted; enlarge to inspect fast modes. | pole_span | 1/s | 4 |
| Playback through response Play moves the marker over the precomputed response. | playhead | 0.12 |
Results
With the default inputs above, the calc gives:
| Result | Value |
|---|---|
| Proportional gain | 2 |
| Integral gain | 0.5 1/s |
| Derivative gain | 0 s |
| Setpoint overshoot | 4.235 % |
| 10–90% rise time | 1.9 s |
| 2% settling time | 6.08 s |
| Full-window absolute error integral | 2.1736 s |
| Final tracking error | 0 p.u. |
| Continuous phase margin | 61.35° at 0.5 rad/s |
| Continuous gain margin | 9.943 dB at 1.571 rad/s |
| Peak sensitivity in frequency range | 1.59 |
| Rightmost pole: Padé if delayed | -0.25 1/s |
| Current poles outside locus display | 0 |
Checked against sources
Each case below was calculated by this calc and agrees with the value from its source (within the tolerance where one is shown).
Skogestad Table 2: FOPDT robustness
Source: Skogestad (2003), Table 2, journal p. 297 (attached PDF p. 7), first-order column with integral time equal to the plant lag. Values are published rounded margins for exact delay and PI, not Padé pole predictions. DOI:10.1016/S0959-1524(02)00062-8.
Inputs: the default inputs above.
| Result | Source | This calc |
|---|---|---|
| Linear gain margin | 3.14 ± 0.015 | 3.142 |
| Limiting signed phase margin closest to zero | 61.4 ± 0.12 deg | 61.352 deg |
| Peak sensitivity in frequency range | 1.59 ± 0.015 | 1.59 |
| Frequency of limiting phase margin; zero if unavailable | 0.5 ± 0.002 rad/s | 0.5 rad/s |
Skogestad Table 3 case 5: setpoint IAE
Source: Skogestad (2003), Table 3 case 5, journal p. 298 (attached PDF p. 8): G(s)=exp(−s)/(4s+1), SIMC gain 2, integral time 4, setpoint IAE=2.17. Only the setpoint experiment is compared; the paper's separate load step at t=20 is disabled here. Finite sampling and a finite 30 s horizon explain the small difference.
Inputs: Minimum command = -100 p.u.; Maximum command = 100 p.u.; the others as above.
| Result | Source | This calc |
|---|---|---|
| Proportional gain | 2 | 2 |
| Equivalent integral time; minus one means disabled | 4 s | 4 s |
| Full-window absolute error integral | 2.17 ± 0.025 s | 2.174 s |
CTMS motor: unit-voltage steady speed
Source: CTMS, DC Motor Speed Modeling, university mirror: https://www.ece.ualberta.ca/~tchen/ctm/examples/motor/motor.html, open-loop example reports about 0.1 rad/s for 1 V. Its inertia list incorrectly prints kg·m²/s²; inertia must be kg·m², consistent with J=0.01 in its MATLAB code. Exact DC gain is 0.0999001, so tolerance allows the source rounding. Controller saturation in this case does not affect the separate open-loop curve.
Inputs: Plant model = DC motor speed; Transport delay = 0 s; Voltage for 1 p.u. command = 1 V; Simulation duration = 10 s; Controller sample intervals = 1,000; the others as above.
| Result | Source | This calc |
|---|---|---|
| Normalized plant DC gain | 0.1 ± 2 × 10⁻⁴ | 0.0999 |
| Open-loop response to the same input step [1001] | 0.1 ± 2 × 10⁻⁴ p.u. | 0.0999 p.u. |
CTMS motor: same case in US mechanical units
Source: Same CTMS unit-voltage example as ctms_motor, with 0.01 kg·m² and 0.1 N·m·s converted to lbm·ft² and lbf·ft·s. https://www.ece.ualberta.ca/~tchen/ctm/examples/motor/motor.html. This checks that mechanical unit selection preserves the published response.
Inputs: Plant model = DC motor speed; Motor mechanical units = US: lbm·ft² and lbf·ft·s; Transport delay = 0 s; Voltage for 1 p.u. command = 1 V; Simulation duration = 10 s; Controller sample intervals = 1,000; the others as above.
| Result | Source | This calc |
|---|---|---|
| Normalized plant DC gain | 0.1 ± 2 × 10⁻⁴ | 0.0999 |
| Open-loop response to the same input step [1001] | 0.1 ± 2 × 10⁻⁴ p.u. | 0.0999 p.u. |
Regression: phase branch with sweep starting above resonance
Source: Independent reviewer supplied −73.87° for this pure-integral second-order loop. Independently confirmed using SciPy brentq on |L(jw)|−1 and NumPy phase unwrapping anchored at 10⁻⁸ rad/s: PM=−73.8727503829°, w=7.45347656066 rad/s. Same benchmark as phase_anchor_low; frequency bounds must not shift the phase branch by 360°. Margin convention: https://www.mathworks.com/help/control/ref/dynamicsystem.margin.html.
Inputs: Plant model = Second order; Transport delay = 0 s; Proportional gain = 0; Integral gain = 100 1/s; Derivative gain = 0 s; Bode start frequency = 3 rad/s; the others as above.
| Result | Source | This calc |
|---|---|---|
| Limiting signed phase margin closest to zero | -73.873 deg | -73.873 deg |
| Frequency of limiting phase margin; zero if unavailable | 7.453 rad/s | 7.453 rad/s |
Regression: same phase branch with sweep starting below resonance
Source: Independent review benchmark and independent SciPy/NumPy check, as phase_anchor_high. The only changed input is the lower Bode bound. Expected PM=−73.8727503829° and crossover=7.45347656066 rad/s. https://www.mathworks.com/help/control/ref/dynamicsystem.margin.html.
Inputs: Plant model = Second order; Transport delay = 0 s; Proportional gain = 0; Integral gain = 100 1/s; Derivative gain = 0 s; the others as above.
| Result | Source | This calc |
|---|---|---|
| Limiting signed phase margin closest to zero | -73.873 deg | -73.873 deg |
| Frequency of limiting phase margin; zero if unavailable | 7.453 rad/s | 7.453 rad/s |
Regression: limiting gain margin at −540° crossing
Source: Independent reviewer supplied GM=5.731 dB at 1.06761 rad/s for this model. Independently confirmed with SciPy brentq on Im L(jw)=0, retaining Re L<0 and selecting the margin closest to 0 dB: 5.73114950606 dB at 1.06761069219 rad/s. The crossing has phase −540°; using only the first −180° crossing incorrectly gives 13.733 dB. Definition: https://www.mathworks.com/help/control/ref/dynamicsystem.margin.html.
Inputs: Plant model = Second order; Natural angular frequency = 1 rad/s; Damping ratio = 0.05; Transport delay = 7.5 s; Proportional gain = 0.03; Integral gain = 0.05 1/s; Derivative gain = 0.12 s; the others as above.
| Result | Source | This calc |
|---|---|---|
| Limiting signed gain margin closest to zero dB | 5.731 dB | 5.731 dB |
| Frequency of limiting gain margin; zero if unavailable | 1.068 rad/s | 1.068 rad/s |
Regression: fast SIMC controller requests sample-period refinement
Source: Independent review, 2026-10-25: with theta=0, SIMC lambda=0.01 s, 30 s duration and 1500 intervals (sample period 0.02 s), the response alternates near 0.012 and 1.988; 3000 intervals settles. The required behavior is to request refinement, coded as 1. This checks the review's explicit warning requirement, not an independent physical reference value.
Inputs: Transport delay = 0 s; SIMC response time = 0.01 s; Minimum command = -1,000 p.u.; Maximum command = 1,000 p.u.; Bode end frequency = 10,000 rad/s; the others as above.
| Result | Source | This calc |
|---|---|---|
| Controller sample-period refinement requested | 1 | 1 |







Responses