SlideShare a Scribd company logo
1 of 8
Download to read offline
v1.0 
Misr University for Science and Technology 
College of Engineering 
Mechatronics Lab 
PROCESS CONTROL MODULE 
PID TUNING AND STABILITY 
(MATLAB Simulation) 
Prof. Farid A. Tolbah 
Eng. Waleed A. El-Badry
v1.0 
1. Objective 
The experiment is aimed to make student acquainted with the preliminary steps to manually tune a PID controller for a plant model by means of MATLAB. 
2. Outcome 
 Writing mathematical models of plants under investigation in Laplace form using MATLAB. 
 Developing the mathematical Laplace representation of Ziegler-Nicholas PID controller in MATLAB. 
 Finding the critical gain (Kc) and the ultimate period (Pu) to calculate PID gains. 
3. Prerequisite 
Student should be familiar with the following terms: 
 Closed loop system. 
 System response. 
 PID controller 
 Ziegler-Nicholas tuning method. 
Also basic understanding of MATLAB syntax is preferred. 
4. The Closed loop system 
The below figure represents the generic closed loop system. 
Figure 1 Closed loop system 
For implementation in this experiment, we are given the following plant model Wp(s): 푊푝(푠)= 1(10푠+1)3= 11000푆3+300푠2+30푠+1 
And the Ziegler-Nicholas PID is formulated as: 푊푐(푠)=퐾푐(1+ 1 푇푖푠 +푇푑푠) 
Controller 
Plant 
Feedback 
FCE 
Set 
Point 
e(t) 
y(t) 
wc 
Current 
Level
v1.0 
Assuming unity feedback, redrawing the block diagram: 
Figure 2 Problem block diagram 
5. Developing MATLAB functions (Plant, Controller and Closed Loop) 
a. Launch MATLAB software. 
b. From the Home tab, select New -> Function. 
c. Write down the generic plant function as shown in the following snippet: 
function [ Wp ] = CreatePlant( num,den ) 
%CreatePlant Creates plant transfer function. 
% The returned value is the system in numerator/denomerator format 
%% Parameters 
% num : Numerator vector (starting from highest order of coefficients) 
% den : Denomerator vector (starting from highest order of coefficients) 
% plant : Plant transfer function 
%% EXAMPLE 
% num=[1]; 
% den=[1 0 1]; 
% sys=CreatePlant(num,den) 
%% Result is 
% 1 
% sys= --------------- 
% S^2+1 
%% Function implementation 
syms s; 
Wp=tf(num,den); 
end 
Snippet 1 CreatePlant function 
d. Save the file. 
e. Close the function file. 
퐾푐(1+ 1 푇푖푠 +푇푑푠) 
1(10푠+1)3 
Set 
Point 
E(S) 
X(S) 
Current 
Level 
Y(S)
v1.0 
f. Repeat steps b-e for creating the following snippet for Ziegler-Nicholas generic function: 
function Wc = ZieglerNicholasPID( Kc,Ti,Td ) 
% ZieglerNicholasPID function to generate the PID controller transfer 
%% Parameters 
% Kc : Critical gain 
% Ti : Reset time (minutes) 
% Td : Derivative time (minutes) 
%% Function implementation 
s=tf('s'); 
Wc=Kc*(1+(1/(Ti*s))+Td*s); 
end 
Snippet 2 Ziger-Nicholas PID implementation 
g. The final function bonds the two functions (plant and controller) to build the closed loop system: 
function sys = CLS( Wp,Wc ) 
%CLS Closed loop system function 
%% Parameters 
% Wp : Plant transfer function 
% Wc : Controller transfer function 
% sys : Closed Loop transfer function with assuming unity feedback. 
%% Function implementation 
CLS=feedback(series(Wp,Wc),1); 
end 
Snippet 3 Closed loop system bonding
v1.0 
6. Open loop system response 
Figure 3 Open loop system 
To plot the open loop response, perform the following steps: 
a. From MATLAB command window, we will call the function CreatePlant to create the transfer function mentioned in shown: 
sys=CreatePlant(1,[1000 300 30 1]); 
step(sys) 
b. From the figure opened, right click on it and select characteristics -> Settling Time, Rise Time and Steady State. Fill in the table: 
Figure 4 Characteristics of Open loop system 
 
