You are on page 1of 15

International Islamic University Islamabad

Faculty of Engineering & Technology


Department of Electrical Engineering

CONTROL SYSTEMS LAB

Experiment No. 4: Time Response analysis of First and Second order systems

using MATLAB

Name of Student: ……………………………………

Registration No.: ……………………………………..

Date of Experiment: …………………………………

Submitted To: ………………………………………...

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 1
Objectives:
 The objective of this exercise is to study and analyze the performance characteristics
of first and second order systems using MATLAB.
Equipment Required:
 Personal Computer (PC)
 MATLAB software (updated)
Theory:
The time response represents how the state of a dynamic system changes in time when
subjected to a particular input. MATLAB provides many useful resources for calculating
time responses for many types of inputs, as we shall see in today’s lab session. The time
response of a linear dynamic system consists of the sum of the transient response, which
depends on the initial conditions, and the steady-state response, which depends on the
system input. These correspond to the homogenous (free or zero input) and the particular
solutions of the governing differential equations, respectively.
Part 1: Analysis of first order systems
First order systems are the simplest dynamic systems to analyze. Some common
examples include mass-damper systems and RC circuits. The general form of a first order
transfer function (G(s)) is:
𝒃 𝒌𝒅𝒄
𝑮(𝒔) = = (4.1)
𝒔+𝒂 𝝉𝒔+𝟏
where the parameters 𝒌𝒅𝒄 and 𝝉 completely define the characteristics of the first order
system.
DC Gain (𝒌𝒅𝒄):
The DC gain (𝑘𝑑𝑐 ) is the ratio of the magnitude of the steady-state step response to
the magnitude of the step input. For stable transfer functions, the final value theorem
demonstrates that the DC gain is the value of the transfer function evaluated at s = 0. For
𝑏
first order systems as defined above, the DC gain is 𝑘𝑑𝑐 =
𝑎
Time Constant (𝝉):
1
The time constant of a first order system is 𝜏 = , which is equal to the time it takes
𝑎
for the system’s response to reach 63% of its steady-state value for a step input (with zero
initial conditions).

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 2
Poles/Zeros:
First order systems have a single real pole, in this case at s = -a. Therefore, the system
is stable if a is positive and unstable if a is negative. The standard first order systems have
no zeros.
Step Response of First order system:
We can obtain the system’s time response to a step input using the following
MATLAB commands:
kdc = 5;
Tc = 10;
s = tf('s');
G = kdc/(Tc*s+1)
step(G)
grid on
legend('Step Response of First Order System')

Figure 4.1
If you right-click on the step response graph and select “characteristics”, you can
observe different parameters associated with the step response like rise time, settling time,
steady state and peak response.
Performance Parameters of First order system:
Let us define transient response specifications, such as rise time (tr) and settling time
(ts). Remember that no overshoots and oscillations can be seen in the time response of first
order systems.

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 3
i. Rise Time (tr):
Rise time (tr) is defined as the time for the output response to rise from 10% to 90%
of its final value. Rise time (tr) can be obtained as:
2.2
𝑡𝑟 = (4.2)
𝑎
ii. Settling Time (ts):
The settling time (ts) is the time required for the system output to fall within a certain
percentage (i.e. 2%) of the steady-state value for a step input. The settling times of a
first order system for the most common tolerances are provided in Table 4.1. Note
that the tighter the tolerance, the longer the system response takes to settle within the
band, as expected.
Table 4.1
Tolerance 1% (0.01) 2% (0.02) 5% (0.05) 10% (0.1)

Settling 4.6 3.9 3 2.3


𝑡𝑠 = = 4.6𝜏 𝑡𝑠 = = 3.9𝜏 𝑡𝑠 = = 3𝜏 𝑡𝑠 = = 2.3𝜏
Time 𝑎 𝑎 𝑎 𝑎

Example of First order system (RC Network):


An electrical RC circuit is the simplest example of a first order system. It comprises
of a resistor and capacitor connected in series to a voltage supply as shown in Figure 4.2.

Figure 4.2: RC Circuit


