PID Controller Demo
Discover the principles of PID controllers and their role in control systems through this interactive demo. This tool is designed to help you visualize and understand key concepts in control theory with hands-on simulations.
- Tutorial
- Model 1
- Model 2
- Deep Dive
- Source Code
- Feedback
© 2025 Julian Winking
Knowledge Wiki
- Introduction
- Controllers
- Proportional Gain (Kp)
- Integral Gain (Ki)
- Derivative Gain (Kd)
- Mass
- Target
- Amplitude
- Frequency
- Noise
- Nyquist Plot
- Bode Plot
- Stability
Introduction to Control Systems
Control systems are used to manage, command, direct, or regulate the behavior of other devices or systems using control loops. They are essential in engineering and technology, enabling automation and precision in various applications, from industrial machinery to household appliances.
A control system typically consists of sensors, controllers, and actuators. Sensors measure the current state of the system, controllers process this information to determine the necessary adjustments, and actuators implement these adjustments to achieve the desired outcome.
What to observe in the simulator:
- Explore how the system responds to changes in parameters like Kp, Ki, and Kd.
- Observe the time-domain response (e.g., overshoot, settling time) and frequency-domain behavior (e.g., stability margins).
- Ogata, K. (2010). Modern Control Engineering (5th ed.). Prentice Hall.
- Dorf, R. C., & Bishop, R. H. (2017). Modern Control Systems (13th ed.). Pearson.
Types of Controllers
Controllers are devices that manage the behavior of other devices or systems. They are the brain of a control system, processing input signals and generating output signals to achieve the desired system behavior.
The most common types of controllers are:
- Proportional (P) Controller: Reacts to the current error. It is simple but may leave a steady-state error.
- Proportional-Integral (PI) Controller: Combines proportional control with integral action to eliminate steady-state error.
- Proportional-Derivative (PD) Controller: Adds derivative action to improve stability and reduce overshoot.
- Proportional-Integral-Derivative (PID) Controller: Combines all three actions for precise and stable control.
What to observe in the simulator:
- Experiment with different controller types by adjusting Kp, Ki, and Kd.
- Notice how each type affects system behavior, such as response time, stability, and error correction.
- Åström, K. J., & Murray, R. M. (2010). Feedback Systems: An Introduction for Scientists and Engineers. Princeton University Press.
- Nise, N. S. (2019). Control Systems Engineering (8th ed.). Wiley.
Proportional Gain (Kp)
The Proportional Gain (Kp) is one of the three core components of a PID controller. It determines how strongly the controller reacts to the current error, which is the difference between the desired setpoint (target) and the current position of the system.
In your PID Controller Demo, you can adjust the Kp value using the slider. Increasing Kp makes the controller react more aggressively to errors. This typically speeds up the system’s response to changes in the target. However, if Kp is set too high, the system can become unstable and start oscillating or even diverge entirely.
Conversely, lowering Kp results in a slower response. The system might take longer to reach the target, and it may not fully correct the error.
What to observe in the simulator:
- Try increasing Kp slowly and watch how the system reacts. You'll likely see the system reach the target more quickly.
- If you push Kp too high, the system might overshoot the target and oscillate back and forth.
- A very low Kp results in sluggish movement, where the system struggles to reach the target.
Proportional control alone cannot eliminate steady-state error (the small remaining difference between the target and the actual value). That’s where the Integral and Derivative components come in.
- Åström, K. J., & Murray, R. M. (2010). Feedback Systems: An Introduction for Scientists and Engineers. Princeton University Press.
- Dorf, R. C., & Bishop, R. H. (2017). Modern Control Systems (13th ed.). Pearson.
Integral Gain (Ki)
The Integral Gain (Ki) is the second component of the PID controller. It focuses on the accumulation of past errors over time. By integrating the error, Ki helps eliminate steady-state error, which is the persistent difference between the system output and the target that a Proportional controller (Kp) alone might not fix.
In your PID Controller Demo, adjusting Ki with the slider changes how much influence the accumulated error has on the controller output. Increasing Ki speeds up the elimination of steady-state error. However, setting Ki too high can make the system unstable, causing it to overshoot and oscillate.
What to observe in the simulator:
- Start with Ki at zero and notice that the system may never fully reach the target, especially if Kp is low.
- Gradually increase Ki and observe how the system corrects any remaining steady-state error.
- Be careful: a high Ki can lead to "integral windup," where the error accumulates too much, causing large overshoots and oscillations.
- Åström, K. J., & Murray, R. M. (2010). Feedback Systems: An Introduction for Scientists and Engineers. Princeton University Press.
- Ogata, K. (2010). Modern Control Engineering (5th ed.). Prentice Hall.
Derivative Gain (Kd)
The Derivative Gain (Kd) is the third component of the PID controller. It reacts to the rate of change of the error. In simpler terms, it predicts where the system is heading by looking at how fast the error is changing and applies corrective action to counteract it.
In your PID Controller Demo, adjusting Kd changes the controller's ability to dampen oscillations and improve stability. Increasing Kd makes the system more resistant to sudden changes or noise, reducing overshoot and smoothing the response. However, too much derivative action can amplify noise and make the system jittery.
What to observe in the simulator:
- Try increasing Kd and see how it helps to reduce oscillations and overshoot after sudden changes in the target.
- Watch out: if there’s noise in the system (try adding noise with the slider), a high Kd can cause erratic behavior, since it amplifies rapid changes in error.
- Åström, K. J., & Murray, R. M. (2010). Feedback Systems: An Introduction for Scientists and Engineers. Princeton University Press.
- Franklin, G. F., Powell, J. D., & Emami-Naeini, A. (2019). Feedback Control of Dynamic Systems (8th ed.). Pearson.
Mass
In your PID Controller Demo, the Mass slider adjusts the mass of the object being controlled. In real systems, mass represents inertia—how resistant the object is to changes in motion.
A heavier mass (larger value) responds more slowly to control actions because it requires more force (controller effort) to move. Conversely, a smaller mass responds faster but might be more sensitive to oscillations.
What to observe in the simulator:
- Increase the mass and watch how the system becomes slower to respond to changes in the target.
- Decrease the mass and notice how the system reacts more quickly, but may oscillate more if the controller gains are too aggressive.
- Ogata, K. (2010). Modern Control Engineering (5th ed.). Prentice Hall.
- Nise, N. S. (2019). Control Systems Engineering (8th ed.). Wiley.
Target
The Target parameter in your PID Controller Demo defines the desired setpoint for the system. It represents the value you want the system output (the controlled variable) to reach and maintain over time.
In practical terms, think of the target as the goal. For example, in a temperature control system, the target would be the desired room temperature.
What to observe in the simulator:
- Move the Target slider to change the desired setpoint. The system will try to adjust to the new target.
- A properly tuned controller will guide the system smoothly toward the target. If the controller parameters are not well-tuned, you might see overshoot, oscillations, or sluggish response.
- Ogata, K. (2010). Modern Control Engineering (5th ed.). Prentice Hall.
- Franklin, G. F., Powell, J. D., & Emami-Naeini, A. (2019). Feedback Control of Dynamic Systems (8th ed.). Pearson.
Amplitude
The Amplitude parameter controls the magnitude of oscillations or external disturbances applied to the system in your simulation.
In real-world systems, disturbances can be anything that pushes the system away from its target—like wind pushing a drone or a sudden load change on a motor. Amplitude simulates how strong these disturbances are.
What to observe in the simulator:
- Increase the Amplitude and see how the system responds to stronger disturbances.
- A well-tuned PID controller should correct for these disturbances and return the system to the target, but high disturbances might cause oscillations or instability if gains are not properly set.
- Nise, N. S. (2019). Control Systems Engineering (8th ed.). Wiley.
- Ogata, K. (2010). Modern Control Engineering (5th ed.). Prentice Hall.
Frequency
The Frequency parameter specifies the rate (how fast) oscillations or disturbances are applied to the system. It determines how frequently the disturbance changes direction or intensity.
Higher frequencies simulate rapid, frequent disturbances, while lower frequencies represent slower, more gradual changes.
What to observe in the simulator:
- Increase the Frequency slider to simulate faster disturbances. Watch if the system can keep up with these quick changes.
- A controller with a high Derivative Gain (Kd) can help deal with high-frequency disturbances, but too much Kd may make the system noisy.
- Franklin, G. F., Powell, J. D., & Emami-Naeini, A. (2019). Feedback Control of Dynamic Systems (8th ed.). Pearson.
- Ogata, K. (2010). Modern Control Engineering (5th ed.). Prentice Hall.
Noise
The Noise parameter introduces random variations into the system, simulating unpredictable real-world disturbances such as sensor inaccuracies, external interferences, or measurement noise.
In your PID Controller Demo, adding noise makes the system's behavior less predictable and tests the controller’s robustness.
What to observe in the simulator:
- Add a small amount of Noise and observe how the system reacts.
- High noise levels make it harder for the controller to maintain stability. Derivative control (Kd) is especially sensitive to noise because it reacts to rapid changes.
- Nise, N. S. (2019). Control Systems Engineering (8th ed.). Wiley.
- Åström, K. J., & Murray, R. M. (2010). Feedback Systems: An Introduction for Scientists and Engineers. Princeton University Press.
Nyquist Plot
The Nyquist Plot is a graphical representation of a system’s frequency response in the complex plane. It helps analyze system stability by showing how the open-loop transfer function behaves as frequency varies.
In your PID Controller Demo, the Nyquist Plot updates as you change controller parameters. You can observe how the curve approaches the critical point (-1, 0), which relates to the Nyquist stability criterion.
What to observe in the simulator:
- Look at whether the Nyquist plot encircles the critical point (-1, 0). If it does improperly, the system may be unstable.
- Tuning Kp, Ki, and Kd changes the shape and path of the Nyquist plot.
- Ogata, K. (2010). Modern Control Engineering (5th ed.). Prentice Hall.
- Dorf, R. C., & Bishop, R. H. (2017). Modern Control Systems (13th ed.). Pearson.
Bode Plot
The Bode Plot shows how the system responds to different frequencies. It consists of two plots: magnitude (gain) in decibels (dB) versus frequency and phase in degrees versus frequency.
In your PID Controller Demo, the Bode Plot updates in real-time as you adjust the controller parameters. This lets you see how the controller influences the system’s ability to handle inputs at different frequencies.
What to observe in the simulator:
- A well-tuned controller will show a smooth magnitude plot with a gain crossover frequency and adequate phase margin (the difference from -180° at that point).
- High Kd can increase phase lag, while Ki affects low-frequency behavior (steady-state response).
- Franklin, G. F., Powell, J. D., & Emami-Naeini, A. (2019). Feedback Control of Dynamic Systems (8th ed.). Pearson.
- Åström, K. J., & Murray, R. M. (2010). Feedback Systems: An Introduction for Scientists and Engineers. Princeton University Press.
Stability
Stability in control systems refers to the system’s ability to return to its desired state (equilibrium) after a disturbance. A stable system behaves predictably, without diverging or oscillating uncontrollably.
In your PID Controller Demo, stability depends on the balance of Kp, Ki, and Kd. If gains are too high or poorly tuned, the system can become unstable—leading to oscillations or divergence.
What to observe in the simulator:
- Gradually increase Kp and watch how the system may become unstable if Kp is too high.
- Tune Ki and Kd to help regain stability and smoothness.
- Observe stability using both the time-domain response (upper plot) and frequency-domain plots (Nyquist and Bode).
- Dorf, R. C., & Bishop, R. H. (2017). Modern Control Systems (13th ed.). Pearson.
- Ogata, K. (2010). Modern Control Engineering (5th ed.). Prentice Hall.