Table 1 Characteristics of open loop system 
Rise Time (sec) 
42.2 
Settling Time (sec) 
75.2 
Steady State (sec) 
120 
1(10푠+1)3 
Set 
Point 
Y(s)
v1.0 
7. Finding the critical gain (Kc) via Nyquist plot 
a. To plot the Nyquist of frequency response of the plant, write down the following code: 
Wp=CreatePlant(1,[1000 300 30 1]); 
nyquist(Wp); 
b. Right click on the plot and select characteristics -> Minimum Stability Margins as shown in figure 
Figure 5 Nyquist plot (Open loop) 
c. Write down the gain margin Gm (in dB) and convert it to magnitude. Write down the margin frequency Wc . 
d. Calculate 퐾푐=퐺푚= 8.0011 , and 푃푢= 2휋 휔푐 = 2휋 0.173=36.32 푠푒푐 and consequently 푇푖=
v1.0 
e. Check that Kc is the critical gain by writing down the following MATLAB code: 
t=0:0.01:200; 
Wp=CreatePlant(1,[1000 300 30 1]); 
%Setting Kc=8, Ki=~0 and Kd=0 
Wc=ZieglerNicholasPID(8,100000,0); 
sys=CLS(Wp,Wc); 
%plotting step response from t0=0 to tf=200 sec 
step(sys,t) 
Snippet 4 Plotting the system response at critical gain 
Figure 6 Step response at Kc=8 
8. Calculating P, PI and PID control gains 
After obtaining the critical gain from the previous step, we are able to calculate the P,I and D parameters and perform comparison of each controller type. According to Ziegler Nicholas table: 
Table 2 Ziegler Nicholas Tuning Chart Controller Type Kp Ti (sec) Td (sec) P 
0.5*Kc = 0.5*8=4 
100000 
0 PI 
0.45*Kc = 0.45*8=3.6 
0.83*Pu=0.83*36.32=30.1 
0 PID 
0.59* Kc = 0.59*8=4.7 
0.5*Pu=0.5*36.32=18.2 
0.12*Pu =0.12*36.32=4.4
v1.0 
Plot the step response of each controller over the plant by writing the following code: 
Wp=CreatePlant(1,[1000 300 30 1]); 
Wcp=ZieglerNicholasPID(4,100000,0); 
Wcpi=ZieglerNicholasPID(3.6,30.1,0); 
Wcpid=ZieglerNicholasPID(4.7,18.2,4.4); 
t=0:0.01:500; 
sys=CLS(Wp,Wcp); 
step(sys,t) 
hold on 
sys=CLS(Wp,Wcpi); 
step(sys,t) 
sys=CLS(Wp,Wcpid); 
step(sys,t) 
legend('P','PI','PID') 
Figure 7 step response of P, PI and PID controller

More Related Content

What's hot

Chapter 4 time domain analysis
Chapter 4 time domain analysisChapter 4 time domain analysis
Chapter 4 time domain analysisBin Biny Bino
 
Lecture 19 mathematical modeling of pneumatic and hydraulic systems
Lecture 19   mathematical modeling of pneumatic and hydraulic systemsLecture 19   mathematical modeling of pneumatic and hydraulic systems
Lecture 19 mathematical modeling of pneumatic and hydraulic systemsManipal Institute of Technology
 
Pid controller tuning using fuzzy logic
Pid controller tuning using fuzzy logicPid controller tuning using fuzzy logic
Pid controller tuning using fuzzy logicRoni Roshni
 
Modern Control - Lec 06 - PID Tuning
Modern Control - Lec 06 - PID TuningModern Control - Lec 06 - PID Tuning
Modern Control - Lec 06 - PID TuningAmr E. Mohamed
 
Override control system
Override control systemOverride control system
Override control systemAshvani Shukla
 
modeling of system electrical, Basic Elements Modeling-R,L,C Solved Examples ...
modeling of system electrical, Basic Elements Modeling-R,L,C Solved Examples ...modeling of system electrical, Basic Elements Modeling-R,L,C Solved Examples ...
modeling of system electrical, Basic Elements Modeling-R,L,C Solved Examples ...Waqas Afzal
 
Time response of discrete systems 4th lecture
Time response of discrete systems 4th lectureTime response of discrete systems 4th lecture
Time response of discrete systems 4th lecturekhalaf Gaeid
 
Lecture 2 transfer-function
Lecture 2 transfer-functionLecture 2 transfer-function
Lecture 2 transfer-functionSaifullah Memon
 
