Understanding PID Controller

Jay Mistry
13 min readJun 1, 2021

At this stage when one wants to know about the PID controller, you would have come across control systems, and if not you may go through one of my past blogs on Control Systems.

The basic need of one is to have a stable control system, we know to stabilize any system we usually configure a closed-loop system which is also called feedback control. The feedback control which is introduced in a system is capable of:

  1. Improving stability
  2. Meeting the performance specifications
  3. Decreasing the sensitivity to parametric variation
  4. Improving the disturbance rejection
  5. Attenuating measurement noise

So, the idea of introducing feedback in control systems is extremely powerful, applications of the feedback principle have resulted in breakthroughs in control systems and instrumentation.

Now, the PID controller (Proportional — Integral — Derivative Controller)is a simple implementation of feedback. It can eliminate/remove the steady-state errors, anticipate the future. We will go through all this in detail. The PID controllers are an important ingredient of distributed systems for process controls. They are often combined with logic, sequential functions, selectors, and simple function blocks to build complicated automation systems. It is said that the PID controllers are the ‘bread and butter’ of control engineering.

So in this blog, first we will go through the basics and the theoretical part of the PID controllers, then we will test, verify and analyze them using MATLAB.

The following figure represents a basic system/ plant/ or an instrument.

Representation of general system.
A general system.

Using the concept of feedback, a device is driven by the available measurements (inputs), which generates the corrective control input which is feed to the plant. Our main aim is to keep the output/s at the setpoint/ reference value and hence by using the concept of feedback the controller controls the measurements and maintains the output. It also rejects or minimizes the disturbances caused.

A feedback control system.
A feedback system.

Hence, so far we must be very clear that why we need a controller. A controller helps to make our system stable, and a PID controller is by far the most common form of feedback and we know introducing feedback in a system is for the same reason that the system becomes stable. Now to realize feedback it is necessary to have appropriate sensors and actuators and a mechanism performing the control actions.

Controller

A controller gets input an error signal. The controller then processes the error signal accordingly and gives an output that is fed to the plant. The main aim is to have a stable system and maintaining the output at the reference or the set-point. Hence, the controller is chosen or programmed accordingly.

General block diagram of closed loop control system
A closed-loop control system general block diagram.

Hence a controller gets an error signal which is the difference between the reference input / set-point and the feedback signal or the measured signal. The input to the plant is the signal that is the output of the controller also referred to as the manipulated or the actuating signal / controlling signal.

The different types of controller are:

Different modes of control actions
Types of Controllers

We will mainly focus on the continuous type of controller and mainly on the PID one.

Let us consider one example of a second-order system G(s).

Second-order system.

This will be one of the examples on which we will continue to analyze the behavior of different controllers.

Second order system block diagram.
Open-loop block diagram of a second-order system.

Now applying the unit step reference input to our system G(s).

Unit step input to second-order system.
Unit step input to the second-order system.

The ideal output should be a curve tracing the unit step input. But practically the output obtained is not the ideal one.

Open-loop unit step response.
Open-loop unit step response.

From above, we can infer that on applying the unit step we are getting 0.0144 as a peak value, also the steady-state error is almost around 1. These parameters are not favorable and hence let us implement a unity feedback closed-loop system.

Unity feedback closed-loop system.
Unity feedback closed-loop system.
Closed-loop transfer function.
Closed-loop transfer function.

The transfer function of the unity feedback closed-loop system is shown alongside.

The unit step response for same we get as follows:

A closed-loop unity feedback system step response.
A closed-loop unity feedback system step response.

From above we can see that, simply introducing unity feedback in the system is not working since the parameters obtained are all same as the open-loop system only. The amplitude gain is small and not at all near to unity, steady-state remains the same. So simple feedback will not always help in achieving the best specs and ideal response.

Need of Controller:

From above we can see that the response obtained from the open-loop system is unfavorable and also the same case with the closed-loop unity feedback system. So now implementing a controller as already discussed above, the types of the controller and the inputs and outputs for the same.

Proportional Controller

The proportional action is simply proportional to the control error e(t). Mathematically this action can be given as stated in the equation below:

Proportional action mathematical form.
Proportional action mathematical form.

So this controller basically will try to amplify our output, which in the above cases (open and closed-loop we were getting very low). Hence, it is also referred to as the gain amplifier controller. But this controller has few limitations like it reduces the steady-state error, but it is not unable to eliminate it. If one wants to eliminate the same, the value of Kp must be very high, and keeping Kp very high gives offset error. Also, this increases the overshot. Let’s check this out in our example.

Proportional action mathematical form.
Implementing proportional controller.
Unit step response for different values of Kp — implementing P Controller.
Unit step response for different values of Kp — implementing P Controller.
Comparing the different parameters for different Kps.
Comparing the different parameters for different Kp’s.

