Error when saving the signals

This commit is contained in:
Thomas Dehaeze 2019-09-12 15:50:31 +02:00
parent c3ef88a366
commit b2d6317679
3 changed files with 348 additions and 111 deletions

View File

@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2019-09-11 mer. 09:10 -->
<!-- 2019-09-12 jeu. 15:20 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Cercalo Test Bench</title>
@ -276,27 +276,39 @@ for the JavaScript code in this tag.
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org7d7af99">1. Identification</a>
<li><a href="#orgff87b8d">1. Introduction</a></li>
<li><a href="#org2459267">2. Identification</a>
<ul>
<li><a href="#org720ab4f">1.1. Excitation Data</a></li>
<li><a href="#org2335cee">1.2. Input / Output data</a></li>
<li><a href="#orgddaeb4a">1.3. Estimation of the Frequency Response Function Matrix</a></li>
<li><a href="#org3d15257">1.4. Coherence</a></li>
<li><a href="#org891ffe6">1.5. Extraction of a transfer function matrix</a></li>
<li><a href="#org9b7ddaf">2.1. Excitation Data</a></li>
<li><a href="#org04e353b">2.2. Huddle Test</a></li>
<li><a href="#org4dc3ca0">2.3. Input / Output data</a></li>
<li><a href="#org1f732b6">2.4. Estimation of the Frequency Response Function Matrix</a></li>
<li><a href="#org8986a6a">2.5. Coherence</a></li>
<li><a href="#orgb611053">2.6. Extraction of a transfer function matrix</a></li>
</ul>
</li>
<li><a href="#orgbb47804">2. Plant Analysis</a></li>
<li><a href="#org7348e54">3. Control</a></li>
<li><a href="#org5cfd6fc">3. Sensor Noise</a></li>
<li><a href="#org2bd416c">4. Plant Analysis</a>
<ul>
<li><a href="#orge74c87e">4.1. Rotation Matrix</a></li>
</ul>
</li>
<li><a href="#org7b9c8d0">5. Control Objective</a></li>
<li><a href="#orgbefa210">6. Plant Scaling</a></li>
<li><a href="#org90e1042">7. Control Design</a></li>
</ul>
</div>
</div>
<div id="outline-container-orgff87b8d" class="outline-2">
<h2 id="orgff87b8d"><span class="section-number-2">1</span> Introduction</h2>
</div>
<div id="outline-container-org7d7af99" class="outline-2">
<h2 id="org7d7af99"><span class="section-number-2">1</span> Identification</h2>
<div class="outline-text-2" id="text-1">
<div id="outline-container-org2459267" class="outline-2">
<h2 id="org2459267"><span class="section-number-2">2</span> Identification</h2>
<div class="outline-text-2" id="text-2">
<p>
<a id="org57da1c6"></a>
<a id="org1f481c7"></a>
</p>
<div class="note">
<p>
@ -306,9 +318,9 @@ All the files (data and Matlab scripts) are accessible <a href="data/plant_ident
</div>
</div>
<div id="outline-container-org720ab4f" class="outline-3">
<h3 id="org720ab4f"><span class="section-number-3">1.1</span> Excitation Data</h3>
<div class="outline-text-3" id="text-1-1">
<div id="outline-container-org9b7ddaf" class="outline-3">
<h3 id="org9b7ddaf"><span class="section-number-3">2.1</span> Excitation Data</h3>
<div class="outline-text-3" id="text-2-1">
<div class="org-src-container">
<pre class="src src-matlab">fs = <span class="org-highlight-numbers-number">1e4</span>;
Ts = <span class="org-highlight-numbers-number">1</span><span class="org-type">/</span>fs;
@ -344,9 +356,80 @@ Discrete-time zero/pole/gain model.
</div>
</div>
<div id="outline-container-org2335cee" class="outline-3">
<h3 id="org2335cee"><span class="section-number-3">1.2</span> Input / Output data</h3>
<div class="outline-text-3" id="text-1-2">
<div id="outline-container-org04e353b" class="outline-3">
<h3 id="org04e353b"><span class="section-number-3">2.2</span> Huddle Test</h3>
<div class="outline-text-3" id="text-2-2">
<p>
We load the data taken during the Huddle Test.
</p>
<div class="org-src-container">
<pre class="src src-matlab">load<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'mat/data_huddle_test.mat', 't', 'xh', 'xv', 'cuh', 'cuv'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
</pre>
</div>
<p>
The variables are:
</p>
<dl class="org-dl">
<dt>\(x_h\)</dt><dd>Normalized position of the beam in the horizontal direction as measured by the 4 quadrant diode</dd>
<dt>\(x_v\)</dt><dd>Normalized position of the beam in the vertical direction as measured by the 4 quadrant diode</dd>
<dt>\(cu_h\)</dt><dd>Voltage across the inductance used for the horizontal positioning of the Cercalo</dd>
<dt>\(vu_v\)</dt><dd>Voltage across the inductance used for the vertical positioning of the Cercalo</dd>
</dl>
<div class="org-src-container">
<pre class="src src-matlab">xh<span class="org-rainbow-delimiters-depth-1">(</span>t<span class="org-type">&lt;</span><span class="org-highlight-numbers-number">1</span><span class="org-rainbow-delimiters-depth-1">)</span> = <span class="org-rainbow-delimiters-depth-1">[]</span>;
xv<span class="org-rainbow-delimiters-depth-1">(</span>t<span class="org-type">&lt;</span><span class="org-highlight-numbers-number">1</span><span class="org-rainbow-delimiters-depth-1">)</span> = <span class="org-rainbow-delimiters-depth-1">[]</span>;
cuh<span class="org-rainbow-delimiters-depth-1">(</span>t<span class="org-type">&lt;</span><span class="org-highlight-numbers-number">1</span><span class="org-rainbow-delimiters-depth-1">)</span> = <span class="org-rainbow-delimiters-depth-1">[]</span>;
cuv<span class="org-rainbow-delimiters-depth-1">(</span>t<span class="org-type">&lt;</span><span class="org-highlight-numbers-number">1</span><span class="org-rainbow-delimiters-depth-1">)</span> = <span class="org-rainbow-delimiters-depth-1">[]</span>;
t<span class="org-rainbow-delimiters-depth-1">(</span>t<span class="org-type">&lt;</span><span class="org-highlight-numbers-number">1</span><span class="org-rainbow-delimiters-depth-1">)</span> = <span class="org-rainbow-delimiters-depth-1">[]</span>;
t = t <span class="org-type">-</span> t<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-highlight-numbers-number">1</span><span class="org-rainbow-delimiters-depth-1">)</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-rainbow-delimiters-depth-1">[</span>psd_xh, f<span class="org-rainbow-delimiters-depth-1">]</span> = pwelch<span class="org-rainbow-delimiters-depth-1">(</span>xh, hanning<span class="org-rainbow-delimiters-depth-2">(</span>ceil<span class="org-rainbow-delimiters-depth-3">(</span><span class="org-highlight-numbers-number">1</span><span class="org-type">*</span>fs<span class="org-rainbow-delimiters-depth-3">)</span><span class="org-rainbow-delimiters-depth-2">)</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, fs<span class="org-rainbow-delimiters-depth-1">)</span>;
<span class="org-rainbow-delimiters-depth-1">[</span>psd_xv, <span class="org-type">~</span><span class="org-rainbow-delimiters-depth-1">]</span> = pwelch<span class="org-rainbow-delimiters-depth-1">(</span>xv, hanning<span class="org-rainbow-delimiters-depth-2">(</span>ceil<span class="org-rainbow-delimiters-depth-3">(</span><span class="org-highlight-numbers-number">1</span><span class="org-type">*</span>fs<span class="org-rainbow-delimiters-depth-3">)</span><span class="org-rainbow-delimiters-depth-2">)</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, fs<span class="org-rainbow-delimiters-depth-1">)</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-type">figure</span>;
hold on;
plot<span class="org-rainbow-delimiters-depth-1">(</span>f, sqrt<span class="org-rainbow-delimiters-depth-2">(</span>psd_xh<span class="org-rainbow-delimiters-depth-2">)</span>, <span class="org-string">'DisplayName', '</span>$<span class="org-type">\</span>Gamma_<span class="org-rainbow-delimiters-depth-2">{</span>x_h<span class="org-rainbow-delimiters-depth-2">}</span>$'<span class="org-rainbow-delimiters-depth-1">)</span>;
plot<span class="org-rainbow-delimiters-depth-1">(</span>f, sqrt<span class="org-rainbow-delimiters-depth-2">(</span>psd_xv<span class="org-rainbow-delimiters-depth-2">)</span>, <span class="org-string">'DisplayName', '</span>$<span class="org-type">\</span>Gamma_<span class="org-rainbow-delimiters-depth-2">{</span>x_v<span class="org-rainbow-delimiters-depth-2">}</span>$'<span class="org-rainbow-delimiters-depth-1">)</span>;
hold off;
<span class="org-type">set</span><span class="org-rainbow-delimiters-depth-1">(</span><span class="org-variable-name">gca</span>, <span class="org-string">'xscale', 'log'</span><span class="org-string"><span class="org-rainbow-delimiters-depth-1">)</span></span><span class="org-string">; set</span><span class="org-string"><span class="org-rainbow-delimiters-depth-1">(</span></span><span class="org-string">gca, 'yscale', 'log'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
xlabel<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'Frequency </span><span class="org-string"><span class="org-rainbow-delimiters-depth-2">[</span></span><span class="org-string">Hz</span><span class="org-string"><span class="org-rainbow-delimiters-depth-2">]</span></span><span class="org-string">'</span><span class="org-string"><span class="org-rainbow-delimiters-depth-1">)</span></span><span class="org-string">; ylabel</span><span class="org-string"><span class="org-rainbow-delimiters-depth-1">(</span></span><span class="org-string">'</span>ASD $<span class="org-type">\</span>left<span class="org-rainbow-delimiters-depth-2">[</span><span class="org-type">\</span>frac<span class="org-rainbow-delimiters-depth-3">{</span>V<span class="org-rainbow-delimiters-depth-3">}{</span><span class="org-type">\</span>sqrt<span class="org-rainbow-delimiters-depth-4">{</span>Hz<span class="org-rainbow-delimiters-depth-4">}</span><span class="org-rainbow-delimiters-depth-3">}</span><span class="org-type">\</span>right<span class="org-rainbow-delimiters-depth-2">]</span>$'<span class="org-rainbow-delimiters-depth-1">)</span>
legend<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'Location', 'southwest'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
xlim<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-rainbow-delimiters-depth-2">[</span><span class="org-highlight-numbers-number">1</span>, <span class="org-highlight-numbers-number">1000</span><span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">)</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-rainbow-delimiters-depth-1">[</span>psd_cuh, f<span class="org-rainbow-delimiters-depth-1">]</span> = pwelch<span class="org-rainbow-delimiters-depth-1">(</span>cuh, hanning<span class="org-rainbow-delimiters-depth-2">(</span>ceil<span class="org-rainbow-delimiters-depth-3">(</span><span class="org-highlight-numbers-number">1</span><span class="org-type">*</span>fs<span class="org-rainbow-delimiters-depth-3">)</span><span class="org-rainbow-delimiters-depth-2">)</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, fs<span class="org-rainbow-delimiters-depth-1">)</span>;
<span class="org-rainbow-delimiters-depth-1">[</span>psd_cuv, <span class="org-type">~</span><span class="org-rainbow-delimiters-depth-1">]</span> = pwelch<span class="org-rainbow-delimiters-depth-1">(</span>cuv, hanning<span class="org-rainbow-delimiters-depth-2">(</span>ceil<span class="org-rainbow-delimiters-depth-3">(</span><span class="org-highlight-numbers-number">1</span><span class="org-type">*</span>fs<span class="org-rainbow-delimiters-depth-3">)</span><span class="org-rainbow-delimiters-depth-2">)</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, fs<span class="org-rainbow-delimiters-depth-1">)</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-type">figure</span>;
hold on;
plot<span class="org-rainbow-delimiters-depth-1">(</span>f, sqrt<span class="org-rainbow-delimiters-depth-2">(</span>psd_cuh<span class="org-rainbow-delimiters-depth-2">)</span>, <span class="org-string">'DisplayName', '</span>$<span class="org-type">\</span>Gamma_<span class="org-rainbow-delimiters-depth-2">{</span>cu_h<span class="org-rainbow-delimiters-depth-2">}</span>$'<span class="org-rainbow-delimiters-depth-1">)</span>;
plot<span class="org-rainbow-delimiters-depth-1">(</span>f, sqrt<span class="org-rainbow-delimiters-depth-2">(</span>psd_cuv<span class="org-rainbow-delimiters-depth-2">)</span>, <span class="org-string">'DisplayName', '</span>$<span class="org-type">\</span>Gamma_<span class="org-rainbow-delimiters-depth-2">{</span>cu_v<span class="org-rainbow-delimiters-depth-2">}</span>$'<span class="org-rainbow-delimiters-depth-1">)</span>;
hold off;
<span class="org-type">set</span><span class="org-rainbow-delimiters-depth-1">(</span><span class="org-variable-name">gca</span>, <span class="org-string">'xscale', 'log'</span><span class="org-string"><span class="org-rainbow-delimiters-depth-1">)</span></span><span class="org-string">; set</span><span class="org-string"><span class="org-rainbow-delimiters-depth-1">(</span></span><span class="org-string">gca, 'yscale', 'log'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
xlabel<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'Frequency </span><span class="org-string"><span class="org-rainbow-delimiters-depth-2">[</span></span><span class="org-string">Hz</span><span class="org-string"><span class="org-rainbow-delimiters-depth-2">]</span></span><span class="org-string">'</span><span class="org-string"><span class="org-rainbow-delimiters-depth-1">)</span></span><span class="org-string">; ylabel</span><span class="org-string"><span class="org-rainbow-delimiters-depth-1">(</span></span><span class="org-string">'</span>ASD $<span class="org-type">\</span>left<span class="org-rainbow-delimiters-depth-2">[</span><span class="org-type">\</span>frac<span class="org-rainbow-delimiters-depth-3">{</span>V<span class="org-rainbow-delimiters-depth-3">}{</span><span class="org-type">\</span>sqrt<span class="org-rainbow-delimiters-depth-4">{</span>Hz<span class="org-rainbow-delimiters-depth-4">}</span><span class="org-rainbow-delimiters-depth-3">}</span><span class="org-type">\</span>right<span class="org-rainbow-delimiters-depth-2">]</span>$'<span class="org-rainbow-delimiters-depth-1">)</span>
legend<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-string">'Location', 'southwest'</span><span class="org-rainbow-delimiters-depth-1">)</span>;
xlim<span class="org-rainbow-delimiters-depth-1">(</span><span class="org-rainbow-delimiters-depth-2">[</span><span class="org-highlight-numbers-number">1</span>, <span class="org-highlight-numbers-number">1000</span><span class="org-rainbow-delimiters-depth-2">]</span><span class="org-rainbow-delimiters-depth-1">)</span>;
</pre>
</div>
</div>
</div>
<div id="outline-container-org4dc3ca0" class="outline-3">
<h3 id="org4dc3ca0"><span class="section-number-3">2.3</span> Input / Output data</h3>
<div class="outline-text-3" id="text-2-3">
<p>
The identification data is loaded
</p>
@ -388,7 +471,7 @@ uy.yy = uy.yy<span class="org-type">-</span>mean<span class="org-rainbow-delimit
</div>
<div id="orgfbb461b" class="figure">
<div id="org2d6aeb1" class="figure">
<p><img src="figs/identification_ux.png" alt="identification_ux.png" />
</p>
<p><span class="figure-number">Figure 1: </span>Identification signals when exciting the \(x\) axis (<a href="./figs/identification_ux.png">png</a>, <a href="./figs/identification_ux.pdf">pdf</a>)</p>
@ -396,7 +479,7 @@ uy.yy = uy.yy<span class="org-type">-</span>mean<span class="org-rainbow-delimit
<div id="orgdfdfab9" class="figure">
<div id="orgd5e71a4" class="figure">
<p><img src="figs/identification_uy.png" alt="identification_uy.png" />
</p>
<p><span class="figure-number">Figure 2: </span>Identification signals when exciting the \(y\) axis (<a href="./figs/identification_uy.png">png</a>, <a href="./figs/identification_uy.pdf">pdf</a>)</p>
@ -404,9 +487,9 @@ uy.yy = uy.yy<span class="org-type">-</span>mean<span class="org-rainbow-delimit
</div>
</div>
<div id="outline-container-orgddaeb4a" class="outline-3">
<h3 id="orgddaeb4a"><span class="section-number-3">1.3</span> Estimation of the Frequency Response Function Matrix</h3>
<div class="outline-text-3" id="text-1-3">
<div id="outline-container-org1f732b6" class="outline-3">
<h3 id="org1f732b6"><span class="section-number-3">2.4</span> Estimation of the Frequency Response Function Matrix</h3>
<div class="outline-text-3" id="text-2-4">
<p>
We compute an estimate of the transfer functions.
</p>
@ -419,7 +502,7 @@ We compute an estimate of the transfer functions.
</div>
<div id="orga43b16c" class="figure">
<div id="org2051377" class="figure">
<p><img src="figs/frequency_response_matrix.png" alt="frequency_response_matrix.png" />
</p>
<p><span class="figure-number">Figure 3: </span>Frequency Response Matrix (<a href="./figs/frequency_response_matrix.png">png</a>, <a href="./figs/frequency_response_matrix.pdf">pdf</a>)</p>
@ -427,9 +510,9 @@ We compute an estimate of the transfer functions.
</div>
</div>
<div id="outline-container-org3d15257" class="outline-3">
<h3 id="org3d15257"><span class="section-number-3">1.4</span> Coherence</h3>
<div class="outline-text-3" id="text-1-4">
<div id="outline-container-org8986a6a" class="outline-3">
<h3 id="org8986a6a"><span class="section-number-3">2.5</span> Coherence</h3>
<div class="outline-text-3" id="text-2-5">
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-rainbow-delimiters-depth-1">[</span>coh_ux_yx, f<span class="org-rainbow-delimiters-depth-1">]</span> = mscohere<span class="org-rainbow-delimiters-depth-1">(</span>ux.ux, ux.yx, hanning<span class="org-rainbow-delimiters-depth-2">(</span>ceil<span class="org-rainbow-delimiters-depth-3">(</span><span class="org-highlight-numbers-number">1</span><span class="org-type">*</span>fs<span class="org-rainbow-delimiters-depth-3">)</span><span class="org-rainbow-delimiters-depth-2">)</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, fs<span class="org-rainbow-delimiters-depth-1">)</span>;
<span class="org-rainbow-delimiters-depth-1">[</span>coh_ux_yy, <span class="org-type">~</span><span class="org-rainbow-delimiters-depth-1">]</span> = mscohere<span class="org-rainbow-delimiters-depth-1">(</span>ux.ux, ux.yy, hanning<span class="org-rainbow-delimiters-depth-2">(</span>ceil<span class="org-rainbow-delimiters-depth-3">(</span><span class="org-highlight-numbers-number">1</span><span class="org-type">*</span>fs<span class="org-rainbow-delimiters-depth-3">)</span><span class="org-rainbow-delimiters-depth-2">)</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, <span class="org-rainbow-delimiters-depth-2">[]</span>, fs<span class="org-rainbow-delimiters-depth-1">)</span>;
@ -439,7 +522,7 @@ We compute an estimate of the transfer functions.
</div>
<div id="org02b2d5b" class="figure">
<div id="orgf0f9ad1" class="figure">
<p><img src="figs/identification_coherence.png" alt="identification_coherence.png" />
</p>
<p><span class="figure-number">Figure 4: </span>Coherence (<a href="./figs/identification_coherence.png">png</a>, <a href="./figs/identification_coherence.pdf">pdf</a>)</p>
@ -448,9 +531,9 @@ We compute an estimate of the transfer functions.
</div>
<div id="outline-container-org891ffe6" class="outline-3">
<h3 id="org891ffe6"><span class="section-number-3">1.5</span> Extraction of a transfer function matrix</h3>
<div class="outline-text-3" id="text-1-5">
<div id="outline-container-orgb611053" class="outline-3">
<h3 id="orgb611053"><span class="section-number-3">2.6</span> Extraction of a transfer function matrix</h3>
<div class="outline-text-3" id="text-2-6">
<p>
First we define the initial guess for the resonance frequencies and the weights associated.
</p>
@ -503,7 +586,7 @@ Ignore data above some frequency.
</div>
<div id="orga5e5efc" class="figure">
<div id="org9d870b3" class="figure">
<p><img src="figs/weights.png" alt="weights.png" />
</p>
<p><span class="figure-number">Figure 5: </span>Weights amplitude (<a href="./figs/weights.png">png</a>, <a href="./figs/weights.pdf">pdf</a>)</p>
@ -555,7 +638,7 @@ An we run the <code>vectfit3</code> algorithm.
</div>
<div id="org690224b" class="figure">
<div id="orgce7fc34" class="figure">
<p><img src="figs/identification_matrix_fit.png" alt="identification_matrix_fit.png" />
</p>
<p><span class="figure-number">Figure 6: </span>Transfer Function Extraction of the FRF matrix (<a href="./figs/identification_matrix_fit.png">png</a>, <a href="./figs/identification_matrix_fit.pdf">pdf</a>)</p>
@ -583,16 +666,65 @@ G = <span class="org-rainbow-delimiters-depth-1">[</span>G_ux_yx, G_uy_yx;
</div>
</div>
<div id="outline-container-orgbb47804" class="outline-2">
<h2 id="orgbb47804"><span class="section-number-2">2</span> Plant Analysis</h2>
<div id="outline-container-org5cfd6fc" class="outline-2">
<h2 id="org5cfd6fc"><span class="section-number-2">3</span> Sensor Noise</h2>
</div>
<div id="outline-container-org7348e54" class="outline-2">
<h2 id="org7348e54"><span class="section-number-2">3</span> Control</h2>
<div id="outline-container-org2bd416c" class="outline-2">
<h2 id="org2bd416c"><span class="section-number-2">4</span> Plant Analysis</h2>
<div class="outline-text-2" id="text-4">
</div>
<div id="outline-container-orge74c87e" class="outline-3">
<h3 id="orge74c87e"><span class="section-number-3">4.1</span> Rotation Matrix</h3>
<div class="outline-text-3" id="text-4-1">
<div class="org-src-container">
<pre class="src src-matlab">G0 = freqresp<span class="org-rainbow-delimiters-depth-1">(</span>G, <span class="org-highlight-numbers-number">0</span><span class="org-rainbow-delimiters-depth-1">)</span>;
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org7b9c8d0" class="outline-2">
<h2 id="org7b9c8d0"><span class="section-number-2">5</span> Control Objective</h2>
<div class="outline-text-2" id="text-5">
<p>
The maximum expected stroke is \(y_\text{max} = 3mm \approx 5e^{-2} rad\) at \(1Hz\).
The maximum wanted error is \(e_\text{max} = 10 \mu rad\).
</p>
<p>
Thus, we require the sensitivity function at \(\omega_0 = 1\text{ Hz}\):
</p>
\begin{align*}
|S(j\omega_0)| &< \left| \frac{e_\text{max}}{y_\text{max}} \right| \\
&< 2 \cdot 10^{-4}
\end{align*}
<p>
In terms of loop gain, this is equivalent to:
\[ |L(j\omega_0)| > 5 \cdot 10^{3} \]
</p>
</div>
</div>
<div id="outline-container-orgbefa210" class="outline-2">
<h2 id="orgbefa210"><span class="section-number-2">6</span> Plant Scaling</h2>
<div class="outline-text-2" id="text-6">
<ul class="org-ul">
<li>measured noise</li>
<li>expected perturbations</li>
<li>maximum input usage</li>
<li>maximum wanted error</li>
</ul>
</div>
</div>
<div id="outline-container-org90e1042" class="outline-2">
<h2 id="org90e1042"><span class="section-number-2">7</span> Control Design</h2>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Dehaeze Thomas</p>
<p class="date">Created: 2019-09-11 mer. 09:10</p>
<p class="date">Created: 2019-09-12 jeu. 15:20</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>

243
index.org
View File

@ -24,8 +24,7 @@
#+PROPERTY: header-args:matlab+ :mkdirp yes
:END:
Notes:
145 994 8
* Introduction
* Identification
:PROPERTIES:
@ -89,11 +88,93 @@ Sample time: 0.0001 seconds
Discrete-time zero/pole/gain model.
#+end_example
** Huddle Test
We load the data taken during the Huddle Test.
#+begin_src matlab
load('mat/data_huddle_test.mat', 't', 'xh', 'xv', 'cuh', 'cuv');
#+end_src
The variables are:
- $x_h$ :: Normalized position of the beam in the horizontal direction as measured by the 4 quadrant diode
- $x_v$ :: Normalized position of the beam in the vertical direction as measured by the 4 quadrant diode
- $cu_h$ :: Voltage across the inductance used for the horizontal positioning of the Cercalo
- $vu_v$ :: Voltage across the inductance used for the vertical positioning of the Cercalo
We remove the first second of data where everything is settling down.
#+begin_src matlab
xh(t<1) = [];
xv(t<1) = [];
cuh(t<1) = [];
cuv(t<1) = [];
t(t<1) = [];
t = t - t(1);
#+end_src
#+begin_src matlab :exports none
figure;
hold on;
plot(t, xh, 'DisplayName', '$x_h$');
plot(t, xv, 'DisplayName', '$x_v$');
hold off;
xlabel('Time [s]');
ylabel('Amplitude [V]');
xlim([t(1), t(end)]);
legend();
#+end_src
We compute the Power Spectral Density of the horizontal and vertical positions of the beam as measured by the 4 quadrant diode.
#+begin_src matlab
[psd_xh, f] = pwelch(xh, hanning(ceil(1*fs)), [], [], fs);
[psd_xv, ~] = pwelch(xv, hanning(ceil(1*fs)), [], [], fs);
#+end_src
#+begin_src matlab :results none
figure;
hold on;
plot(f, sqrt(psd_xh), 'DisplayName', '$\Gamma_{x_h}$');
plot(f, sqrt(psd_xv), 'DisplayName', '$\Gamma_{x_v}$');
hold off;
set(gca, 'xscale', 'log'); set(gca, 'yscale', 'log');
xlabel('Frequency [Hz]'); ylabel('ASD $\left[\frac{V}{\sqrt{Hz}}\right]$')
legend('Location', 'southwest');
xlim([1, 1000]);
#+end_src
#+begin_src matlab :exports none
figure;
hold on;
plot(t, cuh, 'DisplayName', '$cu_h$');
plot(t, cuv, 'DisplayName', '$cu_v$');
hold off;
xlabel('Time [s]');
ylabel('Amplitude [V]');
xlim([t(1), t(end)]);
legend();
#+end_src
We compute the Power Spectral Density of the voltage across the inductance used for horizontal and vertical positioning of the Cercalo.
#+begin_src matlab
[psd_cuh, f] = pwelch(cuh, hanning(ceil(1*fs)), [], [], fs);
[psd_cuv, ~] = pwelch(cuv, hanning(ceil(1*fs)), [], [], fs);
#+end_src
#+begin_src matlab :results none
figure;
hold on;
plot(f, sqrt(psd_cuh), 'DisplayName', '$\Gamma_{cu_h}$');
plot(f, sqrt(psd_cuv), 'DisplayName', '$\Gamma_{cu_v}$');
hold off;
set(gca, 'xscale', 'log'); set(gca, 'yscale', 'log');
xlabel('Frequency [Hz]'); ylabel('ASD $\left[\frac{V}{\sqrt{Hz}}\right]$')
legend('Location', 'southwest');
xlim([1, 1000]);
#+end_src
** Input / Output data
The identification data is loaded
#+begin_src matlab
ux = load('mat/data_ux.mat', 't', 'ux', 'yx', 'yy');
uy = load('mat/data_uy.mat', 't', 'uy', 'yx', 'yy');
uh = load('mat/data_uh.mat', 't', 'xh', 'xv', 'uh', 'cuh', 'cuv');
uv = load('mat/data_uv.mat', 't', 'xh', 'xv', 'uv', 'cuh', 'cuv');
#+end_src
We remove the first seconds where the Cercalo is turned on.
@ -102,102 +183,102 @@ We remove the first seconds where the Cercalo is turned on.
i0y = 10*fs;
ux.t = ux.t( i0x:end) - ux.t(i0x);
ux.ux = ux.ux(i0x:end);
ux.yx = ux.yx(i0x:end);
ux.yy = ux.yy(i0x:end);
uh.t = uh.t( i0x:end) - uh.t(i0x);
uh.uh = uh.uh(i0x:end);
uh.xh = uh.xh(i0x:end);
uh.xv = uh.xv(i0x:end);
uy.t = uy.t( i0y:end) - uy.t(i0x);
uy.uy = uy.uy(i0y:end);
uy.yx = uy.yx(i0y:end);
uy.yy = uy.yy(i0y:end);
uv.t = uv.t( i0y:end) - uv.t(i0x);
uv.uv = uv.uv(i0y:end);
uv.xh = uv.xh(i0y:end);
uv.xv = uv.xv(i0y:end);
#+end_src
#+begin_src matlab
ux.ux = ux.ux-mean(ux.ux);
ux.yx = ux.yx-mean(ux.yx);
ux.yy = ux.yy-mean(ux.yy);
uh.uh = uh.uh-mean(uh.uh);
uh.xh = uh.xh-mean(uh.xh);
uh.xv = uh.xv-mean(uh.xv);
uy.ux = uy.ux-mean(uy.ux);
uy.yx = uy.yx-mean(uy.yx);
uy.yy = uy.yy-mean(uy.yy);
uv.uv = uv.uv-mean(uv.uv);
uv.xh = uv.xh-mean(uv.xh);
uv.xv = uv.xv-mean(uv.xv);
#+end_src
#+begin_src matlab :exports none
figure;
ax1 = subplot(1, 2, 1);
plot(ux.t, ux.ux);
plot(uh.t, uh.uh);
xlabel('Time [s]');
ylabel('Amplitude [V]');
legend({'$u_x$'});
ax2 = subplot(1, 2, 2);
hold on;
plot(ux.t, ux.yx, 'DisplayName', '$y_x$');
plot(ux.t, ux.yy, 'DisplayName', '$y_y$');
plot(uh.t, uh.xh, 'DisplayName', '$y_x$');
plot(uh.t, uh.xv, 'DisplayName', '$y_y$');
hold off;
xlabel('Time [s]');
ylabel('Amplitude [V]');
legend()
linkaxes([ax1,ax2],'x');
xlim([ux.t(1), ux.t(end)])
xlim([uh.t(1), uh.t(end)])
#+end_src
#+HEADER: :tangle no :exports results :results none :noweb yes
#+begin_src matlab :var filepath="figs/identification_ux.pdf" :var figsize="full-normal" :post pdf2svg(file=*this*, ext="png")
#+begin_src matlab :var filepath="figs/identification_uh.pdf" :var figsize="full-normal" :post pdf2svg(file=*this*, ext="png")
<<plt-matlab>>
#+end_src
#+NAME: fig:identification_ux
#+CAPTION: Identification signals when exciting the $x$ axis ([[./figs/identification_ux.png][png]], [[./figs/identification_ux.pdf][pdf]])
[[file:figs/identification_ux.png]]
#+NAME: fig:identification_uh
#+CAPTION: Identification signals when exciting the $x$ axis ([[./figs/identification_uh.png][png]], [[./figs/identification_uh.pdf][pdf]])
[[file:figs/identification_uh.png]]
#+begin_src matlab :exports none
figure;
ax1 = subplot(1, 2, 1);
plot(uy.t, uy.uy);
plot(uv.t, uv.uv);
xlabel('Time [s]');
ylabel('Amplitude [V]');
legend({'$u_y$'});
ax2 = subplot(1, 2, 2);
hold on;
plot(uy.t, uy.yy, 'DisplayName', '$y_y$');
plot(uy.t, uy.yx, 'DisplayName', '$y_x$');
plot(uv.t, uv.xh, 'DisplayName', '$y_x$');
plot(uv.t, uv.xv, 'DisplayName', '$y_y$');
hold off;
xlabel('Time [s]');
ylabel('Amplitude [V]');
legend()
linkaxes([ax1,ax2],'x');
xlim([uy.t(1), uy.t(end)])
xlim([uv.t(1), uv.t(end)])
#+end_src
#+HEADER: :tangle no :exports results :results none :noweb yes
#+begin_src matlab :var filepath="figs/identification_uy.pdf" :var figsize="full-normal" :post pdf2svg(file=*this*, ext="png")
#+begin_src matlab :var filepath="figs/identification_uv.pdf" :var figsize="full-normal" :post pdf2svg(file=*this*, ext="png")
<<plt-matlab>>
#+end_src
#+NAME: fig:identification_uy
#+CAPTION: Identification signals when exciting the $y$ axis ([[./figs/identification_uy.png][png]], [[./figs/identification_uy.pdf][pdf]])
[[file:figs/identification_uy.png]]
#+NAME: fig:identification_uv
#+CAPTION: Identification signals when exciting the $y$ axis ([[./figs/identification_uv.png][png]], [[./figs/identification_uv.pdf][pdf]])
[[file:figs/identification_uv.png]]
** Estimation of the Frequency Response Function Matrix
We compute an estimate of the transfer functions.
#+begin_src matlab
[tf_ux_yx, f] = tfestimate(ux.ux, ux.yx, hanning(ceil(1*fs)), [], [], fs);
[tf_ux_yy, ~] = tfestimate(ux.ux, ux.yy, hanning(ceil(1*fs)), [], [], fs);
[tf_uy_yx, ~] = tfestimate(uy.uy, uy.yx, hanning(ceil(1*fs)), [], [], fs);
[tf_uy_yy, ~] = tfestimate(uy.uy, uy.yy, hanning(ceil(1*fs)), [], [], fs);
[tf_uh_xh, f] = tfestimate(uh.uh, uh.xh, hanning(ceil(1*fs)), [], [], fs);
[tf_uh_xv, ~] = tfestimate(uh.uh, uh.xv, hanning(ceil(1*fs)), [], [], fs);
[tf_uv_xh, ~] = tfestimate(uv.uv, uv.xh, hanning(ceil(1*fs)), [], [], fs);
[tf_uv_xv, ~] = tfestimate(uv.uv, uv.xv, hanning(ceil(1*fs)), [], [], fs);
#+end_src
#+begin_src matlab :exports none
figure;
ax11 = subplot(2, 2, 1);
hold on;
plot(f, abs(tf_ux_yx))
plot(f, abs(tf_uh_xh))
title('Frequency Response Function $\frac{y_x}{u_x}$')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude')
@ -205,14 +286,14 @@ We compute an estimate of the transfer functions.
ax12 = subplot(2, 2, 2);
hold on;
plot(f, abs(tf_uy_yx))
plot(f, abs(tf_uv_xh))
title('Frequency Response Function $\frac{y_x}{u_y}$')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
hold off;
ax21 = subplot(2, 2, 3);
hold on;
plot(f, abs(tf_ux_yy))
plot(f, abs(tf_uh_xv))
title('Frequency Response Function $\frac{y_y}{u_x}$')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude')
@ -221,7 +302,7 @@ We compute an estimate of the transfer functions.
ax22 = subplot(2, 2, 4);
hold on;
plot(f, abs(tf_uy_yy))
plot(f, abs(tf_uv_xv))
title('Frequency Response Function $\frac{y_y}{u_y}$')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
xlabel('Frequency [Hz]')
@ -244,17 +325,17 @@ We compute an estimate of the transfer functions.
** Coherence
#+begin_src matlab
[coh_ux_yx, f] = mscohere(ux.ux, ux.yx, hanning(ceil(1*fs)), [], [], fs);
[coh_ux_yy, ~] = mscohere(ux.ux, ux.yy, hanning(ceil(1*fs)), [], [], fs);
[coh_uy_yx, ~] = mscohere(uy.uy, uy.yx, hanning(ceil(1*fs)), [], [], fs);
[coh_uy_yy, ~] = mscohere(uy.uy, uy.yy, hanning(ceil(1*fs)), [], [], fs);
[coh_uh_xh, f] = mscohere(uh.uh, uh.xh, hanning(ceil(1*fs)), [], [], fs);
[coh_uh_xv, ~] = mscohere(uh.uh, uh.xv, hanning(ceil(1*fs)), [], [], fs);
[coh_uv_xh, ~] = mscohere(uv.uv, uv.xh, hanning(ceil(1*fs)), [], [], fs);
[coh_uv_xv, ~] = mscohere(uv.uv, uv.xv, hanning(ceil(1*fs)), [], [], fs);
#+end_src
#+begin_src matlab :exports none
figure;
ax11 = subplot(2, 2, 1);
hold on;
plot(f, coh_ux_yx)
plot(f, coh_uh_xh)
set(gca, 'Xscale', 'log');
title('Coherence $\frac{y_x}{u_x}$')
ylabel('Coherence')
@ -262,14 +343,14 @@ We compute an estimate of the transfer functions.
ax12 = subplot(2, 2, 2);
hold on;
plot(f, coh_uy_yx)
plot(f, coh_uv_xh)
set(gca, 'Xscale', 'log');
title('Coherence $\frac{y_x}{u_y}$')
hold off;
ax21 = subplot(2, 2, 3);
hold on;
plot(f, coh_ux_yy)
plot(f, coh_uh_xv)
set(gca, 'Xscale', 'log');
title('Coherence $\frac{y_y}{u_x}$')
ylabel('Coherence')
@ -278,7 +359,7 @@ We compute an estimate of the transfer functions.
ax22 = subplot(2, 2, 4);
hold on;
plot(f, coh_uy_yy)
plot(f, coh_uv_xv)
set(gca, 'Xscale', 'log');
title('Coherence $\frac{y_y}{u_y}$')
xlabel('Frequency [Hz]')
@ -381,16 +462,16 @@ We define the number of iteration.
An we run the =vectfit3= algorithm.
#+begin_src matlab
for iter = 1:Niter
[SER_ux_yx, poles, ~, fit_ux_yx] = vectfit3(tf_ux_yx.', 1i*2*pi*f, poles, weight, opts);
[SER_uh_xh, poles, ~, fit_uh_xh] = vectfit3(tf_uh_xh.', 1i*2*pi*f, poles, weight, opts);
end
for iter = 1:Niter
[SER_uy_yx, poles, ~, fit_uy_yx] = vectfit3(tf_uy_yx.', 1i*2*pi*f, poles, weight, opts);
[SER_uv_xh, poles, ~, fit_uv_xh] = vectfit3(tf_uv_xh.', 1i*2*pi*f, poles, weight, opts);
end
for iter = 1:Niter
[SER_ux_yy, poles, ~, fit_ux_yy] = vectfit3(tf_ux_yy.', 1i*2*pi*f, poles, weight, opts);
[SER_uh_xv, poles, ~, fit_uh_xv] = vectfit3(tf_uh_xv.', 1i*2*pi*f, poles, weight, opts);
end
for iter = 1:Niter
[SER_uy_yy, poles, ~, fit_uy_yy] = vectfit3(tf_uy_yy.', 1i*2*pi*f, poles, weight, opts);
[SER_uv_xv, poles, ~, fit_uv_xv] = vectfit3(tf_uv_xv.', 1i*2*pi*f, poles, weight, opts);
end
#+end_src
@ -398,8 +479,8 @@ An we run the =vectfit3= algorithm.
figure;
ax11 = subplot(2, 2, 1);
hold on;
plot(f, abs(tf_ux_yx))
plot(f, abs(fit_ux_yx))
plot(f, abs(tf_uh_xh))
plot(f, abs(fit_uh_xh))
title('Frequency Response Function $\frac{y_x}{u_x}$')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude')
@ -407,16 +488,16 @@ An we run the =vectfit3= algorithm.
ax12 = subplot(2, 2, 2);
hold on;
plot(f, abs(tf_uy_yx))
plot(f, abs(fit_uy_yx))
plot(f, abs(tf_uv_xh))
plot(f, abs(fit_uv_xh))
title('Frequency Response Function $\frac{y_x}{u_y}$')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
hold off;
ax21 = subplot(2, 2, 3);
hold on;
plot(f, abs(tf_ux_yy))
plot(f, abs(fit_ux_yy))
plot(f, abs(tf_uh_xv))
plot(f, abs(fit_uh_xv))
title('Frequency Response Function $\frac{y_y}{u_x}$')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
ylabel('Amplitude')
@ -425,8 +506,8 @@ An we run the =vectfit3= algorithm.
ax22 = subplot(2, 2, 4);
hold on;
plot(f, abs(tf_uy_yy))
plot(f, abs(fit_uy_yy))
plot(f, abs(tf_uv_xv))
plot(f, abs(fit_uv_xv))
title('Frequency Response Function $\frac{y_y}{u_y}$')
set(gca, 'Xscale', 'log'); set(gca, 'Yscale', 'log');
xlabel('Frequency [Hz]')
@ -449,18 +530,42 @@ An we run the =vectfit3= algorithm.
And finally, we create the identified state space model:
#+begin_src matlab
G_ux_yx = minreal(ss(full(SER_ux_yx.A),SER_ux_yx.B,SER_ux_yx.C,SER_ux_yx.D));
G_uy_yx = minreal(ss(full(SER_uy_yx.A),SER_uy_yx.B,SER_uy_yx.C,SER_uy_yx.D));
G_ux_yy = minreal(ss(full(SER_ux_yy.A),SER_ux_yy.B,SER_ux_yy.C,SER_ux_yy.D));
G_uy_yy = minreal(ss(full(SER_uy_yy.A),SER_uy_yy.B,SER_uy_yy.C,SER_uy_yy.D));
G_uh_xh = minreal(ss(full(SER_uh_xh.A),SER_uh_xh.B,SER_uh_xh.C,SER_uh_xh.D));
G_uv_xh = minreal(ss(full(SER_uv_xh.A),SER_uv_xh.B,SER_uv_xh.C,SER_uv_xh.D));
G_uh_xv = minreal(ss(full(SER_uh_xv.A),SER_uh_xv.B,SER_uh_xv.C,SER_uh_xv.D));
G_uv_xv = minreal(ss(full(SER_uv_xv.A),SER_uv_xv.B,SER_uv_xv.C,SER_uv_xv.D));
G = [G_ux_yx, G_uy_yx;
G_ux_yy, G_uy_yy];
G = [G_uh_xh, G_uv_xh;
G_uh_xv, G_uv_xv];
#+end_src
#+begin_src matlab
save('mat/plant.mat', 'G');
#+end_src
* Sensor Noise
* Plant Analysis
* Control
** Rotation Matrix
#+begin_src matlab
G0 = freqresp(G, 0);
#+end_src
* Control Objective
The maximum expected stroke is $y_\text{max} = 3mm \approx 5e^{-2} rad$ at $1Hz$.
The maximum wanted error is $e_\text{max} = 10 \mu rad$.
Thus, we require the sensitivity function at $\omega_0 = 1\text{ Hz}$:
\begin{align*}
|S(j\omega_0)| &< \left| \frac{e_\text{max}}{y_\text{max}} \right| \\
&< 2 \cdot 10^{-4}
\end{align*}
In terms of loop gain, this is equivalent to:
\[ |L(j\omega_0)| > 5 \cdot 10^{3} \]
* Plant Scaling
- measured noise
- expected perturbations
- maximum input usage
- maximum wanted error
* Control Design

View File

@ -5,7 +5,7 @@ tg = slrt;
% if tg.Status == "stopped"
% %% Load the application
% tg.load('test_cercalo');
%
%
% %% Run the application
% tg.start;
% pause(10);
@ -26,8 +26,8 @@ uh = data(:, 1); % Voltage sent to cercalo in horizontal direction
uv = data(:, 2); % [...] in vertical direction
xh = data(:, 3); % Measured horizontal position of the beam by the 4QD
xv = data(:, 4); % [...] vertical position
cuh = data(:, 3); % Voltage of the cercalo's inductors used for horizontal
cuv = data(:, 4); % [...] vertical
cuh = data(:, 5); % Voltage of the cercalo's inductors used for horizontal
cuv = data(:, 6); % [...] vertical
save('mat/data_uv.mat', 't', 'uh', 'uv', 'xh', 'xv', 'cuh', 'cuv');