Root Locus Plot Is Way Off
Mostra commenti meno recenti
If anyone knows how to use matlab, can someone explain what is going wrong.
I am working on a project for a class called Linear Systems. I am plotting a root locus and it is supposed to have a curve that goes through 2 desired poles but its so off and its not even funny. I have a transfer function with desired poles.
This is my code: (The first section is very similar to my professors. Its the second section that is just way off).
sys = tf(0.03965,[5.28e-08,1.856e-05,0.00080187,0]);
rlocus(sys)
hold on;
plot(-7.9,11.85,'rx')
plot(-7.9,-11.85,'rx')
% sys_new = tf([10],[1 5])*tf([1],[1 60])*tf([1],[1 0])*tf([1 13.33],[1])
sys_new = tf(0.03965,[5.28e-08, 1.856e-05, 0.00080187, 0])*tf([1 22.835],1);
figure()
rlocus(sys_new)
hold on;
% plot(-20,20,'rx')
% plot(-20,-20,'rx')
plot(-7.9,11.85,'rx')
plot(-7.9,-11.85,'rx')
The part of the code with % is my professors.


Risposte (4)
Hi Arpad,
Let's take a look at that root locus for the uncompensated system. I asusme that the red x's indicate the desired closed loop pole locations after compensation.
sys = tf(0.03965,[5.28e-08,1.856e-05,0.00080187,0]);
rlocus(sys)
hold on;
plot(-7.9,11.85,'rx')
plot(-7.9,-11.85,'rx')
Now add the compensation, which is a single zero at s = -22.835. Also, it's better use sys to define sysnew to avoid typos or copy/paste errors.
% sys_new = tf([10],[1 5])*tf([1],[1 60])*tf([1],[1 0])*tf([1 13.33],[1])
%sys_new = tf(0.03965,[5.28e-08, 1.856e-05, 0.00080187, 0])*tf([1 22.835],1);
sys_new = sys*tf([1 22.835],1);
figure()
rlocus(sys_new)
hold on;
% plot(-20,20,'rx')
% plot(-20,-20,'rx')
plot(-7.9,11.85,'rx')
plot(-7.9,-11.85,'rx')
So I guess the question is what is the basis for thinking that adding the zero at s = -22 would cause the root locus to go through, or even near, the desired pole locations. As shown, the compensator zero results in a real closed loop pole somewhere between the zero and the plant pole near the orign. If you put the compensator zero to the left of the plant pole at s = -50, the root locus will qualitatively look more like the "proferssor's solution", but the loci will be pulled much further to the left than the desired closed-loop poles. So maybe a single compensator zero isn't sufficient for this plant and the desired closed-loop pole locations.
26 Commenti
Arpad
il 26 Nov 2023
Paul
il 26 Nov 2023
Well, I assume that you're tyring to define compensation such that closed-loop system has poles at the locations indicated by the red x's. One of the nice things about Matlab is that you can quickly try different things and see how things change. Perhaps you should consider modifying the compensation. Apparently a single zero is not sufficient. What can be added to the compensation that would modif the rool locus further?
Arpad
il 26 Nov 2023
Paul
il 26 Nov 2023
Ok. Add a pole and see what happens. Try adding it both the left and the right of the zero.
Arpad
il 26 Nov 2023
Paul
il 26 Nov 2023
Try adding a pole to the second term on the right in this expression and see what happens when you plot the root locus
sys_new = sys*tf([1 22.835],1);
sys = tf(0.03965,[5.28e-08,1.856e-05,0.00080187,0]);
new_pole_location = -22.835;
new_sys = sys * tf(1, [1 -new_pole_location])
%verification
zsys = zpk(sys)
zsys.P{1}
new_zsys = zpk(new_sys)
new_zsys.P{1}
%yup, the new_sys has the same poles as sys but with the extra pole
%specified by new_pole_location
Arpad
il 26 Nov 2023
Arpad
il 26 Nov 2023
Paul
il 26 Nov 2023
It's always better to copy/paste the actual code rather than an image.
How did you come up with the expression for sysnew?
Why not leave sys alone and only modify tf([1 22.835],1) to get the root locus that you want?
Arpad
il 26 Nov 2023
Well, I don't know what your math is, so I'm not sure what you've done, and frankly, at this point, I'm not sure what you're trying to do.
I assume that you have a model of plant, which is defined by sys in your original question
sys = tf(0.03965,[5.28e-08,1.856e-05,0.00080187,0])
and you are trying to define a compensator, for which your starting with
tf([1 22.835],1)
with the goal of getting a closed-loop system that has desired poles at s = -7.9 +- 11.85j.
Is my understanding of the problem correct? If not, you'll need to better explain what the meaning is of sys and of sysnew and how either or both of those relate to the desired closed-loop poles.
Arpad
il 26 Nov 2023
s = tf('s');
ys = tf(0.03965,[5.28e-08,1.856e-05,0.00080187,0])
desired_sys = 1/((s - (-7.9 - 11.85i)) * (s - (-7.9 + 11.85i)))
compensator = desired_sys / ys
%verify
compensated_sys = ys * compensator
compensated_sys - desired_sys
I wondered whether ignoring the high order coefficients of the compensator would be "good enough", since they are on the order of 2e-5 or less. Unfortunately I do not know how to read root locus diagrams, so I can't tell.
s = tf('s');
ys = tf(0.03965,[5.28e-08,1.856e-05,0.00080187,0])
desired_sys = 1/((s - (-7.9 - 11.85i)) * (s - (-7.9 + 11.85i)))
trial_compensator = 0.0008109*s / (0.03965 * s^2 + 0.6265 * s + 8.042)
compensator = desired_sys / ys
compensated_sys = ys * compensator
trial_compensated_sys = ys * trial_compensator
trial_compensated_sys - desired_sys
rlocus(desired_sys)
rlocus(compensated_sys)
rlocus(trial_compensated_sys)
Here is your plant model:
sysplant = tf(0.03965,[5.28e-08,1.856e-05,0.00080187,0])
and here is your initial compensator
syscomp = tf([1 22.835],1)
How would you modify syscomp so that it has one real pole at a value of your choosing, in addition to the zero s = -22.835? In other words, pick a value for the the pole, any value you want, and show the updated form of syscomp.
Paul
il 26 Nov 2023
Also, are you sure you meant for the compensator to have a single zero at s = -22.835? Maybe there is some confusion as to whether the compensator should have a single zero or a single pole?
Paul
il 27 Nov 2023
From this comment:
"Apparently what im supposed to do is introduce a pole that can give me a negative angle (-38.43degrees).(removing the 22.835 pole) "
But you don't have a pole at s = -22.835 in your compensator. Instead, you have a zero at s = -22.835. I suspect you intended that to be a pole, which is why I asked precicely that in the preceding comment.
Why don't you change your compensator to have a single pole at s = -22.835 and and then polot the root locus of sysnew.
Arpad
il 27 Nov 2023
Paul
il 27 Nov 2023
Ok. Let's try to focus on what I'm talking about. Forget about Matlab for now.
Problem statement: Write down a transfer function, call it K(s), that has only a single pole at s = -10.
K(s) = ???
What should the ??? be replaced with to meet the problem statement?
Arpad
il 27 Nov 2023
Let me try to reconstruct what you did.
Here's the transfer function model of the system, or the uncompensated plant, that you started with:
sys = tf(0.03965,[5.28e-08, 1.856e-05, 0.00080187, 0])
First you, found the poles of the system, which are the roots of the denominator polynomial
p = roots(sys.Den{1})
Your calculations were very close.
Next, you defined a desired pole location
pdes = -7.9 + 1i*11.85;
Then, you found the angles from the system poles to the desired pole
angles = 180/pi*angle(pdes - p)
which also track with your caculations.
Because these are the angles to the poles, we take the negative of each and then compute the sum sum
totalangle = -sum(angles)
Now we need add one more pole that will provide an additional
-180 - totalangle
degrees to reach 180.
Suppose we have point in the s-plane at s0 = -22.835.
s0 = -22.835;
The incremental angle relative to pdes is
angle(pdes - s0)*180/pi
The negative of that is basically the angle that we need.
Because we want s0 to contribute a negative angle, should we add s0 into the system as a zero or a pole?
Arpad
il 27 Nov 2023
In your original code you had this term
tf([1 22.835],1)
which has one zero at s0 = -22.835 and no poles. So you need to figure out how to change that tf command to represent a pole at s0 = -22.835 and no zeros. If you don't know how to that, I suggest checking the doc page for tf. Or, it might be more intuitive to use a zpk form and convert it to a tf. For example
tf(zpk(-22.835,[],1)) % same as above.
Strictly speaking, it's not necssary to convert the zpk to a tf. I just did that here for comparison to your original tf.
BTW, that was a nice idea to use the angle criterion to determine the pole location of the compensator.
The Symbolic Toolbox can be helpful in solving a problem like this.
Define the plant and the desired location of the dominant pair of complex poles.
sys = tf(0.03965,[5.28e-08,1.856e-05,0.00080187,0]);
pdes = -7.9+1j*11.85;
Define the plant symbolically
syms s
P(s) = simplify(poly2sym(sys.num{1},s)/poly2sym(sys.den{1},s));
Asusme we want to us a single-pole compensator
syms p real
K(s) = 1/(s + p);
Solve for the value of p that satifsfies the root locus angle criteria
sol.p = solve(angle(P(pdes)*K(pdes))==sym(pi),p);
double(sol.p)
Same value as found above. Plot the root locus using this compensation
figure
rlocus(sys*tf(1,[1 double(sol.p)])),
hold on
plot(pdes,'r*')
plot(conj(pdes),'r*')
axis([-30 0 -70 70])
The compensator pole introduces a breakaway point on the real axis to the left of the desired poles and the loci migrate to the right through the desired pole locations as the gain increases.
Assume we want a compensator with one zero and one pole
syms z real
K(s) = (s+z)/(s+p);
Solve for the locations based on the angle criteria. Because we have one equation in two unknowns, we solve for one in terms of the other. I chose to solve for p in terms of z.
sol = solve(angle(P(pdes)*K(pdes))==sym(pi),p,'ReturnConditions',true);
Pick a value of z. Here, I'm using the value of z as was originally defined in the question.
z = 22.835;
Get the value of p that corresponds to that value of p.
p = double(subs(sol.p,z))
Plot the root locus.
figure
rlocus(sys*tf([1 z],[1 p])),
hold on
plot(pdes,'r*')
plot(conj(pdes),'r*')
axis([-30 0 -70 70])
We see that shifting the compensator pole to lower frequency yields a breakaway point the right of the desired pole locations and the compensator plays its role as an attractor to bring the loci to the left through the desired pole locations before the loci evetually migrate toward the RHP as the gain increases.
Hi @Arpad
I am uncertain about what your professor intends for you to learn. Initially, the problem seems akin to a standard Pole Placement issue. However, upon delving into it for several hours, it emerges as a mathematically challenging problem, particularly if you aim to precisely align the root locus to traverse the two specified closed-loop poles while exhibiting the desired 2nd-order system behavior simultaneously.
From the given complex poles
, a reference 2nd-order system can be formulated as
. Although you suggested an improper compensator, for practical systems, a strictly proper compensator is preferable, wherein the numerator's degree is lower than that of the denominator.
Essentially, as previously mentioned, this problem can be tackled using pole placement only when all desired poles are known, as is the case in most exercises. However, the plant system is of 3rd-order, and only two desired closed-loop poles are known. Hence, the dominant pole approximation method can be employed. You can explore this topic on Google, or it may already be covered in your professor's lectures.
In my proposed solution, I opted for a relatively high-order but strictly proper compensator.
s = tf('s');
% 3rd-order Plant transfer function
Gp = tf(0.03965, [5.28e-8 1.856e-5 0.00080187 0])
% A relatively high-order Compensator (but strictly proper)
a1 = 31264.2848484848;
a2 = 363954426.075654;
a3 = 1849668573733.87;
b1 = 4355207983.5442;
b2 = 45076892441.6564;
b3 = 1052053220570.43;
c1 = 241.562107836302;
d1 = 10.3501124658055;
d2 = c1;
G1 = (b1*s^2 + b2*s + b3)/(s^3 + a1*s^2 + a2*s + a3);
G2 = tf(c1, [1 d1 d2]);
% My compensator formula (maybe it appears in literature, I didn't check)
Gcom = G2*G1/(1 + G1*Gp - G2*G1*Gp);
Gcom = minreal(Gcom)
% Closed-loop system
Gcls = minreal(feedback(Gcom*Gp, 1))
% Check closed-loop system poles
CL_poles = pole(Gcls);
CL_poles(19:20)
% Plot Step response
figure(1)
step(Gcls, 1), hold on
% Compare with the reference 2nd-order Transfer function
Gref = 202.833/(s^2 + 15.8*s + 202.833)
step(Gref, 1), grid on, hold off
legend('Closed-loop system', '2nd-order system')
% Plot Root Locus
figure(2)
rlocus(Gcom*Gp), hold on
plot(-7.9, 11.85, 'rx', 'markersize', 12, 'linewidth', 3)
plot(-7.9, -11.85, 'rx', 'markersize', 12, 'linewidth', 3)
axis([-10 -6 -20 20]), hold off
Hi @Arpad
It seems that employing the place() command is a more efficient approach to solving the pole placement problem. I will leave the task of converting the matrix gain K to the compensator transfer function as an exercise for you. Please verify this with your professor.
% Plant
Gp = tf(0.03965, [5.28e-8 1.856e-5 0.00080187 0])
% Convert Plant TF to State-Space
sys = ss(Gp)
% Make desired closed-loop poles
coef = conv([1 15.8 202.833], [1 7.9e3]); % dominant pole technique
p = roots(coef)
% Find gain matrix K to place closed-loop poles at desired locations
A = sys.A;
B = sys.B;
K = place(A, B, p)
% Closed-loop system
Acl = A - B*K;
syscl = ss(Acl, B, sys.C, sys.D);
N = 1/dcgain(syscl); % Input scaler
syscl = ss(Acl, B*N, sys.C, sys.D);
Pcl = pole(syscl) % if K is correctly designed, then Pcl = p
% Plot Step response
step(syscl), hold on
% Compare with the reference 2nd-order Transfer function
s = tf('s');
Gref = 202.833/(s^2 + 15.8*s + 202.833)
step(Gref, 1), grid on, hold off
legend('Closed-loop system', '2nd-order system')
Based on the description from the OP, the compensated system should form a closed-loop system. The formula for a closed-loop transfer function, when the compensator is placed in series with the plant (ys), is given by:
% closed-loop transfer function (CLTF):
% compensated_sys = (compensator*ys)/(1 + compensator*ys) % actual G/(1 + G)
% desired_sys = (compensator*ys)/(1 + compensator*ys) % desired G/(1 + G)
The OP aims to design the compensator in a way that two of the closed-loop poles are (-7.9 ± 11.85i). When these poles are plotted on the root locus diagram, the locus should traverse the two desired closed-loop poles.
s = tf('s');
ys = tf(0.03965, [5.28e-08, 1.856e-05, 0.00080187, 0])
% Desired system (closed-loop) to maintain unity (1) when s = 1
desired_sys = ((-7.9 - 11.85i)*(-7.9 + 11.85i))/((s - (-7.9 - 11.85i)) * (s - (-7.9 + 11.85i)))
% Compensator (improper, numerator's degree > denominator's degree
% The compensator can be inversely obtained by solving the CLTF equation
compensator = desired_sys/(ys - ys*desired_sys)
% Closed-loop system
compensated_sys = feedback(compensator*ys, 1); % can use feedback() command for CLTF
compensated_sys = minreal(compensated_sys)
The poles (or roots of the denominator) of the compensated system can be checked using this command:
% Check closed-loop poles
CL_poles = pole(compensated_sys)
% Plot the step response of Compensated system and compare with Desired system
figure(1)
step(compensated_sys, 1), hold on
step(desired_sys, 1), grid on, hold off
legend('Compensated system', 'Desired system')
% Plot Root locus
figure(2)
rlocus(compensator*ys), hold on
plot(-7.9, 11.85, 'rx', 'markersize', 12, 'linewidth', 3)
plot(-7.9, -11.85, 'rx', 'markersize', 12, 'linewidth', 3)
axis([-10 -6 -20 20]), hold off
While this method can make the root loci pass through the desired closed-loop poles, the compensator will consequently be improper. Note that the closed-loop poles of the compensated system have six additional poles.
3 Commenti
Arpad
il 27 Nov 2023
Yup, @Arpad. The Angle Deficiency Compensation method is commonly taught in the Root Locus to determine the locations of the compensator's zero(s) and pole(s). As shown in yours and @Paul's calculations, introducing the compensator's pole at
should make the root locus pass through the desired closed-loop poles (see Figure 1). You will also need to make a gain adjustment to move the closed-loop poles to the desired locations (
). However, this method only approximates the desired 2nd-order system (see Figure 2), due to the presence of nearby closed-loop poles. But I think the result is acceptable to your Professor.
Previously, I thought your professor wanted you to drive the closed-loop system to behave "exactly" like the reduced 2nd-order system with two poles at
, producing the desired overshoot and settling time. That's why I introduced the Dominant Closed-loop Poles concept in which you can freely assign the 3rd desired closed-loop negative real pole that is far far away from the dominant closed-loop poles (
).
figure(1)
figure(2)
Sam Chak
il 28 Nov 2023
Hi @Arpad
By the way, these techniques of placing the closed-loop poles in the desired locations fall under the Pole Placement method. I also forgot to mention that the solution to your problem is not unique because there are infinitely many solutions. You can present alternative solutions to your Professor and ask for opinions (considering the pros and cons of each technique).
Categorie
Scopri di più su Classical Control Design in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
















