Uploaded by Chi Fu

eecs306labs

advertisement
EECS 306
January 27, 2004, [Grizzle]
Laboratory #1
Laboratory # 1
System Identification
1.1
Introduction
The purpose of this laboratory assignment is to give you an idea about building empirical
linear models on the basis of measured data. This is a very deep subject and we will just
touch on the basics. At points where things seem just too simple to be true, or very ad
hoc, well, that is where I am cutting corners in order to make this accessible to Signals &
Systems Students.
If you ever need to do this for real, for a system where you or your employer really care
about the results, you should do a bit more than what I will show you here. For starters,
read the following:
• System Identification Toolbox (For use with MATLAB), Lennart Ljung, the Math
Works, Inc. (the company that markets MATLAB). At a minimum, you will want
to read the sections in the System ID Toolbox which deal with identifying models for
systems that are corrupted by noise. This is an important part of the theory that we
cannot cover because you have not yet taken EECS 401, the probability course.
• Run the System Identification Demo on Matlab:
>> iddemo % runs the demo for you
• Good reference book: T. Soderstrom and P. Stoica, System Identification, Prentice
Hall, 1989.
With all of these caveats, the simple ideas that follow are extremely useful to understand
and use for “simple” models with low levels of measurement noise. System Identification
works in engineering practice! Moreover, once you get the hang of the syntax of the System
Identification Toolbox, you do not have to be a genius to use it. This laboratory assignment
will show you that system identification is essentially a linear regression problem.
1.2
Assignment
• Read this document. You can read it as a stand alone document, or you can work the
examples in Matlab as you go.
The University of Michigan, All rights reserved
1
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
• Download the file “Lab Sys ID.zip” from the laboratory area of the class web site (this
is a subfolder in the resources folder). Place the file in the directory of your choice
and then unzip the file.
• Required Matlab files: all required Matlab files are in the file “Lab Sys ID.zip”
• The laboratory and prelab may be worked on any computer equipped with a sufficiently
recent version of Matlab, though no guarantees are made on compatibility with
Student Matlab.
• We have covered two handouts that provide crucial background material for this laboratory: Linear Regression or Least Squares Fit of Functions to Data and Discrete-time
Models of Continuous-Time Signals and Systems. You may need to refresh your memory from time-to-time, so it is best to have these handy.
• The Pre-lab should take less than ten minutes to complete once you have read this
document! The due date is posted on the class web site. Note that you are to turn in
your work in your discussion section, and not in the lecture. The pre-lab assignment
is given toward the end of this document in Section 1.6.
• For the actual laboratory, you need to complete the problems given in Section 1.7.
The due date is posted on the class web site. Note that you are to turn in your work
in your discussion section, and not in the lecture.
1.3
Some Matlab commands for this lab
Suppose we are given an nth order transfer function
bm sm + bm−1 sm−1 + · · · + b1 s + b0
sn + an−1 sn−1 + · · · + a1 s + a0
(1.1)
The corresponding LTI ODE is
dn−1 y(t)
dy(t)
dm x(t)
dx(t)
dn y(t)
+
a
+ b0 x(t) (1.2)
+
a
+
·
·
·
+
a
y(t)
=
b
+ · · · + b1
n−1
1
0
m
n
n−1
m
dt
dt
dt
dt
dt
If the conditions below are satisfied
1. m ≤ n
2. an−1 , . . . , a1 , a0 and bm , . . . , b1 , b0 are constant coefficients
3. sample period is constant and equal to Ts
4. the input is constant over the interval [kts , (k + 1)Ts ] (this is the idea of a zero order
hold (zoh))
then we can compute an equivalent discrete-time model. Define x(k) = x(kTs ) and y(k) =
y(kTs ). Then, there exist coefficients
an−1 , . . . , a1 , a0 , bm , . . . , b1 , b0
2
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
Laboratory #1
such that the solution of the difference equation
y(k + n) + an−1 y(k + n − 1) + . . . + a1 y(k + 1) + a0 y(k)
= bm x(k + m) + . . . + b1 x(k + 1) + b0 x(k)
(1.3)
exactly agrees with the solution of differential equation at the sampling points, that is
t = kTs .
Since Matlab works with vectors, we express the coefficients of the difference and
differential equations in vector form as:
N um
N um
= [bm , bm−1 , . . . , b0 ]
£
¤
= bm , bm−1 , . . . , b0
Den = [1, an−1 , . . . , a0 ]
Den = [1, an−1 , . . . , a0 ]
We can use Matlab commands c2d jwg and d2c jwg, to pass back and forth between a
differential equation and a difference equation:
[Num_Bar, Den_Bar] = c2d_jwg(Num,Den,Ts);% continuos to discrete
[Num, Den] = d2c_jwg(Num_Bar,Den_Bar,Ts);% discrete to continuous
specialized m-files used in the lab section
• def simple funs.m
• c2d jwg.m
• d2c jwg.m
• model fit.m
You can get more information by typing help filename in Matlab .
1.4
1.4.1
System Identification
Classical System Identification: Direct Measurement of the
Transfer Function
The classical approach to system identification is to identify the transfer function from
data. Suppose you have a BIBO-stable LTI system with transfer function H(s). Let x(t) =
cos(w0 t)u(t). Then, the output y(t) at steady-state is (as t ⇒ ∞),
y(t) ∼
= |H(jw0 )| cos(w0 t + ∠H(jw0 )).
Note that the output is amplified by |H(jw0 )| and shifted in time by ∠H(jw0 )/w0 . The
amplification gives the magnitude of the transfer function at the frequency of the input
signal and the shift gives the phase. Thus, by applying cosines at different frequencies we
can determine the magnitude and phase of the transfer function at discrete points on the
imaginary axis, and from this data, attempt to interpolate (or fit) a parameterized function
of s to the measured data.
The University of Michigan, All rights reserved
3
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
However, note that the system should be in steady-state to determine |H(jw0 )| and
∠H(jw0 ). This is one of the disadvantages, because it slows down the process. Moreover, if
you do not have the right equipment, it can be tedious to determine the magnitude and the
phase of the output. The last step is to fit a function to the measured data. In general, this
is a nonlinear regression problem which is much harder than a linear regression problem.
For these reasons, we will explore an alternative method for determining a model from data.
1.4.2
A More Modern View
UNKNOWN y(t)
x(kT) SYSTEM y(kT)
x(t)
Figure 1.1: Unknown model. Could be continuous-time or discrete-time system. It is
assumed that we can measure the inputs and outputs of the model, either as x(t), y(t) or as
x̄(k) = x(kT ), ȳ(k) = y(kT ), though in practice, we will probably only make discrete-time
measurements. We live in a digital world.
Suppose that we have a physical system that is exactly described by the LTI discrete-time
model
y(k + 1) + 0.5y(k) = 0.4x(k)
For the sake of the example, let us suppose that we believe the system can be modelled as
a first-order difference equation
y(k + 1) + a0 y(k) = b0 x(k)
but that we do not know the coefficients a0 and b0 . Is it possible to “probe” the system
with external inputs and “identify” the unknown coefficients in the model on the basis of
experimental data?
Here is what we could do. Re-arrange terms in the model to put all of the unknowns on
the right hand side:
y(k + 1) = −a0 y(k) + b0 x(k)·
¸
£
¤ a0
.
−y(k) x(k)
=
b0
This leads to






y(2)
y(3)
y(4)
y(5)
y(6)


 
 
=
 
 
−y(1)
−y(2)
−y(3)
−y(4)
−y(5)
x(1)
x(2)
x(3)
x(4)
x(5)

·
¸
 a0

 b0 ,

which looks like a regression problem!
4
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
Laboratory #1
Table 1.1: Experimental Data from Simple Model.
k
1
2
3
4
5
6
xk
0
1
1
1
1
1
yk
0
0
0.4
0.2
0.3
0.25
Suppose now that we make the measurements shown in Table
problem, we can define Y , Φ and Θ as follows:



 


−y(1) x(1)
0.0
y(2)
0.0
 −y(2) x(2) 
 y(3)   0.4 
  0.0


 








Y =  y(4)  =  0.2  , Φ =  −y(3) x(3)  = 
−0.4
 −y(4) x(4) 
 y(5)   0.3 
−0.2
−y(5) x(5)
0.25
y(6)
1.1. For the regression

0.0
·
¸
1.0 
 , Θ = a0
