Control Lab 10 0670

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR


MtE-328L Control system LAB, 6th Semester
Student Name: Muaaz Ismail
Registration Number: 19PWMCT0670

Lab No.10: Tuning Method of PID controller.

Criteria (Taxonomy Excellent (4) Proficient (3) Basic (2) Below Basic (1) Student’s
Level) Score

Report is mostly Report is


as per the guidelines disorganized and
To organize the lab follows some Sections/Step
Report is as per and most s are not
report and practice the guidelines but
the guidelines. All most of the
writing skills as per the sections/steps are
sections/steps are ordered and
guidelines
clearly organized in ordered well but guidelines are Report is not as
a logical order. requires minor missing
improvements. per the

guidelines

The report
completely
discusses the The report
discusses the
required experiment/lab
The report The report is
discusses the work but have totally
experiment/lab
To discuss the actual required
work in own words irrelevant
experiment/task irrelevant to the
with some relevant experiment/lab work information experiment/lab
additional
work
information

Calculations and
data analysis were
performed
accurately, but Most data and
minor errors were observations were
Calculations and Calculations
recorded
data analyses were and data
performed clearly, made both in
adequately, but
To perform calculations calculations and in with several analyses of lab
concisely, and
and data analysis applying correct were missing
significant errors
accurately, with units or omissions.
correct units.

Graphs, if
necessary, were
drawn accurately Graphs, if Major
Graphs, if
necessary, were necessary, were components of
and neatly and
To present results in the drawn adequately drawn but lab were
were clearly
form of graphs inadequately. missing
labelled.

1
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

LAB NO: 10

TITLE: TUNING METHOD OF PID CONTROLLER.


OBJECTIVES:
• To study how to manually tune a controller.

• To study how to tune a controller using command in script window.

• To study how to tune a controller using PID Tuner APP.

• To study how to tune controller in Simulink model.

SOFTWARE OR TOOL:
▪ MATLAB (with control toll box)

THEORY:
TUNING OF PID CONTROLLER:
There are three methods to tune a PID Controller.

1. TRIAL AND ERROR METHOD:


This is the simple method of tuning a PID controller. Once we get the clear understanding of PID
parameters, the trial and error method become relatively easy.

• Set integral and derivative terms to zero first and then increase the proportional gain until
the output of the control loop oscillates at a constant rate. This increase of proportional
gain should be in such that response the system becomes faster provided it should not make
system unstable.
• Once the P-response is fast enough, set the integral term, so that the oscillations will be
gradually reduced. Change this I-value until the steady state error is reduced, but it may
increase overshoot.
• Once P and I parameters have been set to a desired values with minimal steady state error,
increase the derivative gain until the system reacts quickly to its set point. Increasing
derivative term decreases the overshoot of the controller response.

2
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

2. ZEIGLER-NICHOLS METHOD :
It is another popular method for tuning PID controllers. Ziegler and Nichols presented two classical
methods for determining values of proportional gain, integral time and derivative time based on
transient response characteristics of a given plant or system.

1) FIRST METHOD:
• Obtain a unit step response of the plant experimentally and it may look‘s’ shaped curve as
shown in figure below. This method applies, if obtained response exhibit s-shaped curve
for unit step input otherwise it cannot be applied. This curve can also be obtained by
dynamic simulation of the plant.

Fig: 10.1 Unit Step Response

• Obtain two constants, delay time L and time constant T by drawing a tangent line at the
inflection point of the s-shaped curve.
• Set the parameters of Kp, Ti, and Td values from the table given below for three types of
controllers.

3
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

Fig: 10.2

2) SECOND METHOD:

• It is very similar to the trial and error method where integral and derivative terms are set to
the zero, i.e., making Ti infinity and Td zero.
• Increase the proportional gain such that the output exhibits sustained oscillations. If the
system does not produce sustained oscillations then this method cannot be applied. The
gain at which sustained oscillations produced is called as critical gain.

Fig: 10.3

4
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

• Once the sustain oscillations are produced, set the values of Ti and Td as per the given
table for P, PI and PID controllers based on critical gain and critical period. [1]

Fig: 10.4

3) AUTOMATIC METHOD USING MATLAB TOOL:

There is an automatic method for tuning of PID controller using software tool MATLAB by
command, GUI and SIMULINK block diagram.

GENERAL TIPS FOR DESIGNING A PID CONTROLLER:

When you are designing a PID controller for a given system, follow the steps shown below to
obtain a desired response.

1. Obtain an open-loop response and determine what needs to be improved.


2. Add a proportional control to improve the rise time.
3. Add a derivative control to reduce the overshoot.
4. Add an integral control to reduce the steady-state error.
5. Just each of the gains.

EXAMPLE:

Fig: 10.5

5
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR


MtE-328L Control system LAB, 6th Semester

The governing equation of the system is

𝑚𝑥.. + 𝑏𝑥. + 𝑘𝑥 = 𝐹

Taking Laplace transform

𝑚𝑠2𝑋(𝑠) + 𝑏𝑠𝑋(𝑠) + 𝑘𝑋(𝑠) = 𝐹(𝑠)

The transfer function of the system is:

𝑋(𝑠) 1
=
𝐹(𝑠) 𝑚𝑠2 + 𝑏𝑠 + 𝑘

MATHEMATICAL MODELLING:

Let m=1kg, b=10 Ns/m, k= 20 N/m


The transfer function becomes:

𝑋(𝑠) 1
=
𝐹(𝑠) 𝑠2 + 10𝑠 + 20

APPLYING PROPORTIONAL INTEGRATIVE DERIVATIVE


