 # Dragon Notes UNDER CONSTRUCTION
Latest content:
 Apr 05 Deep Learning Mar 19 Anomaly Detection - ML Mar 13 +Data Tables Mar 08 Clustering - Machine Learning Feb 28 Support Vector Machines - ML Feb 20 Regression - Data Science

# Control Systems:Solved Problems

$$\bb{Pr1}\$$[Circuit $$\rightarrow$$ State space]: Find the state and output equations for the electrical network shown below if the output vector is $$\bn{y}=[v_{R_2}\ i_{R_2}]^T$$. [Sol]
$$\hspace{55px} \bb{1}$$ Label all the branch currents on the network, as in the figure
$$\hspace{55px} \bb{2}$$ Select the state variables by listing the $$IV$$-relations for all energy storage elements:
$$\ds L\frac{di_L}{dt}=v_L,\ \ C\frac{dv_C}{dt}=i_C\quad \bb{1^*}$$

$$\hspace{55px}$$ Select the state variables to be the differentiated variables: $$i_L, v_C$$.
$$\hspace{55px} \bb{3}$$ Transform the RHS of $$\bb{1^*}$$ into linear combinations of state variables and input source. Applying KVL & KCL,
$$\ds v_L=v_C+i_{R_2}R_2,\ i_{R_2}=i_C+4v_L\Rightarrow v_L=v_C+(i_C+4v_L)R_2$$
$$\Rightarrow\boxed{v_L=\frac{1}{1-4R_2}(v_C+i_CR_2)}\quad \bb{2^*}$$

$$\hspace{55px}$$ To obtain $$v_L$$ in terms of state variables, find $$i_C$$ in terms of state variables. Applying KCL,
\ds \begin{align} i_C &= i(t)-i_{R_1}-i_L \\ &= i(t)-\frac{v_{R_1}}{R_1}-i_L \\ &= \boxed{i(t)-\frac{v_L}{R_1}-i_L=i_C}\quad \bb{3^*}\end{align}
$$\hspace{55px}$$ Rewrite $$\bb{2^*}$$ and $$\bb{3^*}$$ to obtain two simultaneous equations yielding $$v_L$$ and $$i_C$$ as linear combinations of state variables $$i_L$$ and $$v_C$$:
\ds \begin{align} (1-4R_2)v_L-R_2i_C &= v_C \\ -\frac{1}{R_1}v_L-i_C &= i_L-i(t)\end{align}
$$\hspace{55px}$$ Solving for $$v_L$$ and $$i_C$$ yields
\begin{matrix} \begin{align} v_L &= \frac{1}{\Delta}[R_2i_L-v_C-R_2i(t)],\ \ \bb{4^*}\\i_C&=\frac{1}{\Delta}[(1-4R_2)i_L+\frac{1}{R_1}v_C-(1-4R_2)i(t)],\ \ \bb{5^*}\end{align} \hspace{30px}\Delta = -\lrbra{(1-4R_2)+\frac{R_2}{R_1}}. \end{matrix}
$$\hspace{55px}$$ Substituting $$\bb{4^*}$$ and $$\bb{5^*}$$ into $$\bb{1^*}$$ and writing the result in vector-matrix form renders the state equation:
$$\ds \Bxred{\mtx{\dot{i}_L}{\dot{v}_C}=\mtxx{R_2/(L\Delta)}{-1/(L\Delta)}{(1-4R_2)/(C\Delta)}{1/(R_1C\Delta)}\mtx{i_L}{v_C}+\mtx{-R_2/(L\Delta)} {-(1-4R_2)/(C\Delta)}i(t)}$$
$$\hspace{55px}\bb{4}$$ Derive the output equation. Since the output variables are $$v_{R_2}$$ and $$i_{R_2}$$, note that around the mesh containing $$C,L$$ and $$R_2$$,
\ds \begin{align}v_{R_2}&=-v_C+v_L,&&\bb{6^*}\\i_{R_2}&=i_C+4v_L && \bb{7^*}\end{align}

