diff --git a/figs/bode_plot_example_afm.pdf b/figs/bode_plot_example_afm.pdf new file mode 100644 index 0000000..cc192e3 Binary files /dev/null and b/figs/bode_plot_example_afm.pdf differ diff --git a/figs/bode_plot_example_afm.png b/figs/bode_plot_example_afm.png new file mode 100644 index 0000000..2153b95 Binary files /dev/null and b/figs/bode_plot_example_afm.png differ diff --git a/figs/classical_feedback_test_system.pdf b/figs/classical_feedback_test_system.pdf new file mode 100644 index 0000000..2a973aa Binary files /dev/null and b/figs/classical_feedback_test_system.pdf differ diff --git a/figs/classical_feedback_test_system.png b/figs/classical_feedback_test_system.png new file mode 100644 index 0000000..521b6c4 Binary files /dev/null and b/figs/classical_feedback_test_system.png differ diff --git a/figs/classical_feedback_test_system.svg b/figs/classical_feedback_test_system.svg new file mode 100644 index 0000000..384dc5f --- /dev/null +++ b/figs/classical_feedback_test_system.svg @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figs/loop_gain_manual_afm.pdf b/figs/loop_gain_manual_afm.pdf new file mode 100644 index 0000000..00d0db0 Binary files /dev/null and b/figs/loop_gain_manual_afm.pdf differ diff --git a/figs/loop_gain_manual_afm.png b/figs/loop_gain_manual_afm.png new file mode 100644 index 0000000..2dd5f56 Binary files /dev/null and b/figs/loop_gain_manual_afm.png differ diff --git a/figs/mech_sys_1dof_inertial_contr.pdf b/figs/mech_sys_1dof_inertial_contr.pdf new file mode 100644 index 0000000..352600b Binary files /dev/null and b/figs/mech_sys_1dof_inertial_contr.pdf differ diff --git a/figs/mech_sys_1dof_inertial_contr.png b/figs/mech_sys_1dof_inertial_contr.png new file mode 100644 index 0000000..b29b45e Binary files /dev/null and b/figs/mech_sys_1dof_inertial_contr.png differ diff --git a/figs/mech_sys_1dof_inertial_contr.svg b/figs/mech_sys_1dof_inertial_contr.svg new file mode 100644 index 0000000..d3dfda5 --- /dev/null +++ b/figs/mech_sys_1dof_inertial_contr.svg @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/figs/open_loop_shaping.pdf b/figs/open_loop_shaping.pdf new file mode 100644 index 0000000..a9dc5df Binary files /dev/null and b/figs/open_loop_shaping.pdf differ diff --git a/figs/open_loop_shaping.png b/figs/open_loop_shaping.png new file mode 100644 index 0000000..38fcae7 Binary files /dev/null and b/figs/open_loop_shaping.png differ diff --git a/figs/open_loop_shaping.svg b/figs/open_loop_shaping.svg new file mode 100644 index 0000000..bbb325b --- /dev/null +++ b/figs/open_loop_shaping.svg @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/index.html b/index.html index 31eece2..3bb2be2 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Robust Control - \(\mathcal{H}_\infty\) Synthesis @@ -30,29 +30,46 @@

Table of Contents

-
-

1 Introduction to the Control Methodology - Model Based Control

+
+

1 Introduction to the Control Methodology - Model Based Control

+
+
+

1.1 Control Methodology

+

-The typical methodology when applying Model Based Control to a plant is schematically shown in Figure 1. +The typical methodology when applying Model Based Control to a plant is schematically shown in Figure 1. It consists of three steps:

    @@ -66,7 +83,7 @@ It consists of three steps:
-
+

control-procedure.png

Figure 1: Typical Methodoly for Model Based Control

@@ -78,9 +95,9 @@ In this document, we will mainly focus on steps 2 and 3.
-
-

2 Some Background: From Classical Control to Robust Control

-
+
+

1.2 Some Background: From Classical Control to Robust Control

+

Classical Control (1930)

@@ -156,10 +173,363 @@ Robust Control (1980)
-
-

3 The \(\mathcal{H}_\infty\) Norm

+ +
+

1.3 Example System

+
+

+Let’s consider the test-system shown in Figure 2. +The notations used are listed in Table 1. +

+ + +
+

mech_sys_1dof_inertial_contr.png +

+