First & second order of the control systems
First & second order of the control systemsFirst & second order of the control systems
First & second order of the control systemsSatheeshCS2
 
Introduction of control engineering
Introduction of control engineeringIntroduction of control engineering
Introduction of control engineeringAshvani Shukla
 
[Katsuhiko ogata] system_dynamics_(4th_edition)(book_zz.org)
[Katsuhiko ogata] system_dynamics_(4th_edition)(book_zz.org)[Katsuhiko ogata] system_dynamics_(4th_edition)(book_zz.org)
[Katsuhiko ogata] system_dynamics_(4th_edition)(book_zz.org)alika1-2
 
lecture1 (5).ppt
lecture1 (5).pptlecture1 (5).ppt
lecture1 (5).pptHebaEng
 
DC Motor Modling,Controlling and Simulation
DC Motor Modling,Controlling and SimulationDC Motor Modling,Controlling and Simulation
DC Motor Modling,Controlling and SimulationSyed Atif Naseem
 
Lag lead compensator design in frequency domain 7th lecture
Lag lead compensator design in frequency domain  7th lectureLag lead compensator design in frequency domain  7th lecture
Lag lead compensator design in frequency domain 7th lectureKhalaf Gaeid Alshammery
 

What's hot (20)

Chapter 4 time domain analysis
Chapter 4 time domain analysisChapter 4 time domain analysis
Chapter 4 time domain analysis
 
Lecture 19 mathematical modeling of pneumatic and hydraulic systems
Lecture 19   mathematical modeling of pneumatic and hydraulic systemsLecture 19   mathematical modeling of pneumatic and hydraulic systems
Lecture 19 mathematical modeling of pneumatic and hydraulic systems
 
Class 7 mathematical modeling of liquid-level systems
Class 7   mathematical modeling of liquid-level systemsClass 7   mathematical modeling of liquid-level systems
Class 7 mathematical modeling of liquid-level systems
 
Pid controller tuning using fuzzy logic
Pid controller tuning using fuzzy logicPid controller tuning using fuzzy logic
Pid controller tuning using fuzzy logic
 
Modern Control - Lec 06 - PID Tuning
Modern Control - Lec 06 - PID TuningModern Control - Lec 06 - PID Tuning
Modern Control - Lec 06 - PID Tuning
 
Override control system
Override control systemOverride control system
Override control system
 
modeling of system electrical, Basic Elements Modeling-R,L,C Solved Examples ...
modeling of system electrical, Basic Elements Modeling-R,L,C Solved Examples ...modeling of system electrical, Basic Elements Modeling-R,L,C Solved Examples ...
modeling of system electrical, Basic Elements Modeling-R,L,C Solved Examples ...
 
Time response of discrete systems 4th lecture
Time response of discrete systems 4th lectureTime response of discrete systems 4th lecture
Time response of discrete systems 4th lecture
 
Lecture 2 transfer-function
Lecture 2 transfer-functionLecture 2 transfer-function
Lecture 2 transfer-function
 
Class 30 controller tuning
Class 30   controller tuningClass 30   controller tuning
Class 30 controller tuning
 
Transfer Function
Transfer FunctionTransfer Function
Transfer Function
 
PID Tuning
PID TuningPID Tuning
PID Tuning
 
First & second order of the control systems
First & second order of the control systemsFirst & second order of the control systems
First & second order of the control systems
 
Introduction of control engineering
Introduction of control engineeringIntroduction of control engineering
Introduction of control engineering
 
[Katsuhiko ogata] system_dynamics_(4th_edition)(book_zz.org)
[Katsuhiko ogata] system_dynamics_(4th_edition)(book_zz.org)[Katsuhiko ogata] system_dynamics_(4th_edition)(book_zz.org)
[Katsuhiko ogata] system_dynamics_(4th_edition)(book_zz.org)
 
lecture1 (5).ppt
lecture1 (5).pptlecture1 (5).ppt
lecture1 (5).ppt
 
DC Motor Modling,Controlling and Simulation
DC Motor Modling,Controlling and SimulationDC Motor Modling,Controlling and Simulation
DC Motor Modling,Controlling and Simulation
 
Lag lead compensator design in frequency domain 7th lecture
Lag lead compensator design in frequency domain  7th lectureLag lead compensator design in frequency domain  7th lecture
Lag lead compensator design in frequency domain 7th lecture
 
Control chap8
Control chap8Control chap8
Control chap8
 
