Lab 10 Supplement
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
This prelab is intended to be a little extra practice on frequency response plots, poles and zeros, step responses, and phase margin, to help solidify your understanding while you work on the CCMM lab.
State space will begin with a short pre-prelab next week, and a more serious prelab the week after, followed by the first of two state-space labs.
Quick Tour: Matlab Tools for CT and Frequency Response.
You can use matlab to manipulate continuous-time transfer functions, but there are a few differences between s- and z-domain manipulation. First, you have to tell matlab to use s as the CT transform variable, by typing
>> s = tf('s')
After that, you can define a CT transfer function. For example, suppose your system is described by a set of differential equations
In matlab, if you type
>> H = (1/(s+0.1))*(1/s)*(1/s)
Matlab will response with
H =
1
-------------
s^3 + 0.1 s^2
Then if you type
>> pole(H)
matlab will respond with
ans =
0
0
-0.1000
as you would expect since in CT, two of your poles are at zero.
Many of the matlab commands you've used before translate in the obvious way (feedback, step, etc), and we will also make extensive use of the bode command
bode(H)
For example, consider a system with input x(t) and output y(t) described by a first-order differential equation,
In this case, the system function is H(s) = \frac{1000}{s+1}. We say x(t) is equation to a unit step if x(t)=0 for t < 0, and x(t) = 1 for t \ge 0. To plot the response to the unit step using matlab, in the command window type (be sure you have defined s to matlab using s = tf('s')).
H = 1000/(s+1)
to define the system function to matlab, and then
step(H)
to plot y(t) given x(t) is a unit step. Note that y(t) rises to 1000 with a time constant of one second (about two-thirds of the rise in one second).
The frequency response of this first-order system can be plotted using
bode(H)
A Bode plot with the unity-gain |H(j\omega)|=1 frequency and phase margin denoted can be plotted using
margin(H)
If we use feedback with this first order system, so that
G = feedback(1000/(s+1),1)
In order to plot the locus of poles of G(s) as a function of K_0 of
rlocus(1000/(s+1))
Root locus plots can be used to select a good controller. For example, for third-order system given by
rlocus((s+4)/((s+20)*(s*s+2*s+1)))
hold on
rlocus((s+8)/((s+20)*(s*s+2*s+1)))
rlocus((s+12)/((s+20)*(s*s+2*s+1)))
rlocus((s+16)/((s+20)*(s*s+2*s+1)))
The above commands will generate a plot like the following (where we have recolored the lines and added a legend). Note that the controllers zeros at -4,-8,-12, and -16 generate root loci that have progressively less negative real parts, for worsening stability.
To plot the step response of the feedback system,
step(G)
The frequency response also shows the impact of including the first-order system in a closed loop, as can be seen in the plot generated by
bode(G)
For our third-order example, the step responses for the closed-loop systems can be compared, where notice that we have set a scale factor for each controller so that they all have the same steady-state value, K(j\omega)H(j\omega) for \omega = 0.
step(feedback((240*(s+4)/((s+20)*(s*s+2*s+1))),1))
hold on
step(feedback((120*(s+8)/((s+20)*(s*s+2*s+1))),1))
step(feedback((80*(s+12)/((s+20)*(s*s+2*s+1))),1))
step(feedback((60*(s+16)/((s+20)*(s*s+2*s+1))),1))
In the above plot, the step response for the s+4 controller has the smallest overshoot, unsurprising given the root locus plot. And what about the closed loop frequency response?
bode(feedback((240*(s+4)/((s+20)*(s*s+2*s+1))),1))
hold on
bode(feedback((120*(s+8)/((s+20)*(s*s+2*s+1))),1))
bode(feedback((80*(s+12)/((s+20)*(s*s+2*s+1))),1))
bode(feedback((60*(s+16)/((s+20)*(s*s+2*s+1))),1))
And the phase margin
margin(240*(s+4)/((s+20)*(s*s+2*s+1)))
hold on
margin(120*(s+8)/((s+20)*(s*s+2*s+1)))
margin(80*(s+12)/((s+20)*(s*s+2*s+1)))
margin(60*(s+16)/((s+20)*(s*s+2*s+1)))
Notice that the s+16 controller resulted in a system whose step response had the most overshoot, whose frequency response had the most peaking, and whose phase margin was the smallest. Step response, closed-loop frequency response, and phase margin, they all they all tell the same story. The s+4 controller is more stable.
Now try yourself!
- No such prelab: bode_poles_zeros
- No such prelab: bode_steps
- No such prelab: phasemargin