Figure 2: Test System consisting of a payload with a mass \(m\) on top of an active system with a stiffness \(k\), damping \(c\) and an actuator.

+
+ + + + +++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Table 1: Example system variables
NotationDescriptionValueUnit
\(m\)Payload’s mass to position / isolate [kg]
\(k\)Stiffness of the suspension system [N/m]
\(c\)Damping coefficient of the suspension system [N/(m/s)]
\(y\)Payload absolute displacement (measured by an inertial sensor) [m]
\(d\)Ground displacement, it acts as a disturbance [m]
\(u\)Actuator force [N]
\(r\)Wanted position of the mass (the reference) [m]
\(\epsilon = r - y\)Position error [m]
\(K\)Feedback controllerto be designed[N/m]
+ +
+

+Derive the following open-loop transfer functions: +

+\begin{align} + G(s) &= \frac{y}{u} \\ + G_d(s) &= \frac{y}{d} +\end{align} + +

+Hint: You can follow this generic procedure: +

+
    +
  1. List all applied forces ot the mass: Actuator force, Stiffness force (Hooke’s law), …
  2. +
  3. Apply the Newton’s Second Law on the payload +\[ m \ddot{y} = \Sigma F \]
  4. +
  5. Transform the differential equations into the Laplace domain: +\[ \frac{d\ \cdot}{dt} \Leftrightarrow \cdot \times s \]
  6. +
  7. Write \(y(s)\) as a function of \(u(s)\) and \(w(s)\)
  8. +
+ +
+ +

+Having obtained \(G(s)\) and \(G_d(s)\), we can transform the system shown in Figure 2 into a classical feedback form as shown in Figure 4. +

+ + +
+

classical_feedback_test_system.png +

+

Figure 3: Block diagram corresponding to the example system

+
+
+
+
+ +
+

2 Classical Open Loop Shaping

+
+
+
+

2.1 Introduction ot Open Loop Shaping

+
+

+Usually, the controller \(K(s)\) is designed such that the loop gain \(L(s)\) has desirable shape. +This technique is called Open Loop Shaping. +

+ +
+Explain why the Loop gain si an important “value”
+

+For instance example all the specifications can usually be explained in terms of the open loop gain. +

+
+ + + +
+

open_loop_shaping.png +

+

Figure 4: Classical Feedback Architecture

+
+ +

+This is usually done manually has the loop gain \(L(s)\) depends linearly of \(K(s)\): +

+\begin{equation} + L(s) = G(s) K(s) +\end{equation} +
    +
  • where \(L(s)\) is called the Loop Gain Transfer Function
  • +
+ +

+\(K(s)\) then consists of a combination of leads, lags, notches, etc. such that its product with \(G(s)\) has wanted shape. +

+
+
+ +
+

2.2 Example of Open Loop Shaping

+
+
+
k = 1e-6;
+m = 10;
+c = 10;
+
+G =
+
+
+ + + +
+

bode_plot_example_afm.png +

+

Figure 5: Bode plot of the plant \(G(s)\)

+
+ +

+Specifications: +

+
    +
  • Performance: Bandwidth of approximately 50Hz
  • +
  • Noise Attenuation: Roll-off of -40dB/decade past 250Hz
  • +
  • Robustness: Gain margin > 5dB and Phase margin > 40 deg
  • +
+ +
+

+Using SISOTOOL, design a controller that fulfill the specifications. +

+ +
+
sisotool(G)
+
+
+ +
+ +

+In order to have the wanted Roll-off, two integrators are used, a lead is also added to have sufficient phase margin. +

+ +

+The obtained controller is shown below, and the bode plot of the Loop Gain is shown in Figure 6. +

+
+
K = 6e4 * ... % Gain
+    1/(s^2) * ... % Double Integrator
+    (1 + s/111)/(1 + s/888); % Lead
+
+
+ + +
+

loop_gain_manual_afm.png +

+

Figure 6: Bode Plot of the obtained Loop Gain \(L(s) = G(s) K(s)\)

+
+ +

+And we can verify that we have the wanted stability margins: +

+
+
[Gm, Pm, ~, Wc] = margin(G*K)
+
+
+ + + + +++ ++ + + + + + + + + + + + + + + + + + + + + + + +
 Value
Gain Margin [dB]7.2
Phase Margin [deg]48.1
Crossover [Hz]50.7
+
+
+ +
+