So from above, we can see that on introducing a proportional controller, the amplitude of the response increases near to 1, steady-state error decreases. So the advantages of the P controller are:

  1. Steady-state error is reduced and hence system becomes more stable.
  2. Easy to implement.
  3. It minimizes fluctuations (note that high Kp will lead to high overshoot).
  4. The slow overdamped response is made faster.

Disadvantages of the P controller are:

  1. No fine controlling.
  2. Presence of offset error.
  3. The damping ratio is reduced which leads to an increase in overshoot.
  4. Leads to the instability of the system for a very high large gain Kp.

Where can be P controllers used? Applications:

For small set points or small load changes, used for maintaining higher tolerance and timely responsiveness.

Integral Controller

The limitation of the P controller i.e., the offset error is eliminated by this controller. Its main function is to make sure that the process output agrees with the set-point/reference value in the steady-state. So with the integral controller action, a small positive error will lead to an increased control signal and a negative error will give a decreasing control signal. We can visualize this action as a device that resets. Hence the output signal is directly proportional to the integral of the error signal.

The following points must be remembered for I-controller:

The type/order of the system increases by 1 (since we are adding one pole at origin), and hence the system becomes less stable. The steady-state error decreases (almost zero). It improves the steady-state response.

Block diagram of implementation of integral controller.
Implementing integral controller.

The mathematical representation of this controller can be given as:

Integral action mathematical form.
Integral action mathematical form.

Usually, we have seen that only I controller is not used alone, why? let us check it with our system. Implementing only integral controller with the system.

Response of the system only with an integral controller.
Response of the system only with an integral controller.

So from above, we can see that the peak is infinite and the response is not getting stable. We get too much of a transient. Hence only using the integral controller with the system leads to the instability of the system.

So using this controller along with the P controller can be helpful.

PI Controller

It is the combination of Proportional mode + Integral mode.

Implementing PI Controller.
Implementing PI Controller.

Mathematical expression to represent the PI action is:

Mathematical representation of the PI controller action.
Mathematical representation of the PI controller action.

Getting the response of the PI control action on our system:

Response of our system with PI controller (different Kp and Ki).
Response of our system with PI controller (different Kp and Ki).

From above, we can see that the integral action is improving the steady-state response. Since we have already seen the P controller response, just keeping the Kp = 500 gain as the overall best gain (constant)and then checking the effect of integral action on our system.

Keeping Kp=500 & varying Ki.
Keeping Kp=500 & varying Ki.
Comparing the different parameters for different Ki’s.
Comparing the different parameters for different Ki’s.

From above, we can see that the steady-state error reduces as we increase the value of Ki. Also, the transient response and its corresponding response are not improved, we can see that on introducing I controller action the settling time increases to 127s, as increasing Ki the settling time decreases, however an increase in Ki leads to overshoot which can be also seen above. So we can say from above that Ki = 1000 can be one of the best choices with Kp = 500 to stabilize our system, however, the overshoot and transient parameters remain bad and not to our ideal specs.

Comparing P & PI response:

Difference between P & PI controllers on our system
Difference P & PI controller implementation on our system.

Advantages of PI controller:

  1. Good transient response.
  2. Eliminates the offset error.
  3. Provides better stability.
  4. Improves the gain margin, and phase margin.

Disadvantages of PI controller:

  1. The system becomes sluggish due to the addition of integral terms.
  2. It increases the order of the system by one which results in the reduction of the stability, however, the P-type in combination maintains and overcomes this effect. The overshoot obtained from the response of the system is still high.

Usually, PI controllers are widely used in most of the industries since it eliminates the steady-state error. It is used in maintaining production rates in liquid flow control, steam pressure control, used for maintaining tighter tolerance and timely responsiveness, and also it is used as a low pass filter.

Derivative Controller

The derivative control makes our system improve the closed-loop stability and also improves the transient response (transient parameters — ts, tr, etc.). It can be described as the output of the controller is directly proportional to the rate of change of error. The control action is made proportional to the predicated process output, where the prediction is made by extrapolating the error by the tangent to the error curve.

Implementing this controller is like adding a zero to the system. The block diagram for the same is:

Implementing derivative controller.
Implementing derivative controller.

The mathematical representation of this controller is:

Mathematical representation of derivative controller.
Mathematical representation of derivative controller.

Again this controller cannot be implemented alone, since if the error will be constant then the output will be zero because the derivative of any constant is zero. We can verify this with our system too.

Response of implementing only D controller with our system.

From above, we can see that our output is going to zero over the period of time, as mentioned above that if error becomes constant then the derivative o the constant will result in zero and hence we get output as zero. So we don't use/implement only D controller.

