U I (UIU) : Expt. No. 2 M S
U I (UIU) : Expt. No. 2 M S
EXPT. NO. 2
A. Introduction
To understand and control physical systems, one of the initial requirements is to obtain the mathematical
models of these systems. A model is one that quantitatively describes the relationship between the input and
output of a dynamic system. To model systems, we use physical laws, such as Kirchhoff’s laws for electrical
networks and Newton’s law for mechanical systems, along with simplifying assumptions.
Figure 2.1
(A system showing input and output)
The classical approach of modeling linear systems is the transfer function technique which is derived from the
differential equation using Laplace transform. Other than transfer function G(s), a system can be modeled by
state-space model such that input and output can be related in the following manner.
1. By transfer function: Y ( s ) G ( s ).U ( s )
x A x Bu
2. By state-space: ,
y C x Du
Where x represent a set of system variable called state variable that will be discussed in the later section.
Following section will present example of modeling physical system using both transfer function and state
space.
1
m f
Frictional force, bv
dv
dt
Figure 2.5
(A cruise control system)
Since our output is the velocity, V(s), the transfer function of the system becomes,
V ( s) 1
G (s)
F ( s ) ms b
Matlab code :
m=1000;
b=50;
num=[1];
den=[m,b];
G=tf(num,den)
step(G)
Output :
2
Step Response
0.02
0.018
0.016
0.014
0.012
Amplitude
0.01
0.008
0.006
0.004
0.002
0
0 20 40 60 80 100 120
Time (sec)
Figure 2.6
(Step response of a cruise control system)
Task:
i) Use “for” loop to simulate the above system for different value of b =[5, 15, 50]. You
may use “hold on” and “pause” command inside the loop.
ii) Simulate the above system for different mass value of m =[50, 200, 1000]
iii) Comment on the changes in output in terms of steady state value and settling time.
e=K
V
Figure 2.7
(DC motor)
For this example, we will assume the following values for the physical parameters.
moment of inertia of the rotor (J) = 0.01 kg.m^2/s^2
damping ratio of the mechanical system (b) = 0.1 Nms/rad
electromotive force constant (K) = 0.01 Nm/Amp
electric resistance (R) = 1 ohm J
3
electric inductance (L) = 0.5 H
input (V): Source Voltage
output (theta): position of shaft
The rotor and shaft are assumed to be rigid
The back emf, e, is related to the rotational velocity by the following equation :
d
ek
dt
d 2
d
From Newton’s law, J 2
b Ki …………………………………………….(i)
dt dt
di d
From Kirchhoff’s law, L Ri V K ……………………………………………(ii)
dt dt
Eliminating i from these two equations we get,
d 2 d
JL 2 bL JR Rb K 2 VK [Here, ω = dθ/dt]
dt dt
Since, the rotational speed is the output and the voltage is the input., the transfer function is
W K
G(s) [Here, W = sθ]
V JLs JR bL s ( Rb K 2 )
2
MATLAB code
J=0.01;
b=0.1;
K=0.01;
R=1;
L=0.5;
num=K;
den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)];
G= tf(num,den);
t=0:0.1:10;
step(G,t)
Output:
4
Step Response
0.1
0.09
0.08
0.07
0.06
Amplitude
0.05
0.04
0.03
0.02
0.01
0
0 0.5 1 1.5 2 2.5 3
Time (sec)
Figure 2.8
(Step response of a dc motor)
Task:
i) Simulate the above system for different value of J, b, R. Specially try K=[.01 .05 .5
1 1.5]. Try to explain how system response changes from overdamped to
underdamped condition.
ii) Comment on changes in output responses.
x ( n 1) state vector
u (m 1) input or control signal vector
y ( p 1) output or signal vector
A ( n n)
B (n m)
matrices of constant elements
C ( p n)
D ( p m)
MATLAB representation of state-space analysis :
Use of ss( ) function
5
Example: Obtain MATLAB representation of a control system described in it’s state-space
representation given by :
1 1 1
x x u and y [1 1]x [0]u
0 1 0
The MATLAB codes are given below :
>> A=[1 1;0 -1];
>> B=[1;0];
>> C=[1 1];
>> D=[0];
>> system=ss(A,B,C,D)
b=
u1
x1 1
x2 0
c=
x1 x2
y1 1 1
d=
u1
y1 0
Continuous-time model.
6
Obtain the state-space representation of this system and obtain the unit step response.
Solution :
1) Let the state variables are, x 1 v c and x 2 i
and the output is v c .
Using Kirchhoff's voltage law, we obtain a differential equation that can be reduced to a set of first-
order system:
dVc di
2) From C i and L iR Vc Vi we get State Equations:
dt dt
1
Vc i
C
R 1 1
i Vc i vin
L L L
3) Output Equation: y Vc
Now we can rewrite the above equations in matrix form:
1 0
0 x
x 1 C 1 x1
1 u
y [1 0] 0.u
x 1 R x 2 x 2
2 L
L L
Thus we get four matrices from above two equations:
1
0 0
A= C B 1 C [1 0] and, D=[0]
1 R L
L L
7
The MATLAB codes are given below (create an M-file):
R= 10;
L= 20;
Cap= 0.05;
A = [0 1/Cap; -1/L -R/L];
B=[0 ;1/L];
C=[1 0];
D=[0];
step(A,B,C,D)
Step Response
1.5
1
Amplitude
0.5
0
0 5 10 15 20 25
Time (sec)
Task:
Simulate the above system for different value of R,L,C. You can chose to vary R=[5 20 40 100]
to find that the response is changing from underdamped to overdamped. Comment on the
findings.
D=
0
Converting state-space representation to a transfer function :
Use of ss2tf( ) command
Useful commands :
[n , d ] ss2 tf ( A, B, C, D, k )
where the argument k is required only if the system has more than one input and specifies kth input.
If the system has only one input, it can be omitted. So, if k=1, the syntax may be,
[ n , d ] ss 2 tf (A, B, C, D,1)
or,
[n , d ] ss 2tf ( A, B, C, D)
Example 5.3: Obtain the transfer function of the system described by the following state-space
equations :
x 1 0 1x1 0
u x 1
y 1 0
5 10x2 15
and
x 2
x 2
The MATLAB codes are given below :
>> A=[0 1;-5 -10];
>> B=[0;15];
>> C=[1 0];
>> D=[0];
>> [n,d]=ss2tf(A,B,C,D);
>> G=tf(n,d)
9
And the output is obtained as,
Transfer function:
15
--------------
s^2 + 10 s + 5
G. Response of a MIMO system by State-space approach
State-space approach to plot unit step response :
Use of step(A,B,C,D)
Example:
(a) Obtaining step response for all inputs of a MIMO system: Obtain step response of the
system whose state-space representation is given as,
10
y1 1 0x1 0 u1
y2 0 1x2 0 u2
(b) Obtaining step response for specific input of a MIMO system: Obtain step response of the
same system when only the first input is applied and the second input is zero.
(a)The MATLAB codes are given below :
11
Step Response
From: In(1) From: In(2)
0.6
0.4
To: Out(1)
0.2
-0.2
Amplitude
-0.4
5
4
To: Out(2)
0
0 5 10 0 5 10
Time (sec)
0.4
To: Out(1)
0.2
0 y1
-0.2
Amplitude
-0.4
5
4
y2
To: Out(2)
0
0 2 4 6 8 10 12 14
Time (sec)
12
H. Simulating system response by SIMULINK
Example: Obtain the unit step response of a control system described by the following state-space
representation :
0 1 0 x 1 0
x 0 0 1 x 0u x1
and, y [1 0 0] x
2 2
x 3
4 3 2x2 4
Solution:
Step-1 : Construct the following model using SIMULINK . (State-Space box can be found in
Continuous block library.) Connect the blocks, and set input and output points (e.g., right click on
arrow>linearization points>input).
x' = Ax+Bu
y = Cx+Du
Step State-Space Scope
Step-2 : Double Click the State-Space block and set the values of A,B,C and D .
Step-3 : From the LTI viewer, see the step response . [Click on Tools>Control
Design>LinearAnalysis, then click on Linearize model]
13
Task: Simulate the above system in SIMULINK by transfer function.
(Hint: first convert the state-space into transfer function, then bring a transfer function block instead
of state-space block.)
I. Home Work :
2.1 Define rise time, settling time, percentage overshoot and steady state error of a system for step input.
2.2 How steady state speed, rise time and overshoot of the output response vary with the variation of
m and b in the cruise control system? (Figure 2.6)
2.3 What are the differences between SISO and MIMO system. What are the advantages of using State-
Space model to handle a MIMO system ?
14
0 1 0 x 1 0
x 0 0 1 x 0u x1
and, y [1 0 0] x
2 2
x 3
2 4 3x2 1
(a) Using state-space equation, find the impulse response.
(b) Using state-space equation, find the step response.
(c) Using SIMULINK model , find the step response.
(d) Obtain the response for an input of u = 1+t for a 6 sec interval using MATLAB dialogue .
[ Hints : Use lsim(A,B,C,D, u, t ) ]
2.5 Find the transfer function G(s) of the above system (A,B,C,D) in problem 2.4. Now convert back the
G(s) into state-space (A1,B1,C1,D1). Are the any differences between (A,B,C,D) and (A1,B1,C1,D1)
? explain why.
15