What Are PID Controllers and How Do They Work?

Written by andreysolovev | Published 2023/05/04
Tech Story Tags: electronic-design | pid-controllers | signal-processing | control-loops | hardware | engineering | hardware-engineering | how-do-pid-controllers-work

TLDRThe article covers the basics of PID controllers: what PID is, how it works, its advantages and disadvantages, and application peculiarities.via the TL;DR App

PID controllers are mechanisms used in control loops for shaping control signals to achieve the required accuracy and quality of transient response. They compute the signal as the sum of three control terms: proportional, integral, and derivative.
PID controllers can be physical mechanisms or algorithms implemented on microcontrollers. They can be applied to almost any type of process. That’s why they are widely used in electronics design and find applications in various industries as parts of control systems.

Working Principle

In a control loop, the process variable (PV) is measured with a sensor that sends the signal back to the controller. PV can be anything: speed, pressure, angle, level, temperature, etc. The controller receives a set point (SP) from the outside. It is the value which the system must achieve.
The controller compares the PV and SP, computes a control signal based on the difference between them, and transmits it to the actuation device. The device drives the plant to the desired process value (set point).
A scheme showing the structure of a closed loop control system with a PID controller.

How the control signal is Calculated

To compute the control signal, the PID controller sums the proportional, integral, and derivative terms, with each multiplied by a corresponding gain. The gains increase or decrease the weight of the term in the formula and are used for tuning PID controllers.
The proportional term is the difference between the set point (SP) and the measured process variable (PV).
The higher it is, the higher the value of the manipulated variable and the faster the system will drive the process variable to the desired value. In the heating process shown below, the manipulated variable drops as the measured process variable (temperature) rises.
A plot showing the work of a P-only controller in a temperature control system. The I and D terms are off.
But in some systems, the difference between the SP and PV cannot be completely eliminated, which results in steady state error. That’s when the I component is required.
The integral term is proportional to the time integral of the error value.
While the P component takes into account only the current error value, the I component considers the previous errors. It eliminates the steady state error, but a pure I controller is very slow and makes the PV oscillate.
A plot showing the work of a pure I controller. The P and D terms are off.
That’s why engineers use PI controllers much more often, as this modification of a PID controller results in an almost perfect transient response.
Two graphs showing the work of a P controller, that causes a steady-state error, and a PI controller, that eliminates the error.
The derivative term uses the difference between the current and previous error values divided by the time between measurements (dt).
Thus, the D component takes into account future error values. It compensates for sharp fluctuations in the system, prevents it from strong overshoot, and decreases oscillations. This is how it affects process response compared to the work of a PI controller.
Two plots showing the work of a PID controller with and without the D term.

Applications of PID Controllers

Universal PID controllers can quickly drive the process variable into an acceptable range, keep this value at the desired level, and respond to disturbances quickly. In some cases, applying a P-only controller or a PI controller is enough. But when you need better stability or tracking, which requires eliminating undesirable overshoot, the use of a PID controller is a better option.
These features make PID controllers good for a variety of applications.
  • Manufacturing
  • The algorithm allows for regulating various parameters in manufacturing equipment such as pressure, flow rate, voltage, etc. The use of PID controllers for temperature control is especially important in the metallurgical industry. Heat treatment of metals often requires high precision. 
  • Chemical and pharmaceutical industries
  • Here, the mechanism allows you to regulate pressure, temperature, PH, and humidity in different chemical processes. It is also used to control the flow rate of fluids to achieve the desired concentration of chemicals.
  • Autopilot
  • Any self-driving vehicle from a car to a plane can’t move with perfect precision. Its trajectory is affected by the environment, so the vehicle needs corrections. This need explains the use of PID controllers in the aircraft and automobile industries. The cruise control system of a car is a good example of basic PID control. The mechanism also finds applications in hoverboards, quadcopters, as well as plane and drone autopilots. 
  • Robotics
  • The use of PID controllers in robotics development allows for achieving high accuracy of movement. Depending on the application, it can be sufficient to apply a P-only or a PI modification. Using a PID controller for DC motor control is another frequent application.
  • Power conversion
  • The PID algorithm can be incorporated into power converters to make energy consumption more efficient by regulating the output voltage. That’s why it is used both in consumer-grade solutions and industrial power electronics development.
  • Photovoltaics
  • The power output of solar panels depends on the weather. Tracking the highest power point of a PV cell allows for maintaining stable current and voltage. PID controllers reduce the response time of the system.

Advantages of PID Controllers

The PID algorithm is universal. It suits almost any kind of process as long as the desired effect can be achieved by forcing the process variable to match the desired value sooner or later. Here are some of the key advantages of this control technique:
  • The PID technique provides higher accuracy than simpler on/off controllers.
  • The algorithm is more energy efficient.
  • It isn’t heavy on hardware, so devices with PID controllers are mostly cheap.
  • The algorithm can be implemented as analog electronics, digital electronics, and mechanical solutions. Today, engineers mostly use digital PID controllers, but there are also pneumatic, hydraulic, and mechanical PID controllers.
  • The P, I, and D components can be tuned intuitively, by trial and error. Even if tuning the PID controller in a control system does require a specialist, one session should last for years.
  • More advanced controllers will probably require stopping the process for re-tuning. But a universal PID controller can often be re-tuned while the process is still running, which is often more convenient.
  • Unlike simpler solutions, the PID algorithm can substantially extend the life of an actuation device.
  • While advanced controllers are more efficient, using them may not be worth the expense and effort.
  • Unlike model-based controllers, the PID algorithm responds to unmeasured disturbances better due to having proportional and derivative actions.
  • The PID algorithm has been in use for over 70 years, so engineers have found workarounds for many of the existing problems.

Modifications of PID Controllers

PID controllers use proportional, integral, and derivative components to regulate a process. By setting a gain to zero, one eliminates the term from the equation. Such types of PID controllers are called PID modifications. Engineers generally use the following modifications:
A table with the most popular modifications of the PID controller.
A proportional controller reduces the rise time (time required for the process variable to reach the set point) and speeds up the response.
A derivative controller minimizes the overshoot and oscillations in the output of the system.
An integral controller reduces the time-invariant error and lags the output phase.
A PI controller allows for reducing the rise time and eliminating the steady-state error.
A PD controller reduces the rise time, overshoot, and oscillations in the plant.

Final Thoughts

Compared to simpler solutions, the PID algorithm is more accurate. It can keep a process variable almost perfectly at the required level. It is less efficient than fuzzy logic controllers and optimal controllers. However, PID controllers are cheaper and easier to implement. This and their ability to control almost any process make them the most popular solutions for a huge number of applications.
Also published here.

Written by andreysolovev | Co-founder and CTO at Integra Sources. PhD in Physics and Mathematics.
Published by HackerNoon on 2023/05/04