Forming few combinations of D controller with others.

PD Controller

It is a combination of the proportional controller and the derivative controller.

Implementing PD controller.
Implementing PD controller.

Mathematical representation for same is:

Mathematical representation of PD controller.
Mathematical representation of PD controller.

Getting the response for our system when implementing PD controller, keeping Kp = 500 constant, as done before, and varying Kd.

Response of our system with PD controller implemented, keeping Kp constant and varying Kd.
Response of our system with PD controller implemented, keeping Kp constant and varying Kd.
Comparing different parameters for PD controller.
Comparing different parameters for PD controller.

From above, we can see that the transient response of our system has improved, also the steady-state error obtained is around 0.1. We can see that our system is getting settled fast (less settling time). But as we increase the derivative gain (Kd) to decrease the overshoot and also get less settling time, the peak value decreases and this can be observed in the last two columns in the above table.

Advantages of PD controller:

  1. It improves gain margin, phase margin, and also peak overshoot.
  2. It improves the stability of the system.
  3. It reduces the rise time and settling time.

Disadvantages of PD controller:

  1. It cannot eliminate offset error, it reduces it.
  2. The damping ratio is increased.
  3. It attenuates high-frequency noise.

This type of controller can be used used to control the position of the DC motor, for tuning fractional-order controllers, and it works as a high pass filter.

Comparing the implementation of P, PI, PD controller on our system

Comparision of P, PI, PD controller
Comparison of P, PI, PD controller.
Different parameters for P, PI, PD controller implementation with our system.

Clearly, we can see the differences, PD controller in our case is giving us a good result, the only undesirable thing is overshoot.

ID Controller

We do not use or see the implementation of ID-type controllers. The reason behind this is very simple, as seen above that the integral controller is dependent on past values and it accumulates the same, whereas the derivative controller’s output is directly proportional to the rate of change of error (future), so adding these two controllers together no present state will be seen and hence this makes on sense. The overshoot may get reduced and the swings are dampened but the loop becomes even slower than the I-controller only. So ID gives no advantage.

ID controller block diagram
ID Controller block diagram.
Response of our system with implementation of ID controller.
Response of our system with the implementation of ID controller.

From above, we can see that the transient parameters are too high and our system’s response becomes sluggish as mentioned above. So we do not implement ID controllers with systems. The system may sometimes respond properly to too few values of Ki and Kd on specific systems only, but using an ID controller is not advantageous.

PID Controller

The final combination of the proportional, integral, and derivative controller.

Implementation of PID controller with our system.
Implementation of PID controller with our system.
Mathematical representation of PID Controller
Mathematical representation of PID Controller
Response of our system implemented with PID Controller
Response of our system implemented with PID Controller

From above, we can see that the settling time is low, peak overshoot reduces, and our system stabilizes.

Advantages of PID Controller:

  1. It improves the stability of the system.
  2. It reduces/eliminates the steady-state error.
  3. It improves both the transient as well as the steady-state response.
  4. It is feasible and easy to implement.
  5. It makes our system’s response faster by reducing the time constant.

Disadvantages of PID Controller:

  1. Low robustness.
  2. PID controllers are linear and symmetric, hence it does not affect non-linear systems.
  3. Noise in the derivative part which can be reduced by using the derivative kick configuration.

PID controller is widely used, it is used for regulating pressure, speed, flow, the temperature in the automatic control process, it is used in heat treatment of metals, in pH control neutralization, in furnace temperature control, etc.

Comparing P, PI, PD, PID controllers

Comparing P, PI, PD, PID controllers response with our system.
Comparing P, PI, PD, PID controllers' responses with our system.
Different parameters for P, PI, PD, PID controllers.
Different parameters for P, PI, PD, PID controllers.

From above we can see the benefits of implementing PID controller with our system, the steady-state error is almost zero, settling time near 1.2s, peak value around 1.1 and the overshoot obtained is 10.6. So we can take PID as one of the best choices and options for the controller implementation.

One can think of proportional action mainly focused on the present, integral action focused on the past and derivative action focused on the future. So now you can also think of the different combinations that we made just above about this.

One can co-relate the concept of PID controllers with some real-life examples like cruise control of a car, leg used for accelerating accelerator, etc.

These were all basics behind PID controllers, and how they are useful and beneficial to our systems/ plants. Note that during the analysis above done, the values chosen for the gains are arbitrary. Proper tuning methods are present to obtain the best optimum values of the gains. Also, an auto-tuning feature of SIMULINK can be utilized for the same. The tuning methods can a topic for future discussions.

The following is an animation that shows the comparison of open-loop, closed-loop, P, PI, PD, and PID controller implementation on our system.

Response of different configurations of the system.

Improvements, feedbacks, suggestions are always welcomed!

--

--