Professional Documents
Culture Documents
Computer Techniques Engineering Department: Dijlah University College
Computer Techniques Engineering Department: Dijlah University College
College
DUC
Computer
Techniques
Engineering
Department
List of contents
Experiment
Experiment page
No.
1 The Transfer Function 2
Open-Loop & Closed-Loop Control System
2 5
3 Block Reduction 7
4 The Routh-Hurwitz Stability Criterion 11
Root Locus
5 17
Design by Means of Root Locus Plots.
6 21
Frequency – Domain Plots
7 23
Design of Lead and Lag Compensation by using
8 Bode Diagram 25
2
Control Lab.
Object:
How to deal with a transfer function and using its coefficients (num , den) in a
matlab program.
Theory:
Procedure:
18( s 20)
A) a transfer function such as G ( s) the numerator of it is
( s 15)(s 25)
=18(S+20),so we enter in it in a matlab program as num=18*[1 20] , where
(1) is a coefficient of the S and 20 is a coefficient of S^0 thus the
arrangement of coefficient is as follow:
3
Control Lab.
Example :
If G(S)= 18(S+20)
(S+15)(S+25)(S+0.4)
num=18*[1 20];
d1=[1 15];
d2=[1 25];
d3=[1 0.4];
d12=conv(d1,d2);
den=conv ( d12,d3);
sys=tf(num,den)
B)if we want to find a T.F. of a 2nd order control system by knowing its natural
frequency Wn & damping ratio ζ by a matlab program this could be known as
follows:
4
Control Lab.
Program:
wn=2; damping=0.707;
[num , den]=ord2(wn , damping);
Sys=tf(num , den)
cases
s ( s 5)
1 G ( s)
( s 2 s 6)(s 0.1)
2
18s 2
2 G(s)
( s 2 3)(s 2)
01s 6
3 G ( s)
( s 0.1)(0.2 s 3)
4 n 3; damping 0.51
5 n 2.5; damping 0.45
Discussion
1) Write aprogram in matlab
15s (0.1s 2s 5)
2
1 G(s)
(0.3s 2 1)(s 6)
s 2 ( s 0.1)
2 G(s) 2
( s 3s 5)(0.1s 1)
5
Control Lab.
Object:
Using Matlab Program to implement the o/l & c/l control system
Theory:
Closed-loop control systems are feedback control systems are often reformed as
closed-loop control systems. In such systems, the actuating error signal which is
the difference between the input signals and the feedback signals is fed to the
controllers so as to reduce the error and bring the output of the system to the
desired value.
measurement
Procedure:
Using Matlab/Simulink to implement the block diagram .
6
Control Lab.
error
Scope 1
o/p
1 1
s+1 s+1
Step Transfer Fcn Scope Step1 Transfer Fcn 2
i/p
Scope 3
1
1
s+1 o/p s+1
Scope 2 Transfer Fcn 1 Transfer Fcn 3
Cases
s ( s 5)
1 G (s) ; H (s) 1
( s 3s 5)
2
10 1
2 G ( s) ; H (s)
( s 3)(s 2) s 1
10( s 1)
3 G (s) 2
( s 3s 8)(s 3)
Discussion
1-What the main difference between the o/l &c/l control system .
2-Compare between all cases. And what the best case.
7
Control Lab.
Object:
Theory:
The simplest form of the block diagram is the single block, with one input and
one output. The interior of the rectangle representing the block usually contains
a description of or the name of the element, or the symbol for the mathematical
operation to be performed on the input to yield the output. The arrows represent
the direction of information or signal flow. Block diagram is a short hand,
graphical representation of a physical system, illustrating the functional
relationships among its components.
d
x y
dt
The operations of addition and subtraction have a special representation.
The block becomes a small circle, called a summing point, with the appropriate
plus or minus sign associated with the arrows entering the circle.
Procedure:
8
Control Lab.
1 / ( s+2)
(s+3)
(s+10)
program :
R(S
S+1 Y(S)
(S+3)(S+5)
9
Control Lab.
Program:
n=[1 1];
d1=[1 3];
d2=[1 5];
d=conv(d1 ,d2);
sys1=tf(n,d);
sys2=1
sysf=feedback (sys1,sys2 )
so T.F.= S + 1
S^2 +9S+1
S+1 Y(S)
R(S) (S+3)(S+5)
S+6
S+10
Program:
ngo=[1 1];
d1=[1 3];d2=[1 5];
dgo=conv(d1,d2);
sys1=tf(ngo,dgo);
nh=[1 6] ; dh=[1 10];
sys2=tf(nh,dh);
10
Control Lab.
sysf=feedback(sys1,sys2);
R(S)
S+6 S+1
S+10 (S+3)(S+5) Y(S
)
H Go
G(S)
Program :
ngo =[1 1];
d1=[1 3];d2=[1 5];
dgo =conv(d1,d2);
sys1=tf(ngo,dgo);
nh =[1 6];
dh =[1 10];
sys2=tf(nh,dh);
syss=series(sys1,sys2);
sys3=1;
Syst=feedback (syss,sys3);
CLASS WORK
Write a program to find the overall transfer function of the following block
diagram:
11
Control Lab.
Discussion
1-What the advantages of block reduction
2-calculate the type & order of the overall T.F.
3-Solve the above block diagram theoretical and compare the solution in
practical & theoretical.
12
Control Lab.
Experiment no4:
The Routh-Hurwitz Stability Criterion
Object:
Theory:
13
Control Lab.
14
Control Lab.
15
Control Lab.
16
Control Lab.
Discussion
k ( s 2)
2)G ( s ) 2
( s 5s 15)
17
Control Lab.
Experiment no5:
ROOT LOCUS
Object:
I Finding and plotting the root locus from the system transfer function.
I
Theory:
A pole-zero plot is simply a plot of the open-loop poles in the complex plane. A
plot of the closed-loop poles can be similarly helpful. Since the closed-loop
poles depend on the controller parameters, we don't get single points; instead,
we get curves showing the pole position as a function of controller gain. Such
plots are called Root Locus Plots.
Quickly sketched root locus plots can be made using a little bit of algebra and
following a few basic rules. It usually isn't necessary to have exact numerical
values. The plots that result provide some very useful qualitative understanding
of the closed loop response.
Root locus plots illustrate how the closed – loop poles of a system change as a
system parameter is varied. These plots are particularly useful for control
system design when the plant can be modeled by a rational transfer function. So
, we will learn how to write a Matlab program to create root locus plots.
I
1.for the control system shown below :
I
18
Control Lab.
Procedure:
For the
( s 2)
G (s)
( s 6 s 10)
2
K= variable gain.
I
So , the program which used to create root locus plot is :
I
I
Program:
I clf
num = [1 2];
den = [1 6 10];
rlocus( num , den);
or
sys=tf(num,den);
rlocuse(sys)
I
I
Where rlocus , is the command that calculates and plots the root locus of the
system defined by a transfer function.
Now , we can calculate poles and gain K for this control system by adding the
command.
I
[k , poles] = rlocfind (num , den)
I
There are many reasons for customizing a root locus plot. For example , the
following program will find root locus plot , but after running a program we
will see that it is difficult to see the important part of the root locus.
Program:
clf
num=1;
den=conv([1 20] , conv([1 0] , [1 1]));
19
Control Lab.
rlocus(num , den)
So , we customize the graph in order to see more clearly the portion of the root
locus that corresponds to the dominant poles.
Customizing programs :
clf;
num=1;
den=conv([1 20] , conv([1 0] , [1 1]));
rlocus(num , den)
axis([-2 2 -6 6])
So , the axis command , which is used to plot the root locus with the desired
formatting.
num=1 1 1.3];
den=conv([1 0],conv([1 1],conv ([1 1 1.25] , [1 1 4.25])));
rlocus(num , den);
axis([-1 0 0.5 1.5]);
clf;
num=[1 1 1.3];
den=conv([1 0] , conv [1 1] , conv ([1 1 1.25] , [1 1 4.25])));
[p , k]=rlocus(num , den);
rlocus(num , den , ‘k’);
axis([-1 0 0.5 1.5]);
[k star , p star]= rlocfind(num , den);
L=(k<k star);
index = sum(L);
K add=[k (index):0.001:k(index + 1)];
K new = [k(1:index)’k add k(index+1:length(k))’];
clf
20
Control Lab.
Cases:
K ( s 1)
1 GH ( s ) ;k 1
s ( s 1)
k ( s 2 6 s 10)
2 GH ( s ) 2 ; k 10
( s 2 s 10)
k ( s 2)(s 4)
3 GH ( s )
s ( s 13s 10)(s 2)
2
Discussion:
1-Compare between the theoretical and the results of program
2-Discusse the stability for each case
21
Control Lab.
Exp.no.6:
Design by means of root locus plots
Object:
The root locus plot , can be extremely useful design tool , so we use it in
controller design here. Adding a lead compensator to improve the natural
frequency of the closed-loop system.
Theory:
Using root locus techniques, we have seen how the pole positions of a closed
loop can be adjusted by varying a parameter gain. The compensator adds poles
and zeros to the P(s) in the root locus procedure.
Hence we can change the shape of the root locus. If we can capture desirable
performance in terms of positions of closed loop poles then compensator design
problem reduces to:
-changing the shape of the root locus so that these desired closed-loop pole
positions appear on the root locus
- finding the gain that places the closed-loop pole positions at their desired
positions.
If we would like to improve the transient performance of a closed loop.
We can try to place the dominant closed-loop poles in desired positions.
One approach to doing that is lead compensator design , however, that typically
requires the use of an amplifier in the compensator, and hence requires a power
supply. Broadening of bandwidth improves transient performance but exposes
loop to noise ,if we would like to improve the steady-state error performance of
a closed loop without changing the dominant transient features too much
We can consider designing a lag compensator to provide the required gain.
Procedure:
For a system with three real poles one normally puts the zero of compensator
close to the middle pole of the plant .
The compensator pole is placed as far to the left as possible.
Generally , noise and actuator limits prevent one from making this pole larger
than ten times the compensator zero.
We have chosen the lead compensator
C(S) = K ( S+1)
0.1 S+1
22
Control Lab.
it is shown as the long line leaving the real axis near S=-2 , this is a great
improvement. choosing a controller gain that produces a damping of 0.707 also
produces a wn = 2.7.
program:
hold on
num=[1 1];
den=conv(conv(conv[1 0] , [1 1] ) , [0.2 1]) , [0.1 1]);
rlocus(num , den)
hold off
we now must add zeros (complex or real) or add poles(complex or real) on the
rootlocus plot , and notice what happen to the rooylocus , will it be stable , or
unstable .
Cases:
20 (1 5s )
1 G(s) ; Gc
s (1 0.5s )(1 0.05s ) (1 50s )
20 (1 0.118ss)
2 G( s) ; Gc
s (1 0.2s ) (1 0.05s )
30 (1 3.57s )
3 G(s) ; Gc
s (1 0.1s )(1 0.2s ) (1 35.7 s )
10 (1 0.374s )
4 G( s) 2 ; Gc
s (1 0.25s ) (1 0.0074s )
Discussion:
1-Discusses the effect of compensator on stability for each case.
2-Draw the root locus of all cades y using Matlab program and by using rules
(theoretical).
3- Compare between the theoretical solution and the results of program.
23
Control Lab.
Experiment no.7 :
Object:
Theory:
Procedure:
program:
24
Control Lab.
clf
num=[0 5.979 53.8122 197.3113 388.6435];
den=[1 13 58 0 260];
bode(num , den)
program:
clf
z=[-2 -2+5*i -2-5*i];
p=[-1 -5 -7 -1+7*i -1-7*i];
k=(35*50)/(2*29) %k is chosen to give a d.c. gain of 1
[num , den]=zp2tf(z’ , p’ , k);
subplot(211) , nyquist(num , den)
subplot(212) , nichols(num , den)
ngrid
axis([-360 0 -40 30]);
Cases:
1000
1 G ( s)
s(1 0.1s)(1 0.001s)
20
2 G( s)
s(1 0.5s )(1 0.05s )
20
3 G(s)
s(0.2s 1)
30
4 G( s)
s(1 0.1s)(0.2s 1)
Discussion:
1-Compare between the theoretical and the results of program
2-Discusse the stability for each case.
3-Draw the Bode diagram for all cases by using Matlab program and rules
(Theoretical)
25
Control Lab.
Experiment no.8:
Object:
Theory:
As with phase lag and phase lead compensation, the purpose of lag-lead
compensator design in the frequency domain generally is to satisfy
specifications on steady-state accuracy and phase margin. Typically, there is
also a specification (implicitly or explicitly) on gain crossover frequency or
closed-loop bandwidth. A phase margin specification can represent a
requirement on relative stability due to pure time delay in the system, or it can
represent desired transient response characteristics that have been translated
from the time domain into the frequency domain. A specification on bandwidth
or crossover frequency can represent a requirement on speed of response in the
time domain or a frequency-domain requirement on which sinusoidal
frequencies will be passed by the system without significant attenuation. The
overall philosophy in the design procedure presented here is for the lead part of
the compensator to adjust the system’s Bode phase curve to establish the
required phase margin at a specified frequency, without reducing the zero-
frequency magnitude value. The lag part of the compensator is used to drop the
magnitude curve down to 0 db at that specified frequency. The lag compensator
must attenuate the magnitude of the series combination of the lead compensator
Gc_lead (s) and the plant Gp(s) at the chosen frequency. Thus, in the procedure
presented here, the lead compensator is designed first. In order for lag-lead
compensation to work in this context, the following two characteristics are
needed: • the uncompensated phase shift at the chosen gain crossover frequency
must be more negative than the value needed to satisfy the phase margin
26
Control Lab.
Procedure:
G(S)= 40/[(S+0.01)(S+4)(S+1+6i)(S+1-6i)
Clf
[num , den] =zp2tf ([ ] ,[-0.01 -4 -1+6*I -1-6*i] , 40);
nyquist(num , den)
there are two warnings that indicate this might not be true , but they require
careful observation.
First , the scale of the plot is rather larger and the nyquist locus does appear to
go slightly to the left of the jw-axis .
Second, we also know that a system with a4-poles and no-zeros should have -
180deg. Of phase shift at a non-zero gain and that its nyquist locus should be
asymptotic to -360deg. As , thus we used the axis command to zoom
in on the region.
Clf
27
Control Lab.
this use of the axis command causes the command nyquist to display only the 1
by -1 square range of the plot centered at the origin.
As we can see , this system would be closed – loop unstable with a feedback
gain of more approximately 120.
Cases:
1000 (1 0.016s)
1 G ( s) ; Gc ( s )
s(1 0.1s)(1 0.001s) (1 0.00214s)
20 (1 5s)
2 G ( s) ; Gc ( s )
s(1 0.5s )(1 0.05s) (1 50s)
20 (1 0.0118s)
3 G( s) ; Gc ( s )
s (0.2s 1) (1 0.058s )
30 (1 3.57s )
4 G ( s) ; Gc ( s )
s(1 0.1s)(0.2s 1) (1 35.7 s )
Discussion:
1-Discusses the effect of compensator on stability for each case.
2-Draw the root locus of all cades y using Matlab program and by using rules
(theoretical).
3- Compare between the theoretical solution and the results of program.
28
Control Lab.
Experiment no.9:
Specification of Step Response for Control System
Object:
How to create graphs of the time-domain response of a linear time-invariant
systems.
Theory:
Control systems are often required to satisfy specifications on several aspects of
their step response.
Typical examples are:
1. time to peak = the time for the step response to reach its first (and largest)
peak.
2. percent over shoot =100 (peak value – final value )
final value
3. rise time = time at which step response first reaches (90%)of its final
value minus time at which it first reaches (10%)of its final value.
4. settling time = last time the step response is farther than (+,- 2%) from its
final value.
5. note that the computation of final value is a direct implementation of the
formula
Procedure:
Matlab will tell you there are problems with this formula , for example , you
will be warned about %if G(S) has a pole at zero.
Program:
[y , x , t]=step(num , den);
[y , k]=max(y);
29
Control Lab.
timetopeak = t(k)
percent over shoot = 100*(y-final value)/final value
%computerise time
n=1;
while y(n)<0.1*final value , n=n+1;end
m=1;
while y(n)<0.9 * final value , m=m+1;end
rise time = t(m)-t(n)
%compute settling time
Ll=length(t);
while (y(L)>0.98*final value)&(y(Ll)<1.02*final value)
L=L-1;
End
Settling time = t(L)
We compute the step response using step command and stores it in the vector
corresponding to y is stored in the vector t. the vector x represent the (matlab
selected) state as a function of time.
However , we are not interested in the state in this example .
2. the command MAX to find the peak value of y and its index these are stored
as y and k.
Cases:
10
1 G (s)
( s 13)
9
2 G (s) 2
s 2s 9
13
3 G(s) 2
s 7s 9
25
4 G (s) 2
s 7 s 13
( s 1)
4 G (s)
( s 5)(0.1s 1)
Discussion:
1-For the above cases find the specification of step response (tr,td,tp,Mp%,e.s.s)
2- For the 2nd order transfer function find the ωn and ζ .
3- Compare between the results of program with the theoretical solution.
30
Control Lab.
EXPERIMENT NO.10:
Object:
To learn how to used Matlab & Simulink to control system in order to find the
steady state error & transient response .
Theory:
In control system analysis and design it is important to consider the complete
system response and to design controllers such that a satisfactory response is
obtained for all time instants , where stands for the initial time. It is known that
the system response has two components: transient response and steady state
response. The transient response is present in the short period of time
immediately after the system is turned on. If the system is asymptotically stable,
the transient response . However, if the system is unstable, the transient
response will increase very quickly (exponentially) in time, and in the most
cases the system will be practically unusable or even destroyed during the
unstable transient response (as can occur, for example, in some electrical
networks). Even if the system is asymptotically stable, the transient response
should be carefully monitored since some undesired phenomena like high-
frequency oscillations (e.g. in aircraft during landing and takeoff), rapid
changes, and high magnitudes of the output may occur. Assuming that the
system is asymptotically stable, then the system response in the long run is
determined by its steady state component only.
Procedure:
-Model connected
31
Control Lab.
Error signal
sum
Scope
s+1
Step
Sourse G(s) output
sink
math operation tansfer function
s+1
H(s)
countinous
mux
Step
Integrator Step
32
Control Lab.
Prapola
Integrato
Cases:
5
1 G(s) ; H ( s) 1
( s 2)
10
2 G ( s) 2 ; H (s) 1
s 2 s 10
( s 2) 2
3 G (s) 2 ; H (s)
s 12s 20 s2
s ( s 5) 1
4 G ( s) ; H ( s)
(0.1s 2 s 13)
2
s
1
(0.1s 5) H ( s)
5 G ( s) ; s ( s 3)
s ( s 2 3s 6)
Discussion:
1-For the above cases find the steady state error & transient response .
2- Compare between the results of program with the theoretical solution.
33
Control Lab.
Theory:
An initial question that the reader might reasonably ask is what happens if a
linear controller is applied to a nonlinear plant. We know from experience that
this must be a reasonable strategy in many cases because one knows that all real
plants exhibit some (presumably) mild form of nonlinearity and yet almost all
real-world controllers are based on linear design .We will thus pause to analyze
the effect of using a linear controller (C) on a nonlinear plant (which we think
of as being composed of a linear nominal part G0 together with nonlinear
additive model error Ge).
In the sequel we will need to mix linear and nonlinear descriptions of systems,
simple interpretation can be given by the analysis by simply thinking of an
operator (such as Ge) as some kind of nonlinear function. Of course, Ge will in
general be a dynamical system. A more rigorous statement of what we mean by
an operator Ge is given on the next slide. We define a nonlinear dynamic
operator f as a mapping from one function space to another. Thus, f maps
functions of time into other functions of time. Say, for example, that the time
functions have finite energy; then we say that they belong to the space L2, and
we then say that f maps functions from L2 into L2. We will use the symbol
y (without brackets) to denote an element of a function space; i.e. y as L2 is
of the form {y(t) : IR→IR}. We also use the notation y = f(u) to represent the
.mapping (transformation) from u to y via f.
Procedure:
1- Run Matlab by selecting [start] →Matlab 0202 →Matlab
command window opens.
34
Control Lab.
35
Control Lab.
Object :
Theory:
The first step in this experiment of PID control is to use SIMULINK to create
following sys.
36
Control Lab.
there are many ways to determine the appropriate gains for a PID
controller.
C(S)=Kp +Ki /S +KdS
Procedure:
Now , to find the rootlocus plot of the PID plant .
Program:
Clear
Num=20*[1 0.11];
Den=conv([1 10] , conv(1 0.1) , conv([1 0] , [1 2])));
Rlocus(num , den)
Sgrid([0.707] , [1])
Axis([-1 0 -1 1])
[Kp , poles]=rlocfind(num , den)
Ki=0.11 * Kp
Instructions :
in matlab there is command called simulink a block with its T.F. , from (' ') ,
for example & mathematical operations from ('math op') , and provide different
function as inputs step , ramp from ('source') , and find the response with
scope from (' sink') ; and there are many fields which enables you to implement
any block diagram you need.
CLASS WORK :
37
Control Lab.
3. set G=1 / 1
5. discuss the changes between case 2. & 4. and what the effect of integrator
(1/S) is on the response.
The first step in this experiment of PID control is to use SIMULINK to create
following sys.
there are many ways to determine the appropriate gains for a PID
controller.
C(S)=Kp +Ki /S +KdS
Program:
Clear
Num=20*[1 0.11];
Den=conv([1 10] , conv(1 0.1) , conv([1 0] , [1 2])));
38
Control Lab.
Rlocus(num , den)
Sgrid([0.707] , [1])
Axis([-1 0 -1 1])
[Kp , poles]=rlocfind(num , den)
Ki=0.11 * Kp
Dissuasion:
1- Explained the effect of PID Controller on the specifications of transient
response.
2- For the above examples design the PID controller by using theoretical
method.
3- Compare between results.
39
Control Lab.
EXPERIMENT NO.13:
Physical Setup
For this example, we will assume the following values for the physical
parameters. These values were derived by experiment from an actual motor in
Carnegie Mellon's undergraduate controls lab.
40
Control Lab.
System Equations
From the figure above we can write the following equations based on Newton's
law combined with Kirchhoff's law:
1. Transfer Function
Using Laplace Transforms the above equations can be expressed in terms of s.
41
Control Lab.
By eliminating I(s) we can get the following transfer function, where the
rotating speed is the output and the voltage is an input.
However during this example we will be looking at the position, as being the
output. We can obtain the position by integrating Theta Dot, therefore we just
need to divide the transfer function by s.
1. Transfer Function
We can put the transfer function into Matlab by defining the numerator and
denominator as vectors:
J=3.2284E-6;
b=3.5077E-6;
K=0.0274;
R=4;
L=2.75E-6;
num=K;
den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2) 0];
Now let's see how the original open-loop system performs. Add the following
command onto the end of the m-file and run it in the Matlab command window:
step(num,den,0:0.001:0.2)
42
Control Lab.
From the plot we see that when 1 volt is applied to the system, the motor
position changes by 6 radians, six times greater than our desired position. For a
1 volt step input the motor should spin through 1 radian. Also, the motor doesn't
reach a steady state which does not satisfy our design criteria
43
Control Lab.
Introduction
In this chapter, the proposed control training kit is discussed in more
details in order to highlight the capability of this training kit to perform
effective control experiments which represents the main target of this thesis.
Interfacing with PC
The proposed training kit is designed to interface it with standard PC
using USB port which is the easiest way of interfacing with PC. The overall
interfacing diagram in the proposed training kit is mentioned in Figure (3.1).
44
Control Lab.
13 Analog
Input
Channels
PC
Smart
Interfaci USB
ng unit
Figure (1): General Block Diagram of Interfacing Proposed Control Training Kit with PC
using USB port.
Internal Structure
Basically, the proposed control training kit includes is a single electronic
board which is placed in metal had bag. The external view of this board is
mentioned in Figure (2).
45
Control Lab.
46