If the capacitor is initially uncharged, as the circuit is switched ON, capacitor starts to
charge due to the current “i” through the resistor until the voltage across it reaches the
supply voltage (E). As soon as this happens, the current stops flowing or decays to zero,
and the circuit becomes like an open circuit. However, if the supply voltage is removed,
and the circuit is closed, the capacitor will be discharged through the resistor. The time
required to charge the capacitor depends upon the time constant (𝜏) of the system, which is
defined as the time taken by the capacitive voltage to rise up to 63% of the supply voltage.
For a RC circuit, the time constant is, 𝜏 = RC. Note that the voltage across the capacitor

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 4
will never increase indefinitely. In this respect, we will say that the system is passive and
because of this property, it is stable. For the RC circuit of Figure 4.2, the equation
governing its behavior can be written using KVL:
𝑉𝑅 (𝑡) + 𝑉𝑐 (𝑡) = 𝐸(𝑡) (4.3)
𝑖(𝑡). 𝑅 + 𝑉𝑐 (𝑡) = 𝐸(𝑡) (4.4)

𝑑𝑉𝑐 (𝑡)
𝑅𝐶 + 𝑉𝑐 (𝑡) = 𝐸(𝑡) (4.5)
𝑑𝑡
𝑑𝑉𝑐 (𝑡) 𝑣𝑐 (𝑡) 𝐸(𝑡)
+ = (4.6)
𝑑𝑡 𝑅𝐶 𝑅𝐶
Eq. (4.6) can be expressed in terms of time constant as:
𝑑𝑉𝑐 (𝑡) 𝑉𝑐 (𝑡) 𝐸(𝑡)
+ = where, 𝑉𝑐 (0) = 𝑉𝑜 (4.7)
𝑑𝑡 τ τ
where 𝑉𝑐 (𝑡) is the voltage across the capacitor, R is the resistance, C is the capacitance and
τ = RC is the time constant of the system.
Finally, the transfer function of the RC network can be written as:
𝑉𝑐 (𝑠) 1
= (4.8)
𝐸(𝑠) τ𝑠+1
Response Analysis of a RC Network using MATLAB:
a. Write a MATLAB code to obtain the unit step response of the first order system (RC
network of Figure 4.2) such that R = 2-kΩ and C = 0.01-F.
b. Write a MATLAB code to find the rise time (tr) and settling time (ts) of the given first
order system.
Given: τ = RC = 20s, a = 1/ τ = 0.05.
clc;
close all;
clear all
% To obtain the unit step response of the first order system
a = 0.05
num = [1];
den = [20 1];
sys = tf(num,den)
step (sys)
grid on
% To find the rise time and settling time
Rise_Time = 2.2/a
Settling_Time = 3.9/a

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 5
Figure 4.3
Part 2: Analysis of second order systems
Second order systems are commonly encountered in practice, and are the simplest
type of dynamic system to exhibit oscillations. Examples include mass-spring-damper
systems and RLC circuits. Second order systems have only two poles. Many true higher-
order systems may be approximated as second order in order to facilitate the analysis. The
generalized equation for second order system can be written as:
𝑌(𝑠) 2
𝜔𝑛
= 2 (4.9)
𝑅(𝑠) 𝑠 2 +2𝜁𝜔𝑛 𝑠+ 𝜔𝑛

where Y(s) is the output of the system, R(s) is the input to the system, 𝜔𝑛 is the natural
frequency, 𝜁 is the damping ratio (0 < 𝜁 < 1).
Natural Frequency (𝛚𝐧 ):
The natural frequency (ωn ) of a second order system is the frequency of oscillation of
the system without damping (ζ = 0). For example, the frequency of oscillation of a series
RLC circuit with the shorted resistance would be the natural frequency.
Damping Ratio (𝛇):
The damping ratio (ζ) is a dimensionless quantity characterizing the rate at which an
oscillation in the system's response decays due to effects such as viscous friction or
electrical resistance. The transient response of the system changes for different values of
damping ratio (𝜻).
Performance Parameters of Second order system:
The transient response of a practical control system often exhibits damped oscillations
before reaching steady state. In specifying the transient-response characteristics of a
control system to a unit-step input, it is common to specify some performance parameters

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 6
including rise time, peak time, % overshoot and settling time. These parameters are
graphically shown in Figure 4.4.

Figure 4.4: Unit step response curve for second order system
i. Rise Time (tr):
Rise time (tr) is the time required for the response to rise from 10% to 90% of its
final value. A precise analytical relationship between rise time and damping ratio (𝜁 )
cannot be found.
ii. Peak Time (tp):
Peak time (tp) is the time required to reach the first, or maximum peak. The peak
time (tp) can be calculated as:
𝜋
𝑡𝑝 = (4.10)
𝜔𝑛 √1−𝜁 2

iii. % Overshoot (%Mp):