Class 27 pd, pid electronic controllers
Class 27   pd, pid electronic controllersClass 27   pd, pid electronic controllers
Class 27 pd, pid electronic controllers
 

Viewers also liked

PID Controller
PID ControllerPID Controller
PID Controllersaishah72
 
Level Control of Tank System Using PID Controller-A Review
Level Control of Tank System Using PID Controller-A ReviewLevel Control of Tank System Using PID Controller-A Review
Level Control of Tank System Using PID Controller-A ReviewIJSRD
 
Controller ppt
Controller pptController ppt
Controller pptgourav0077
 

Viewers also liked (6)

PID Controller
PID ControllerPID Controller
PID Controller
 
Level Control of Tank System Using PID Controller-A Review
Level Control of Tank System Using PID Controller-A ReviewLevel Control of Tank System Using PID Controller-A Review
Level Control of Tank System Using PID Controller-A Review
 
Controller Tuning Method for Non-Linear Conical Tank System
Controller Tuning Method for Non-Linear Conical Tank SystemController Tuning Method for Non-Linear Conical Tank System
Controller Tuning Method for Non-Linear Conical Tank System
 
Controller ppt
Controller pptController ppt
Controller ppt
 
Water level controller
Water level controllerWater level controller
Water level controller
 
Pid controllers
Pid controllersPid controllers
Pid controllers
 

Similar to PID Tuning using Ziegler Nicholas - MATLAB Approach

Control tutorials for matlab and simulink introduction pid controller desig...
Control tutorials for matlab and simulink   introduction pid controller desig...Control tutorials for matlab and simulink   introduction pid controller desig...
Control tutorials for matlab and simulink introduction pid controller desig...ssuser27c61e
 
Ece 415 control systems, fall 2021 computer project 1
Ece 415 control systems, fall 2021 computer project  1 Ece 415 control systems, fall 2021 computer project  1
Ece 415 control systems, fall 2021 computer project 1 ronak56
 
Linear Control Hard-Disk Read/Write Controller Assignment
Linear Control Hard-Disk Read/Write Controller AssignmentLinear Control Hard-Disk Read/Write Controller Assignment
Linear Control Hard-Disk Read/Write Controller AssignmentIsham Rashik
 
control system lab 02 - PID tuning
control system lab 02 - PID tuning control system lab 02 - PID tuning
control system lab 02 - PID tuning nalan karunanayake
 
Modeling, simulation and control of a robotic arm
Modeling, simulation and control of a robotic armModeling, simulation and control of a robotic arm
Modeling, simulation and control of a robotic armcesarportilla8
 
Raymond.Brunkow-Project-EEL-3657-Sp15
Raymond.Brunkow-Project-EEL-3657-Sp15Raymond.Brunkow-Project-EEL-3657-Sp15
Raymond.Brunkow-Project-EEL-3657-Sp15Raymond Brunkow
 
Tarea1 francisco moya_mena_a74449_grupo02
Tarea1 francisco moya_mena_a74449_grupo02Tarea1 francisco moya_mena_a74449_grupo02
Tarea1 francisco moya_mena_a74449_grupo02FrankMoya3
 
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...Zac Darcy
 
Optimal and pid controller for controlling camera’s position in unmanned aeri...
Optimal and pid controller for controlling camera’s position in unmanned aeri...Optimal and pid controller for controlling camera’s position in unmanned aeri...
Optimal and pid controller for controlling camera’s position in unmanned aeri...Zac Darcy
 
cruise control system
cruise control systemcruise control system
cruise control systemLusiana Diyan
 
Tarea 2 francisco_moya_mena_a74449_grupo02
Tarea 2 francisco_moya_mena_a74449_grupo02Tarea 2 francisco_moya_mena_a74449_grupo02
Tarea 2 francisco_moya_mena_a74449_grupo02FrankMoya3
 
Time response of first order systems and second order systems
Time response of first order systems and second order systemsTime response of first order systems and second order systems
Time response of first order systems and second order systemsNANDHAKUMARA10
 
BS LAB Manual (1).pdf
BS LAB Manual  (1).pdfBS LAB Manual  (1).pdf
BS LAB Manual (1).pdfssuser476810
 

Similar to PID Tuning using Ziegler Nicholas - MATLAB Approach (20)

Control tutorials for matlab and simulink introduction pid controller desig...
Control tutorials for matlab and simulink   introduction pid controller desig...Control tutorials for matlab and simulink   introduction pid controller desig...
Control tutorials for matlab and simulink introduction pid controller desig...
 
