Three Day Workshop By Engr Imtiaz Hussain Kalwar
TUTORIAL#04 CONTROL SYSTEM TOOLBOX
4.1 INTRODUCTION A linear control system may be presented either by a set of differential equations or by a transfer function. A transfer function is defined as the ratio of the Laplace transform of output to the Laplace transform of the input. Transfer functions are defined in MATLAB by storing the coefficients of the numerator and the denominator in vectors. In this tutorial, the names of the vectors are generally chosen to be num and den, but any other name could be used. For example, G(S) =
100 S +14S+100 2
Can be stored in the MATLAB workspace by typing num = 100; den = [1 14 100]; Note that all coefficients must be included in the vector, even zero coefficients. To check your entry you can use the command printsys as shown below: printsys(num,den); To find the zeros, poles and gain of a transfer function from the vectors num and den which contain the coefficients of the numerator and denominator polynomials, type [z,p,k] = tf2zp(num,den) The zeros are stored in z, the poles are stored in p, and the gain is stored in k. To find the numerator and denominator polynomials from z, p, and k, type
[num,den] = zp2tf(z,p,k) 4.2 POLES AND ZEROS The poles of the system are the roots of the denominator polynomial (the characteristic polynomial) and zeros are the roots of numerator polynomial. The poles and zeros of the above transfer function can be found by
http://imtiaz.kalwar.googlepages.com/home
1
Three Day Workshop By Engr Imtiaz Hussain Kalwar
poles = roots(den) zeros = roots(num) To plot the poles and zeros of any transfer function there is a built in function pzmap in the MATLAB. Note that the cross symbol in the figure present poles while the circles represents zeros, which are not shown in this particular plot, because the system has not any zeros.
Exercise#4.1: A transfer function is given by: G(S) =
S+1 S +4S2+10 3
(a) Find poles and zeros of above transfer function. (b) Use the plot function and the built-in function pzmap to plot the poles of the above transfer function marked by the symbol ‘x’.
4.3 MULTIPLICATION OF TRANSFER FUNCTIONS Consider the following block diagram: 9(S+3) 2S + 9s + 27
S 9S + 17
2
These two transfer functions can be multiplied by using the following MATLAB code: num1 = [1 0]; den1 = [9 17]; num2 = 9*[1 3]; den2 = [2 9 27]; [num12, den12] = series (num1,den1,num2,den2);s printsys(num12,den12); This transfer function can also be multiplied by using the following code: num1 = [1 0]; den1 = [9 17]; num2 = 9*[1 3];
http://imtiaz.kalwar.googlepages.com/home
2
Three Day Workshop By Engr Imtiaz Hussain Kalwar
den2 = [2 9 27]; num12 =conv(num1,num2); den12 = conv(,den1,den2); printsys(num12,den12);
Exercise#4.2 (a) Reduce the following block diagrams into a single block also find poles and zeros and sketch pole zero diagram. 2
S+6 2 S +S+1
S S+3
9S S+8
22 S + 5.6
4.4 CLOSED-LOOP TRANSFER FUNCTION A simple closed loop control system can be represented as shown in the following block diagram. R(S)
G(S)
-
C(S)
The closed loop transfer function of the above block diagram is given by C(S) R(S)
=
G(S) 1 + G(S)
We can obtain this transfer function by using MATLAB functions cloop or feedback.
Exercise#4.3 (a) Consider the following block diagram. Find the closed loop transfer function.
R(S) -
http://imtiaz.kalwar.googlepages.com/home
9 S+5
3
C(S)
Three Day Workshop By Engr Imtiaz Hussain Kalwar
(b) Find the closed loop transfer function of the following block diagram.
1 S +1
R(S) -
C(S)
2 S
4.5 STATE SPACE REPRESENTATION A Control system can be represented as: .
x = Ax + BU .
y = Cx + DU Where A, B, C and D are matrices, x is the state vector, y is the output vector and u is the input vector. The above representation can be obtained from the differential equation or transfer function of the system under considerations. MATLAB has built-in functions tf2ss (transfer function to state space) and ss2tf (state space to transfer function) to convert transfer function model into state space representation and vice versa. Following examples demonstrate the use of both of these functions. Example: - The transfer function of a control system is given below. Find the state space representation of the system.
G(S) =
12S + 59 S 2+ 6S + 8
Use following MATLAB code num = [12 59]; den = [1 6 8];
http://imtiaz.kalwar.googlepages.com/home
4
Three Day Workshop By Engr Imtiaz Hussain Kalwar
[A,B,C,D] = tf2ss(num,den); printsys(A,B,C,D) Exercise#4.4: - Find the state space representation of the following transfer functions. G(S) =
G(S) =
2
S + 7S + 12
(S+1)(S +2) S(S 2+3S+1)
Example: - The state space representation of a control system is dx1/dt dx2/dt
-5
-1
=
3
y =
1
-1
1
x1 +
x2
U
0
x1
2
x2 The transfer function of the system can be obtained as A = [-5 -1;3 -1] B = [1 ; 0]; C = [1 2]; D = [0]; [num,den]= ss2tf(A,B,C,D); printsys(num,den); Exercise#4.5: - Find the transfer function of the following systems.
A=
C =
-1
0
0
0
-2
-3
0
0
3
1
http://imtiaz.kalwar.googlepages.com/home
1
1
3 B=
3
D = 0
5
-6
Three Day Workshop By Engr Imtiaz Hussain Kalwar
4.6 TIME RESPONSE OF A CONTROL SYSTEM When a time domain signal is applied to a control system it produces a response of that signal in time domain. This response of the system is called time response of a control system. At the first instant the system exhibits some transients and after some time it comes to steady state. While designing a control system the information of transient response characteristics and the steady state characteristics is very important. In this tutorial we will apply different test signals (Step, Impulse and Ramp) to a particular control system and from the response of that signal we will acquire the information about the peak response, steady state, settling time, rise time and steady state error. Example: - The transfer function of a control system is given below. In order to find the values of transient response characteristics and steady state characteristics of the system lets apply the test signals one by one. 100 S +14S+100 Use following MATLAB code we can find the step response of the system num = 100 den = [1 14 100]; step(num,den) grid on G(S) =
2
Similarly to find the impulse response of the system use following MATLAB code num = 100 den = [1 14 100]; impulse(num,den) grid on and for ramp response there is no built in function so we will use lsim command to plot the ramp response. t=0:0.01:10 r=t; num = 100 den = [1 14 100]; lsim(num,den,u,t) grid on
Exercise#4.6: - Find transient and steady state characteristics of the following transfer function. (S+1)(S +2) G(S) = S(S 2+3S+1)
http://imtiaz.kalwar.googlepages.com/home
6
Three Day Workshop By Engr Imtiaz Hussain Kalwar
4.7 FREQUENCY DOMAIN ANALYSIS Performance of a control system is measured more realistically by its time domain characteristics. These characteristics can be easily obtained by applying certain test signals to the system. However in the analysis and design of communication systems, for which the frequency response is of more importance, the frequency response approach is more suitable. Frequency domain analysis is more convenient for the measurement of system sensitivity to noise and parameter variation. In the frequency domain analysis many graphical methods are available that can be used to determine the frequency domain specifications like resonant peak (Mr), resonant frequency (ωr) and bandwidth (BW). In this tutorial we will use different graphical approaches to analyze the control systems in frequency domain. 4.7.1
BODE PLOTS
The bode plot of a function G(jω) is composed of two plots, one with the amplitude of G(jω) in decibels versus log10ω or ω, and other with the phase of G(jω) in degrees as a function of log10ω or ω. The bode plot is known as the corner plot or the asymptotic plot of G(jω). Example: - In order to obtain the bode plot of the transfer function G(S) =
S+1 S (S + 3)
We will write the following MATLAB code: num = [1 1]; den1 = [1 0]; den2 = [1 3]; den = conv(den1,den2 ); bode(num,den); bode(num,den) draws the Bode plot of the system. The frequency range and number of points are chosen automatically.
Exercise#4.7: Obtain the bode plots of the following systems: G(S) =
10 (S + 10) S (S + 2) (S + 5)
http://imtiaz.kalwar.googlepages.com/home
G(S) =
7
2500 S (S + 5) (S + 50)
Three Day Workshop By Engr Imtiaz Hussain Kalwar
4.7.2
POLAR PLOTS OR NYQUIST PLOT
The polar plot of a function of the complex variable S, G(S), is a plot of the magnitude of G(jω) versus the phase of G(jω) on polar coordinates as ω is varied from zero to infinity. Example: - In order to obtain the Nyquist plot of the transfer function G(S) =
S+1 (S + 5)
We will write the following MATLAB code: num = [1 1]; den= [1 53]; nyquist(num,den);
Exercise#8: Obtain the nyquist plots of the following systems: G(S) =
4.7.3
10 (S + 1) S (S + 2)
G(S) =
10 S (S + 2)
MAGNITUDE-PHASE PLOTS OR NICHOLS CHART
The Nichols chart (Magnitude-Phase plot) of G(jω) is a plot of the magnitude of G(jω) in decibels versus its phase in degrees, with ω as a parameter on the curve. Example: - In order to obtain the Nyquist plot of the transfer function G(S) =
10 (S + 10) S (S + 2) (S + 5)
We will write the following MATLAB code: num = 10*[1 10]; den1 = [1 0]; den2 = [1 2]; den3=[1 5]; den12 = conv(den1,den2 ); den=conv(den12,den3); nichols(num,den);
http://imtiaz.kalwar.googlepages.com/home
8
Three Day Workshop By Engr Imtiaz Hussain Kalwar
Exercise#4.8: Obtain the Nichols plots of the following systems: G(S) =
10 (S + 1) S (S + 2) (S + 10)
http://imtiaz.kalwar.googlepages.com/home
G(S) =
9
2500 S (S + 5) (S + 50)