$$\hspace{55px}$$ Substituting $$\bb{4^*}$$ & $$\bb{5^*}$$ into $$\bb{6^*}$$ and $$\bb{7^*}$$, $$v_{R_2}$$ and $$i_{R_2}$$ are obtained as linear combinations of the state variables, $$i_L$$ and $$v_C$$. In vector-matrix
$$\hspace{55px}$$ form, the output equation is
$$\ds \Bxred{\mtx{v_{R_2}}{i_{R_2}}=\mtxx{R_2/\Delta}{-(1+1/\Delta)}{1/\Delta}{(1-4R_1)/(\Delta R_1)}\mtx{i_L}{v_C}+ \mtx{-R_2/\Delta}{-1/\Delta}i(t)}$$
$$\hspace{55px}\vplup$$ Tip: Write KCL/KVL's so to include as many state variables and variables in $$\bb{1^*}$$ as possible, to minimize # of eq's to be solved
$$\bb{Pr2}\$$[Transfer function $$\rightarrow$$ State space]: Find the state-space representation of the transfer function shown below: [Sol]
$$\hspace{55px} \bb{1}$$ Separate the system into two cascaded blocks, as shown below; the first block contains the denominator and the second the numerator. $$\hspace{55px} \bb{2}$$ Write the differential equation for the first block:
\ds \begin{align}\frac{X_1(s)}{R(s)} &= \frac{1}{s^3+9s^2+26s+24} \\ (s^3+9s^2+26s+24)X_1(s) &= R(s) \Rightarrow \\ \dddot{x}_1 + 9\ddot{x}_1 + 26\dot{x}_1 + 24x_1 &= r \ \ \bb{1^*}\end{align}
$$\hspace{55px} \bb{3}$$ Set the state variables:
\ds \begin{align} x_1 &= x_1 \\ x_2 &= \dot{x}_1 \\ x_3 &= \ddot{x}_1 \end{align}
$$\hspace{55px}$$ Differentiating both sides and applying $$\bb{1^*}$$ to find $$\dddot{x}_1=\dot{x}_3$$, we obtain the state equations:
$$\ds\nmttx{\dot{x}_1=}{\dot{x}_2=}{\dot{x}_3=}$$$$\mtxxx{\hspace{-10px}}{x_2\hspace{-10px}}{}{\hspace{-10px}} {\hspace{-10px}}{x_3}{-\ 24x_1\hspace{-10px}}{-\ 26x_2\hspace{-10px}}{-\ 9x_3}$$$$\nmttx{}{}{+\ r\ }$$
$$\hspace{55px}$$ In vector-matrix form,
$$\ds\bxred{\lrbra{\amttx{\dot{x_1}}{\dot{x_2}}{\dot{x_3}}}=\lrbra{\amtxxx{\ph{-2}0}{\ph{-2}1}{\ph{-}0}{\ph{-2}0} {\ph{-2}0}{\ph{-}1}{-24}{-26}{-9}}\lrbra{\amttx{x_1}{x_2}{x_3}}+\lrbra{\amttx{0}{0}{1}}r}$$
$$\hspace{55px} \bb{4}$$ Introduce the effect of the numerator block. Writing in input-output form and taking inverse Laplace transform w/ I.C.'s $$=0$$, we get
\ds \begin{align}C(s)&=(s^2+7s+2)X_1(s)\Rightarrow\\c&=\ddot{x_1}+7\dot{x_1}+2x_1\end{align}
$$\hspace{55px}$$ Rewriting in terms of state variables,
$$\ds y = c(t)=x_3+7x_2+2x_1\Rightarrow$$
$$\bxred{y = [\hspace{1px} 2\ \ 7\ \ 1\hspace{1px} ]\lrbra{\nmttx{x_1}{x_2}{x_3}}}$$
$$\hspace{55px}$$ Thus, the last box "collects" the states and generates the output equation. The equivalent block diagram is hence $$\bb{Pr3}\$$[State space $$\rightarrow$$ Transfer function]: Find the transfer function of the system defined by

$$\ds \bn{\dot{x}}=\lrbra{\amtxxx{\ph{-}0}{\ph{-}1}{\ph{-}0}{\ph{-}0}{\ph{-}0}{\ph{-}1}{-1}{-2}{-3}}\bn{x}+\lrbra{\amttx{10}{0}{0}}u$$, $$\ds \quad y=\lrbra{\hspace{1px}1\ \ 0\ \ 0\hspace{1px}}\bn{x}$$

[Sol]
$$\hspace{55px}$$ Since $$\bn{D}=0$$, the solution revolves around finding the resolvent, $$(s\bn{I}-\bn{A})^{-1}$$, in $$T(s)=\bn{C}(s\bn{I}-\bn{A})^{-1}\bn{B}+\bn{D}\ \bb{1^*}$$. Hence, first find
$$\hspace{55px}\ (s\bn{I}-\bn{A})$$:
$$\ds (s\bn{I}-\bn{A}) = \lrbra{\amtxxx{s}{0}{0}{0}{s}{0}{0}{0}{s}}-\lrbra{\amtxxx{\ph{-}0}{\ph{-}1}{\ph{-}0}{\ph{-}0}{\ph{-}0}{\ph{-}1}{-1}{-2}{-3}} = \lrbra{\amtxxx{s}{-1}{0}{0}{s}{-1}{1}{2}{s+3}}$$
$$\hspace{55px}$$ Now, determine $$(s\bn{I}-\bn{A})^{-1}$$:
$$\ds (s\bn{I}-\bn{A})^{-1} = \frac{\t{adj}(s\bn{I}-\bn{A})}{\t{det}(s\bn{I}-\bn{A})} = \frac{\lrbra{\amtxxx{(s^2+3s+2)}{(s+3)}{1} {-1}{s(s+3)}{s}{-s}{-(2s+1)}{s^2}}}{s^3+3s^2+2s+1}$$
$$\hspace{55px}$$ Substituting into $$\bb{1^*}$$, with $$\bn{B}=[\hspace{1px}10\ \ 0\ \ 0\hspace{1px}]^T$$, and $$\bn{C}=[\hspace{1px}1\ \ 0\ \ 0\hspace{1px}]$$, we obtain
$$\ds \bxred{T(s)=\frac{10(s^2+3s+2)}{s^3+3s^2+2s+1}}$$