The percent overshoot (% Mp) is the percent by which a system’s step response
exceeds its final steady-state value. For a second order underdamped system, the
percent overshoot is directly related to the damping ratio as presented in Eq. (4.11).
𝜁𝜋
(− )
√1−𝜁2
% 𝑜𝑣𝑒𝑟𝑠ℎ𝑜𝑜𝑡 (𝑀𝑝 ) = 𝑒 ∗ 100 % (4.11)
Similarly, from the response curve, % overshoot can be obtained as:
𝐶𝑚𝑎𝑥 − 𝐶𝑓𝑖𝑛𝑎𝑙
% 𝑜𝑣𝑒𝑟𝑠ℎ𝑜𝑜𝑡 = ∗ 100 % (4.12)
𝐶𝑓𝑖𝑛𝑎𝑙

where Cmax is the peak value of the time response and Cfinal is the final value of the
response.

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 7
iv. Settling Time (ts):
The settling time (ts), is the time required for the system output to fall within a
certain percentage of the steady-state value for a step input. For a canonical second
order, underdamped system, the settling time can be approximated by the following
equation:
− ln (𝑡𝑜𝑙𝑒𝑟𝑎𝑛𝑐𝑒)
𝑡𝑠 = (4.13)
𝜁𝜔𝑛
The approximated settling times for the most common tolerances are presented in Table
4.2.
Table 4.2
Tolerance 1% (0.01) 2% (0.02) 5% (0.05) 10% (0.1)

Settling 4.6 3.912 3 2.3


𝑡𝑠 = 𝑡𝑠 = 𝑡𝑠 = 𝑡𝑠 =
Time 𝜁𝜔𝑛 𝜁𝜔𝑛 𝜁𝜔𝑛 𝜁𝜔𝑛

Example of Second order system:


a. Write a MATLAB code to obtain the step response of second order system given in
Eq. (4.9).
b. Also, find the rise time (tr), peak time (tp), settling time (ts) and % overshoot (Mp) of
the given system, with ωn = 7 and 𝜁 = 0.4.
Solution:
clc
clear all
close all
% To obtain the unit step response of the second order system
wn = 7;
zeta = 0.4;
num = [wn^2];
den = [1 2*zeta*wn wn^2];
sys = tf(num,den);
step(sys)
grid on
% To find the rise time, peak time settling time and %overshoot
StepData = stepinfo(sys,'RiseTimeLimits',[0.1,0.9])

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 8
Figure 4.5: Step Response of Second Order system
Types of second order systems:
Depending upon the damping ratio (𝜁), there are four types of second order systems.
a. Underdamped systems
b. Overdamped systems
c. Critically Damped systems
d. Undamped systems
i. Underdamped systems:
If 𝜁 < 1, then the system is said to be underdamped. In this case, both poles are
complex-valued with negative real parts (p1,2 = − 𝜁𝜔𝑛 ± 𝑗 𝜔𝑛 √1 − 𝜁 2 ); therefore, the
system is stable but oscillates while approaching the steady-state value. Specifically, the
natural response oscillates with the damped natural frequency, 𝜔𝑑 = 𝜔𝑛 √1 − 𝜁 2 (in
rad/sec). The poles, zeros and step response of an underdamped system can be obtained
as:
clc;
clear all;
close all
wn = 10;
zeta = 0.2;
num = [wn^2];
den = [1 2*zeta*wn wn^2];
sys = tf(num,den);
[p z] = pzmap(sys)
step(sys)
grid on
axis([0 3 0 2])
legend('Step Response of Second Order Underdamped System')

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 9
Figure 4.6: Step Response of Second Order Underdamped system

Effect of Damping Ratio (ζ):


