Control System Lab 5
Control System Lab 5
Speed Control
- Using rlocus Matlab command
Drawing the open-loop root locus
Finding the gain using the rlocfind command
Adding a lag controller
Plotting the closed-loop response
From the main problem, the dynamic equations and the open-loop transfer
function of DC Motor Speed are:
For the original problem setup and the derivation of the above equations,
please refer to the Modeling a DC Motor page.
1
Create a new m-file and type in the following commands (refer to main
problem for the details of getting those commands).
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)];
Two arguments in the sgrid command are the damping ratio (zeta) term (0.8
corresponds to a overshoot of 5%), and the natural frequency (Wn) term (=
0 corresponds to no rise time criterion) respectively. The single argument in
the sigrid command is the sigma term (4.6/2 seconds = 2.3). After you have
saved sigma.m file to your directly, run the above m-file in the command
window. You should get the root locus plot shown below:
2
Finding the gain using the rlocfind command
If you recall, we need the settling time and the overshoot to be as small as
possible. Large damping corresponds to points on the root locus near the
real axis. A fast response corresponds to points on the root locus far to the
left of the imaginary axis. To find the gain corresponding to a point on the
root locus, we can use the rlocfind command. We can find the gain and plot
the step response using this gain all at once. To do this, enter the following
commands at the end of your m-file and rerun it.
[k,poles] = rlocfind(num,den)
[numc,denc]=cloop(k*num,den,-
t=0:0.01:3;
step(numc,denc,t)
title('Step response with gain')
Go to the plot and select a point on the root locus half-way between the real
axis and the damping requirement, say at -6+2.5i. Matlab should return the
output similar to the following.
selected_point =
-5.9596 + 2.0513i
k =
poles =
- 00 + 2.0511i
-6.0000 - 2.0511i
3
Note that the values returned in your Matlab command window may not be
exactly the same, but should at least have the same order of magnitude. You
should also get the following plot:
As you can see, the system is overdamped and the settling time is about one
second, so the overshoot and settling time requirements are satisfied. The
only problem we can see from this plot is the steady- state error of about
50%. If we increase the gain to reduce the steady-state error, the overshoot
becomes too large (Try this yourself). We need to add a lag controller to
reduce the steady-state error.
This can be done by changing your m-file to look like the following:
J=0.01;
b=0.1;
4
K=0.01;
R=1;
L=0.5;
num=K;
den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)];
z1=1;
p1=0.01;
numa = [1 z1];
dena = [1 p1];
numb=conv(num,numa);
denb=conv(den,dena);
rlocus(numb,denb)
sgrid
sigrid
title('Root Locus with a lag controller')
numa and dena are the numerator and denominator of the controller,
and numb and denb are the numerator and denominator of the overall open-
loop transfer function.
You should get the following root locus, which looks very similar to the
original one:
5
title('Step response with a lag controller')
Rerun this m-file in the Matlab command window. When prompted to select
a point, pick one that is near the damping requirement (diagonal dotted line).
You should get the a plot similar to the following:
Your gain should be about 20. As you can see the response is not quite
satisfactory. You may also note that even though the gain was selected to
correlate with a position close to the damping criterion, the overshoot is not
even close to five percent. This is due to the effect of the lag controller
kicking in at a later time than the plant. (its pole is slower). What this means
is that we can go beyond the dotted lines that represent the limit, and get the
higher gains without worrying about the overshoot . Rerun your m-file,
place the gain just above the white, dotted line. Keep trying until you get a
satisfactory response. It should look similar to the following (we used a gain
of around 50):
6
The steady-state error is smaller than 1%, and the settling time and
overshoot requirements have been met. As you can see, the design process
for root locus is very much a trial and error process. That is why it is nice to
plot the root locus, pick the gain, and plot the response all in one step. If we
had not been able to get a satisfactory response by choosing the gains, we
could have tried a different lag controller, or even added a lead controller.
7
- Root Locus Controller Design using control system
designer toolbox
Drawing the open-loop root locus
Finding the loop gain
Adding a lag controller
Finding the loop gain with a lag controller
From the main problem, the dynamic equations in the Laplace domain and the open-loop transfer
function of the DC Motor are the following.
The structure of the control system has the form shown in the figure below.
For the original problem setup and the derivation of the above equations, please refer to the DC Motor
Speed: System Modeling page.
For a 1-rad/sec step reference, the design criteria are the following.
J = 0.01;
b = 0.1;
K = 0.01;
R = 1;
L = 0.5;
s = tf('s');
P_motor = K/((J*s+b)*(L*s+R)+K^2);
8
Drawing the open-loop root locus
The main idea of root locus design is to predict the closed-loop response from the root locus plot which depicts
possible closed-loop pole locations and is drawn from the open-loop transfer function. Then by adding zeros
and/or poles via the controller, the root locus can be modified in order to achieve a desired closed-loop response.
We will use for our design the Control System Designer graphical user interface. This tool allows you to
graphically tune the controller via the root locus plot. Let's first view the root locus for the uncompenstated plant.
This is accomplished by adding the command controlSystemDesigner('rlocus', P_motor) to the end of your m-file
and running the file at the command line or by going to the APPS tab of the MATLAB toolstrip and clicking on
the app icon under Control System Analysis and Design.
One window titled Control System Designer will open initially having the form shown in the figure below. In the
window, you will be able to see both the root locus plot and the closed-loop step response of the transfer function
passed via the controlSystemDesigner function. If the string 'rlocus' is omitted from the function call, the default
initial window includes the Bode plot, in addition to the root locus plot and closed-loop step response plot. You
can arrange the position of plots from the VIEW tab of the Control System Designer window. Right-clicking on
the root locus plot and selecting Grid will make your window appear as follows.
9
specific design requirements. The provided regions correspond to a canonical second-order system, but in general
are a good place to start from even for higher-order systems or systems with zeros.
These desired regions can be added to the root locus plot by right-clicking on the plot and choosing Design
Requirements > New from the resulting menu. You can add many design requirements including Settling time,
Percent overshoot, Damping ratio, Natural frequency, and generic Region constraint.
Adding our settling time and percent overshoot requirements to the root locus plot produces the following figure.
The resulting desired region for the closed-loop poles is shown by the unshaded region of the above figure. More
specifically, the two rays centered at the origin represent the overshoot requirement; the smaller the angle these
rays make with the negative real-axis, the less overshoot is allowed. The vertical line at s = -2 represents the
settling time requirement, where the farther to left the closed-loop poles are located the smaller the settling time is.
From examination of the above figure, there are values of the loop gain that will place both closed-loop poles in
the desired region. This can be seen from the fact that the two branches of the root locus are symmetric and pass
through the unshaded region. Furthermore, since the closed-loop system has two poles with no zeros, placing the
closed-loop poles in the shown region will guarantee satisfaction of our transient response requirements.
You can select a specific pair of closed-loop poles from the resulting figure in order to determine the
corresponding loop gain that places the poles at that location. For our system, let's choose to place the closed-loop
poles so that they are located on the vertical branches of the root-locus between the real axis and the boundary of
the overshoot requirement. The pink boxes on the root locus indicate the location of the closed-loop poles for the
current loop gain. Clicking on the pink boxes and dragging them along the root locus to the desired location
automatically modifies the controller to place the closed-loop poles at the indicated position. Let us drag
a closed-loop pole to a location near -6 + 2i. The pole location will be indicated at the bottom of the window along
with the corresponding damping ratio and natural frequency. We can also check the corresponding loop gain in the
lower left corner by clicking on C in the Controllers and Fixed Blocks tab. The loop gain, as we can see in the
figure, is approximately 10.
11
We can check the closed-loop step response for the system with this new gain by moving to the IOTransfer_r2y:
step tab. If you have accidentally closed this tab, you can re-open it from the Control System Designer window
by clicking on the New Plot menu and selecting New Step. In response, a new window titled New Step to
plot will appear. From the Select Responses to Plot menu, then choose IOTransfer_r2y and click the
button Plot. The response of the output y of the closed-loop system for a step reference r will then appear in
the Control System Designer window. You can also identify some characteristics of the step response.
Specifically, right-click on the figure and under Characteristics choose Settling Time. Then repeat for Steady
State. Your figure will appear as shown below.
From inspection of the above, one can see that there is no overshoot and the settling time is less than one second,
therefore, the overshoot and settling time requirements are satisfied. However, we can also observe that the steady-
state error is approximately 50%. If we increase the loop gain to reduce the steady-state error, the overshoot will
become too large. You can see this for yourself by graphically moving the closed-loop poles vertically upward
along the root locus, this corresponds to increasing the loop gain. The step response plot will change automatically
to reflect the modified loop gain. We will attempt to add a lag controller to reduce the steady-state error
requirement while still satisfying the transient requirements.
11
We can use the Control System Designer to design our lag compensator. To make the Control System
Designer have a compensator parameterization corresponding to the one shown above, click on
the Preferences menu at the top of the Control System Designer window. Then From the Options tab, select
a Zero/pole/gain parameterization as shown below.
To add the lag compensator, right click on the root locus plot and select Edit Compensator. To add a pole zero
pair to your compensator, in the Compensator Editor window, right-click the Dynamics table and select Add
Pole/Zero > lag. After that, enter the Real Zero and Real Pole locations as shown in the following figure.
12
Note that the maximum phase lag contributed by the compensator and the frequency where it is located are
updated to match the pole and zero locations chosen.
13
The corresponding closed-loop step response will then update automatically to match the figure shown below.
14
As you can see, the response is not quite satisfactory even though two of the closed-loop poles were placed in the
desired region. The reason for this is because the closed-loop system no longer has the form of a canonical second-
order system. Specifically, there is a third pole on the real axis indicated in the root locus plot above that is outside
of the desired region. The fact that this third pole is to the right of the two conjugate poles placed above means that
it will slow the system response down, that is why the settling time requirement is no longer met. Additionally, the
overshoot requirement is met easily even though the two conjugate poles are near the edge of the allowed region.
This is due again to the third pole which is well damped and tends to dominate the response because it is "slower"
than the other poles. What this means is that we can further increase the loop gain such that the conjugate poles
move beyond the diagonal lines while still meeting the overshoot requirement.
You can now return to the root locus plot and graphically move the conjugate poles farther away from the real
axis; this corresponds to increasing the loop gain. As you move the closed-loop poles a sufficient distance, the
limits of the plot should update automatically. Alternatively, you can change the limits manually by right-clicking
on the root locus and selecting Properties to open the Property Editor. Then you can click on the Limits tab and
change the imaginary axis limits to [-15,15], for example, as shown below.
15
Experiment with different gains (closed-loop pole locations) until you achieve the desired response. Below is the
root locus with a loop gain of 44 and the corresponding closed-loop step response.
16
Now the settling time is less than 2 seconds and the steady-state error and overshoot requirements are still met. As
you can see, the root locus design process requires some trial and error. The Control System Designer is very
helpful in this process. Using the Control System Designer, it is very easy to tune your controller and
immediately see the effect on the root locus and various analysis plots, like the closed-loop step response. If we
had not been able to get a satisfactory response by tuning the loop gain, we could have tried moving the pole and
zero of the lag compensator or we could have tried a different type of dynamic compensator (additional poles
and/or zeros).
17