$$\bb{Pr4}\$$[Output $$\rightarrow$$ Transfer function](First-order): Given the unit step response below, estimate the system transfer function. [Sol] The output waveform exhibits first-order characteristics: no overshoot and nonzero initial slope. Hence, it's same to assume the system is
first-order, with general unit step response given by
$$\ds C(s)=\frac{1}{s}\cdot\frac{K}{s+a}=\frac{K/a}{s}-\frac{K/a}{s+a}\quad\bb{1^*}$$
Begin by finding the time constant $$a$$: since the output final value is $$\approx 0.72$$, the time constant is evaluated where the curve reaches $$0.63\times 0.72 = 0.45$$, or about $$0.13\ \t{sec}$$. Hence, $$0.13^{-1} = \boxed{a = 7.7}$$.
To find $$K$$, note from $$\bb{1^*}$$ that the forced response reaches a steady-state value of $$K/a=0.72$$. Substituting $$a$$, we find $$\boxed{K=5.54}$$ - and thus the system transfer function is
$$\ds\bxred{G(s)=\frac{5.54}{s+7.7}}$$
Note that the exact system transfer function used in generating the figure was $$G(s)=5/(s+7)$$.

$$\bb{Pr5}\$$[State-variable feedback design]: For plant below, design phase-variable feedback gains to yield $$9.5$$% overshoot and a setting time of $$0.74$$ sec.:
$$\ds G(s)=\frac{20(s+5)}{s(s+1)(s+4)}\quad \bn{[1^*]}$$

[Sol] The solution shall be executed as follows:

: Represent the plant in phase-variable form
: Feed back each phase variable to the input of the plant through a gain $$k_i$$
: Find the char. eq. for the cl-sys. in 
: Decide upon all cl-p locations and determine an equivalent char. eq.
: Equate like coefficients of the char. eqs. from  and  and solve for $$k_i$$.

Begin by obtaining the desired char. eq. Using the transient response requirements, the cl-p's are $$s_{1,2}=-5.4\pm j7.2$$ (see Time Response).
$$\up$$Next, select another cl'p (since sys. is third-order). The cl-sys. will have a zero at $$-5$$, the same as the ol-sys. We could select the third cl-p to cancel the cl-z; however, to demonstrate the effect of the third pole and the design process, including the need for simulation, let us choose $$-5.1$$ instead.
$$\up$$Now draw the signal-flow diagram for the plant, (a): Next feed back all state variables to the control, $$u$$, through gains $$k_i$$, as shown in (b).
From (b), the cl-sys. state equations are:
$$\ds\bn{\dot{x}}=\lrbra{\mtxxx{0}{1}{0}{0}{0}{1}{-k_1}{-(4+k_2)}{-(5+k_3)}}\bn{x}+\lrbra{\amttx{0}{0}{1}}$$$$\quad \bn{[2^*]}$$
$$\dsup y = \lrbra{100\ \ 20\ \ 0}\bn{x}$$

Comparing $$\bn{[2^*]}$$ to $$\bn{[1^*]}$$, we identify the cl-sys. matrix as$$\up$$
$$\ds \bn{A}-\bn{BK} = \lrbra{\mtxxx{0}{1}{0}{0}{0}{1}{-k_1}{-(4+k_2)}{-(5+k_3)}}\hspace{50px}$$

To find the cl-sys. char. eq., form
$$\ds \t{det}(s\bn{I}-(\bn{A}-\bn{BK}))=s^3 + (5+k_3)s^2 + (4+k_2)s + k_1 = 0$$

This equation must match the desired char. eq.,
$$\ds s^3 + 15.9s^2 +136.08s +413.1 = 0$$

- formed from the poles $$s=-5.4+j7.2,-5.4-j7.2,$$ and $$-5.1$$, as determined previously.
$$\up$$Equating the coefficients from prior to eqs, we obtain
$$\bxred{k_1 = 413.1,\ k_2 = 132.08,\ k_3=10.9}$$

Completing the design; the zero term of the cl transfer function is the same as that of the ol-sys, or $$(s+5)$$.
$$\up$$Using $$\bn{[2^*]}$$, we obtain the following state-space representation of the cl-sys:
$$\ds \bn{\dot{x}} = \lrbra{\mtxxx{0}{1}{0}{0}{0}{1}{-413.1}{-136.08}{-15.9}}\bn{x}+\lrbra{\amttx{0}{0}{1}}r$$
$$\dsup y=[100\ 20\ 0]\bn{x}$$

- and the transfer function is thus
$$\ds \bxred{T(s)=\frac{20(s+5)}{s^3+15.9s^2+136.08s+413.1}}$$

A simulation of the cl-sys is shown below; the plot displays a $$11.5$$% overshoot and a setting time of $$0.8$$ sec. A redesign with the third pole canceling the zero at $$-5$$ will yield performance equal to the requirements.
$$\up$$Lastly, since the ss-response approaches $$0.24$$ instead of unity, the ss-error is large - which can be reduced using integral control. 