Ece 415 control systems, fall 2021 computer project 1
Ece 415 control systems, fall 2021 computer project  1 Ece 415 control systems, fall 2021 computer project  1
Ece 415 control systems, fall 2021 computer project 1
 
matlab_simulink_for_control082p.pdf
matlab_simulink_for_control082p.pdfmatlab_simulink_for_control082p.pdf
matlab_simulink_for_control082p.pdf
 
Linear Control Hard-Disk Read/Write Controller Assignment
Linear Control Hard-Disk Read/Write Controller AssignmentLinear Control Hard-Disk Read/Write Controller Assignment
Linear Control Hard-Disk Read/Write Controller Assignment
 
CE150--Hongyi Huang
CE150--Hongyi HuangCE150--Hongyi Huang
CE150--Hongyi Huang
 
Quiz
QuizQuiz
Quiz
 
control system lab 02 - PID tuning
control system lab 02 - PID tuning control system lab 02 - PID tuning
control system lab 02 - PID tuning
 
Modeling, simulation and control of a robotic arm
Modeling, simulation and control of a robotic armModeling, simulation and control of a robotic arm
Modeling, simulation and control of a robotic arm
 
Raymond.Brunkow-Project-EEL-3657-Sp15
Raymond.Brunkow-Project-EEL-3657-Sp15Raymond.Brunkow-Project-EEL-3657-Sp15
Raymond.Brunkow-Project-EEL-3657-Sp15
 
Tarea1 francisco moya_mena_a74449_grupo02
Tarea1 francisco moya_mena_a74449_grupo02Tarea1 francisco moya_mena_a74449_grupo02
Tarea1 francisco moya_mena_a74449_grupo02
 
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...
Optimal and Pid Controller for Controlling Camera's Position InUnmanned Aeria...
 
Simulink
SimulinkSimulink
Simulink
 
Optimal and pid controller for controlling camera’s position in unmanned aeri...
Optimal and pid controller for controlling camera’s position in unmanned aeri...Optimal and pid controller for controlling camera’s position in unmanned aeri...
Optimal and pid controller for controlling camera’s position in unmanned aeri...
 
cruise control system
cruise control systemcruise control system
cruise control system
 
Using matlab simulink
Using matlab simulinkUsing matlab simulink
Using matlab simulink
 
Using matlab simulink
Using matlab simulinkUsing matlab simulink
Using matlab simulink
 
Tarea 2 francisco_moya_mena_a74449_grupo02
Tarea 2 francisco_moya_mena_a74449_grupo02Tarea 2 francisco_moya_mena_a74449_grupo02
Tarea 2 francisco_moya_mena_a74449_grupo02
 
Time response of first order systems and second order systems
Time response of first order systems and second order systemsTime response of first order systems and second order systems
Time response of first order systems and second order systems
 
Chapter10
Chapter10Chapter10
Chapter10
 
BS LAB Manual (1).pdf
BS LAB Manual  (1).pdfBS LAB Manual  (1).pdf
BS LAB Manual (1).pdf
 

More from Waleed El-Badry

Design of mechatronics systems team #4
Design of mechatronics systems team #4Design of mechatronics systems team #4
Design of mechatronics systems team #4Waleed El-Badry
 
Mechatronics design team project v2
Mechatronics design team project v2Mechatronics design team project v2
Mechatronics design team project v2Waleed El-Badry
 
Instructions on how to configure NI SoftMotion with SOLIDWORKS
Instructions on how to configure NI SoftMotion with SOLIDWORKSInstructions on how to configure NI SoftMotion with SOLIDWORKS
Instructions on how to configure NI SoftMotion with SOLIDWORKSWaleed El-Badry
 
Motion Control with LabVIEW and SOLIDWORKS
Motion Control with LabVIEW and SOLIDWORKSMotion Control with LabVIEW and SOLIDWORKS
Motion Control with LabVIEW and SOLIDWORKSWaleed El-Badry
 
The Development of Mechatronic Machine Vision System for Inspection of Cerami...
The Development of Mechatronic Machine Vision System for Inspection of Cerami...The Development of Mechatronic Machine Vision System for Inspection of Cerami...
The Development of Mechatronic Machine Vision System for Inspection of Cerami...Waleed El-Badry
 