CONTROLLER:
clear all
clc
clear
num=[1];
dnum=[1 10 20];
system=tf(num,dnum) ;
Kp =10;
Ki=10;
Kd=10;
C = pid(Kp,Ki,Kd);
T = feedback(C*system,1);
linearSystemAnalyzer(T);

6
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR


MtE-328L Control system LAB, 6th Semester

RESULT:

Fig: 10.6

This is the manual tuning of a PID Controller by changing the Kp, Ki, and Kd values for the PID
controller and looking at the output waveform. In manual tuning, the PID has the following
characteristics in a control system.

TUNE THE SYSTEM MANUALLY:


These characteristics are taken into account while manual tuning the PID controller.

Fig: 10.6

7
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

DRAWBACKS OF MANUAL TUNING:


The only drawback of manual tuning is that it is time consuming because we have to manually
adjust the PID values and analyze the output waveform every time.

AUTOMATIC PID TUNING:


MATLAB provides tools for automatically choosing optimal PID gains which makes the trial
and error process described above unnecessary.

1. You can access the tuning algorithm directly using pidtune.


2. Through a nice graphical user interface (GUI) using pidTuner.
3. Or Using PIDTuner App.

PID TUNE ALGORITHM METHOD:

It Designs a PID controller of type (controller) for the plant system. If type specifies a one-degree-
of-freedom (1-DOF) PID controller, then the controller is designed for the unit feedback loop.
Its syntax is C = pidtune (system, types)
System = open loop transfer function of system
Types= Controller type

CONTROLLER TYPES:
'P' — Proportional only
'I' — Integral only
'PI' — Proportional and integral
'PD' — Proportional and derivative
'PDF' — Proportional and derivative with first-order filter on derivative term
'PID' — Proportional, integral, and derivative
'PIDF' — Proportional, integral, and derivative with first-order filter on derivative term

TUNED PROPROTIONAL CONTROLLER:


clear all
clc
clear
num=[1];
dnum=[1 10 20];
system=tf(num,dnum) ;
[C_p] = pidtune(system,'P')
T = feedback(C_p*system,1);
linearSystemAnalyzer(T);

8
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

OUTPUT:

Fig: 10.7

TUNED PD CONTROLLER:
clear all
clc
clear
num=[1];
dnum=[1 10 20];
system=tf(num,dnum) ;
[C_pD] = pidtune(system,'PD')
T = feedback(C_pD*system,1);
linearSystemAnalyzer(T);

OUTPUT:

9
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR


Fig: 10.8

10
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

TUNED PI CONTROLLER:
clear all
clc
clear
num=[1];
dnum=[1 10 20];
system=tf(num,dnum) ;
[C_pI] = pidtune(system,'PI')
T = feedback(C_pI*system,1);
linearSystemAnalyzer(T);

RESULT:

Fig: 10.9

11
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

TUNED PID CONTROLLER:


clear all
clc
clear
num=[1];
dnum=[1 10 20];
system=tf(num,dnum) ;
[C_pID] = pidtune(system,'PID')
T = feedback(C_pID*system,1);
linearSystemAnalyzer(T);

RESULT:

Fig: 10.10

12
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

SLOW AND FAST RESPONSE OF P CONTROLLER:


clear all

clc

clear

num=[1];

dnum=[1 10 20];

system=tf(num,dnum) ;

[C_P] = pidtune(system,'P')

[C_P_fast] = pidtune(system,'P',1)

T1 = feedback(C_P*system,1);

T2 = feedback(C_P_fast*system,1);

linearSystemAnalyzer(T1,T2);

Fig: 10.11

13
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

'PIDF' — PROPORTIONAL, INTEGRAL, AND DERIVATIVE


WITH FIRST-ORDER FILTER ON DERIVATIVE TERM:

clear all
clc
clear
num=[1];
dnum=[1 10 20];
system=tf(num,dnum) ;
[C_P] = pidtune(system,'PID')
[C_P_fast] = pidtune(system,'PIDF',1)
T1 = feedback(C_P*system,1);
T2 = feedback(C_P_fast*system,1);
linearSystemAnalyzer(T1,T2);

Fig: 10.12

14
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

pidTuner(P,C)

clear all
clc
clear
num=[1];
dnum=[1 10 20];
system=tf(num,dnum) ;
pidTuner(system,'p')

Fig: 10.13

CONTROLLER TYPE:

Fig: 10.14

14
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

SPEED AND TRANSIENT RESPONSE CHANGE:

Fig: 10.15

SHOW PARAMETERS:

Fig: 10.16

15
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

PID TUNER IN SIMULINK:

DONE IN LAB TASK:

LAB TASK 10

a) Plot the open loop response of the system.


CODE:

COMMAND WINDOW:

16
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

GRAPH:

17
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

b) Plot the output response with PID controller


CODE:

18
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

GRAPH:

19
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

c) Tune the controller using pidtuner command


CODE:

GRAPH:

d) Tune the controller using GUI (through PidTuner command


and APP)
USING COMMAND:

20
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

GUI:

21
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

USING APP:

22
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

e) Model the system in Simulink.

23
DEPARTMENT OF MECHATRONICS ENGINEERING

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

f) Tune the controller in Simulink

24
DEPARTMENT OF MECHATRONICS ENGINEERING

MtE
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, PESHAWAR

References

[1] "https://www.electronicshub.org/pid-controller-working-and-tuning-methods/," [Online]. [Accessed


18 July 2021].

[2] "https://www.electrical4u.com/types-of-controllers-proportional-integral-derivative-controllers/,"
[Online]. [Accessed 11 June 2021].

25

You might also like