clc;
clear all;
close all
wn = 5;
zeta1 = 0.1;
zeta2 = 0.4;
zeta3 = 0.7;
s = tf('s');
sys1 = wn^2/(s^2 + 2*zeta1*wn*s + wn^2) %for zeta = 0.1, wn = 5
sys2 = wn^2/(s^2 + 2*zeta2*wn*s + wn^2) %for zeta = 0.4, wn = 5
sys3 = wn^2/(s^2 + 2*zeta3*wn*s + wn^2) %for zeta = 0.7, wn = 5
step(sys1,sys2,sys3)
axis([0 8 0 2])
grid on
title('Step Responses of Second Order Underdamped for different
values of zeta')
legend('Step Response when zeta = 0.1','Step Response wihen zeta =
0.4','Step Response when zeta = 0.7')

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 10
Figure 4.7

ii. Overdamped systems:


If 𝜁 >1, then the system is overdamped, both poles are real and negative; therefore, the
system is stable and does not oscillate. The poles, zeros and step response of an
overdamped system can be obtained as:
clc;
clear all;
close all
wn = 10;
zeta = 1.4;
num = [wn^2];
den = [1 2*zeta*wn wn^2];
sys = tf(num,den);
[p z] = pzmap(sys)
step(sys)
grid on
axis([0 2 0 1.5])
legend('Step Response of Second Order Overdamped System')

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 11
Figure 4.8: Step Response of Second Order Overdamped system

iii. Critically Damped systems:


If 𝜁 = 1, then the system is critically damped, both poles are real and have the same
magnitude, p1,2 = − 𝜁𝜔𝑛 . For a canonical second order system, the quickest settling time
is achieved when the system is critically damped. The poles, zeros and step response of a
critically damped system can be obtained as:

clc;
clear all;
close all
wn = 10;
zeta = 1;
num = [wn^2];
den = [1 2*zeta*wn wn^2];
sys = tf(num,den);
[p z] = pzmap(sys)
step(sys)
grid on
axis([0 2 0 1.5])
legend('Step Response of Second Order Critically Damped System')

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 12
Figure 4.9: Step Response of Second Order Critically Damped system

iv. Undamped systems:


If 𝜁 = 0, then the system is undamped, both poles are purely imaginary; therefore, the
system is marginally stable and the step response oscillates indefinitely. The poles, zeros
and step response of an undamped system can be obtained as:
clc;
clear all;
close all
wn = 10;
zeta = 0;
num = [wn^2];
den = [1 2*zeta*wn wn^2];
sys = tf(num,den);
[p z] = pzmap(sys)
step(sys)
grid on
axis([0 3 0 2.5])
legend('Step Response of Second Order Undamped System')

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 13
Figure 4.10: Step Response of Second Order Undamped system
Stability Measures:
The transfer function representation is very useful for analyzing system stability. If all
poles of the transfer function (values of s for which the denominator equals zero) have
negative real parts, then the system is stable. If any pole has a positive real part, then the
system is unstable. If the poles lie on the complex s-plane, then all poles must be in the
left-half plane (LHP) to ensure stability. If any pair of poles is on the imaginary axis, then
the system is marginally stable and the system will tend to oscillate. A system with purely
imaginary poles is not considered BIBO stable. For such a system, there exist finite inputs
which lead to an unbounded response.
Reading Assignment:
% This is a MATLAB program to find the rise time, peak time
% maximum overshoot, and settling time of the second-order system
% and higher-order system
% ------- In this example, we assume zeta = 0.6 and wn = 5 -------
>> num = [25];
>> den = [1 6 25];
>> sys = tf(num,den)
>> t = 0:0.005:5;
>> step(sys,t)
>> [y,x,t] = step(num,den,t);
>> r1 = 1; while y(r1) < 0.1, r1 = r1+1; end;
>> r2 = 1; while y(r2) < 0.9, r2 = r2+1; end;
>> rise_time = (r2-r1)*0.005 % Rise Time (10% to 90%)
>> [ymax,tp] = max(y);
>> peak_time = (tp - 1)*0.005 % Peak Time
>> max_overshoot = ymax-1 %Maximum Overshoot
>> s = 1001; while y(s) > 0.98 & y(s) < 1.02; s = s - 1; end;
>> settling_time = (s - 1)*0.005 % Settling Time (2%)

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 14
Exercise Problems
Question No. 1: A first system has a transfer function G(s) as,
50
G(s) =
𝑠 + 50
a. Write a MATLAB code to obtain the unit step response of the system.
b. Write a MATLAB code to find the rise time (tr) and settling time (ts) of the given first
order system.

Question No. 2: A generalized second order system has a transfer function H(s) as,
𝝎𝟐𝒏
𝑯(𝒔) =
𝒔𝟐 + 𝟐𝜻𝝎𝒏 𝒔 + 𝝎𝟐𝒏
a. Use built-in MATLAB command (stepinfo) to find the rise time (tr), peak time (tp),
settling time (tp) and % overshoot (Mp) for ωn = 3 with 𝜁 = 0.2, 0.5, 0.8, 1 and 1.5
respectively. Fill the Table 4.3.
The goal is to find the effect of damping ratio (𝜁) on performance parameters of the system.
Table 4.3
Rise time Settling time Peak Time
Sr. % Overshoot
ωn 𝜁 (t r ) (t s ) (tp)
No. (% Mp)
(sec) (sec) (sec)
1 3 0.2
2 3 0.5
3 3 0.8
4 3 1.0
5 3 1.5

b. Plot all the unit step responses on the same figure window with particular legend.

Experiment No. 4: Time Response analysis of First and Second order systems using
MATLAB Page 15

You might also like