EEE3001 Software Manual
EEE3001 Software Manual
EXPT. NO:
DATE:
AIM:
To reduce the given Block diagram to transfer function model using M-file Editor in MATLAB.
APPARATUS REQUIRED:
THEORY:
It is a representation of the control system giving the inter-relation between the transfer function
of various components. The block diagram is obtained after obtaining the differential equation & Transfer
function of all components of a control system. The arrow head pointing towards the block indicates the
i/p & pointing away from the block indicates the o/p. After obtaining the block diagram for each & every
component, all blocks are combined to obtain a complete representation. It is then reduced to a simple
form with the help of block diagram algebra.
S 1 S 1
G(s) = Gc(s) =
R(s) 500 S 2 S 2 Y(s)
s^2 + 2 s + 1
------------------
500 s^3 + 1000 s^2
Blocks connected in parallel
A simple open – loop control system can be obtained by interconnecting a plant and a controller
in parallel.
1
G(s) =
S 2
+
R(s) + Y(s)
S 3
Gc(s) =
S 10
The transfer function in this case is Gc(s)+G(s).Let the process represented by the transfer
1
function G(s) be G(s) = .and let the controller represented by the transfer function Gc(s) be
S 2
S 3
Gc(s) = . Compute the combined transfer function of the blocks.
S 10
»num1 = 1;
»den1 =[1 2];
»num2 =[1 3];
»den2 =[1 10];
» [nump, denp] = parallel(num1, den1, num2, den2);
»printsys(nump, denp);
num/den =
s^2 + 6s +16
s^2 + 12s + 20
Feedback function
This function reduces the process of computing the closed loop transfer function for single or
multiple loops.
R(s) Ys)
G(s)
H(s)
Single loop
Example :1
R(s) S 1 Y(s)
G(s) =
500 S 2
S 1
H(s) =
S 2
Transfer function
s^2 + 3 s + 2
----------------------------
500 s^3 + 1001 s^2 + 2 s + 1
PROCEDURE:
For reducing very complex systems, blkbuild and connect commands are used as
illustrated below;
BLKBUILD Builds a block-diagonal state-space structure from a block diagram of
transfer functions and state models. This is a SCRIPT FILE.
Each block is numbered as shown. In the first seven lines of the program, the above
blocks are completely defined. The numbers of blocks are then defined n blocks. The command
blkbuild uses the variable nblocks to begin building the system. It converts all the transfer
functions to state space models and assembles them into one large block state space model called
a, b, c, d.
The next step is to create the matrix q that describes the interconnections of various
blocks. Each row corresponds to a block and the first element in the row is the block number and
the remaining elements indicate the blocks whose outputs are connected to the input of the
current block.
After defining q, the block 1 that receives the system input and block 4 that produces the system
output are defined by the variables „input‟ and „output‟. The connect command makes the
connections and reduces the system into a single state space model which is then converted back
into transfer function.
INPUTS:
n is the number of blocks in the diagram.
ni and di are the numerator and denominator polynomials for the ith block if it is a
transfer function.
ai,bi,ci,di are the state matrices for the ith block if it is a state model.
OUTPUTS:
a,b,c,d is the resulting state space structure. The matrices are built up by progressive
APPENDs of the state
PROBLEM (i)
R(S) +
+ C(S)
G1(S) + G3 (S) + G4(S)
G2(S)
1 - 22 - 3 3 - 44
H2(S) H3(S)
66 7
H1(S)
System Response:
State model [a,b,c,d] of the block diagrams has 7 inputs and 7 outputs
num/den =
1s + 3 _____ .
s^3 + 26 s^2 + 179s + 210
Inference:
Result:
The Block diagram to transfer function reduction of the given model has been done using
MATLAB.
Exp No:
Date:
APPARATUS REQUIRED:
THEORY:
It is a representation of the control system giving the inter-relation between the transfer function
of various components. The block diagram is obtained after obtaining the differential equation & Transfer
function of all components of a control system. The arrow head pointing towards the block indicates the
i/p & pointing away from the block indicates the o/p. After obtaining the block diagram for each & every
component, all blocks are combined to obtain a complete representation. It is then reduced to a simple
form with the help of block diagram algebra.
Procedure:
i) Write the differential equation of Armature controlled DC Motor
ii) Derive the Transfer Function
iii) Draw the block diagram of Armature controlled DC Motor
iv) Model the block diagram in Simulink
v) Apply input and very the output
(Finish the first 3 steps as pre-lab work before coming to the Lab))
Exp No : STABILITY ANALYSIS OF LINEAR SYSTEMS
Date :
AIM:
To obtain the various plots and check for stability of the system with open loop transfer function,
APPARATUS REQUIRED:
THEORY:
A Linear Time-Invariant Systems is stable if the following two notions of system stability are
satisfied
When the system is excited by Bounded input, the output is also a Bounded
output.
In the absence of the input, the output tends towards zero, irrespective of the
initial conditions.
o If all the roots of the characteristic equation have negative real parts, then the
impulse response is bounded and eventually decreases to zero, then system is
stable.
o If any root of the characteristic equation has a positive real part, then system is
unstable.
o If the characteristic equation has repeated roots on the jω-axis, then system is
unstable.
o If one are more non-repeated roots of the characteristic equation on the jω-axis,
then system is unstable.
Rule 1 A system is stable if the phase lag is less than 180˚ at the frequency for
which the gain is unity (one).
Rule 2 A system is stable if the gain is less than one (unity) at the frequency for
which the phase lag is 180˚.
The application of these rules to an actual process requires evaluation of the gain and phase shift
of the system for all frequencies to see if rules 1 and 2 are satisfied. This is obtained by plotting
the gain and phase versus frequency. This plot is called BODE PLOT. The gain obtained here is
open loop gain. The exact terminology is in terms of a Gain Margin and Phase Margin from
the limiting values quoted.
If the phase lag is less than 140˚ at the unity gain frequency, the system is stable.
This then, is a 40˚ Phase Margin from the limiting values of 180˚.
If the gain is 5dB below unity (or a gain of about 0.56) when the phase lag is
180˚, the system is stable. This is 5dB Gain Margin.
PROCEDURE:
Step 1: Write a program to obtain the Bode plot for the given system.
Step 2: Access the stability of given system using the plot obtained.
PROGRAM
RESULT:
The Bode plot is drawn for the given transfer function using MATLAB and verified manually.
From the plot obtained, the system is found to be ______________.
AIM:
To obtain the Root locus plot and to verify the stability of the system with transfer function,
G(s) =
APPARATUS REQUIRED:
THEORY:
The characteristic of the transient response of a closed-loop system is related to the location of
the closed loop poles. If the system has a variable loop gain, then the location of the closed-loop
poles depend on the value of the loop gain chosen. A simple technique known as “Root Locus
Technique” used for studying linear control systems in the investigation of the trajectories of the
roots of the characteristic equation.
This technique provides a graphical method of plotting the locus of the roots in the s-plane as a
given system parameter is varied over the complete range of values (may be from zero to
infinity). The roots corresponding to a particular value of the system parameter can then be
located on the locus or the value of the parameter for a desired root location can be determined
form the locus. The root locus is a powerful technique as it brings into focus the complete
dynamic response of the system. The root locus also provides a measure of sensitivity of roots to
the variation in the parameter being considered. This technique is applicable to both single as
well as multiple-loop systems.
PROCEDURE:
1. Write a program to obtain the root locus plot for the given system.
2. Access the stability of given system using the plot obtained.
PROGRAM:
MANUAL CALCULATIONS:
The Root locus plot is drawn for the given transfer function, G(s)= ___________________
using MATLAB and the range of gain K for stability is______________.
AIM:
To obtain the Nyquist plot and check the stability of the system using Nyquist Stability Criterion
for the given unity feedback system with transfer function
G(s)H(s) =
APPARATUS REQUIRED
THEORY:
From equation (1), it is seen that G(jω) may be represented as a phasor of magnitude M and
phase angle Φ. As the input frequency varies from 0 to ∞, the magnitude M and phase angle Φ
changes and hence the tip of the phasor G(jω) traces a locus in the complex plane. The locus
thus obtained is known as POLAR PLOT. The major advantage of the polar plot lies in
stability study of systems. Nyquist related the stability of a system to the form of these plots.
Polar plots are referred as NYQUIST PLOTS.
PROCEDURE:
1. Write a program to obtain the Nyquist plot for the given system.
2. Access the stability of given system using the plot obtained.
PROGRAM
%NYQUIST PLOT
%Enter the numerator and denominator of the transfer function
num=[ ]
den=[ ]
sys=tf(num,den)
MANUAL CALCULATIONS:
RESULT:
The Nyquist plot is drawn for the given transfer function, G(s) = ______________________
using MATLAB and the system is found to be ______________________.
Exp No : TIME RESPONSE OF LINEAR SYSTEMS
Date :
AIM:
To obtain the various plots and study the response of the given system with various input given.
APPARATUS REQUIRED:
THEORY:
The order of a system is defined as being the highest power of derivative in the differential
equation, or being the highest power of s in the denominator of the transfer function. A first-
order system only has s to the power one in the denominator, while a second-order system has
the highest power of s in the denominator being two.
Types of the input functions (or test input signals) commonly used are:
• Impulse function:
• Step function: In the time domain, u(t) = c. In the s domain, U(s) = c/s.
• Ramp function: In the time domain, u(t) = ct. In the s domain, U(s) = c/s2
Sinusoidal function
where c is a constant in all the above.
With these test signals, mathematical and experimental analyses of control systems can be
carried out easily since the signals are very simple functions of time.
This of these typical signals to use for analyzing system characteristics may be determined by the
form of the input that the system will be subjected to most frequently under normal operation. If
the inputs to a control system are gradually changing functions of time, then a ramp function of
time may be a good test signal. Similarly, if a system is subjected to sudden disturbances, a step
function of time may be a good test signal, and for a system subjected to a shock input, a pulse or
an impulse function may be best.
PROCEDURE:
1. Write a program to obtain the various plot for the given system.
2. From the given system find the values for rise , peak ,settling times and % overshoot .
%Compute step response for a second-order system for a different Zeta values
t=[0:0.1:10];num=[1];
zeta1=0.1;den1=[1 2*zeta1 1]; sys1=tf(num,den1);
zeta2=0.25; den2=[1 2*zeta2 1 ]; sys2=tf(num,den2);
zeta3=0.5; den3=[1 2*zeta3 1]; sys3=tf(num,den3);
zeta4=1.0; den4=[1 2*zeta4 1]; sys4=tf(num,den4);
[y1 ,T1]=step(sys1 ,t);
[y2,T2]=step(sys2,t);
[y3,T3]=step(sys3,t);
[y4,T4]=step(sys4,t);
plot(t,y1 ,t,y2,t,y3,t,y4)
xlabel(' \omega _nt');
ylabel('y(t)/omega_n');
title('\zeta = 0.1, 0.25, 0.5, 1.0');
grid
n1=[1 5]
d1=[5 1 4 3]
g=tf(n1,d1);
t = 0: 0.005 :5;
r = 2 - 2*t+ t.^2;
c =lsim(n1,d1,r,t);%compute response using lsim function
plot(t,r,'*k',t,c,'-k');
grid;
xlabel('time,t in sec');
ylabel('Input,r(t) and Output,c(t)');
text(0.25,2.65,'r(t)')
text(0.25,0.6,'c(t)')
%computing the Time domain specifications
num = [6.3223 18 12.811];
den = [1 6 11.3223 18 12.811];
t = 0:0.02:20;
[y,x,t] = step(num,den,t);
plot(t,y)
grid
title('Unit-Step Response')
xlabel('t (sec)')
ylabel('Output y(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.02
[ymax,tp] = max(y);
peak_time = (tp-1)*0.02
max_overshoot = ymax-1
s = 1001; while y(s) > 0.98 & y(s) < 1.02; s = s-1; end;
settling_time = (s-1)*0.02
RESULT:
Expt. No. Date:
AIM:
APPARATUS REQUIRED:
THEORY:
The time response characteristics of control systems are specified in terms of time
domain specifications. Systems with energy storage elements cannot respond instantaneously
and will exhibit transient responses, whenever they are subjected to inputs or disturbances.
The desired performance characteristics of a system of any order may be specified in
terms of transient response to a unit step input signal. The transient response characteristics of a
control system to a unit step input is specified in terms of the following time domain
specifications
Delay time td
Rise time tr
Peak time tp
Maximum peak overshoot Mp
Settling time ts
The name MATLAB stands for MATRIX LABORATORY. MATLAB was originally written
to provide easy access to matrix software developed by the LINPACK and EISPACK projects.
Today, MATLAB engines incorporate the LAPACK and BLAS libraries, embedding the state of
the art in software for matrix computation. It has evolved over a period of years with input from
many users. In university environments, it is the standard instructional tool for introductory and
advanced courses in MATHEMATICS, ENGINEERING, AND SCIENCE. In industry,
MATLAB is the tool of choice for high-productivity research, development, and analysis.
It is an interactive system whose basic data element is an array that does not require
dimensioning. This allows you to solve many technical computing problems, especially those
with matrix and vector formulations, in a fraction of the time it would take to write a program in
a scalar non-interactive language such as C or Fortran. It also features a family of add-on
application-specific solutions called toolboxes. Very important to most users of MATLAB,
toolboxes allow you to learn and apply specialized technology. Toolboxes are comprehensive
collections of MATLAB functions (M-files) that extend the MATLAB environment to solve
particular classes of problems. Areas in which toolboxes are available include SIGNAL
PROCESSING, CONTROL SYSTEMS, NEURAL NETWORKS, FUZZY LOGIC,
WAVELETS, SIMULATION, AND MANY OTHERS.
PROCEDURE:
BLOCK DIAGRAM:
2. MATLAB (m-file) program to obtain the step response and impulse response
num=[ ];
den=[ ];
sys = tf (num,den);
step (sys);
grid
num=[ ];
den=[ ];
sys = tf (num,den);
impulse (sys);
grid
CALCULATIONS:
RESULT:
The time response characteristics of a first order system is simulated digitally and verified
manually.
AIM:
To digitally simulate the time response characteristics of a second order system and verify
manually.
APPARATUS REQUIRED
The time characteristics of control systems are specified in terms of time domain specifications.
Systems with energy storage elements cannot respond instantaneously and will exhibit transient
responses, whenever they are subjected to inputs or disturbances. The desired performance
characteristics of a system of any order may be specified in terms of transient response to a unit
step input signal. The transient response characteristics of a control system to a unit step input is
specified in terms of the following time domain specifications:
Delay time td
Rise time tr
Peak time tp
Maximum overshoot Mp
Settling time ts
PROCEDURE:
BLOCK DIAGRAM:
2. MATLAB program to obtain the step response and impulse response of second order
system.
num=[ ];
den=[ ];
sys = tf (num,den);
impulse (sys);
CALCULATIONS:
RESULT:
The time response characteristics of the given second order system is simulated digitally and
verified manually.
Exp No Date:
Implementation of PID Controller
Objective: Study the three term (PID) controller and its effects on the feedback loop response.
Investigate the characteristics of the each of proportional (P), the integral (I), and the derivative (D)
controls, and how to use them to obtain a desired response.
APPARATUS REQUIRED
Theory :
R e u
Plant
Controller
+ - Y
Controller: Provides excitation for the plant; Designed to control the overall system behavior.
The three-term controller: The transfer function of the PID controller looks like the following:
KI
Gc (s) K P KDs
s (1)
The transfer function of a PID controller is found by taking the Laplace transform of Eq.(1).
(2)
We can define a PID controller in MATLAB using the transfer function directly, for example:
Kp = 1;
Ki = 1;
Kd = 1;
s = tf('s');
C = Kp + Ki/s + Kd*s
C =
s^2 + s + 1
-----------
s
C = pid(Kp,Ki,Kd)
C =
1
Kp + Ki * --- + Kd * s
s
with Kp = 1, Ki = 1, Kd = 1
convert the PID object to a transfer function to see that it yields the same result as above:
tf(C)
ans =
s^2 + s + 1
-----------
s
This signal (u) will be sent to the plant, and the new output (Y) will be obtained. This new output (Y)
will be sent back to the sensor again to find the new error signal (e). The controller takes this new
error signal and computes its derivatives and its internal again. The process goes on and on.
A proportional controller ( ) will have the effect of reducing the rise time and will reduce but
never eliminate the steady-state error. An integral control ( ) will have the effect of
eliminating the steady-state error for a constant or step input, but it may make the transient
response slower. A derivative control ( ) will have the effect of increasing the stability of the
system, reducing the overshoot, and improving the transient response.
Note that these correlations may not be exactly accurate, because , , and are dependent
on each other. In fact, changing one of these variables can change the effect of the other two. For
this reason, the table should only be used as a reference when you are determining the values for
, and .
Example Problem:
(3)
(4)
The transfer function between the displacement and the input then becomes
(5)
Let
M = 1 kg
b = 10 N s/m
k = 20 N/m
F=1N
(6)
Do the open-loop step response. Create a new m-file and run the following code:
s = tf('s');
P = 1/(s^2 + 10*s + 20);
step(P)
The DC gain of the plant transfer function is 1/20, so 0.05 is the final value of the output to an
unit step input. This corresponds to the steady-state error of 0.95, quite large indeed.
Furthermore, the rise time is about one second, and the settling time is about 1.5 seconds. Then
now design a controller that will reduce the rise time, reduce the settling time, and eliminate the
steady-state error.
Proportional Control
From the table shown above, we see that the proportional controller (Kp) reduces the rise time,
increases the overshoot, and reduces the steady-state error.
The closed-loop transfer function of the above system with a proportional controller is:
(7)
Let the proportional gain ( ) equal 300 and change the m-file to the following:
Kp = 300;
C = pid(Kp)
T = feedback(C*P,1)
t = 0:0.01:2;
step(T,t)
C=
Kp = 300
P-only controller.
T=
300
----------------
s^2 + 10 s + 320
Proportional-Derivative Control
Now, let's take a look at a PD control. From the table shown above, we see that the derivative
controller (Kd) reduces both the overshoot and the settling time. The closed-loop transfer
function of the given system with a PD controller is:
(8)
Let equal 300 as before and let equal 10. Enter the following commands into an m-file and
run it in the MATLAB command window.
Kp = 300;
Kd = 10;
C = pid(Kp,0,Kd)
T = feedback(C*P,1)
t = 0:0.01:2;
step(T,t)
C=
Kp + Kd * s
with Kp = 300, Kd = 10
T=
10 s + 300
----------------
s^2 + 20 s + 320
This plot shows that the derivative controller reduced both the overshoot and the settling time,
and had a small effect on the rise time and the steady-state error.
Proportional-Integral Control
Before going into a PID control, let's take a look at a PI control. From the table, we see that an
integral controller (Ki) decreases the rise time, increases both the overshoot and the settling time,
and eliminates the steady-state error. For the given system, the closed-loop transfer function with
a PI control is:
(9)
Let's reduce the to 30, and let equal 70. Create a new m-file and enter the following
commands.
Kp = 30;
Ki = 70;
C = pid(Kp,Ki)
T = feedback(C*P,1)
t = 0:0.01:2;
step(T,t)
C=
1
Kp + Ki * ---
s
with Kp = 30, Ki = 70
T=
30 s + 70
------------------------
s^3 + 10 s^2 + 50 s + 70
Proportional-Integral-Derivative Control
Now, let's take a look at a PID controller. The closed-loop transfer function of the given system
with a PID controller is:
(10)
After several trial and error runs, the gains = 350, = 300, and = 50 provided the desired
response. To confirm, enter the following commands to an m-file and run it in the command
window. You should get the following step response.
Kp = 350;
Ki = 300;
Kd = 50;
C = pid(Kp,Ki,Kd)
T = feedback(C*P,1);
t = 0:0.01:2;
step(T,t)
C=
1
Kp + Ki * --- + Kd * s
s
Now, we have obtained a closed-loop system with no overshoot, fast rise time, and no steady-
state error.
When you are designing a PID controller for a given system, follow the steps shown below to
obtain a desired response.