2.3 \(\mathcal{H}_\infty\) Loop Shaping Synthesis

+
+

+The Open Loop Shaping synthesis can be performed using the \(\mathcal{H}_\infty\) Synthesis. +

+ +

+Even though we will not go into details, we will provide one example. +

+ +

+Using Matlab, the \(\mathcal{H}_\infty\) synthesis of a controller based on the wanted open loop shape can be performed using the loopsyn command: +

+
+
K = loopsyn(G, Gd);
+
+
+

+where: +

+
    +
  • G is the (LTI) plant
  • +
  • Gd is the wanted loop shape
  • +
  • K is the synthesize controller
  • +
+ +
+

+Matlab documentation of loopsyn (link). +

+ +
+
+
+ +
+

2.4 Example of the \(\mathcal{H}_\infty\) Loop Shaping Synthesis

+
+

+Let’s re-use the previous plant. +

+ +

+Translate the specification into the wanted shape of the open loop gain. +

+ +
+
G = tf(16,[1 0.16 16]);
+
+Gd = 3.7e4*1/s*(1 + s/2/pi/20)/(1 + s/2/pi/220)*1/(s + s/2/pi/500);
+
+
+ +
+
[K,CL,GAM,INFO] = loopsyn(G, Gd);
+
+
+ +
+
bodeFig({K})
+
+
+
+
+
+ +
+

3 The \(\mathcal{H}_\infty\) Norm

-
+

The \(\mathcal{H}_\infty\) norm is defined as the peak of the maximum singular value of the frequency response

@@ -176,7 +546,7 @@ For a SISO system \(G(s)\), it is simply the peak value of \(|G(j\omega)|\) as a
-
+

Let’s define a plant dynamics:

@@ -201,23 +571,23 @@ And compute its \(\mathcal{H}_\infty\) norm using the hinfnorm func

-The magnitude \(|G(j\omega)|\) of the plant \(G(s)\) as a function of frequency is shown in Figure 2. +The magnitude \(|G(j\omega)|\) of the plant \(G(s)\) as a function of frequency is shown in Figure 7. The maximum value of the magnitude over all frequencies does correspond to the \(\mathcal{H}_\infty\) norm of \(G(s)\) as Equation \eqref{eq:hinf_norm_siso} implies.

-
+

hinfinity_norm_siso_bode.png

-

Figure 2: Example of the \(\mathcal{H}_\infty\) norm of a SISO system

+

Figure 7: Example of the \(\mathcal{H}_\infty\) norm of a SISO system

-
-

4 \(\mathcal{H}_\infty\) Synthesis

+
+

4 \(\mathcal{H}_\infty\) Synthesis

Optimization problem: @@ -246,17 +616,17 @@ The maximum value of the magnitude over all frequencies does correspond to the \

-
-

5 The Generalized Plant

+
+

5 The Generalized Plant

-
+

general_plant.png

- - +
Table 1: Notations for the general configuration
+@@ -303,10 +673,10 @@ The maximum value of the magnitude over all frequencies does correspond to the \ -
-

6 Problem Formulation

+
+

6 Problem Formulation

-
+

The \(\mathcal{H}_\infty\) Synthesis objective is to find all stabilizing controllers \(K\) which minimize

@@ -317,27 +687,27 @@ The \(\mathcal{H}_\infty\) Synthesis objective is to find all stabilizing contro
-
+

general_control_names.png

-

Figure 4: General Control Configuration

+

Figure 9: General Control Configuration

-
-

7 Classical feedback control and closed loop transfer functions

+
+

7 Classical feedback control and closed loop transfer functions

-
+

classical_feedback.png

-

Figure 5: Classical Feedback Architecture

+

Figure 10: Classical Feedback Architecture

-
Table 2: Notations for the general configuration
- +
Table 2: Notations for the Classical Feedback Architecture
+@@ -390,8 +760,8 @@ The \(\mathcal{H}_\infty\) Synthesis objective is to find all stabilizing contro -
-

8 From a Classical Feedback Architecture to a Generalized Plant

+
+

8 From a Classical Feedback Architecture to a Generalized Plant

