# Compensator design for control systems

Currently, I'm working on linear control course from Nise's book. In the root-locus design chapter, some methods were explained for lag and lead compensator design which uses root-locus properties. But without these methods, it is possible to calculate the compensator analytically with the following closed-loop formula.

(compensator x system)/(1 + compansetor x system) = desiredClosedLoopSytem

We know the transfer function of the system and the desired system, so we can calculate the compensator and this method works in MATLAB 100%.

I didn't see this method in the control books. Why is this method not used in the literature? My guess is compensator formula could come out with higher orders. But even in this case, we can implement the compensators transfer function in a microcontroller. So is it an issue?

I compared a lead compensator with the mentioned method and it worked perfectly at the simulations.

I will start by posing yet another question, given a system $$\H(s)\$$ why can't we determine a compensator $$\C(s)\$$ such that $$C(s)H(s) = P(s)$$ where $$\P(s)\$$ is the desired system? Well, although it is possible to mathematically find some $$\C(s)\$$ to do that, it can be undesirable to do so. As $$\C(s) = P(s)H^{-1}(s) \$$ can be unstable, and if we calculate $$\C(s) = P(s)\hat{H}^{-1}(s) \$$ based on an estimate of the system, $$\\hat{H}(s)\$$, which differs slightly from $$\H(s)\$$, will also lead to problematic performance (and maybe even instability too.)
Now, going back to the question of finding an arbitrary $$\C(s)\$$ to have $$\ \frac{C(s)H(s)}{1+C(s)H(s)} = P(s)\$$, we have similar problems that won't be clear by looking at $$\\frac{C(s)H(s)}{1+C(s)H(s)}\$$ but will be perceived by looking at the Bode plot, Nyquist plot and so on of the resulting closed-loop system, as you might find that the "desired" $$\C(s)\$$ that makes $$\ \frac{C(s)H(s)}{1+C(s)H(s)} = P(s)\$$ will only work if you know $$\H(s)\$$ perfectly, and for any deviation from $$\H(s)\$$ to the real system will lead to a narrow, or no, gain/phase margin in the experimental Bode plot and others.
The issues will likely show up on the "gang of six" (see Aström & Murray Ch. 10 onward, but in particular section 12.1. Sensitivity Functions, but also 9.4 on Pole/Zero Cancellations) which are sensitivity functions and indicate how likely your current closed-loop configuration is to be affected by noise being injected in different parts of the loop, i.e., you can have sensor noise altering the measured output or have noise in the actuator changing the system in a way different than what the controller actually aimed at. The "gang of six" are the transfer functions modeling the impact of $$\(r,v,w)\$$ on $$\(u,y)\$$, where $$\r\$$ is the reference of the control system, $$\v\$$ is the noise injected on the control effort $$\u\$$, and $$\w\$$ is the noise injected on the output $$\y\$$.
An example, given the system $$\ H(s) = \frac{1}{s-10} \$$ we desire that it behaves as $$\P(s) = \frac{1}{s+100}\$$ after adding the feedback control. So we use your idea and obtain that the controller should be $$\C(s) = \frac{s -10}{s+99}\$$. The controller is a stable transfer function, and $$\frac{C(s)H(s)}{1+C(s)H(s)} = \frac{\frac{s -10}{s+99}\frac{1}{s-10}}{1+\frac{s -10}{s+99}\frac{1}{s-10}} = \frac{\frac{1}{s+99}}{1+\frac{1}{s+99}}= \frac{1}{s+100}=P(s)$$ also checks out, and will be stable. But now lets look at the load disturbance to measurement signal, that is, how a noise in the actuation $$\u\$$ affects the output $$\y\$$. The transfer function will be $$G_{y\xleftarrow{}u}(s) = \frac{H(s)}{1+C(s)H(s)} = \frac{\frac{1}{s-10}}{1+\frac{s -10}{s+99}\frac{1}{s-10}} = \frac{\frac{1}{s-10}}{1+\frac{1}{s+99}} = \frac{s+99}{(s-10)(s+100)}$$