1.0 
b0
1.0
Now, we apply our usual regression formula, and compute:
·
¸
0.5
Θ = (ΦT Φ)−1 ΦT Y =
0.4
In this case, we have EXACTLY identified the coefficients. Of course, in real life, we will
NEVER exactly match a model (first of all, if we knew the exact model, we wouldn’t be
doing system identification in the first place! Secondly, real data are perturbed by noise and
other imperfections. Finally, real models are never exactly linear, though a linear model
may be a very good approximation.). Thus, we will eventually have to discuss how we can
tell that we have done a reasonable job of identifying the coefficients in a model. This will
be done a little later in the laboratory.
R
x(t)
i
C
y (t )
Figure 1.2: Low Pass Filter
Let’s next look at how we can identify the coefficients of a continuous-time model, using
the above ideas. For definiteness, let’s take the RC filter model that we’ve used several
The University of Michigan, All rights reserved
5
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
times so far. For the exact model, let’s take R = 3 × 104 ohms and F = 2 × 10−6 F. Thus
the true model is
1
1
dy(t)
+
y(t) =
x(t),
dt
RC
RC
1
= 16.7 If we take a sample period of Ts = 5 ms, then the corresponding discretewhere RC
time model would be
ȳ(k + 1) − 0.92ȳ(k) = 0.08x̄(k),
which is exact as long as we apply inputs x(t) that are constant over intervals of time given
by the sample period, Ts . Recall that the discrete-time model is computed via the c2d jwg
command in Matlab
R=3*10^4; % define model parameters
C=2*10^(-6);
num=1/(R*C); % define numerator of transfer function
den=[1 1/(R*C)]; % define denominator of transfer function
Ts=.005;
% set the sample period
[num_disc,den_disc]=c2d_jwg(num,den,Ts) % discretize the LTI-ODE model
num_disc =
0
0.0800
den_disc = 1.0000
-0.9200
Remark: As a side note, the discrete-time transfer function
b̄1 z + b̄0
z + ā0
corresponds to the difference equation model
y(k + 1) + ā0 y(k) = b̄1 x(k + 1) + b̄0 x(k),
and is strictly analogous to a continuous-time transfer function with s replaced by z. So,
num disc and den disc represent the difference equation
y(k + 1) − 0.92y(k) = 0x(k + 1) + 0.08x(k).
6
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
Laboratory #1
1
0.8
x
0.6
0.4
0.2
0
−0.1
−0.05
0
0.05
0.1
0.15
t
0.2
0.25
0.3
0.35
0.4
−0.05
0
0.05
0.1
0.15
t
0.2
0.25
0.3
0.35
0.4
1
0.8
y(kTs)
0.6
0.4
0.2
0
−0.1
Figure 1.3: Experimental data that we have collected for our RC-filter
Let’s get back to system ID. Meeting the requirement that x(t) is constant over intervals
of length Ts is trivially achieved by taking x(t) = u(t). So, we experimentally apply a step
to the RC-network model and measure its output at a sample rate of Ts = .005. The result
is displayed in Figure 1.3. We do the same thing as before, except this time we cannot
conveniently print out the full matrices because Y has N = 101 points in it! However, we
still do as before:


 
−y(1)
x(1)
y(2)
·
¸
 y(3)  
−y(2)
x(2) 
 a0

 
 ..
=
..
..  b
 .
 
.
.  | {z0 }
−y(N − 1) x(N − 1)
y(N )
Θ
{z
}
| {z } |
Y
Φ
to obtain our standard regression equation Y = ΦΘ. We solve for Θ, and obtain
·
¸
0.92
T
−1 T
Θ = (Φ Φ) Φ Y =
0.08
This gives us the coefficients of the discrete-time model. We obtain the coefficients of the
continuous-time model via the d2c jwg command in MATLAB.
The University of Michigan, All rights reserved
7
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
>> num_disc_est = 0.0800;
>> den_disc_est =[ 1.0
-0.92];
>> [num_cont,den_cont]=d2c_jwg(num_disc_est,den_disc_est,Ts) % this is the inverse
% operation of discretization....it finds the
% equivalent LTI-ODE (if one exists)
num_cont =
0
16.6667
den_cont = 1.0000
16.6667
In other symbols, the identified transfer function is
H(s) =
16.6667
,
s + 16.6667
which we know to be correct. The differential equation corresponding to the transfer function
16.6667
Y (s)
= H(s) =
X(s)
s + 16.6667
is
dy(t)
+ 16.6667y(t) = 16.6667x(t)
dt
Key Points: On the basis of input-output measurements (i.e., measuring only the inputs
and outputs of the “unknown” system), we have constructed a mathematical model of the
system! Moreover, we were able to make use of transient data in building the model. This
is a powerful tool in engineering practice. In general, if you can build a model based
on knowledge of the physics of the system, you are wise to do so. However, in many cases
you do not have enough time nor enough data to build models from first principles, and in
such cases, System ID can be very helpful.
Higher Order Models and Automating All of This
Suppose that we have a difference equation model of a system as follows
y(k + n) + an−1 y(k + n − 1) + . . . + a1 y(k + 1) + a0 y(k)
= bm x(k + m) + bm−1 x(k + m − 1) + . . . + b1 x(k + 1) + b0 x(k)
We can rewrite the equation by moving all the terms except the most future term (i.e.
y(k+n)) of the left hand side of the equation to the right hand side. Then if we use matrix
8
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
Laboratory #1
notation we get

an−1
an−2
..
.





 a1

 a0
y(k + n) = [−y(k + n − 1), . . . , −y(k), −x(k + m), −x(k + m − 1), . . . , −x(k)] 
 bm

 bm − 1


..

.


b1
b0









.








If we write down this equation for every k = 1, 2, . . . , N , we have a series of equations






y(n + 1)
y(n + 2)
..
.
|
y(N )
{z
Y


−y(n) − . . .
−y(1) −x(1 + m) . . .
−x(1)
  −y(n + 1) − . . .
−y(2)
−x(2
+
m)
.
.
.
−x(2)
 
=
..
..
..
..
..
..
 
.
.
.
.
.
.
−y(N − 1) − . . . −y(N − n)
−x(N ) . . . −x(N − m)
} |
{z
Φ
an−1
an−2
..
.





 a1

a0



 bm
 bm − 1

..
}

.