The procedure is: @@ -401,16 +771,16 @@ The procedure is:

  • Remove \(K\) and rearrange the inputs and outputs
  • -
    +

    -Let’s find the Generalized plant of corresponding to the tracking control architecture shown in Figure 6 +Let’s find the Generalized plant of corresponding to the tracking control architecture shown in Figure 11

    -
    +

    classical_feedback_tracking.png

    -

    Figure 6: Classical Feedback Control Architecture (Tracking)

    +

    Figure 11: Classical Feedback Control Architecture (Tracking)

    @@ -425,14 +795,14 @@ First, define the signals of the generalized plant:

    Then, Remove \(K\) and rearrange the inputs and outputs. -We obtain the generalized plant shown in Figure 7. +We obtain the generalized plant shown in Figure 12.

    -
    +

    mixed_sensitivity_ref_tracking.png

    -

    Figure 7: Generalized plant of the Classical Feedback Control Architecture (Tracking)

    +

    Figure 12: Generalized plant of the Classical Feedback Control Architecture (Tracking)

    @@ -449,12 +819,12 @@ Using Matlab, the generalized plant can be defined as follows:

    -
    -

    9 Modern Interpretation of the Control Specifications

    +
    +

    9 Modern Interpretation of the Control Specifications

    -
    -

    9.1 Introduction

    +
    +

    9.1 Introduction

    • Reference tracking Overshoot, Static error, Setling time @@ -488,22 +858,22 @@ Using Matlab, the generalized plant can be defined as follows:
    -
    -

    10 Resources

    +
    +

    10 Resources

    - +

    - +

    Author: Dehaeze Thomas

    -

    Created: 2020-11-25 mer. 19:38

    +

    Created: 2020-11-27 ven. 18:20

    diff --git a/index.org b/index.org index 10af179..4da99de 100644 --- a/index.org +++ b/index.org @@ -38,6 +38,7 @@ #+PROPERTY: header-args:latex+ :post pdf2svg(file=*this*, ext="png") :END: +* Introduction :ignore: * Matlab Init :noexport:ignore: #+begin_src matlab :tangle no :exports none :results silent :noweb yes :var current_dir=(file-name-directory buffer-file-name) <> @@ -48,6 +49,7 @@ #+end_src * Introduction to the Control Methodology - Model Based Control +** Control Methodology The typical methodology when applying Model Based Control to a plant is schematically shown in Figure [[fig:control-procedure]]. It consists of three steps: @@ -91,7 +93,7 @@ It consists of three steps: In this document, we will mainly focus on steps 2 and 3. -* Some Background: From Classical Control to Robust Control +** Some Background: From Classical Control to Robust Control Classical Control (1930) - Tools: @@ -136,6 +138,355 @@ Robust Control (1980) - Requires the knowledge of specific tools - Need a reasonably good model of the system + +** Example System + +Let's consider the test-system shown in Figure [[fig:mech_sys_1dof_inertial_contr]]. +The notations used are listed in Table [[tab:example_notations]]. + +#+begin_src latex :file mech_sys_1dof_inertial_contr.pdf + \begin{tikzpicture} + % Parameters + \def\massw{3} + \def\massh{1} + \def\spaceh{1.8} + + % Ground + \draw[] (-0.5*\massw, 0) -- (0.5*\massw, 0); + % Mass + \draw[fill=white] (-0.5*\massw, \spaceh) rectangle (0.5*\massw, \spaceh+\massh) node[pos=0.5](m){$m$}; + + % Spring, Damper, and Actuator + \draw[spring] (-0.3*\massw, 0) -- (-0.3*\massw, \spaceh) node[midway, left=0.1]{$k$}; + \draw[damper] ( 0, 0) -- ( 0, \spaceh) node[midway, left=0.3]{$c$}; + \draw[actuator] ( 0.3*\massw, 0) -- (0.3*\massw, \spaceh) node[midway](F){}; + + % Displacements + \draw[dashed] (0.5*\massw, 0) -- ++(0.5, 0); + \draw[->] (0.6*\massw, 0) -- ++(0, 0.5) node[below right]{$d$}; + + % Inertial Sensor + \node[inertialsensor] (inertials) at (0.5*\massw, \spaceh+\massh){}; + \node[addb={+}{-}{}{}{}, right=0.8 of inertials] (subf) {}; + + \node[block, below=0.4 of subf] (K){$K(s)$}; + + \draw[->] (inertials.east) node[above right]{$y$} -- (subf.west); + \draw[->] (subf.south) -- (K.north) node[above right]{$\epsilon$}; + \draw[<-] (subf.north) -- ++(0, 0.6) node[below right]{$r$}; + \draw[->] (K.south) |- (F.east) node[above right]{$u$}; + \end{tikzpicture} +#+end_src + +#+name: fig:mech_sys_1dof_inertial_contr +#+caption: Test System consisting of a payload with a mass $m$ on top of an active system with a stiffness $k$, damping $c$ and an actuator. A feedback controller $K(s)$ is added to position / isolate the payload. +#+RESULTS: +[[file:figs/mech_sys_1dof_inertial_contr.png]] + +#+name: tab:example_notations +#+caption: Example system variables +| *Notation* | *Description* | *Value* | *Unit* | +|--------------------+----------------------------------------------------------------+----------------+-----------| +| $m$ | Payload's mass to position / isolate | | [kg] | +| $k$ | Stiffness of the suspension system | | [N/m] | +| $c$ | Damping coefficient of the suspension system | | [N/(m/s)] | +| $y$ | Payload absolute displacement (measured by an inertial sensor) | | [m] | +| $d$ | Ground displacement, it acts as a disturbance | | [m] | +| $u$ | Actuator force | | [N] | +| $r$ | Wanted position of the mass (the reference) | | [m] | +| $\epsilon = r - y$ | Position error | | [m] | +| $K$ | Feedback controller | to be designed | [N/m] | + +#+begin_exercice +Derive the following open-loop transfer functions: + \begin{align} + G(s) &= \frac{y}{u} \\ + G_d(s) &= \frac{y}{d} + \end{align} + +*Hint:* You can follow this generic procedure: +1. List all applied forces ot the mass: Actuator force, Stiffness force (Hooke's law), ... +2. Apply the Newton's Second Law on the payload + \[ m \ddot{y} = \Sigma F \] +3. Transform the differential equations into the Laplace domain: + \[ \frac{d\ \cdot}{dt} \Leftrightarrow \cdot \times s \] +4. Write $y(s)$ as a function of $u(s)$ and $w(s)$ +#+end_exercice + +Having obtained $G(s)$ and $G_d(s)$, we can transform the system shown in Figure [[fig:mech_sys_1dof_inertial_contr]] into a classical feedback form as shown in Figure [[fig:open_loop_shaping]]. + +#+begin_src latex :file classical_feedback_test_system.pdf + \begin{tikzpicture} + \node[addb={+}{}{}{}{-}] (addfb) at (0, 0){}; + \node[block, right=0.8 of addfb] (K){$K(s)$}; + \node[block, right=0.8 of K] (G){$G(s)$}; + \node[addb={+}{}{}{}{}, right=0.8 of G] (addd){}; + \node[block, above=0.5 of addd] (Gd){$G_d(s)$}; + + \draw[<-] (addfb.west) -- ++(-0.8, 0) node[above right]{$r$}; + \draw[->] (addfb.east) -- (K.west) node[above left]{$\epsilon$}; + \draw[->] (K.east) -- (G.west) node[above left]{$u$}; + \draw[->] (G.east) -- (addd.west); + \draw[<-] (Gd.north) -- ++(0, 0.8) node[below right]{$d$}; + \draw[->] (Gd.south) -- (addd.north); + \draw[->] (addd.east) -- ++(1.2, 0); + \draw[->] ($(addd.east) + (0.6, 0)$) node[branch]{} node[above]{$y$} -- ++(0, -1.0) -| (addfb.south); + \end{tikzpicture} +#+end_src + +#+name: fig:classical_feedback_test_system +#+caption: Block diagram corresponding to the example system +#+RESULTS: +[[file:figs/classical_feedback_test_system.png]] + +#+begin_src matlab + k = 1e6; % Stiffness [N/m] + c = 4e2; % Damping [N/(m/s)] + m = 16; % Mass [kg] +#+end_src + +#+begin_src matlab + G = 1/(m*s^2 + c*s + k); + Gd = (c*s + k)/(m*s^2 + c*s + k); +#+end_src + +* Classical Open Loop Shaping +** Introduction ot Open Loop Shaping +Usually, the controller $K(s)$ is designed such that the loop gain $L(s)$ has desirable shape. +This technique is called *Open Loop Shaping*. + +*************** TODO Explain why the Loop gain si an important "value" +For instance example all the specifications can usually be explained in terms of the open loop gain. +*************** END + + +#+begin_src latex :file open_loop_shaping.pdf + \begin{tikzpicture} + \node[addb={+}{}{}{}{-}] (addsub) at (0, 0){}; + + \node[block, right=0.8 of addsub] (K) {$K(s)$}; + \node[below] at (K.south) {Controller}; + \node[block, right=0.8 of K] (G) {$G(s)$}; + \node[below] at (G.south) {Plant}; + + \draw[<-] (addsub.west) -- ++(-0.8, 0) node[above right]{$r$}; + + \draw[->] (addsub) -- (K.west) node[above left]{$\epsilon$}; + \draw[->] (K.east) -- (G.west) node[above left]{$u$}; + \draw[->] (G.east) -- ++(0.8, 0) node[above left]{$y$}; + \draw[] ($(G.east) + (0.5, 0)$) -- ++(0, -1.4); + \draw[->] ($(G.east) + (0.5, -1.4)$) -| (addsub.south); + + \draw [decoration={brace, raise=5pt}, decorate] (K.north west) -- node[above=6pt]{$L(s)$} (G.north east); + \end{tikzpicture} +#+end_src + +#+name: fig:open_loop_shaping +#+caption: Classical Feedback Architecture +#+RESULTS: +[[file:figs/open_loop_shaping.png]] + +This is usually done manually has the loop gain $L(s)$ depends linearly of $K(s)$: +\begin{equation} + L(s) = G(s) K(s) +\end{equation} +- where $L(s)$ is called the *Loop Gain Transfer Function* + +$K(s)$ then consists of a combination of leads, lags, notches, etc. such that its product with $G(s)$ has wanted shape. + +** Example of Open Loop Shaping + + +#+begin_src matlab + k = 1e-6; + m = 10; + c = 10; + + G = +#+end_src + + +#+begin_src matlab :exports none + freqs = logspace(1, 4, 1000); + + figure; + tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None'); + + ax1 = nexttile([2,1]); + hold on; + plot(freqs, abs(squeeze(freqresp(G, freqs, 'Hz')))); + hold off; + set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log'); + ylabel('Magnitude'); set(gca, 'XTickLabel',[]); + hold off; + + ax2 = nexttile; + hold on; + plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(G, freqs, 'Hz'))))); + set(gca, 'XScale', 'log'); set(gca, 'YScale', 'lin'); + yticks(-360:90:360); ylim([-270, 90]); + xlabel('Frequency [Hz]'); ylabel('Phase [deg]'); + hold off; + linkaxes([ax1,ax2],'x'); + xlim([freqs(1), freqs(end)]); +#+end_src + +#+begin_src matlab :tangle no :exports results :results file replace + exportFig('figs/bode_plot_example_afm.pdf', 'width', 'wide', 'height', 'normal'); +#+end_src + +#+name: fig:bode_plot_example_afm +#+caption: Bode plot of the plant $G(s)$ +#+RESULTS: +[[file:figs/bode_plot_example_afm.png]] + +Specifications: +- *Performance*: Bandwidth of approximately 50Hz +- *Noise Attenuation*: Roll-off of -40dB/decade past 250Hz +- *Robustness*: Gain margin > 5dB and Phase margin > 40 deg + +#+begin_exercice +Using =SISOTOOL=, design a controller that fulfill the specifications. + +#+begin_src matlab :eval no + sisotool(G) +#+end_src +#+end_exercice + +In order to have the wanted Roll-off, two integrators are used, a lead is also added to have sufficient phase margin. + +The obtained controller is shown below, and the bode plot of the Loop Gain is shown in Figure [[fig:loop_gain_manual_afm]]. +#+begin_src matlab + K = 6e4 * ... % Gain + 1/(s^2) * ... % Double Integrator + (1 + s/111)/(1 + s/888); % Lead +#+end_src + +#+begin_src matlab :exports none + freqs = logspace(1, 4, 1000); + + figure; + tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None'); + + ax1 = nexttile([2,1]); + hold on; + plot(freqs, abs(squeeze(freqresp(G*K, freqs, 'Hz')))); + hold off; + set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log'); + ylabel('Magnitude'); set(gca, 'XTickLabel',[]); + hold off; + ylim([1e-5, 1e1]) + + ax2 = nexttile; + hold on; + plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(G*K, freqs, 'Hz'))))); + set(gca, 'XScale', 'log'); set(gca, 'YScale', 'lin'); + yticks(-360:90:360); ylim([-360, 0]); + xlabel('Frequency [Hz]'); ylabel('Phase [deg]'); + hold off; + + linkaxes([ax1,ax2],'x'); + xlim([freqs(1), freqs(end)]); +#+end_src + +#+begin_src matlab :tangle no :exports results :results file replace + exportFig('figs/loop_gain_manual_afm.pdf', 'width', 'wide', 'height', 'tall'); +#+end_src + +#+name: fig:loop_gain_manual_afm +#+caption: Bode Plot of the obtained Loop Gain $L(s) = G(s) K(s)$ +#+RESULTS: +[[file:figs/loop_gain_manual_afm.png]] + +And we can verify that we have the wanted stability margins: +#+begin_src matlab :results output replace + [Gm, Pm, ~, Wc] = margin(G*K) +#+end_src + +#+begin_src matlab :exports results :results value table replace :tangle no :post addhdr(*this*) + data2orgtable([Gm; Pm; Wc/2/pi], {'Gain Margin [dB]', 'Phase Margin [deg]', 'Crossover [Hz]'}, {'Value'}, ' %.1f '); +#+end_src + +#+RESULTS: +| | Value | +|--------------------+-------| +| Gain Margin [dB] | 7.2 | +| Phase Margin [deg] | 48.1 | +| Crossover [Hz] | 50.7 | + +** $\mathcal{H}_\infty$ Loop Shaping Synthesis +The Open Loop Shaping synthesis can be performed using the $\mathcal{H}_\infty$ Synthesis. + +Even though we will not go into details, we will provide one example. + +Using Matlab, the $\mathcal{H}_\infty$ synthesis of a controller based on the wanted open loop shape can be performed using the =loopsyn= command: +#+begin_src matlab :eval no + K = loopsyn(G, Gd); +#+end_src +where: +- =G= is the (LTI) plant +- =Gd= is the wanted loop shape +- =K= is the synthesize controller + +#+begin_seealso + Matlab documentation of =loopsyn= ([[https://www.mathworks.com/help/robust/ref/loopsyn.html][link]]). +#+end_seealso + +** Example of the $\mathcal{H}_\infty$ Loop Shaping Synthesis + +Let's re-use the previous plant. + +Translate the specification into the wanted shape of the open loop gain. + +#+begin_src matlab + G = tf(16,[1 0.16 16]); + + Gd = 3.7e4*1/s*(1 + s/2/pi/20)/(1 + s/2/pi/220)*1/(s + s/2/pi/500); +#+end_src + +#+begin_src matlab :exports none + bodeFig({Gd}, struct('phase', true)) +#+end_src + +#+begin_src matlab + [K,CL,GAM,INFO] = loopsyn(G, Gd); +#+end_src + +#+begin_src matlab + bodeFig({K}) +#+end_src + +#+begin_src matlab :exports none + freqs = logspace(1, 4, 1000); + + figure; + tiledlayout(3, 1, 'TileSpacing', 'None', 'Padding', 'None'); + + ax1 = nexttile([2,1]); + hold on; + plot(freqs, abs(squeeze(freqresp(G*K, freqs, 'Hz')))); + plot(freqs, abs(squeeze(freqresp(Gd, freqs, 'Hz'))), 'k--'); + plot(freqs, abs(squeeze(freqresp(Gd, freqs, 'Hz')))*GAM, 'k-.'); + plot(freqs, abs(squeeze(freqresp(Gd, freqs, 'Hz')))/GAM, 'k-.'); + hold off; + set(gca, 'XScale', 'log'); set(gca, 'YScale', 'log'); + ylabel('Magnitude'); set(gca, 'XTickLabel',[]); + hold off; + ylim([1e-5, 1e1]) + + ax2 = nexttile; + hold on; + plot(freqs, 180/pi*unwrap(angle(squeeze(freqresp(G*K, freqs, 'Hz'))))); + set(gca, 'XScale', 'log'); set(gca, 'YScale', 'lin'); + yticks(-360:90:360); ylim([-360, 0]); + xlabel('Frequency [Hz]'); ylabel('Phase [deg]'); + hold off; + + linkaxes([ax1,ax2],'x'); + xlim([freqs(1), freqs(end)]); +#+end_src + + * The $\mathcal{H}_\infty$ Norm #+begin_definition
    Table 3: Notations for the Classical Feedback Architecture