The Development of Mechatronic Machine Vision System for Inspection Of Cerami...
The Development of Mechatronic Machine Vision System for Inspection Of Cerami...The Development of Mechatronic Machine Vision System for Inspection Of Cerami...
The Development of Mechatronic Machine Vision System for Inspection Of Cerami...Waleed El-Badry
 
Design and Implementation of DC Motor Speed Control using Fuzzy Logic
Design and Implementation of DC Motor Speed Control using Fuzzy LogicDesign and Implementation of DC Motor Speed Control using Fuzzy Logic
Design and Implementation of DC Motor Speed Control using Fuzzy LogicWaleed El-Badry
 

More from Waleed El-Badry (8)

Design of mechatronics systems team #4
Design of mechatronics systems team #4Design of mechatronics systems team #4
Design of mechatronics systems team #4
 
Mechatronics design team project v2
Mechatronics design team project v2Mechatronics design team project v2
Mechatronics design team project v2
 
Instructions on how to configure NI SoftMotion with SOLIDWORKS
Instructions on how to configure NI SoftMotion with SOLIDWORKSInstructions on how to configure NI SoftMotion with SOLIDWORKS
Instructions on how to configure NI SoftMotion with SOLIDWORKS
 
Motion Control with LabVIEW and SOLIDWORKS
Motion Control with LabVIEW and SOLIDWORKSMotion Control with LabVIEW and SOLIDWORKS
Motion Control with LabVIEW and SOLIDWORKS
 
The Development of Mechatronic Machine Vision System for Inspection of Cerami...
The Development of Mechatronic Machine Vision System for Inspection of Cerami...The Development of Mechatronic Machine Vision System for Inspection of Cerami...
The Development of Mechatronic Machine Vision System for Inspection of Cerami...
 
The Development of Mechatronic Machine Vision System for Inspection Of Cerami...
The Development of Mechatronic Machine Vision System for Inspection Of Cerami...The Development of Mechatronic Machine Vision System for Inspection Of Cerami...
The Development of Mechatronic Machine Vision System for Inspection Of Cerami...
 
Design and Implementation of DC Motor Speed Control using Fuzzy Logic
Design and Implementation of DC Motor Speed Control using Fuzzy LogicDesign and Implementation of DC Motor Speed Control using Fuzzy Logic
Design and Implementation of DC Motor Speed Control using Fuzzy Logic
 
Dc motor speed control
Dc motor speed controlDc motor speed control
Dc motor speed control
 

Recently uploaded

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 

Recently uploaded (20)

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 

