None
In today's notebook, your challenge is to use everything you've learned about the root locus to learn to place a controller's zero in just the right place so that our system's root locus passes through a desired eigenvalue! This technique can be used to design controllers for higher-order (3rd and above) systems!
In our examples and in this week's (lab 6), we are using "guess and check" to find out the right location for our PI controller's zero. While this is fine, it can take quite a while! An analytical tool that would allow us to place this zero "automatically" would save lots of time!
IMPORTANT: This notebook provides an interactive plot as a tool to help you build understanding. This plot is coded in the Python language, so in order to use Octave language in this notebook, we need a special magic
command at the top of each code cell.
ALSO IMPORTANT: Today's exercise is in a separate notebook so that you don't need the magic
command to complete it.
Before we get started with the Angle Deficiency method, let's explore how the angle criterion for the root locus can be understood graphically.
What we've been doing so far is saying that if the characteristic equation of our closed loop system can be written as $-\frac{1}{K}=G(s)H(s)=\frac{N(s)}{D(s)}$, where $N(s)$ and $D(s)$ are the numerator and denominator polynomials, respectively, we can write the total angle of the transfer function $G(s)H(s)$ as:
$$\angle(G(s)H(s)) = \angle(N(s)) - \angle(D(s))$$When we have had a "trial" eigenvalue $s_1$ to evaluate, to determine if it is or is not on the root locus, we have been evaluating:
$$\left.\angle(G(s)H(s))\right|_{s=s_1} = \left.\angle(N(s))\right|_{s=s_1} - \left. \angle(D(s))\right|_{s=s_1}$$Which is computed by:
$$\angle(N(s))-\angle(D(s)) = \tan^{-1}\left(\frac{\left.Imag(N(s)\right|_{s=s_1})}{\left.Real(N(s)\right|_{s=s_1})}\right)-\tan^{-1}\left(\frac{\left.Imag(D(s)\right|_{s=s_1})}{\left.Real(D(s)\right|_{s=s_1})}\right)$$However, if we consider a factored version of our "open loop transfer function," it will take the form:
$$G(s)H(s) =\frac{N(s)}{D(s)}= A\frac{(s+z_1)(s+z_2)\ldots(s+z_m)}{(s+p_1)(s+p_2)\ldots(s+p_n)}$$Which has $m$ zeros at $s=-z_1,s=-z_2,\ldots,s=-z_m$, and $n$ poles at $s=-p_1,s=-p_2,\ldots,s=-p_n$, any of which might be complex, we can break down this calculation even further. Based on the complex exponential form of a complex number:
$$ s = \left|s\right|e^{j\angle(s)}$$And the fact that $e^{a}e^{b}=e^{a+b}$, we know that multiplying two complex numbers $s_1$ and $s_2$ can be written as:
$$s_1s_2 = \left|s_1\right|\left|s_2\right|e^{j\left(\angle s_1+\angle s_2\right)}$$With this in mind, we can treat each factored zero in $N(s)$ and each factored pole in $D(s)$ as separate complex numbers, and evaluate each at our trial point $s=s_1$, we find that:
$$\left.G(s)H(s)\right|_{s=s_1} = \left|s_1+z_1\right|\left|s_1+z_2\right|\ldots\left|s_m+z_m\right|e^{j(\angle(s_1+z_1)+\angle(s_1+z_2)+\ldots+\angle(s_1+z_m))} - \left|s_1+p_1\right|\left|s_1+p_2\right|\ldots\left|s_n+p_n\right|e^{j(\angle(s_1+p_1)+\angle(s_1+p_2)+\ldots+\angle(s_1+p_n))}$$This may look like a bit of a mess, but it's actually very useful. It allows us to rewrite the angle criterion as:
$$\angle \left.G(s)H(s)\right|_{s=s_1} = (\angle(s_1+z_1)+\angle(s_1+z_2)+\ldots+\angle(s_1+z_m)) - (\angle(s_1+p_1)+\angle(s_1+p_2)+\ldots+\angle(s_1+p_n))=\pm 180 ^\circ$$The usefulness of this form of the angle criterion comes from the fact that each of these individual "pieces" of the overall transfer function evaluated at some trial point $s=s_1$ represents something very special graphically. To see how, let's look at the following pole-zero plot for an "open loop transfer function,"
$$G(s)H(s) = \frac{(s+z_1)(s+z_2)}{(s+p_1)(s+p_2)}=\frac{(s+4-j)(s+4+j)}{(s+1-2j)(s+1+2j)}$$If we'd like to check whether a point $s_1 = -3+2j$ is on the root locus for this system under feedback control, we'll need to apply the angle criterion, as usual. Let's plot our trial point on the s-plane with the poles and zeros of $G(s)H(s)$.
Next, let's look at the very first term in the numerator of the open loop transfer function $G(s)H(s)$,
$$(s+z_1)=(s+4-j)$$and see what this represents, graphically, on the pole-zero plot. If we evaluate $(s+4-j)$ at our "trial point" $s=s_1=-3+2j$, this term turns into
$$(s_1+z_1) = (-3+2j+4-j) = (1+j)$$.
Referring to the figure below, if we draw and arrow to point $s_1$ (blue vector) and an arrow to point $-z_1$ (black vector), it can be scene that $(s_1+z_1) = (-3+2j+4-j) = (1+j)$ is the arrow pointing from the zero to our trial point!. This is the result of simple vector addition as shown in the figure below!
NOTE: Something that can be confusing at this point in learning this technique is that on the pole-zero plot we plot the zero at $s=-z_1$. However, we evaluate $(s+z_1)$ in the transfer function.
You can think of the operation on the pole-zero plot to get the complex number $s_1+z_1$ is actually subtracting the black vector $s=-z_1$ from the blue vector $s_1$ using "tip to tip" vector subtraction. If this does not make sense to you, seek some guidance! This is a very important concept to get nailed down.
In this example, $z_1$ is the negative of the zero itself, so $z_1 = 4-j$. Therefore, the purple arrow, $s_1+z_1$, is the number:
$$s_1+z_1 = (-3+2j)+(4-j) = 1+j$$And this number, when shown with its tail starting at our zero at $-z_1$, points directly at our trial point.
Carrying this concept forward, if we evaluate each of the components in $G\left.(s)H(s)\right|_{s=s_1}$, we can draw each of these points as arrows on the complex plane from each of the poles and zeros of $G(s)H(s)$ to our trial point. This looks more or less like this:
Then, checking the angle criterion of the root locus for this point $s_1 = -3+2j$ is as simple as saying:
$$\angle(\left.G(s)H(s)\right|_{s=s_1}) = \sum \angle(zeros(G(s)H(s))\rightarrow s_1) - \sum \angle(poles(G(s)H(s))\rightarrow s_1)=\pm 180^\circ$$So let's check this trial point for our system using this "new" method (it's still just the angle criterion calculated a different way!). First we need to identify each vector from the poles and zeros of $G(s)H(s)$ to the trial point $s_1$.
\begin{equation} \left\{ \begin{matrix} (s_1+z_1)&=1+j\\ (s_1+z_2)&=1+3j\\ (s_1+p_1)&=-2\\ (s_1+p_2)&=-2+4j \end{matrix} \right. \end{equation}Now, we need to calculate the angles of the vector from all of our poles and zeros of $G(s)H(s)$ to the trial point.
\begin{equation} \left\{ \begin{matrix} \angle(s_1+z_1)&=\tan^{-1}\frac{1}{1}&=\frac{\pi}{4}\\ \angle(s_1+z_2)&=\tan^{-1}\frac{3}{1}&=1.2490\\ \angle(s_1+p_1)&=\tan^{-1}\frac{0}{-2}&=\pi\\ \angle(s_1+p_2)&=\tan^{-1}\frac{4}{-2}&=2.0344 \end{matrix} \right. \end{equation}Finally, to check to see whether $s_1$ is on the root locus for $G(s)H(s)$, we merely apply the formula we developed above. If our point $s_1$ is on the root locus,
$$\angle(\left.G(s)H(s)\right|_{s=s_1}) = \sum \angle(zeros(G(s)H(s))\rightarrow s_1) - \sum \angle(poles(G(s)H(s))\rightarrow s_1)=\pm 180^\circ$$In words, we can write this form of the angle criterion as follows:
If a trial point $s_1$ is on the root locus, the sum of all of the angles of the arrows from the zeros of $G(s)H(s)$ to the trial point minus the sum of all of the angles from the poles of $G(s)H(s)$ to the trial point will be $\pm 180^\circ$.
For this example, this means that:
$$\angle(\left.G(s)H(s)\right|_{s=s_1}) = \frac{\pi}{4}+1.2490-\pi-2.0344 = -3.1416\approx -\pi$$So our point $s_1=-3+2j$ is on the root locus! Could we have determined this without calculating all of these angles individually (in other words, by doing things the way we did them earlier this week)? Yes, BUT this new technique will help us with our next task, which is determining angles of departure from complex poles and angles of arrival to complex zeros on the root locus.
Before we move on, take a look at the interactive plot below, which shows you the concept we've just been discussing for a different system. On the left, you can see the system's open loop poles with the root locus plot and a trial point that you can move around. On the right, you'll see the individual angles from each pole to the trial point, along with the "total angle" of the transfer function $G(s)H(s)$. For the demonstration, the transfer function is of the form:
$$G(s)H(s) = \frac{\omega_{n1}^2\omega_{n2}^2}{(s^2+2\zeta_1\omega_{n1}s+\omega_{n1}^2)(s^2+2\zeta_2\omega_{n2}s+\omega_{n2}^2)}$$The sliders on the plot give you control over where each pole pair is, along with where your trial point is. Take particular note of how the "angles of departure" from the open loop poles are affected by where the poles of $G(s)H(s)$ are on the s-plane to prime you for the next part of this reading. Play around with these sliders so that you get a trial point that IS on the root locus, and watch how the individual angles change. In this example, there are no zeros, so the total angle of $G(s)H(s)$ is equal to $\angle G(s)H(s) = 0-\sum(\angle(poles\rightarrow trial))$.
note: there is a simulation cell with 'hidden' code below. If it doesn't appear, please go to Cell-> Run All
At this point, you probably have a pretty good handle on what it means to sketch a root locus, but you might be wondering how it is used to design controllers for systems that may be too complex for the "direct method" of manipulating the characteristic equation.
This design process is called the angle deficiency method of controller design. The design process consists of a few simple steps:
To illustrate the necessity of steps 2-5 of this process, consider a scenario in which you'd like to control a second-order system with: $$P(s) = \frac{1}{(s+8)(s+12)},H(s)=1$$
Let's say that we'd like to hit closed loop performance with $\zeta=.707$ and $\omega_n=\sqrt{288}\frac{rad}{s}$, which puts our desired closed loop eigenvalue at $s_d=-12+12j$. If you don't remember why, revisit the Week 3 Monday notebook, and its discussion of complex conjugate pole pairs.
Step 1 of the angle deficiency design process says that we should try proportional control first. Under proportional control, our system's root locus looks like this:
So, for this scenario, we will need a controller other than a proportional controller to achieve our performance goals.
To decide which type of controller we'll need, we calculate the "angle deficiency" of the system under proportional control. In other words, we calculate how far from $\angle G(s)H(s) = \pm 180^\circ$ our system is. To do this, let's calculate the angle of the transfer function $G(s)H(s)$ when it is evaluated at $s = s_d=-12+12j$.
We'll use the method we learned for calculating angles of departure and arrival, which is generalizable to any scenario in which we need to find a "missing angle," or angle deficiency, needed to satisfy the angle criterion. In other words, if the point $s_d$ was on the root locus, we would know that
$$\left.\angle(G(s)H(s))\right|_{s=s_d}=\sum(\angle zeros(G(s)H(s))\rightarrow s_d) - \sum(\angle poles(G(s)H(s))\rightarrow s_d)=\pm 180^\circ$$For our example system, the angle equation for the open loop transfer function evaluated at $s=s_d$ can be written:
$$\left.\angle(G(s)H(s))\right|_{s=s_d}=0-\angle p_1 - \angle p_2 = 0 - \tan^{-1}\left(\frac{12}{0}\right) - \tan^{-1}\left(\frac{12}{-4}\right) = 0-90^\circ-108.43^\circ = -198.43^\circ \neq -180^\circ$$As you can see, the point $s_d=-12+12j$ is not on the root locus because the angle of our transfer function $G(s)H(s)$ is not $\pm 180^\circ$. We call the angle $-180^\circ-(-198.43^\circ) = 18.43^\circ$ the angle deficiency of the system, which we usually denote as $\alpha$. Formally, we say that:
$$\alpha = 180 - \left.\angle(G(s)H(s))\right|_{s=s_d}$$This angle deficiency for our example system is positive, which means that the root locus branches would have to bend to the left in order to hit our desired point $s=s_d$. This means, according to the steps above, that that we will likely have the best luck with PD control first. This is the subject of the next section of this reading.
Note: I generally use either $-180^\circ$ or $180^\circ$ for evaluating the angle criterion based on which is closer to the total angle of my transfer function evaluated at a particular point. Notice that if we had evaluated the angle deficiency using $+180^\circ$ for this example, we would have found that $\alpha=378.43^\circ$, which, when $360^\circ$ is subtracted (to avoid repeating angles), gives us an identical answer of $\alpha=18.43^\circ$.
This notebook covers angle deficiency design of PD and PI controllers. Before we begin the angle deficiency design for each controller type, we will take a quick look back at how we can modify the PD, and PI control transfer functions we learned about so that they are applicable to the "canonical" root locus block diagram we've been using. Specifically, recall that a root locus is only useful if we vary one parameter in our controller, so we'll have to factor one value out of our controller in order for root locus analysis to be helpful.
If we have a PD controller with a transfer function $C(s)=K_{sum}(K_p+K_ds)$, or a PD controller with a "summing gain," we generally will factor $K_d$ out of $C(s)$ as follows:
$$C(s) = K_{sum}\left(K_p + K_ds\right)=K_{sum}K_d\left(s+\frac{K_p}{K_d}\right)$$What this does is it explicitly calls out the zero that the PD controller adds to the "forward path" of the control system at $s=-\frac{K_p}{K_d}$. The "summing gain," which scales the entire control signal u(s), allows us to "walk around" the root locus without changing the zero location, which is dictated by the ratio of kp and kd. Changing either one of these would change the zero location.
Let's call that zero location, which we can fix by fixing the ratio $\frac{k_p}{k_d}$, "$z$" and rewrite the controller transfer function again:
$$C(s)= K_{sum}K_d\left(s+z\right)$$Now, let's wrap $K_{sum}K_d$ into one "gain factor" which we'll call $K$, so that the system matches what we drew above.
$$C(s) = KC^\star(s)= K\left(s+z\right)$$Now, we draw the system with the plant $P(s)$ and the controller $C(s)$ as the following block diagram:
Then, when we draw the root locus, we draw the root locus of a system with the "open loop transfer function"
$$G(s)H(s)=C^\star (s)P(s)H(s)$$where we vary the "root locus gain" $K=K_{sum}K_d$. WE WANT to place the zero $s=-z$ in a fixed location so that the root locus will pass through the desired eigenvalue location $s=s_d$. This is one of the advantages of using the "summing gain" $K_{sum}$. That is, varying $K_{sum}$ will allow us to change the root locus gain $K=K_{p}K_{sum}$ without changing the ratio of $\frac{K_p}{K_d}$ (that is, without moving the controller zero).
Before we learn to use the angle deficiency method to solve this problem, let's look once again at our example from the introduction, where we wanted to control a plant with:
$$P(s) = \frac{1}{(s+8)(s+12)}$$We will assume that $H(s)=1$ for algebraic simplicity, and we will look at the system's root locus under PD control with $C^\star(s)=s+z$.
Use the following interactive plot to experiment with how hitting your design target eigenvalue $s_d$ requires you to move the controller zero $-z$ around the s-plane. We plot $s_d$ as a "trial point" in the following figure, and as always, if this point is on the root locus, the total angle of the transfer function $G(s)H(s)$ evaluated at this point must be $\pm 180 ^\circ$.
Note: There is a simulation cell below with "hidden" code. If the interactive sim doesn't appear for you, go to Cell->Run All
TEST THIS: As long as our desired eigenvalue is to the left of $s=-10$, we can "hit it" with the root locus using PD control with proper zero placement.
TEST THIS: Adding a controller zero to the left of $s=-12$ will cause the root locus to make a "loop" and bend to the left. The loop's diameter is controlled by the location of the controller zero at $s=-z = -\frac{K_p}{K_d}$
If our desired eigenvalue $s_d$ has a real component of exactly $s=-10$, we could hit the point using plain old P control. If we did ask for a desired angle $s_d$ with a real component of $-10$, the angle deficiency $\alpha$ of our system under proportional control would always be $0$, meaning that our point was on the root locus!
While we could "experimentally" determine the controller zero location that would allow us to hit a desired point using a tool like the interactive plot above, it is actually much less work to use the angle deficiency $\alpha$ to place our controller zero directly. Looking once again at our angle criterion equation,
$$\left.\angle(G(s)H(s))\right|_{s=s_d}=\sum(\angle zeros(G(s)H(s))\rightarrow s_d) - \sum(\angle poles(G(s)H(s))\rightarrow s_d)=\pm 180^\circ$$and noting that if when we don't achieve this we designate the "angle deficiency" as
$$\alpha = 180 - \left.\angle(G(s)H(s))\right|_{s=s_d}$$It seems as if placing our controller zero at an angle $\alpha$ will ensure that our system's root locus touches our desired point! Remember that our system transfer function under PD control is:
$$G(s)H(s) = \frac{s+z}{(s+8)(s+12)}$$Recall that it was simply $G(s)H(s) = \frac{1}{(s+8)(s+12)}$ under P control. Our unknown zero location turns the angle criterion equation into:
$$\left.\angle(G(s)H(s))\right|_{s=s_d} = \alpha_z -\angle p_1 - \angle p_2 = \pm 180^\circ$$Graphically, this scenario looks like this:
To find the controller zero $-z$, we use the angle deficiency. This time, we force the angle deficiency to be zero by solving for the unknown angle $\alpha_z$.
$$\left.\angle(G(s)H(s))\right|_{s=s_d}=\alpha_z-\angle p_1 - \angle p_2 = \alpha_z - \tan^{-1}\left(\frac{12}{0}\right) - \tan^{-1}\left(\frac{12}{-4}\right) = -180^\circ$$Solving this gives $\alpha=18.43^\circ$. Then, looking at the triangle with sides $h$ and $d$ in the figure above, we can calculate that:
$$d=\frac{h}{\tan\alpha_z} = \frac{12}{.333}\approx 36$$This tells us that $-z=-12-d=-48\frac{rad}{s}$. Because our controller transfer function is given by:
$$C(s) = KC^\star(s)=K(s+z) = K_{sum}K_d\left(s+\frac{K_p}{K_d}\right)$$We can now say that $z = \frac{K_p}{K_d}=48$. Unfortunately, we still have to calculate our actual control gains in order to implement our controller!
Our next step toward this is using the magnitude criterion to say that:
$$\left| G(s)H(s)\right|_{s=s_d} = \left|\frac{-1}{K}\right|_{s=s_d}$$Substituting $s_d=-12+12j$ into the magnitude criterion equation gives us:
$$\begin{matrix} \left| G(s)H(s)\right|_{s=s_d} &= \left|\frac{s_d+48}{(s_d+8)(s_d+12)}\right| \\ &= \left|\frac{-12+12j+48}{(-12+12j+8)(-12+12j+12)}\right| \\ &= \left|\frac{\sqrt{36^2+12^2}}{\sqrt{144^2+48^2}}\right| \\ &= 0.25\end{matrix}$$This tells us that $K=K_{sum}K_d=\frac{1}{.25}=4$. But we have only two equations for our three unknowns $K_{sum},K_p,K_d$, so we must "just pick" one of the gains. It is common to choose $K_{sum}=1$, but if the control voltages output by your controller design are either too high for your hardware (motor amplifier, etc) or too low to be useful in the face of the noise expected in your system, you may have to modify your choice for $K_{sum}$. If we assume $K_{sum}=1$, we have enough to solve for $K_p$ and $K_d$. Namely, we obtain:
$K_d = 4$, and $K_p = K_d*z = (4)(48) = 192$. This completes our controller design! The last step is to test our control design and predict its performance. We'll do this using Octave in the cells below. Make sure to run both. We will assume that we'd like a unit step to be the test case for this system. This won't be true for every system.
%load_ext oct2py.ipython
%%octave
s = tf('s');
H = 1;
P = 1/((s+12)*(s+8));
Ksum = 1;
Kp = 192;
Kd = 4;
C = Ksum*(Kp+Kd*s);
G_closedloop = C*P/(1+C*P*H);
%check eigenvalues
[num,den] = tfdata(G_closedloop,'v');
roots(den)%these should include an eig at -12+12j
%magnitude of our step input
r_mag = 1;
%simulate step response
[y,t] = step(r_mag*G_closedloop);
%calculate our error signal
e = r_mag-y;
%calculate error derivative
dedt = [diff(e)./diff(t);0];%pad with a zero at the end
%calculate control voltage from each piece (proportional, derivative)
u_p = Ksum*Kp*e;
u_d = Ksum*Kd*dedt;
u_total = u_p+u_d;
%plot our results
figure()
plot(t,y,'k')
xlabel('Time (s)')
ylabel('System Output y(t)')
figure()
plot(t,u_p,t,u_d,t,u_total)
legend('proportional','derivative','total')
xlabel('Time (s)')
ylabel('control signal')
For this design, we'd have to analyze whether:
Nevertheless, this illustrates an entire loop through the angle deficiency design process for a PD controller.
For the example we just worked, it was sufficient to use PD control to hit our design target. However, what if the desired behavior we wanted meant achieving a pole to the right of the branches of our example system's root locus under proportional control? What if, for instance, we wanted a pole at $s_d=-8+8j$?
Graphically, this would look like:
The angle deficiency for the system under proportional control is:
$$\alpha = 180^\circ - \left.\angle(G(s)H(s))\right|_{s=s_d} = 180^\circ - (0 - \tan^{-1}\frac{8}{0} -\tan^{-1} \frac{8}{4}) = 345.96^\circ = -14.04^\circ$$Because the angle deficiency is negative (the target eigenvalue is to the left of the P-control branch), the rules suggest that we should try PI control.
Let's use a PI controller with a summing gain:
$$C(s) = K_{sum}\left(K_p+\frac{K_i}{s}\right)=K_{sum}\frac{K_ps+K_i}{s}$$We can factor K_p out of this controller as follows:
$$C(s) = K_{sum}K_p\frac{s+\frac{K_i}{K_p}}{s}=K\frac{s+z}{s} = KC^\star(s)$$Which means we can cast our control problem as the following, root-locus-friendly block diagram:
Note that this time the controller adds both a zero and a new pole to the forward path transfer function of the control system. By setting the ratio of $K_i$ and $K_p$, we can specify the location of the forward path transfer function's zero at $s=-z=-\frac{K_i}{K_p}$. Because the controller adds a new pole at the origin to the open-loop transfer function $G(s)H(s) = C^\star (s)P(s)H(s)$, we also change the shape of the root locus! See the interactive plot below, which allows you to place the PI controller's zero to "experimentally" hit a desired point $s=s_d$ on the root locus.
Note: There is an interactive simulation cell below with 'hidden' code. If the simulation doesn't appear for you, go to Cell->Run All
As you play with the interactive plot, notice how the shape of the locus changes when you move the controller zero to different portions of the real axis.
TRY THIS: Watch what happens if the zero is in between the controller pole at $s=0$ and the first plant pole at $s=-8$, if it's in between the two plant poles, or if it's to the left of both plant poles. We could wrestle with the interactive plot to help us place our zero, but just like the PD control design problem, it's far less work to use the angle deficiency to help us place our pole directly.
For our PI controller, we will work with the following controller transfer function:
$$C(s) = K_{sum}K_p\frac{s+\frac{K_i}{K_p}}{s}=K\frac{s+z}{s} = KC^\star(s)$$Which means that our "open loop transfer function" for the root locus is:
$$G(s)H(s) = C^\star P(s)H(s) = \frac{s+z}{s(s+8)(s+12)}$$As before with the PD control example, we will simply apply the angle criterion to our design to find the location of our control zero:
$$\left.\angle(G(s)H(s))\right|_{s=s_d}=\sum(\angle zeros(G(s)H(s))\rightarrow s_d) - \sum(\angle poles(G(s)H(s))\rightarrow s_d)=\pm 180^\circ$$Plotting the angle criterion graphically on a pole-zero plot will allow us to determine the unknown angle from the controller zero to the pole, $\alpha_z$.
Of course, until we enforce the angle criterion numerically, $\alpha_z$ is still unknown. Our drawing of where the controller zero lies on the s-plane could be incorrect, so we won't presume to know exactly how the root locus will look under PI control until we know where our controller zero will end up. To compute $\alpha_z$, we apply the angle criterion:
$$\left. \angle (G(s)H(s))\right|_{s=s_d} = \alpha_z - \angle p_1 - \angle p_2 - \angle p_3 = \alpha_z - \tan^{-1}\frac{8}{-8}-\tan^{-1}\frac{8}{0} - \tan^{-1}\frac{8}{4}=\pm 180^\circ$$Computing these angles yields $\alpha_z = 108.44^\circ$. This tells us that our controller zero is to the right of $s=-8$. Using trigonometry, we can find this zero's exact location at $-z = -5.3325$. Because we didn't draw the root locus for our new "open loop transfer function" above, let's let Python draw it below:
from control import rlocus, TransferFunction #imports the root locus function from python's control library (matlab-like)
from numpy import * #imports matlab-like matrix library
from matplotlib.pyplot import * #imports plotting functions
from scipy.signal import lti,tf2ss #imports functions to make transfer functions
from control import lti
openloop_num = [1, 5.3325]#numerator coefficients in decreasing powers of s
openloop_den = [1,20,96, 0]#denominator coefficients
sys_openloop = TransferFunction(openloop_num,openloop_den)
rlocus(sys_openloop)
plot(-8,8,'ko')
show()
According to Python, our root locus now passes through our design eigenvalue $s_d$!! That's good news. Now, Using the magnitude criterion, we evaluate:
$$\left|G(s)H(s)\right|_{s=s_d} = \left|\frac{-1}{K}\right|$$Evaluating the algebra here yields a root locus gain of $K=95.99$.
Now, for a PI controller, we know that $z=\frac{K_i}{K_p}$, and if we again assume $K_{sum}=1$, we can solve for our controller gains: $K_p = 95.99$, and $K_i = 511.9$.
Last, we'll simulate our design and check out the voltage magnitudes that result from a unit step request on $r(s)$.
%%octave
s = tf('s');
H = 1;
P = 1/((s+12)*(s+8));
Ksum = 1;
Kp = 95.99;
Ki = 511.9;
C = Ksum*(Kp+Ki/s);
G_closedloop = minreal(C*P/(1+C*P*H));
%check eigenvalues
[num,den] = tfdata(G_closedloop,'v');
roots(den)%these should include an eig at -12+12j
%magnitude of our step input
r_mag = 1;
%simulate step response
[y,t] = step(r_mag*G_closedloop);
%calculate our error signal
e = r_mag-y;
%calculate error derivative
[u_i,t] = lsim(Ki/s,e,t);%this simulates the error signal going through the ki/s transfer function.
%calculate control voltage from each piece (proportional, derivative)
u_p = Kp*e;
u_total = Ksum*(u_p+u_i);
%plot our results
figure()
plot(t,y,'k')
xlabel('Time (s)')
ylabel('System Output y(t)')
figure()
plot(t,u_p,t,u_i,t,u_total)
legend('proportional','integral','total')
xlabel('Time (s)')
ylabel('control signal')
Some interesting notes about this design:
If we aren't concerned with the voltage magnitudes, some might argue that PI control was much more successful for this system than PD control (note that PD controller generates a controler signal that is almost 2X what is needed for PI).
However, integral gain of the PI controller drove steady-state error to zero! We asked for $r(s)=1$ in steady state, and the PI controller was able to hit that exactly!
By using the angle criterion, we can place a controller zero at an "unknown angle" that guarantees that our root locus will pass through our design point. This allowed us to design a PD and a PI controller that met our design specifications. We will continue to develop this idea over the next week or two as we use the concept to solve more and more complex problems.