b1
b0
|
{z
Θ
At this point, we are thus back to our standard problem, Y = ΦΘ. We can apply the
regression formula and compute:
Θ = (ΦT Φ)−1 ΦT Y
If our data are noiseless and really came from a model with the assumed structure, we would
exactly identify the coefficients of the difference equation. In real life, we will never exactly
match a model. A little later in the laboratory, we will discuss how we can validate our
identified model.
Of course, setting up the regression problem for high-order problems is very tedious,
and thus one should build an m-file that automates all of this. This has been done and is
available to you. Look in the directory of files you downloaded for this lab, and look for
model fit.m. We will illustrate its use on a second order, quarter car model.
The University of Michigan, All rights reserved
9









.








}
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
Weight, mg
m
Spring
xc
b, shock
absorber
k
V
x(t)
Figure 1.4: Quarter Car Model: m
d 2 vC
dvC
dvr
+ kvC = b
+ kvr
+b
2
dt
dt
dt
Let vc be the vertical velocity of the car body, and let vr be the vertical velocity of the
road (represents change in height as a function of time, such as when hitting a pot-hole).
Let the true parameters be
• m = 500 Kg is the (quarter) mass of the car
• k = 105 N/m is the spring stiffness (of the shock absorber)
√
• b = 2 104 Ns/m is the damping coefficient of the shock absorber
yielding the LTI-ODE
dvc (t)
dvr (t)
d2 vc (t)
+ 200vc (t) = 28.2843
+ 2000vr (t).
+ 28.2843
dt2
dt
dt
Based upon previous experience with the model (Handout: Discrete-time Models of
Continuous-Time Signals and Systems), we take the sampling period to be 5 ms, or 0.005 s.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
10
def_simple_funs
Ts=.005;
t=[0:Ts:2];
x=ustp(t-0.25);
% Set-up input signal
m=500;
% Set-up model parameters
k=10^5;
b=sqrt(2)*10^4;
num=[b/m k/m];
% define transfer function's numerator (b/m) s + (k/m)
den=[1 b/m k/m]; % define transfer function's denominator s^2 + (b/m) s + (k/m)
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
Laboratory #1
>> y=lsim(num,den,x,t); % compute the output of the system. In practice, this would be the
% result of an experiment on your physical system.
>> [num_disc,den_disc]=model_fit(y,x,1,2,t);
% apply system ID m-file to the data
>> [num_cont,den_cont]=d2c_jwg(num_disc,den_disc,Ts)
% convert to continuous-time domain; that is,
% convert discrete-time transfer function to
% continuous-time transfer function (opposite of
% c2d_jwg
num_cont =
0
28.2843
200.0000
28.2843
200.0000
den_cont =
1.0000
1
0.8
x
0.6
0.4
0.2
0
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
Sys ID: Order numerator = 1 Order denominator = 2
Measured y
Modeled y
ymeas and ymod
1
0.8
0.6
0.4
0.2
0
0
0.2
0.4
0.6
0.8
1
Time t
1.2
1.4
1.6
1.8
2
Figure 1.5: ID Results for Quarter Car Model. The identified model is perfect because the
data was perfect and the model was simple.
The University of Michigan, All rights reserved
11
Laboratory #1
1.4.3
January 27, 2004, [Grizzle]
EECS 306
Choice of input signals
Two common input signals in system identification are the unit step and the CHIRP signal.
The chirp signal is discussed here.
We learned that LTI-ODE (Linear time invariant ordinary differential equations) models
can be represented by transfer functions. Consider the time domain model
dy(t)
+ 20y(t) = 20x(t).
dt
(1.4)
The corresponding transfer function of the differential equation (1.4) is as follows
20
.
s + 20
(1.5)
If we look at the Bode plot of the transfer function, we observe that the system has a
certain bandwidth. We might suspect that if the transfer function has a large bandwidth,
then to accurately identify the system, we need to excite it with a signal that has a broad
range of frequency components.
Bode plot of 20/(s+20)
Mag in dB
0
−5
−10
−15
−1
10
0
1
10
10
2
10
frequency(rad/sec)
Phase in degrees
0
−20
−40
−60
−80
−1
10
0
1
10
10
2
10
frequency(rad/sec)
Figure 1.6: Bode plot of the transfer function
20
s+20
One way to achieve an input signal with a broad frequency range is to use a chirp signal.
A chirp signal is a sinusoid with a frequency that changes continuously over a certain band
w1 ≤ w ≤ w2 over a certain time period 0 ≤ t ≤ M
¶
µ
(w2 − w1 ) 2
t .
chirp(t) = A cos w1 t +
2M
The instantaneous frequency wi is given by
wi = w1 +
12
(w2 − w1 )
t
M
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
Laboratory #1
We note that the instantaneous frequency increases linearly with time, that is, we observe
a sinusoid with an increasing frequency in time. Time domain representation of the chirp
signal is given in Figure 1.7 and frequency domain representation is given in Figure 1.8.
Because of their broad frequency range, chirp signals are often used in system identification.
In a perfect, noiseless environment like our Simulink experiments, a step input often works
very well. In a more realistic environment, chirp signals are commonly used.
Chirp signal in time domain
1
0.8
0.6
0.4
Chirp(t)
0.2
0
−0.2
−0.4
−0.6
−0.8
−1
0
0.2
0.4
0.6
time(seconds)
0.8
1
Figure 1.7: Chirp signal in the time domain
The University of Michigan, All rights reserved
13
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
Chirp signal in frequency domain
−55
−60
−65
Chirp in dB
−70
−75
−80
−85
−90
−95
−100
−105
−2
10
−1
10
0
10
w(rad/seconds)
1
10
2
10
Figure 1.8: Chirp signal in the frequency domain
1.4.4
Model Validation
Question: So far, we have known a priori what the true model was, and thus we could
determine easily that our identified models were valid (that is, were correct). But if you do
NOT know the true model, how can you know whether or not you have done a good job
of identifying an approximate model?
Answer: You can NEVER know for sure! What you can do is test whether you have NOT
done a bad job. The idea is that you should do two things:
1. Make sure that your identified model fits well the data that you used to identify the
model.
2. Test the identified model on an independent set of data. That is, evaluate how well
the model fits data that you did not use in the identification process.
A validated model is one that has survived a number of tests of this kind. In other words,
a validated model correctly predicts the system’s response to a number of inputs that are
distinct from the data used to identify the model.
Question: How do you even KNOW what order of model to identify? That is, how many
terms to use in the numerator and denominator of the transfer function model?
Answer: Once again, you can NEVER know for sure! There are some very interesting
statistical tests for deciding model order, but we would need EECS 401 in order to even talk
about them. In practice, what one tends to do is to apply Ockham’s Razor: between
two competing ways of explaining the same phenomenon, choose the simplest
explanation. In other words, choose the LOWEST order model that reasonably fits the
data! Said yet another way, start simple and build up from there!
14
The University of Michigan, All rights reserved
EECS 306
1.5
January 27, 2004, [Grizzle]
Laboratory #1
Worked Examples
Depending on time and interest, some of the following may be covered in the in-class portion
of the laboratory (i.e., in the discussion section). You are responsible for reading all of it as
part of your pre-lab.
1.5.1
Case Study #1
Suppose that you are given a transfer function
H(s) =
10
,
(s2 + 7s + 10)
(1.6)
or, equivalently, the corresponding LTI-ODE
dy(t)
d2 y(t)
+7
+ 10y(t) = 10x(t).
dt
dt
(1.7)
Finding the discrete time model:
num = [10]; % coefficients of the differential equation
den = [1 7 10]; % coefficients of the differential equation
Ts = 0.1;
% seconds
[num_disc,den_disc] = c2d_jwg(num,den,Ts); % difference equation
% difference equation
% a2 y(k+2) + a1 y(k+1) + a0 y(k) = b2 x(k+2) + b1 x(k+1) + b0 x(k)
a2 = den_disc(1)
a2 =
1
a1 = den_disc(2)
a1 =
-1.4253
a0 = den_disc(3)
a0 =
0.4966
b2 = num_disc(1)
The University of Michigan, All rights reserved
15
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
b2 =
0
b1 = num_disc(2)
b1 =
0.0398
b0 = num_disc(3)
b0 =
0.0315
Let us compare the output of the continuous-time system to the output of the discretetime system when the input is a step.
Continuous vs discrete time
2
1.8
1.6
1.4
1.2
1
0.8
0.6
0.4
x(t)
x(kTs)
0.2
0
0
0.2
0.4
0.6
0.8
1
t
Figure 1.9: Step input
16
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
Laboratory #1
Continuous vs discrete time
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
y(t)
y(kTs)
0
0.2
0.4
0.6
0.8
1
t
Figure 1.10: Step response of the continuous and discrete time systems
System Identification via Linear Regression using step input
Suppose that you are given a transfer function
H(s) =
10
,
(s2 + 7s + 10)
(1.8)
the corresponding LTI-ODE is
dy(t)
d2 y(t)
+7
+ 10y(t) = 10x(t).
dt
dt
(1.9)
% Transfer function
%
%
10
% H(s) = ----------%
(s+2)(s+5)
%
% LTI_ODE
%
% d^2y
dy
% ------ + 7 ---- + 10 y =
% dt^2
dt
%
Ts = 0.05;
t = 0:Ts:1;
10 x
% seconds
% time
% actual system
num = [10]; % coefficients of the differential equation
den = [1 7 10]; % coefficients of the differential equation
% We use the actual system to obtain the response of the system to a step input
The University of Michigan, All rights reserved
17
Laboratory #1
%
%
%
x
y
January 27, 2004, [Grizzle]
EECS 306
though, in real life, we would have to make measurements of the
inputs and outputs.
= ustp(t-5*Ts); % input
= lsim(num,den,x,t); % lsim simulates the response of LTI systems
m = 1 % order of the numerator to be fitted
m =
1
n = 2 % order of the denominator to be fitted
n =
2
% use the mfile that automates the linear regression
% num_disc returns b1 and b0
% den_disc returns a2, a1 and a0
[num_disc,den_disc]=model_fit(y,x,m,n,t,1)
num_disc =
0.0111
0.0099
den_disc =
1.0000
-1.6836
0.7047
% find the equivalent continuous time model
% num_cont returns the numerator of H(s) coefficients in decreasing powers of s
% den_cont returns the denominator of H(s) coefficients in decreasing powers of s
[num_cont,den_cont] = d2c_jwg(num_disc,den_disc,Ts)
num_cont =
0
0
10.0000
den_cont =
18
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
1.0000
7.0000
Laboratory #1
10.0000
1
0.8
x
0.6
0.4
0.2
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Sys ID: Order numerator = 1 Order denominator = 2
ymeas and ymod
0.6
0.5
0.4
0.3
0.2
0.1
Measured y
Modeled y
0
0
0.1
0.2
0.3
0.4
0.5
Time t
0.6
0.7
0.8
0.9
1
Figure 1.11: ID result via linear regression using step input
Validation of the model: Since we used a step signal to identify the model, we must
use some other signal to validate the identified model.
% define an input other than the step used in the identification of model
% this new input is sometimes called an independent data set.
x_ind = ustp(t-2*Ts) + ustp(t-5*Ts) + ustp(t-10*Ts);
% Use the actual system to obtain the response of the system to the input
% This is in lieu of an experiment....
y_ind_real = lsim(num,den,x_ind,t); % lsim simulates the response of LTI systems
% find the response of the identified system to the independent input x
y_ind_id = lsim(num_cont,den_cont,x_ind,t);
The University of Michigan, All rights reserved
19
Laboratory #1
January 27, 2004, [Grizzle]
Independent input x
EECS 306
(t)
ind
3
2.5
2
1.5
1
0.5
0
0
0.1
0.2
0.3
0.4
0.5
t(seconds)
0.6
0.7
0.8
0.9
1
Figure 1.12: Input that is different than the one used in the identification
Validation with independent set of data
2
1.8
1.6
1.4
1.2
1
0.8
0.6
0.4
0.2
Response of the actual system
Response of the identified system
0
0
0.1
0.2
0.3
0.4
0.5
t(seconds)
0.6
0.7
0.8
0.9
1
Figure 1.13: Comparison of the responses of the actual system and the identified system to
the validation input of Figure 1.12
In this case, we see that the identified model and the system correspond perfectly on
this new data set, and hence we accept the identified model as being validated. In practice,
at this point, we would run several more tests on independent inputs. Then we would have
to ask ourselves if there were significant errors between the model and the system on the
validation data. If there were significant errors, we would use (part of) the validation data to
improve our identified model, and then we would re-do the validation process. We will not
emphasize this aspect of validation in our laboratory exercises because it is time consuming.
Remark: In point of fact, what you are doing in the validation phase is attempting to
20
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
Laboratory #1
invalidate the model by testing it each time on independent data. If after several attempts
you fail in invalidating the model, then you accept the model as valid. However, you can
NEVER prove that a model is valid. You can only assure yourself that it has a small
probability of being (grossly) invalid. Philosophically, this is very similar to how things
work in physics or chemistry. A given theory, such as Newtonian mechanics, cannot be
proven. The theory can only be tested (validated) against data. If extensive experiments
do not invalidate the theory, then it is accepted....until improved measurements come along
that motivate the need for a different theory (e.g., relativity, quantum mechanics, string
theory, super symmetry, etc.).
System Identification via Linear Regression using a Chirp input
A chirp signal is used instead of a step as the input signal.
% Transfer function
%
%
10
% H(s) = ----------%
(s+2)(s+5)
%
% LTI_ODE
%
% d^2y
dy
% ------ + 7 ---- + 10 y =
% dt^2
dt
%
10 x
% parameters for the chirp signal
%
(w2-w1)
% chirp(t) = (w1*t + ------- t^2 )
%
2M
%
w1 = 0; % instantenous frequency at t = 0
w2 = 2*pi*20; % instantenous frequency at t=t1
M = 1;
Ts = 0.001 % select sampling rate
Ts =
1.00e-003
t = 0:Ts:M; % define the time range
f0 = w1/(2*pi); % matlab needs the parameters given in Hertz
f1 = w2/(2*pi); % matlab needs the parameters given in Hertz
t1 = 1/(2*M);
The University of Michigan, All rights reserved
21
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
% generates samples of a linear swept-frequency signal
% at the instances defined in t
x = chirp(t,f0,t1,f1,'linear');
% actual system
num = [10]; % coefficients of the differential equation
den = [1 7 10]; % coefficients of the differential equation
% Use the actual system to get the response of the system to the Chirp input
%
%
sys=tf(num,den); %tells MATLAB that the system is a transfer function;
%
see help tf and help ltimodels.
%
%
y = lsim(sys,x,t,[],'zoh'); % lsim simulates the response of LTI systems.
% By using the 'zoh' option, the input is held constant between samples. See 'help lsim'.
% We did not have to do this with a step input because it is constant between samples.
m = 1 % order of the numerator to be fitted
m =
1
n = 2 % order of the denominator to be fitted
n =
2
% use the mfile that automates the linear regression
% num_disc returns b1 and b0
% den_disc returns a2, a1 and a0
[num_disc,den_disc]=model_fit(y,x,m,n,t,1);
% find the equivalent continuous time model
% num_cont returns the numerator of H(s) coefficients in decreasing powers of s
% den_cont returns the denominator of H(s) coefficients in decreasing powers of s
[num_cont,den_cont] = d2c_jwg(num_disc,den_disc,Ts)
num_cont =
0
22
-0.0000
10.0000
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
Laboratory #1
den_cont =
1.0000
7.0000
10.0000
1
x
0.5
0
−0.5
−1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Sys ID: Order numerator = 1 Order denominator = 2
Measured y
Modeled y
ymeas and ymod
0.06
0.05
0.04
0.03
0.02
0.01
0
0
0.1
0.2
0.3
0.4
0.5
Time t
0.6
0.7
0.8
0.9
1
Figure 1.14: ID result via linear regression using Chirp signal as input
Validate the identified model by comparing the responses of the actual system and the
identified system.
% define an input other than the chirp signal used in the identification of model
% this new input is called independent set of data
x_ind = urmp(t-0.2) - 2* urmp(t-0.4) + urmp(t-0.8);
% Use the actual system to get the response of the system to the input
%
% In real life we do not know the system. We make measurements at the output
% to get the response of the system to the input
%
sys=tf(num,den); %tells MATLAB that the system is a transfer function;
%
see help tf and help ltimodels.
%
%
y_ind_real = lsim(sys,x_ind,t,[],'zoh'); % lsim simulates the response of LTI systems.
% By using the 'zoh' option, the input is held constant between samples. See 'help lsim'.
% We did not have to do this with a step input because it is constant between samples.
The University of Michigan, All rights reserved
23
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
% find the response of the identified system to the independent input x
sys_id_cont=tf(num_cont,den_cont);
y_ind_id = lsim(sys_id_cont,x_ind,t,[],'zoh'); %
Independent input xind(t)
0.2
0.15
0.1
0.05
0
−0.05
−0.1
−0.15
−0.2
−0.25
0
0.1
0.2
0.3
0.4
0.5
t(seconds)
0.6
0.7
0.8
0.9
1
Figure 1.15: Input that is different than the chirp used in the identification
Validation with independent set of data
0.05
0.04
0.03
0.02
0.01
0
−0.01
Response of the actual system
Response of the identified system
−0.02
0
0.1
0.2
0.3
0.4
0.5
t(seconds)
0.6
0.7
0.8
0.9
1
Figure 1.16: Comparison of the responses of the actual system and the identified system to
the input in Figure 1.15
We note that the validation was successful. If only it were always this simple!
24
The University of Michigan, All rights reserved
EECS 306
1.5.2
January 27, 2004, [Grizzle]
Laboratory #1
Case Study #2
Suppose that you are given a system as a black box and you are asked to identify the system.
The term black box refers to the (all-too-common) situation where you are not very sure
of the physical principles of the system being considered. For us, we will use a black box
modelled in Simulink. We will apply system identification by using both step and chirp
inputs.
To open the Simulink model, first open Matlab and then “cd” to the directory where
you placed the files for this laboratory. Then, in the workspace, type
>> labdemo_cs02_simulink_model
If you have problems, within Matlab type “ls” and make sure that you see the file
“labdemo cs02 simulink model.mdl”. If you do not see it, then you are not in the proper
directory, and must re-do the “cd” (change directory) command. To see which directory
you are in, type “pwd”.
t
Set the value to 1 for a step input,
2 for a chirp signal, and 3
to use the signal generator.
Clock
send time to workspace
Zero-Order
Hold2
x
Input 2 Workspace
1
Constant
s-1
y
den(s)
Step
Chirp Signal
Multiport
Switch
Zero-Order
Hold
Transfer Fcn
Zero-Order
Hold1
Output 2 Workspace
The zero-order hold makes
sure the signal is held constant
over a sample period.
Signal
Generator
Figure 1.17: Simulink model used in Case Study #2.
System Identification via Linear Regression using a Step Input
We use the Simulink model to apply an input step signal to the system (see Figure
1.17); this is the default set-up of the model. We select the sampling time to be 10msec.
This must be set in the Matlab workspace by typing
>> sampling_time=0.01;
The start and stop times of the simulation have been pre-set to 0 and 10. You can
change these by going to the Simulation pull-down menu, selecting Simulation parameters,
and then clicking on the Solver tab.
To execute the model, we have two options: simply click on the solid right triangle in
the banner immediately above the model, or, under the Simulation pull-down menu, select
Start. Executing the model will write to the workspace the following arrays: t (time), x
(input), and y (output). After running the model, we plot the input and output so that we
can see the system’s response. The Matlab plot commands are skipped.
We first try to fit a model which has numerator of order 1 and denominator of order 2,
i.e, m = 1 and n = 2 in the mfile ”model fit.m”. The Matlab code below identifies the
discrete time model using linear regression (we could have started with m = 0 and n = 1).
The University of Michigan, All rights reserved
25
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
m = 1; % order of the numerator to be fitted
n = 2; % order of the denominator to be fitted
% use the mfile that automates the linear regression
% num_disc returns b1 and b0
% den_disc returns a2, a1 and a0
[num_disc,den_disc]=model_fit(y,x,m,n,t,3);
To find the corresponding continuous-time model, we run this code:
% find the equivalent continuous time model
% num_cont returns the numerator of H(s) coefficients in decreasing powers of s
% den_cont returns the denominator of H(s) coefficients in decreasing powers of s
[num_cont,den_cont] = d2c_jwg(num_disc,den_disc,sampling_time);
Remark: The model fit command automatically compares the response of the identified
model to that of the measured data. If we wanted to independently generate the response
of the identified model, we could use the lsim command, with the ‘zoh’ option, as shown
below:
sys_id=tf(num_cont,den_cont);
y_id=lsim(sys_id,x,t,[],'zoh');
figure(3),plot(t,y_id,'g',t,y,'r'), legend('y_{id}','y')
1
0.8
x
0.6
0.4
0.2
0
0
2
4
6
8
10
Sys ID: Order numerator = 1 Order denominator = 2
ymeas and ymod
0.02
Measured y
Modeled y
0
−0.02
−0.04
−0.06
0
2
4
6
8
10
Time t
Figure 1.18: Step response of the system and the step response of the identified system with
m=1 and n=2.
26
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
Laboratory #1
In Figure 1.18, we observe that the identified system does not fit the model very well.
We therefore increase the order of the system. The result is displayed in Figure 1.19. The
identified system parameters are as follows for the higher-order system
num_cont =
0
den_cont =
1.0000
0.0000
1.0000
-1.0000
12.0000
22.0000
20.0000
1
0.8
x
0.6
0.4
0.2
0
0
2
4
6
8
10
Sys ID: Order numerator = 2 Order denominator = 3
ymeas and ymod
0.02
Measured y
Modeled y
0
−0.02
−0.04
0
2
4
6
8
10
Time t
Figure 1.19: Step response of the system and the step response of the identified system with
m=2 and n=3
From Figure 1.19, we observe that the higher order model fits well. At this point we
cannot be sure whether this is a good model or not, but it certainly appears better than
the lower order system. To see if the identified model is valid we need to do one more thing
and that is to see if the actual system and the identified system give similar responses to
an input other than a step. In engineering practice, you can NEVER skip the validation
step. Here, where the data are perfect and the underlying model really is an LTI system,
the validation step seems uninteresting.
To validate the model, we rearrange our Simulink model to include the identified system
(see Figure 1.20). The Simulink diagram has been pre-set to apply a saw-tooth wave, with
frequency 5 Hz, over a one-second interval. To open the model, do as before: (it is assumed
that Matlab is open and that you are in the directory where you placed the files for this
laboratory) in the workspace, type
>> labdemo_cs02_simulink_validate
The University of Michigan, All rights reserved
27
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
t
Set the value to 1 for a step input,
2 for a chirp signal, and 3
to use the signal generator.
Clock
send time to workspace
Zero-Order
Hold2
x
Input 2 Workspace
3
Constant
s-1
y
den(s)
Step
Multiport
Switch
Transfer Fcn
Zero-Order
Hold
Zero-Order
Hold1
Output 2 Workspace
Chirp Signal
num_cont(s)
y_val
den_cont(s)
Signal
Generator
Transfer Fcn1
Zero-Order
Hold3
Output 2 Workspace1
The zero-order hold makes
sure the signal is held constant
over a sample period.
Figure 1.20: Simulink diagram used in Case Study #2 to validate the model.
We continue with a sampling time of 10msec (it is assumed that you still have in your
workspace sampling time=0.01). This Simulink model will write to the workspace the
arrays: t (time), x (input), y (output of model), and y val (output of identified model).
The model is run by clicking on the solid right triangle in the banner immediately above
the model, or, under the Simulation pull-down menu, select Start. After running the
model, we compare the relevant signals as shown in Figures 1.21 and 1.22) (the Matlab
plot commands are skipped)
Input signal x(t)
1
0.8
0.6
0.4
x(t)
0.2
0
−0.2
−0.4
−0.6
−0.8
−1
0
0.2
0.4
0.6
0.8
1
time
Figure 1.21: An independent input signal.
28
The University of Michigan, All rights reserved
EECS 306
January 27, 2004, [Grizzle]
−3
3
Laboratory #1
Output signal y(t)
x 10
y(kT)
yind(kTs)
2.5
2
1.5
1
0.5
0
−0.5
−1
−1.5
−2
0
0.2
0.4
0.6
0.8
1
time
Figure 1.22: Responses of the actual and identified system to the saw-tooth wave of Figure
1.21.
We note that the responses of the actual and the identified systems to the validation
data agree nicely in Figure 1.22, and thus we accept the identified system as
H(s) =
s3
s−1
.
+ 12s2 + 22s + 20
(1.10)
System Identification via Linear Regression using a Chirp Input
Instead of a step input, we could have used a chirp input, though we will NOT belabor
this point here. If you are curious about this, simply go back to the system model and select
the chirp input by changing the “1” to a “2”. You can then repeat the results.
The University of Michigan, All rights reserved
29
Laboratory #1
1.6
January 27, 2004, [Grizzle]
EECS 306
Pre-lab Assignment
If you have not already done so, go to the class web site and download the file “Lab Sys ID.zip”
Start Matlab, and “cd” to the directory where you unzipped the files for the lab. A precomputed (system response) data set has been prepared for you.
1. Execute the command
load prelab_id_data
This will put the following data in your workspace (use the whos command to see
what you have)
>> load prelab_id_data
>> whos
Name
Size
sampling_time
t
x
y
1x1
501x1
501x1
501x1
Bytes
Class
8
4008
4008
4008
double
double
double
double
array
array
array
array
Grand total is 1504 elements using 12032 bytes
You will see the arrays t (time), x (input), y (output), and the scalar sampling time.
2. Use the command model fit to identify a model of the data.
3. Use the command d2c jwg to determine the corresponding continuous-time transfer
function.
4. 2 points: Turn in the following
(a) The final orders of the model you identified (that is, m and n).
(b) A plot comparing the response of the identified model to the measured data.
(c) The continuous-time transfer function that you identified from the data.
In fact, it is enough to write your name at the top of the plot and the other information
at the bottom of the plot so that you only have one sheet of paper to turn in.
Note: Since you have only one data set, you cannot perform the validation step. You will
do model validation in the actual laboratory.
30
The University of Michigan, All rights reserved
EECS 306
1.7
January 27, 2004, [Grizzle]
Laboratory #1
Laboratory Assignment
Prob 1 This problem is very similar to the Second Case Study. All of the necessary commands
are illustrated there.
(a) Define the variable sampling time in the workspace. Choose a value of 10ms.
(b) Open the Simulink file “lab prob01 simulink model.mdl” by typing
“lab prob01 simulink model” in the work space. This file is used to compute
the input-output response for a continuous-time model. It is pre-set to use a step
input, and to compute t (time), x (input), y (output of model)
(c) Execute the Simulink model and identify a continuous-time model from the
generated data.
(d) Use the Simulink file “lab prob01 simulink validate.mdl” to validate your identified model. You may use any independent input. You may also choose the time
interval over which to perform the validation. In each case it is perfectly fine to
use the default values. The file assumes that your identified model is given by
num cont and den cont.
(e) Turn in (3 points):
i. The model orders m and n and the identified continuous-time transfer function.
ii. A plot comparing the identified model to the measurements that were used
to build the model. Use the subplot command to put the input at the top
and outputs on the bottom.
iii. A plot showing your model validation. Use the subplot command to put
the input at the top and outputs on the bottom.
(f) Note: you can double click on the black box model to see the true system.
Prob 2 This problem will introduce you to a little bit of engineering reality. You will NOT
know the true system model. However, the true system will still be LTI.
(a) Define the variable sampling time in the workspace. A value of 10ms is reasonable.
(b) Open the Simulink file “lab prob02 simulink model.mdl” by typing
“lab prob02 simulink model” in the work space. This file is used to compute
the input-output response for a continuous-time model. It is pre-set to use a
chirp input, and to compute t (time), x (input), y (output of model)
(c) Execute the Simulink model and identify a continuous-time model from the
generated data.
(d) Use the Simulink file “lab prob02 simulink validate.mdl” to validate your identified model. You may use any independent input. You may also choose the time
interval over which to perform the validation. In each case it is perfectly fine to
use the default values. The file assumes that your identified model is given by
num cont and den cont.
(e) Turn in (3 points):
i. The model orders m and n and the identified continuous-time transfer function.
The University of Michigan, All rights reserved
31
Laboratory #1
January 27, 2004, [Grizzle]
EECS 306
ii. A plot comparing the identified model to the measurements that were used
to build the model. Use the subplot command to put the input at the top
and outputs on the bottom.
iii. A plot showing your model validation. Use the subplot command to put
the input at the top and outputs on the bottom.
iv. Note: the true system has been effectively hidden from you! You look all
you want in the files provided to you and never figure it out.....
Prob 3 This problem will introduce you to a little bit more of engineering reality. You will
NOT know the true system model. Moreover, the true system will be time-invariant
and nonlinear. You will have to identify an approximate linear model.
(a) Define the variable sampling time in the workspace. A value of 10ms is still
reasonable.
(b) Open the Simulink file “lab prob03 simulink model.mdl” by typing
“lab prob03 simulink model” in the work space. This file is used to compute
the input-output response for a continuous-time model. It is pre-set to use a
chirp input, and to compute t (time), x (input), y (output of model). You are
free to select a different input. Because the system is nonlinear, in engineering
practice, we would have to carefully select the input magnitude. Here, it is assumed that a preliminary study has determined that we will be operating the
system with inputs that have a magnitude between zero and 1.50.
(c) Execute the Simulink model and identify a continuous-time model from the
generated data. Try at least two different model orders.
(d) Use the Simulink file “lab prob03 simulink validate.mdl” to validate your identified model. You may use any independent input. You may also choose the
time interval over which to perform the validation. The file assumes that your
identified model is given by num cont and den cont.
(e) Turn in (2 points):
i. Your model orders m and n and the corresponding identified continuous-time
transfer function.
ii. A plot comparing the identified model to the measurements that were used
to build the model. Use the subplot command to put the input at the top
and outputs on the bottom.
iii. One or more plots showing your model validation. For each plot, use the
subplot command to put the input at the top and outputs on the bottom.
Notes: In reality, all models are approximate! The last problem is worth fewer points
because I do not want you to spend too much time trying to perfect your model. When
you become a paid engineer, you will have additional motivation to really work hard on this
part of the process. For now, I am just trying to make you aware of some of the issues. It is
hoped that you now appreciate that obtaining models is a very do-able process. Moreover,
armed with System ID knowledge, you can build approximate LTI models of mechanical
systems, thermal systems, chemical systems, .... In particular, you, as a Systems Engineer,
are NOT limited to electrical devices! In point of fact, you will often be the glue that brings
together a team of people from disparate engineering disciplines. If you think about it, this
can be a great topic for discussion when you interview for an internship position.
Someday you may wish to learn something about nonlinear models.... :)
32
The University of Michigan, All rights reserved
EECS 306
1.8
January 27, 2004, [Grizzle]
Laboratory #1
References
1. Lennart Ljung, System Identification: Theory for the User, Prentice Hall PTR, 1999.
2. T.Soderstrom and P.Stoica, System Identification, Prentice Hall, 1989
3. Matlab document set “ident.pdf”
The University of Michigan, All rights reserved
33
EECS 306
October 30, 2003, Release 0.1
Laboratory #2
Laboratory # 2
Application to Communication
Systems
2.1
Amplitude Modulation
Read sections 5.2-5.4 of Haykin and Van Veen.
In this laboratory, you are going to simulate an AM radio receiver. The block diagram
for this process is given in Figure 2.1.
y(t)
v(t)
cos(2pf0t)
|s(t)|
s(t)
2pDfIF
B(w)
AB
z(t)
Rectify
BPF
LPF
L(w)
2pDfIF
AL
w(rad/sec)
w(rad/sec)
-2pfIF
2pfIF
-2pfLP
2pfLP
Figure 2.1: Block diagram of the AM radio receiver.
Suppose y(t) = x1 (t) cos(2πfc1 t) + x2 (t) cos(2πfc2 t) where x1 (t) and x2 (t) are nonnegative real valued signals with absolute bandwidths of 2πfB . The ideal bandpass filter is
centered at the frequency 2πfBP and assign ∆fBP to 2fB . Then, set the absolute bandwidth of the low pass filter 2πfLP to the maximum of absolute bandwidths of the input
signals, i.e., fLP = fB . given these specifications let us find the output z(t) in terms of
x1 (t) and x2 (t).
As we have seen in the discussion, the derivations are easier in the frequency domain for
this problem. se the modulation property to find V (ω)
V (ω) =
1
[Y (ω − 2πf0 ) + Y (ω + 2πf0 )].
2
(2.1)
Similarly, Y (ω) is found using the modulation
Y (ω) =
1
1
[X1 (ω − 2πfc1 ) + X1 (ω + 2πfc1 )] + [X2 (ω − 2πfc2 ) + X2 (ω + 2πfc2 )].
2
2
The University of Michigan, All rights reserved
(2.2)
1
Laboratory #2
October 30, 2003, Release 0.1
EECS 306
If substitute for Y (ω) in Equation (2.1), then
V (ω)
1
[X1 (ω − 2π(fc1 + f0 )) + X1 (ω + 2π(fc1 − f0 ))]
4
1
[X1 (ω − 2π(fc1 − f0 )) + X1 (ω + 2π(fc1 + f0 ))]
4
1
[X2 (ω − 2π(fc2 + f0 )) + X2 (ω + 2π(fc2 − f0 ))]
4
1
[X2 (ω − 2π(fc2 − f0 )) + X2 (ω + 2π(fc2 + f0 ))].
4
=
+
+
+
(2.3)
When v(t) is passed through the BPF only the part of V (ω) around ω = ±2πfBP
survives. Realize that in Equation (2.3), if we select f0 such that fc1 ± f0 = ±fIF and
(fc2 ± f0 ) ∈
/ [±fIF − ∆fIF , ±fIF + ∆fIF ], then
S(ω) =
AB
[X1 (ω − 2πfIF ) + X1 (ω + 2πfIF )].
4
(2.4)
From Equation (2.4), s(t) is found as follows
s(t) =
AB
x1 (t) cos(2πfIF t).
2
(2.5)
In discussion (notes #5), given s(t) in Equation (2.5), F {|s(t)|} is derived as follows
F {|s(t)|} =
=
AB
F
2π
AB
4
½
¾
1
x1 (t) ∗ F {| cos(2πfIF t)|}
(2.6)
2
∞
X
P [k] [X1 (ω − (k + 1)2πfIF ) + X1 (ω − (k − 1)2πfIF )] (2.7)
k=−∞
where
½
P [k] =
2 jkπ/2
−j πk
e
, k 6= 0
.
0, k = 0
(2.8)
The output of the LPF block passes the frequencies between −2πfB and 2πfB . In
addition to this, the absolute bandwidth of x1 (t) and x2 (t) is 200π. Thus, when the input
is filtered through LPF block, only the components around ω = 0 survives. So we find Z(ω)
as follows
AB AL
AB AL
Z(ω) =
(P [1] + P [−1])X1 (ω) =
X1 (ω).
(2.9)
4
π
Finally, we write the output of the system in terms of x1 (t) as follows
z(t) =
AB AL
x1 (t)
π
(2.10)
Similar argument follows if we select f0 such that fc2 ± f0 = fIF and (fc1 ± f0 ) ∈
/
[±fIF − ∆fIF , ±fIF + ∆fIF ]. In this case, the output of the system is in terms of x2 (t) as
follows
AB AL
x2 (t)
z(t) =
(2.11)
π
2.2
Butterworth Filters
Read section 8.5.1 of of Haykin and Van Veen on Butterworth filters.
2
The University of Michigan, All rights reserved
EECS 306
2.3
October 30, 2003, Release 0.1
Laboratory #2
Laboratory Assignment
1. Load the model file “AMODULATION.mdl”. This is an analog model file that simulates
the block diagram in Figure 2.1.
Figure 2.2: Amplitude modulation analog model file.
The BPF is an Butterworth bandpass filter of order 8 centered at the frequency of
4000πrad/sec with lower passband edge frequency of 3800πrad/sec and upper passband edge frequency of 4200πrad/sec. The LPF is an Butterworth low pass filter of
order 8 with cutoff passband edge frequency of 150πrad/sec.
Suppose
y(t) = x1 (t) cos(1000πt) + x2 (t) cos(9000πt),
and
x1 (t) = 1 + cos(50πt),
x2 (t) = 1 + cos(100πt).
(a) Derive the output signal z(t) analytically in terms of x1 (t) and x2 (t) for the
following modulation frequencies
i. ω0 = 5000π,
ii. ω0 = 3000π,
iii. ω0 = 13000π.
(b) You change the modulation frequency by double clicking on the block “Sine Wave Modulator”.
Then, block properties window pops up as seen in Figure 2.3.
Run the model file “AMODULATION.mdl” for the following modulation frequencies
i. ω0 = 5000π,
ii. ω0 = 3000π,
iii. ω0 = 13000π.
Turn in the plots of the output z(t) for each modulation frequency. Are the output
z(t) plots consistent with your analytical derivations in the previous part?
The University of Michigan, All rights reserved
3
Laboratory #2
October 30, 2003, Release 0.1
EECS 306
Figure 2.3: Changing the modulation frequency.
Note: You can solve for the Fourier transformations of the signals v(t), s(t), |s(t)|
and z(t) by double clicking the block at the bottom. However, realize that we work with
the finite data. Then, the mfile a_cont_ft.m does not calculate the Fourier transform
of a signal f (t) but the Fourier transform of f (t)rect(t/W ) where W is the length of
the time span of the signal. That is why when you plot the Fourier transformation of
cos(ω0 t) for example, instead of δ functions settled at ±ω0 you see sinc (∗) functions
centered at ±ω0 .
¤
2. Load the model file “LISTENRADIO.mdl” (it may take sometime to load since it loads
the music data). This is a digital model file that simulates the block diagram in Figure
2.1.
Figure 2.4: Amplitude modulation digital model file.
The specifications of the bandpass filter are as follows:
• Center frequency : 50kHz,
4
The University of Michigan, All rights reserved
EECS 306
October 30, 2003, Release 0.1
Laboratory #2
• Lower stop band frequency: 42kHz,
• Lower pass band frequency: 46kHz,
• Upper stop band frequency: 54kHz,
• Upper pass band frequency: 58kHz,
• Stop band 1 amplitude: 6dB,
• Pass band amplitude: 1dB,
• Stop band 2 amplitude: 12dB.
The specifications of the low pass filter are as follows:
• Pass band frequency: 5kHz,
• Stop band frequency: 8kHz,
• Pass band amplitude: 6dB,
• Stop band amplitude: 24dB.
In the model files these specifications are put in the form that Matlab requires. That
is they are scaled by 2 and divided by the sampling frequency of the music data to get
normalized frequencies. Throughout the assignment you do not need to change any of
the parameters of the filters in the model files.
There are 3 radio stations transmitting music modulated at 30kHz, 40kHz and 50kHz
respectively. The absolute bandwidth of the music signal is 5kHz (consistent with the
pass band frequency of the low pass filter).
The signals of these three stations combine in the air and so the radio receives the
summation of the signal. You can listen to this transmission by double clicking the
“Listen2Receiver” block.
Find the modulation frequencies to listen to each station without hearing the other
stations, i.e., images of the other stations should be filtered out. You can listen to
transmission of the stations by double clicking “Station1@30kHz”, “Station1@40kHz”
and “Station1@50kHz”. To listen to the radio tuned to one of the stations double
click “Listen2Station” block at the bottom.
Turn in the modulation frequencies.
Note: You can view the plots of music data stations are transmitting (both the music
and its modulated version) and their Fourier transformations by double clicking the
Fourier transformation blocks at the bottom.
¤
The University of Michigan, All rights reserved
5
EECS 306
November 18, 2003, Final 1.0
Laboratory #3
Laboratory # 3
Control Laboratory
3.1
Introduction
Engineers use feedback control to modify the behavior of systems. For example, a car does
not naturally maintain a constant speed when you take your foot off the accelerator, but it
will if you engage a cruise control system; an airplane will not naturally land itself, but it
can if the appropriate auto-pilot mode is activated. You can probably think of many more
examples on your own.
In this laboratory exercise, we will explore the ability of feedback to make a system
BIBO stable, and we will explore the ability to make an output hold a desired constant
value. This document contains all facts related to feedback control that you will need to
successfully complete the exercises. You should be able to complete this in less than four
hours.
This document does not review basic things like BIBO stability, poles and the Final
Value Theorem.
3.2
Block Diagrams
In this laboratory we consider control systems in unity feedback configuration. The corresponding block diagram is given in Figure 3.1. Note that the plant is the system that we
are attempting to control. This terminology comes from the chemical processing industry.
R(s) + E(s)
S
r(t) e(t)
C(s)
P(s)
Controller
Plant
Y(s)
y(t)
Figure 3.1: Block diagram of the system with controller.
From Figure 3.1 we obtain the following equations for Y (s) and E(s)
Y (s)
= C(s)P (s)E(s),
(3.1)
E(s)
= R(s) − Y (s).
(3.2)
The University of Michigan, All rights reserved
1
Laboratory #3
November 18, 2003, Final 1.0
EECS 306
If we substitute (3.1) in (3.2), we find the Laplace transform of the error as
E(s) =
1
R(s)
1 + C(s)P (s)
(3.3)
When we substitute (3.3) in (3.1), we find the Laplace transform of the output as
Y (s) =
C(s)P (s)
R(s)
1 + C(s)P (s)
(3.4)
There are many different kinds of controllers. A few of them are described here.
• Proportional controller (P):
C(s) = KP
• Proportional-Derivative controller (PD):
C(s) = KP + KD s
Recall: s ↔
d
dt
• Integral controller (I):
C(s) =
Recall:
1
s
↔
Rt
0
KI
s
( )dτ
• Proportional-Integral controller (PI):
C(s) = KP +
KI
s
• Proportional-Integral-Derivative (PID) controller:
C(s) = KP +
KI
+ KD s
s
Clearly the proportional controller, the integral controller, etc. are all special cases of
the PID controller.
You are probably wondering when do you use each type of controller? Very roughly
speaking, PD controllers are used to modify the dynamic behavior of a system or the stability
of a system, a PI controller is used to improve steady-state error and a PID controller can be
used to achieve all of these objectives at once. Once again, these are very rough guidelines,
and in the hands of an expert, a lot more can be accomplished than what was indicated
here. But for this laboratory, we will not try to be experts!
3.3
How to create block diagram models of the systems
using Simulink?
In this section, we model a unity feedback control system on a first order plant using
Simulink.
2
The University of Michigan, All rights reserved
EECS 306
November 18, 2003, Final 1.0
Laboratory #3
Example 3.1 Consider the block diagram given in Figure 3.1. The transfer functions are
given as follows
1
s+1
=
,
s
s
C(s)
=
1+
P (s)
=
10
s+5
(3.5)
(3.6)
and the input is r(t) = 2u(t).
Creating the block diagram in Simulink
1. Open a new model file, i.e., *.mdl file.
2. Open the Simulink library browser and select “Simulink→Continuous→Transfer Fcn”.
Right click on the diamond shape next to the text “Transfer Fcn”. Holding the button
drag and drop the block onto the model file, i.e., “Lab Example.mdl”. See Figure 3.2.
Figure 3.2: Creating a transfer function block.
3. Rename the block on the model file by double clicking on the text “Transfer Fcn” (see
Figure 3.3).
4. Change the transfer function of the block to P (s): When you put a “Transfer Fcn”
1
block on the model file, the transfer function is s+1
by default. To change the transfer function of the block “Plant” double click on the block. A menu will popup (see
Figure 3.4). Click on “Apply” after you made the changes in “Numerator” and “Denominator”. When you are done updating the properties of the block, click “OK” to
exit.
Caution: When using “Transfer Fcn” block, the degree of the numerator must be equal
to or less than the degree of the denominator. We need something more complex to
design a PID controller.
The University of Michigan, All rights reserved
3
Laboratory #3
November 18, 2003, Final 1.0
EECS 306
Figure 3.3: Renaming the transfer function block.
Figure 3.4: Changing the numerator and denominator of the transfer function block.
5. Create another block as described in steps 1, 2 and 3 to model C(s) (see Figure 3.5).
6. The block diagram is almost complete. Now we put input source and a measuring device
to the output. To add a source to the model go to “Simulink→Sources”. Similarly for
the output go to “Simulink→Sinks”. We select the input to be “Constant” and the
output to be “Scope” (see Figure 3.6).
7. The parameters of a Simulink block can be changed by double clicking on the block in
the model file. To change the value of input, double click on “Constant” block in the
model file. After the value is changed, click “Apply” to make the changes effective in
4
The University of Michigan, All rights reserved
EECS 306
November 18, 2003, Final 1.0
Laboratory #3
Figure 3.5: Creating the transfer function block for the controller.
Figure 3.6: Adding sources and sinks to the model.
The University of Michigan, All rights reserved
5
Laboratory #3
November 18, 2003, Final 1.0
EECS 306
the model. You can exit the menu by clicking “OK”. See Figure 3.7.
Figure 3.7: Changing the parameters of the source.
8. You can save the output of the scope to the workspace. To do this double click on the
“Scope” block in the model. A menu with graph paper will pop up. Click on the circled
button (see Figure 3.8) on this menu. Select “Data History” and enable “Save data
to workspace”. Assign a variable name for the data output. Select “Format” to be
“Matrix(compatible with V2.0-2.3)”. Click “OK” to save the changes and exit.
9. The block diagram is complete. After this you may simulate the model. To change the
simulation parameters select “Simulation→Parameters” in the menu bar of the model
file. See Figure 3.9 for details.
3.4
Steady State Error
A common objective of a control system is for the output of the system to follow a specific
reference signal accurately in steady-state. The error was defined as difference between the
output and the input in the previous section. The steady-state error is the steady-state
value of this error. Formally, the steady-state error ess is defined as follows:
ess = lim e(t),
t→∞
(3.7)
or, using the Final Value Theorem, the steady-state error can also be computed as
ess = lim sE(s)
s→0
(3.8)
if the closed-loop system is BIBO stable.
6
The University of Michigan, All rights reserved
EECS 306
November 18, 2003, Final 1.0
Laboratory #3
Figure 3.8: Changing the properties of the scope.
Figure 3.9: Changing the simulation parameters.
Example 3.2 Consider the block diagram in Figure 3.1. Given C(s) = 1 +
10
P (s) = s+5
and r(t) = 2u(t) find the steady-state error.
From the Laplace transform table
r(t) = 2u(t) ⇒ R(s) =
2
s
1
s
+ 2s,
(3.9)
We first show that the system is BIBO stable by finding the poles of the closed-loop
The University of Michigan, All rights reserved
7
Laboratory #3
November 18, 2003, Final 1.0
EECS 306
system. By (3.4), the transfer function of the closed-loop system is found as
H(s)
Y (s)
R(s)
=
=
1
(3.10)
10
1
s+5 (1 + s + 2s)
10
+ s+5 (1 + 1s + 2s)
2
10(2s + s + 1)
21s2 + 15s + 10
=
(3.11)
(3.12)
√
615
The poles of the closed loop system are p1,2 = − 15
which have negative real
42 ± j 42
parts. Then the closed loop system is BIBO stable. Thus, we can use Final Value Theorem
to find the steady-state error. We substitute C(s), P (s) and R(s) in (3.3). Note that C(s)
is a PID contoller with KP = 1, KI = 1, KD = 2.
sE(s)
1
2
10 s
1 + (1 + 1s + 2s) s+5
2
s+1+2s2 10
1+
s
s+5
= s
(3.13)
=
(3.14)
=
=
2s(s + 5)
s(s + 5) + 10(s + 1 + 2s2 )
2s(s + 5)
21s2 + 15s + 10
∴ ess = lim sE(s) = 0
s→0
(3.15)
(3.16)
(3.17)
Example 3.3 Consider the block diagram in Figure 3.1. Given C(s) = 1 + 2s, P (s) =
and r(t) = 2u(t) find the steady-state error.
From our Laplace transform table
r(t) = 2u(t) ⇒ R(s) =
2
s
10
s+5
(3.18)
We first show that the system is BIBO stable by finding the poles of the closed-loop
system. By (3.4), the transfer function of the closed-loop system is found as
H(s) =
=
=
Y (s)
R(s)
1
10
s+5 (1 + 2s)
10
+ s+5
(1 + 2s)
10(1 + 2s)
21s + 5
(3.19)
(3.20)
(3.21)
5
The closed-loop pole of the system is p1 = − 21
which is a negative real number. Thus
the closed-loop system is BIBO stable. Then we can use the Final Value Theorem to find
the steady-state error. We substitute C(s), P (s) and R(s) in (3.3). Note that C(s) is a PD
8
The University of Michigan, All rights reserved
EECS 306
November 18, 2003, Final 1.0
Laboratory #3
controller with KP = 1, KD = 2,i.e., the integral term is equal to zero.
sE(s)
= s
=
=
1
2
10 s
1 + (1 + 2s) s+5
2(s + 5)
(s + 5) + 10(1 + 2s)
2(s + 5)
21s + 15
∴ lim sE(s) = 2/3
s→0
(3.22)
(3.23)
(3.24)
(3.25)
Note: From Example 2.2 and Example 2.3, we note that the steady-state error of
the unity feedback system is zero when the closed-loop system is BIBO stable and G(s) =
C(s)P (s) has pole at the origin.
3.5
Lab Assignment
Maintaining your posture in an upright position when you are standing is an interesting
control problem. Researchers in Kinesiology, Biomechanics, and Control Theory would like
to know the control algorithms used by the body for standing and other tasks. Here we
will follow an idea explored in the Physiology literature which uses a very simple model to
represent the human body in a standing position, namely, we will use an inverted pendulum
model.
Figure 3.10: Inverted pendulum model of the body.
mL2
d2 θ(t)
− mgL sin(θ(t)) = x(t)
dt2
The University of Michigan, All rights reserved
(3.26)
9
Laboratory #3
November 18, 2003, Final 1.0
EECS 306
m
L
q
x
Figure 3.11: Inverted pendulum model of the body.
where
• g = gravitational constant = 9.81 m/sec2 ,
• L = length of the rod = 1 m,
• m = mass of the rod = 80 kg,
• x = ankle torque in N m.
For |θ| small, sin(θ) ≈ θ, which yields a linear model
mL2
d2 θ(t)
− mgLθ(t) = x(t)
dt2
(3.27)
The input to this system is the ankle torque x(t). Equation (3.27) gives the relationship
between the torque and the angle of the body, θ(t). Thus by changing the torque applied
the angle of the body can be manipulated.
Objectives:
Explore stability of the system at
1. θ∗ = 0,
2. θ∗ = π/40
using
1. x = KP (θ∗ − θ), i.e., proportional control,
2. x = (KP + KD s)(θ∗ − θ), i.e., PD control,
3. x = (KP + KD s +
KI
∗
s )(θ
− θ), i.e., PID control.
The transfer function of the plant can easily be computed from (3.27).
P (s) =
10
1/(mL2 )
Θ(s)
= 2
X(s)
s − g/L
(3.28)
The University of Michigan, All rights reserved
EECS 306
November 18, 2003, Final 1.0
*
Q (s) +
*
q (t) -
S
E(s)
C(s)
e(t)
Laboratory #3
X(s)
1/(mL )
x(t)
s -g/L
Controller
2
Q (s)
2
q(t)
Plant
Figure 3.12: The block diagram of the controlled system.
Exercise 1 [10 points] Find the poles of P (s). Is P (s) BIBO stable? Explain why or why
not.
Exercise 2 [15 points] Consider a proportional controller, i.e., C(s) = KP .
*
Q (s) +
*
q (t) -
S
E(s)
e(t)
X(s)
Kp
x(t)
Controller
2
1/(mL )
2
s -g/L
Q (s)
q(t)
Plant
Figure 3.13: The block diagram of the system with a proportional controller.
Evaluate the transfer function ΘΘ(s)
∗ (s) and find the poles of the transfer function as a
function of KP .
Show that for all values of KP , there exists at least one pole that has a nonnegative real
part. Using this fact we conclude that a proportional controller cannot make the feedback
system BIBO stable. Thus the body is doing something more complex!
Exercise 3 [10 points] Consider a polynomial
s2 + bs + c = 0.
(3.29)
Use the quadratic formula to prove that the roots of this polynomial have negative real
parts if and only if b > 0 and c > 0.
Note 1: If you have a problem proving this fact, please still keep it in mind when doing
the next exercise!
Note 2: In general case of
as2 + bs + c = 0, a 6= 0,
(3.30)
the result is that b and c must be nonzero and have the same sign as a.
Exercise 4 Consider the system with a PD-controller, i.e. C(s) = KP + KD s. See Figure
3.14 for details.
a ) [10 points] Compute the transfer function ΘΘ(s)
∗ (s) . Find the poles and the conditions
on KP and KD such that the poles have negative real parts.
The University of Michigan, All rights reserved
11
Laboratory #3
November 18, 2003, Final 1.0
*
Q (s) +
*
q (t) -
S
E(s)
e(t)
Kp+KDs
Controller
EECS 306
X(s)
1/(mL )
x(t)
s -g/L
2
2
Q (s)
q(t)
Plant
Figure 3.14: The block diagram of the system with a PD-controller.
p
p
b ) [5 point] Choose KP and KD so that the poles are equal to − g/L ± j g/L.
p
p
p
p
Hint: Multiply out (s + (g/L) + j (g/L))(s + (g/L) − j (g/L)). This is the
desired denominator polynomial
of p
the closed-loop system because it will have roots
p
(i.e., poles) equal to − (g/L) ± j (g/L). Hence, all you have to do is find the
denominator polynomial of the closed-loop system as a function of KP and KD and
then solve for KP and KD by matching terms!
Exercise 5 Use KP and KD found in Part b of the previous Exercise 4.
a ) [10 points] Simulate the closed loop system for θ∗ (t) = 0. Is the steady-state error
equal to zero? Explain why or why not. Turn in the plot of θ(t).
b ) [10 points] Simulate the closed loop system for θ∗ (t) = π/40u(t). Is the steady-state
error equal to zero? Explain why or why not. Turn in the plot of θ(t).
Hint: Use Simulink model file “Inverted Pendulum.mdl”. See Figure 3.15.
Exercise 6 [10 points] Here, we will explore a PID-controller design. To simplify matters,
we will show that the design can be accomplished in two steps. Note that
C(s) = KP + KD s +
KI
KD s2 + KP s + KI
=
s
s
(3.31)
Next let,
C1 (s) = K P + K D s {PD controller }
C2 (s) = K̃P + K̃I /s {PI controller }
(3.32)
(3.33)
and show that
C1 (s)C2 (s) =
K D K̃P s2 + (K D K̃I + K P K̃P )s + K P K̃I
s
(3.34)
Comparing (3.31) and (3.34) we get
KD
=
KP
KI
=
=
K D K̃P
K D K̃I + K P K̃P
K P K̃I s
(3.35)
(3.36)
(3.37)
Hence, we can realize a PID controller as the cascade (i.e., product) of a PD controller
and PI controller.
Method to construct a PID contoller:
12
The University of Michigan, All rights reserved
EECS 306
November 18, 2003, Final 1.0
Laboratory #3
Figure 3.15: Inverted pendulum Simulink file.
PI
PD
C2(s)
C1(s)
Controller
Controller
*
X(s)
Q (s) +
S
*
q (t) -
x(t)
Q (s)
P(s)
q(t)
Plant
Figure 3.16: The block diagram of the system with cascade PI and PD controllers.
PD
*
Q (s) +
S
*
q (t) -
X(s)
C1(s)
Controller
x(t)
P(s)
Q (s)
q(t)
Plant
Figure 3.17: The block diagram of the system with PD controller.
1. Suppose that K P and K D have been chosen so that the system in (3.17) with a PD
controller only is BIBO stable.
2. Fact: Under these conditions, for K̃P = 1 and K̃I > 0 sufficiently small, the feedback
system in (3.18) is BIBO stable.
The University of Michigan, All rights reserved
13
Laboratory #3
November 18, 2003, Final 1.0
EECS 306
PID Controller
PI
PD
*
Q (s) +
S
*
q (t) -
X(s)
C2(s)
C1(s)
Controller
Controller
x(t)
P(s)
Q (s)
q(t)
Plant
Figure 3.18: The block diagram of the system with cascade PI and PD controllers.
Use the above fact and your controller from Exercise 4 to compute a PID controller that
will yield a BIBO stable control system. Turn in the values of the coefficients K D , K P , K̃P , K̃I .
Exercise 7 Use K D , K P , K̃P , K̃I from previous exercise
a ) [10 points] Simulate the closed-loop system for θ∗ (t) = 0. Is the steady-state error
zero? Explain why or why not. Turn in the plot of θ(t).
π
b ) [10 points] Simulate the closed-loop system for θ∗ (t) = 40
u(t). Is the steady-state
error zero? Explain why or why not. Turn in the plot of θ(t).
Hint: Use “Inverted Pendulum PID.mdl”. See Figure 3.19.
Figure 3.19: Inverted pendulum Simulink file.
14
The University of Michigan, All rights reserved
EECS 306
November 18, 2003, Final 1.0
Laboratory #3
Exercise 8 Not graded Assume that there is a small time delay in the actuator. In
particular, assume that the applied torque is
x(t) = x(t − T )
(3.38)
where T = 10 msec = 0.01 sec. Then, the new plant equation is given as
mL2
d2 θ(t)
− mgLθ(t) = x(t) = x(t − T )
dt2
This means that
We approximate e−T s by
(3.39)
X(s) = e−T s X(s).
(3.40)
s − 2/T
1 − sT /2
=
.
1 + sT /2
s + 2/T
(3.41)
Repeat Exercise 1-7 except Exercise 3 and Exercise 4 b. For Exercise 5 use KP
and KD that satisfied the conditions in Exercise 4a. Also in Exercise 6 use KP and KD
values found in Exercise 4a for C1 (s), i.e., BIBO stable PD-controller.
−T s/2
(1−s
T
)n
Note: e−T s = eeT s/2 = limn→∞ (1+s2nT n . We have taken n = 1.
2n
Hint 1: The transfer function of the new plant is
P (s) =
Θ(s)
Θ(s) X(s)
=
X(s)
X(s) X(s)
The original plant transfer function P (s) =
approximation of e−T s , we find
X(s)
X(s)
=
P (s) =
s−2/T
s+2/T
Θ(s)
X(s)
(3.42)
is given in (3.28). Using the first
. Thus, the plant transfer function is
(s − 2/T )/(mL2 )
(s2 − g/L)(s + 2/T )
(3.43)
Hint 2: Use “Inverted Pendulum BONUS.mdl” and “Inverted Pendulum PID BONUS.mdl”
for the simulations. See Figure 3.20
Hint 3: Given the polynomial
a0 sn + a1 sn−1 + · · · + an−1 s + an = 0, an 6= 0
(3.44)
where the coefficients are real quantities. If any of the coefficients are zero or negative in
the presence of at least one positive coefficient, there is a root or roots that are imaginary
or that have positive real parts.
For n = 3, all of the roots of the polynomial given in (3.44) has negative real parts if
and only if all the coefficients are positive and a1 a2 > a0 a3 .
The University of Michigan, All rights reserved
15
Laboratory #3
November 18, 2003, Final 1.0
EECS 306
Figure 3.20: Inverted pendulum Simulink file.
Figure 3.21: Inverted pendulum Simulink file.
16
The University of Michigan, All rights reserved
Download