PID Tuning using Ziegler Nicholas - MATLAB Approach

  • 1. v1.0 Misr University for Science and Technology College of Engineering Mechatronics Lab PROCESS CONTROL MODULE PID TUNING AND STABILITY (MATLAB Simulation) Prof. Farid A. Tolbah Eng. Waleed A. El-Badry
  • 2. v1.0 1. Objective The experiment is aimed to make student acquainted with the preliminary steps to manually tune a PID controller for a plant model by means of MATLAB. 2. Outcome  Writing mathematical models of plants under investigation in Laplace form using MATLAB.  Developing the mathematical Laplace representation of Ziegler-Nicholas PID controller in MATLAB.  Finding the critical gain (Kc) and the ultimate period (Pu) to calculate PID gains. 3. Prerequisite Student should be familiar with the following terms:  Closed loop system.  System response.  PID controller  Ziegler-Nicholas tuning method. Also basic understanding of MATLAB syntax is preferred. 4. The Closed loop system The below figure represents the generic closed loop system. Figure 1 Closed loop system For implementation in this experiment, we are given the following plant model Wp(s): 푊푝(푠)= 1(10푠+1)3= 11000푆3+300푠2+30푠+1 And the Ziegler-Nicholas PID is formulated as: 푊푐(푠)=퐾푐(1+ 1 푇푖푠 +푇푑푠) Controller Plant Feedback FCE Set Point e(t) y(t) wc Current Level
  • 3. v1.0 Assuming unity feedback, redrawing the block diagram: Figure 2 Problem block diagram 5. Developing MATLAB functions (Plant, Controller and Closed Loop) a. Launch MATLAB software. b. From the Home tab, select New -> Function. c. Write down the generic plant function as shown in the following snippet: function [ Wp ] = CreatePlant( num,den ) %CreatePlant Creates plant transfer function. % The returned value is the system in numerator/denomerator format %% Parameters % num : Numerator vector (starting from highest order of coefficients) % den : Denomerator vector (starting from highest order of coefficients) % plant : Plant transfer function %% EXAMPLE % num=[1]; % den=[1 0 1]; % sys=CreatePlant(num,den) %% Result is % 1 % sys= --------------- % S^2+1 %% Function implementation syms s; Wp=tf(num,den); end Snippet 1 CreatePlant function d. Save the file. e. Close the function file. 퐾푐(1+ 1 푇푖푠 +푇푑푠) 1(10푠+1)3 Set Point E(S) X(S) Current Level Y(S)
  • 4. v1.0 f. Repeat steps b-e for creating the following snippet for Ziegler-Nicholas generic function: function Wc = ZieglerNicholasPID( Kc,Ti,Td ) % ZieglerNicholasPID function to generate the PID controller transfer %% Parameters % Kc : Critical gain % Ti : Reset time (minutes) % Td : Derivative time (minutes) %% Function implementation s=tf('s'); Wc=Kc*(1+(1/(Ti*s))+Td*s); end Snippet 2 Ziger-Nicholas PID implementation g. The final function bonds the two functions (plant and controller) to build the closed loop system: function sys = CLS( Wp,Wc ) %CLS Closed loop system function %% Parameters % Wp : Plant transfer function % Wc : Controller transfer function % sys : Closed Loop transfer function with assuming unity feedback. %% Function implementation CLS=feedback(series(Wp,Wc),1); end Snippet 3 Closed loop system bonding
  • 5. v1.0 6. Open loop system response Figure 3 Open loop system To plot the open loop response, perform the following steps: a. From MATLAB command window, we will call the function CreatePlant to create the transfer function mentioned in shown: sys=CreatePlant(1,[1000 300 30 1]); step(sys) b. From the figure opened, right click on it and select characteristics -> Settling Time, Rise Time and Steady State. Fill in the table: Figure 4 Characteristics of Open loop system Table 1 Characteristics of open loop system Rise Time (sec) 42.2 Settling Time (sec) 75.2 Steady State (sec) 120 1(10푠+1)3 Set Point Y(s)
  • 6. v1.0 7. Finding the critical gain (Kc) via Nyquist plot a. To plot the Nyquist of frequency response of the plant, write down the following code: Wp=CreatePlant(1,[1000 300 30 1]); nyquist(Wp); b. Right click on the plot and select characteristics -> Minimum Stability Margins as shown in figure Figure 5 Nyquist plot (Open loop) c. Write down the gain margin Gm (in dB) and convert it to magnitude. Write down the margin frequency Wc . d. Calculate 퐾푐=퐺푚= 8.0011 , and 푃푢= 2휋 휔푐 = 2휋 0.173=36.32 푠푒푐 and consequently 푇푖=
  • 7. v1.0 e. Check that Kc is the critical gain by writing down the following MATLAB code: t=0:0.01:200; Wp=CreatePlant(1,[1000 300 30 1]); %Setting Kc=8, Ki=~0 and Kd=0 Wc=ZieglerNicholasPID(8,100000,0); sys=CLS(Wp,Wc); %plotting step response from t0=0 to tf=200 sec step(sys,t) Snippet 4 Plotting the system response at critical gain Figure 6 Step response at Kc=8 8. Calculating P, PI and PID control gains After obtaining the critical gain from the previous step, we are able to calculate the P,I and D parameters and perform comparison of each controller type. According to Ziegler Nicholas table: Table 2 Ziegler Nicholas Tuning Chart Controller Type Kp Ti (sec) Td (sec) P 0.5*Kc = 0.5*8=4 100000 0 PI 0.45*Kc = 0.45*8=3.6 0.83*Pu=0.83*36.32=30.1 0 PID 0.59* Kc = 0.59*8=4.7 0.5*Pu=0.5*36.32=18.2 0.12*Pu =0.12*36.32=4.4
  • 8. v1.0 Plot the step response of each controller over the plant by writing the following code: Wp=CreatePlant(1,[1000 300 30 1]); Wcp=ZieglerNicholasPID(4,100000,0); Wcpi=ZieglerNicholasPID(3.6,30.1,0); Wcpid=ZieglerNicholasPID(4.7,18.2,4.4); t=0:0.01:500; sys=CLS(Wp,Wcp); step(sys,t) hold on sys=CLS(Wp,Wcpi); step(sys,t) sys=CLS(Wp,Wcpid); step(sys,t) legend('P','PI','PID') Figure 7 step response of P, PI and PID controller