Pid Controller
Pid Controller
8
Simulation and analysis of PID controller using SIMULINK
THEORY:
In this experiment, a simple PID (Proportional Integral Derivative) is designed using MATLABs’
Simulink. At the start a brief and comprehensive introduction to a PID controller is given and a
simple block diagram which can help you to implement a PID controller on a simple input on your
own. After that a simple example is provided in which the controller is designed using Simulink. We
can design a PID controller on Simulink in two different ways, each of the two ways is implemented
and after the implementation the results from both the methods are compared. At the end a simple
exercise is provided regarding the concepts and blocks used in this tutorial. You may also like to
check these tutorials on Simulink:
Introduction to PID controller
PID (Proportional Integral Derivative) controllers are the most widely used controllers in industrial
settings because of their ease of use and the satisfaction of performance they are capable to provide
the user for a large number of processes. Although the cost/benefit ratio provided by these controllers
is way more than provided by any other controller. Many techniques have been proposed for their
design, because of their widespread use, for the tuning of the parameters of PID i.ieKp, Ki and Kd
and for the implementation of additional functionalities that improve their performance.
91
environment by sensing the previous results of that process we form a closed control loop in our
mind. Changing the speed of the car is one of the best examples. The block diagram of a simple PID
controller is provided in the figure below,
PROCEDURE:
1. OpenMATLAB
2. Open Simulink e
3. After understanding the problem arrange the Simulink block in order and connect in proper
sequence
4. Save in current directory
92
Figure 3: Continuous sub block
Double click on the continuous block in the library browser and from that block select the PID block
as shown in the figure below,
93
Figure 5: Sources
From the sources subsection, now select the Step block which will be used as an input source to the
PID block as shown in the figure below,
94
Figure 7: Sink
From the sinks subsection select the scope which will be used to display the output. You can also
access the scope block from the commonly used blocks section in the library browser. Also if you do
not know where exactly the block is placed in the library browser of simulink you can also search the
block by typing its name in the search bar in the library browser. Refer to the figure below to see the
scope block selected from the sinks section.
Figure 8: Scope
We also need a system to apply the PID controller on it. By placing a system here what I actually
meant is to place a transfer function of the system in the block diagram. We can get a transfer
95
function block from the continuous section of the library browser of the simulink as shown in the
figure below,
The last block left to be placed is the sum block which will be used to subtract the feedback path of
the closed loop system. The sum block can be obtained from the commonly used blocks as shown in
the figure below
96
Figure 11: Placed components
What we need to do know is to change the parameters and properties of all the blocks according to
the current requirement. For instance, lets’ first change the list of signs in the summation block as we
need the second sign to be negative to subtract the feedback path from the current input as shown in
the figure below,
97
Figure 13: Transfer function
Double click on the step response block and adjust the properties as shown in the figure below. This
is done so because we need to start our step from time 0s.
Now double click on the PID block and change the values of Kp, Ki and Kd as shown in the figure
below,
98
Figure 15: PID parameters
These are just a hint we can update them later for the tuning purpose of PID. Connect all the block
with wires and complete circuit diagram will look like as shown in the figure below,
The only step left is to update the model configuration according to the step response and adjust the
sampling time of the system. Click on the model configuration icon as shown in the figure below,
99
Figure 17: Model configuration
In the model configuration dialog box, change the variable step to fixed steps and change the
sampling time to 0.01s as shown in the figure below,
These properties have a great impact on the response of the system. Now run the system from the run
icon at the top of the simulink page as shown in the figure below,
After running open the scope to see the generated waveform. The output of the waveform is shown in
the figure below,
100
Figure 20: Output
The output is a little overdamped and we can adjust it by tuning the values of Kp, Ki and Kd.
Lets’ now move toward the other method. Place 3 gain blocks in row and at the input connect
the output of the step block and name them as Kp, Ki and Kd. Refer to the figure below,
101
Figure 22: Derivative block
Place this block at the output of the Kd gain block and sum up all these gain using a
sum block as shown in the figure below,
Adjust the values of the gain as we have adjusted in previous method and the complete block diagram
of the PID controller is shown in the figure below,
102
Figure 24: Complete block diagram
Run the block diagram again and open the scope to see the response of the system as shown in the
figure below,
The output is slightly underdamped and it can be adjusted by tuning the gains of the PID controller
and it is left as an exercise for the reader.
Exercise:
Tune the values of Kp, Ki, and Kd try to make the step response of the transfer
function critically damped.
103