dcm-feedback-control/dcm_feedback.html

1694 lines
94 KiB
HTML
Raw Normal View History

2022-02-15 14:16:10 +01:00
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2022-02-15 mar. 14:15 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>ESRF Double Crystal Monochromator - Feedback Controller</title>
<meta name="author" content="Dehaeze Thomas" />
<meta name="generator" content="Org Mode" />
<link rel="stylesheet" type="text/css" href="https://research.tdehaeze.xyz/css/style.css"/>
<script type="text/javascript" src="https://research.tdehaeze.xyz/js/script.js"></script>
</head>
<body>
<div id="org-div-home-and-up">
<a accesskey="h" href="../index.html"> UP </a>
|
<a accesskey="H" href="../index.html"> HOME </a>
</div><div id="content" class="content">
<h1 class="title">ESRF Double Crystal Monochromator - Feedback Controller</h1>
<div id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#org9127764">1. Estimation of Sensitivity Function</a>
<ul>
<li><a href="#org7b2fb65">1.1. Load Data</a></li>
<li><a href="#org7416bd6">1.2. Controller</a></li>
<li><a href="#org05c311a">1.3. Test</a></li>
</ul>
</li>
<li><a href="#org594dd0a">2. System Identification</a>
<ul>
<li><a href="#org0a18e7e">2.1. Identification</a></li>
<li><a href="#orgf48794a">2.2. Identification - New</a></li>
<li><a href="#org60d766d">2.3. Identification - White noise</a></li>
<li><a href="#org31395a9">2.4. Test</a></li>
<li><a href="#orgf58cff7">2.5. New controller - Higher bandwidth</a></li>
<li><a href="#org3141035">2.6. Added gain</a></li>
</ul>
</li>
<li><a href="#orgf483f30">3. Noise Budgeting</a>
<ul>
<li><a href="#org186fa6a">3.1. No Displacement</a></li>
<li><a href="#org64f1438">3.2. Scans</a></li>
<li><a href="#org60807a5">3.3. Noise budgeting - No rotation</a></li>
<li><a href="#orgf1f9c40">3.4. Noise budgeting - Bragg rotation</a></li>
</ul>
</li>
<li><a href="#orge12a029">4. Test Mode C</a>
<ul>
<li><a href="#org9173ef5">4.1. Mode B and Mode C</a></li>
</ul>
</li>
<li><a href="#org0482355">5. Export numerator and denominator</a>
<ul>
<li><a href="#orga946414">5.1. Export</a></li>
<li><a href="#org8ed08fd">5.2. Verify</a></li>
</ul>
</li>
</ul>
</div>
</div>
<hr>
<p>This report is also available as a <a href="./dcm_feedback.pdf">pdf</a>.</p>
<hr>
<div id="outline-container-org9127764" class="outline-2">
<h2 id="org9127764"><span class="section-number-2">1.</span> Estimation of Sensitivity Function</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-org7b2fb65" class="outline-3">
<h3 id="org7b2fb65"><span class="section-number-3">1.1.</span> Load Data</h3>
<div class="outline-text-3" id="text-1-1">
<p>
Two scans are performed:
</p>
<ul class="org-ul">
<li><code>1.1</code> in mode B</li>
<li><code>3.1</code> in mode C</li>
</ul>
<p>
The difference between the two is that mode C adds the feedback controller.
</p>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Load Data of the new LUT method</span>
Ts = 0.1;
ol_drx = 1e<span class="org-builtin">-</span>9<span class="org-builtin">*</span>double(h5read(<span class="org-string">'xanes_0003.h5'</span>,<span class="org-string">'/1.1/measurement/xtal_111_drx_filter'</span>)); <span class="org-comment-delimiter">% </span><span class="org-comment">Rx [rad]</span>
cl_drx = 1e<span class="org-builtin">-</span>9<span class="org-builtin">*</span>double(h5read(<span class="org-string">'xanes_0003.h5'</span>,<span class="org-string">'/3.1/measurement/xtal_111_drx_filter'</span>)); <span class="org-comment-delimiter">% </span><span class="org-comment">Rx [rad]</span>
ol_dry = 1e<span class="org-builtin">-</span>9<span class="org-builtin">*</span>double(h5read(<span class="org-string">'xanes_0003.h5'</span>,<span class="org-string">'/1.1/measurement/xtal_111_dry_filter'</span>)); <span class="org-comment-delimiter">% </span><span class="org-comment">Ry [rad]</span>
cl_dry = 1e<span class="org-builtin">-</span>9<span class="org-builtin">*</span>double(h5read(<span class="org-string">'xanes_0003.h5'</span>,<span class="org-string">'/3.1/measurement/xtal_111_dry_filter'</span>)); <span class="org-comment-delimiter">% </span><span class="org-comment">Ry [rad]</span>
t = linspace(Ts, Ts<span class="org-builtin">*</span>length(ol_drx), length(ol_drx));
</pre>
</div>
<p>
By comparison the frequency content of the crystal orientation errors between mode B and mode C, it is possible to estimate the Sensitivity transfer function (Figure <a href="#orge994d1e">1</a>).
</p>
<div class="org-src-container">
<pre class="src src-matlab">win = hanning(ceil(1<span class="org-builtin">/</span>Ts));
[pxx_ol_drx, f] = pwelch(ol_drx, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_cl_drx, <span class="org-builtin">~</span>] = pwelch(cl_drx, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_ol_dry, <span class="org-builtin">~</span>] = pwelch(ol_dry, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_cl_dry, <span class="org-builtin">~</span>] = pwelch(cl_dry, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
<div id="orge994d1e" class="figure">
<p><img src="figs/sensitivity_function_drx_est.png" alt="sensitivity_function_drx_est.png" />
</p>
<p><span class="figure-number">Figure 1: </span>Estimation of the sensitivity transfer function magnitude</p>
</div>
</div>
</div>
<div id="outline-container-org7416bd6" class="outline-3">
<h3 id="org7416bd6"><span class="section-number-3">1.2.</span> Controller</h3>
<div class="outline-text-3" id="text-1-2">
<div class="org-src-container">
<pre class="src src-matlab">load(<span class="org-string">'X_tal_cage_PID.mat'</span>, <span class="org-string">'K'</span>);
</pre>
</div>
<div id="org20267be" class="figure">
<p><img src="figs/bode_plot_cur_controller.png" alt="bode_plot_cur_controller.png" />
</p>
<p><span class="figure-number">Figure 2: </span>Bode Plot of the Controller</p>
</div>
</div>
</div>
<div id="outline-container-org05c311a" class="outline-3">
<h3 id="org05c311a"><span class="section-number-3">1.3.</span> Test</h3>
<div class="outline-text-3" id="text-1-3">
<div class="org-src-container">
<pre class="src src-matlab">Ts = 5e<span class="org-builtin">-</span>3;
cl_drx = 1e<span class="org-builtin">-</span>9<span class="org-builtin">*</span>double(h5read(<span class="org-string">'xanes_0003.h5'</span>,<span class="org-string">'/16.1/measurement/xtal_111_drx_filter'</span>)); <span class="org-comment-delimiter">% </span><span class="org-comment">Rx [rad]</span>
ol_drx = 1e<span class="org-builtin">-</span>9<span class="org-builtin">*</span>double(h5read(<span class="org-string">'xanes_0003.h5'</span>,<span class="org-string">'/18.1/measurement/xtal_111_drx_filter'</span>)); <span class="org-comment-delimiter">% </span><span class="org-comment">Rx [rad]</span>
t = linspace(Ts, Ts<span class="org-builtin">*</span>length(ol_drx), length(ol_drx));
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(t, ol_drx)
<span class="org-builtin">plot</span>(t, cl_drx)
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">win = hanning(ceil(10<span class="org-builtin">/</span>Ts));
[pxx_ol_drx, f] = pwelch(ol_drx, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_cl_drx, <span class="org-builtin">~</span>] = pwelch(cl_drx, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org594dd0a" class="outline-2">
<h2 id="org594dd0a"><span class="section-number-2">2.</span> System Identification</h2>
<div class="outline-text-2" id="text-2">
</div>
<div id="outline-container-org0a18e7e" class="outline-3">
<h3 id="org0a18e7e"><span class="section-number-3">2.1.</span> Identification</h3>
<div class="outline-text-3" id="text-2-1">
<div class="org-src-container">
<pre class="src src-matlab">ur = load(<span class="org-string">'FJPUR_step.mat'</span>);
uh = load(<span class="org-string">'FJPUH_step.mat'</span>);
d = load(<span class="org-string">'FJPD_step.mat'</span>);
</pre>
</div>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-right" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-right">1</td>
<td class="org-left">dz311</td>
</tr>
<tr>
<td class="org-right">2</td>
<td class="org-left">dry311</td>
</tr>
<tr>
<td class="org-right">3</td>
<td class="org-left">drx311</td>
</tr>
<tr>
<td class="org-right">4</td>
<td class="org-left">dz111</td>
</tr>
<tr>
<td class="org-right">5</td>
<td class="org-left">dry111</td>
</tr>
<tr>
<td class="org-right">6</td>
<td class="org-left">drx111</td>
</tr>
<tr>
<td class="org-right">7</td>
<td class="org-left">fjpur</td>
</tr>
<tr>
<td class="org-right">8</td>
<td class="org-left">fjpuh</td>
</tr>
<tr>
<td class="org-right">9</td>
<td class="org-left">fjpd</td>
</tr>
<tr>
<td class="org-right">10</td>
<td class="org-left">bragg</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-matlab">ur.time = ur.time <span class="org-builtin">-</span> ur.time(1);
ur.allValues(<span class="org-builtin">:</span>, 1) = ur.allValues(<span class="org-builtin">:</span>, 1) <span class="org-builtin">-</span> mean(ur.allValues(ur.time<span class="org-builtin">&lt;</span>1, 1));
ur.allValues(<span class="org-builtin">:</span>, 2) = ur.allValues(<span class="org-builtin">:</span>, 2) <span class="org-builtin">-</span> mean(ur.allValues(ur.time<span class="org-builtin">&lt;</span>1, 2));
ur.allValues(<span class="org-builtin">:</span>, 3) = ur.allValues(<span class="org-builtin">:</span>, 3) <span class="org-builtin">-</span> mean(ur.allValues(ur.time<span class="org-builtin">&lt;</span>1, 3));
t_filt = ur.time <span class="org-builtin">&gt;</span> 48 <span class="org-builtin">&amp;</span> ur.time <span class="org-builtin">&lt;</span> 60;
ur.u = ur.allValues(t_filt, 7);
ur.y_111 = [<span class="org-builtin">-</span>ur.allValues(t_filt, 1), ur.allValues(t_filt, 2), ur.allValues(t_filt, 3)];
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">uh.time = uh.time <span class="org-builtin">-</span> uh.time(1);
uh.allValues(<span class="org-builtin">:</span>, 1) = uh.allValues(<span class="org-builtin">:</span>, 1) <span class="org-builtin">-</span> mean(uh.allValues(uh.time<span class="org-builtin">&lt;</span>1, 1));
uh.allValues(<span class="org-builtin">:</span>, 2) = uh.allValues(<span class="org-builtin">:</span>, 2) <span class="org-builtin">-</span> mean(uh.allValues(uh.time<span class="org-builtin">&lt;</span>1, 2));
uh.allValues(<span class="org-builtin">:</span>, 3) = uh.allValues(<span class="org-builtin">:</span>, 3) <span class="org-builtin">-</span> mean(uh.allValues(uh.time<span class="org-builtin">&lt;</span>1, 3));
uh.u = uh.allValues(t_filt, 8);
uh.y_111 = [<span class="org-builtin">-</span>uh.allValues(t_filt, 1), uh.allValues(t_filt, 2), uh.allValues(t_filt, 3)];
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">d.time = d.time <span class="org-builtin">-</span> d.time(1);
d.allValues(<span class="org-builtin">:</span>, 1) = d.allValues(<span class="org-builtin">:</span>, 1) <span class="org-builtin">-</span> mean(d.allValues(d.time<span class="org-builtin">&lt;</span>1, 1));
d.allValues(<span class="org-builtin">:</span>, 2) = d.allValues(<span class="org-builtin">:</span>, 2) <span class="org-builtin">-</span> mean(d.allValues(d.time<span class="org-builtin">&lt;</span>1, 2));
d.allValues(<span class="org-builtin">:</span>, 3) = d.allValues(<span class="org-builtin">:</span>, 3) <span class="org-builtin">-</span> mean(d.allValues(d.time<span class="org-builtin">&lt;</span>1, 3));
d.u = d.allValues(t_filt, 9);
d.y_111 = [<span class="org-builtin">-</span>d.allValues(t_filt, 1), d.allValues(t_filt, 2), d.allValues(t_filt, 3)];
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">J_a_111 = [1, 0.14, <span class="org-builtin">-</span>0.0675
1, 0.14, 0.1525
1, <span class="org-builtin">-</span>0.14, 0.0425];
J_a_311 = [1, 0.14, <span class="org-builtin">-</span>0.1525
1, 0.14, 0.0675
1, <span class="org-builtin">-</span>0.14, <span class="org-builtin">-</span>0.0425];
ur.y = [J_a_311 <span class="org-builtin">*</span> ur.y_111<span class="org-builtin">'</span>]<span class="org-builtin">'</span>;
uh.y = [J_a_311 <span class="org-builtin">*</span> uh.y_111<span class="org-builtin">'</span>]<span class="org-builtin">'</span>;
d.y = [J_a_311 <span class="org-builtin">*</span> d.y_111<span class="org-builtin">'</span>]<span class="org-builtin">'</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Sampling Time and Frequency</span>
Ts = 1e<span class="org-builtin">-</span>4; <span class="org-comment-delimiter">% </span><span class="org-comment">[s]</span>
Fs = 1<span class="org-builtin">/</span>Ts; <span class="org-comment-delimiter">% </span><span class="org-comment">[Hz]</span>
<span class="org-comment-delimiter">% </span><span class="org-comment">Hannning Windows</span>
win = hanning(ceil(5<span class="org-builtin">*</span>Fs));
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% And we get the frequency vector</span>
[G_ur, f] = tfestimate(ur.u, ur.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[G_uh, <span class="org-builtin">~</span>] = tfestimate(uh.u, uh.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[G_d, <span class="org-builtin">~</span>] = tfestimate(d.u, d.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">[coh_ur, <span class="org-builtin">~</span>] = mscohere(ur.u, ur.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[coh_uh, <span class="org-builtin">~</span>] = mscohere(uh.u, uh.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[coh_d, <span class="org-builtin">~</span>] = mscohere(d.u, d.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
<div id="org0a5ca51" class="figure">
<p><img src="figs/coherence_id_dcm_dyn.png" alt="coherence_id_dcm_dyn.png" />
</p>
<p><span class="figure-number">Figure 3: </span>Coherence</p>
</div>
<div id="org632afe1" class="figure">
<p><img src="figs/bode_plot_dcm_dynamics.png" alt="bode_plot_dcm_dynamics.png" />
</p>
<p><span class="figure-number">Figure 4: </span>Bode Plot of the DCM dynamics in the frame of the fast jack.</p>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Previously used controller</span>
load(<span class="org-string">'X_tal_cage_PID.mat'</span>, <span class="org-string">'K'</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Controller design</span>
s = tf(<span class="org-string">'s'</span>);
<span class="org-comment-delimiter">% </span><span class="org-comment">Lead</span>
a = 4; <span class="org-comment-delimiter">% </span><span class="org-comment">Amount of phase lead / width of the phase lead / high frequency gain</span>
wc = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>20; <span class="org-comment-delimiter">% </span><span class="org-comment">Frequency with the maximum phase lead [rad/s]</span>
<span class="org-comment-delimiter">% </span><span class="org-comment">Low Pass Filter</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>100; <span class="org-comment-delimiter">% </span><span class="org-comment">Cut-off frequency [rad/s]</span>
xi = 0.4; <span class="org-comment-delimiter">% </span><span class="org-comment">Damping Ratio</span>
Kb = eye(3)<span class="org-builtin">*</span>(2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>20)<span class="org-builtin">^</span>2<span class="org-builtin">/</span>(s<span class="org-builtin">^</span>2) <span class="org-builtin">*</span>1<span class="org-builtin">/</span>(sqrt(a))<span class="org-builtin">*</span> (1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(wc<span class="org-builtin">/</span>sqrt(a)))<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(wc<span class="org-builtin">*</span>sqrt(a))) <span class="org-builtin">*</span> 1<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>xi<span class="org-builtin">/</span>w0<span class="org-builtin">*</span>s <span class="org-builtin">+</span> s<span class="org-builtin">^</span>2<span class="org-builtin">/</span>w0<span class="org-builtin">^</span>2);;
</pre>
</div>
<div id="org8397eee" class="figure">
<p><img src="figs/loop_gain_dcm_contr_simple.png" alt="loop_gain_dcm_contr_simple.png" />
</p>
<p><span class="figure-number">Figure 5: </span>Loop gain</p>
</div>
<div id="org35c3172" class="figure">
<p><img src="figs/loop_gain_diag_old_new_contr.png" alt="loop_gain_diag_old_new_contr.png" />
</p>
<p><span class="figure-number">Figure 6: </span>Loop gain</p>
</div>
<p>
Compare Sensitivity functions
</p>
<div id="org3879d08" class="figure">
<p><img src="figs/sensitivity_comp.png" alt="sensitivity_comp.png" />
</p>
<p><span class="figure-number">Figure 7: </span>Comparison of sensitivity functions</p>
</div>
<div class="org-src-container">
<pre class="src src-matlab">L = zeros(3, 3, length(f));
Lb = zeros(3, 3, length(f));
<span class="org-keyword">for</span> <span class="org-variable-name">i_f</span> = <span class="org-constant">1:length(f)</span>
L(<span class="org-builtin">:</span>,<span class="org-builtin">:</span>,i_f) = [G_ur(i_f,<span class="org-builtin">:</span>); G_uh(i_f,<span class="org-builtin">:</span>); G_d(i_f,<span class="org-builtin">:</span>)]<span class="org-builtin">*</span>freqresp(K , f(i_f), <span class="org-string">'Hz'</span>);
Lb(<span class="org-builtin">:</span>,<span class="org-builtin">:</span>,i_f) = [G_ur(i_f,<span class="org-builtin">:</span>); G_uh(i_f,<span class="org-builtin">:</span>); G_d(i_f,<span class="org-builtin">:</span>)]<span class="org-builtin">*</span>freqresp(Kb, f(i_f), <span class="org-string">'Hz'</span>);
<span class="org-keyword">end</span>
</pre>
</div>
<div id="org3e2aa6f" class="figure">
<p><img src="figs/loci_loop_gain_comp_controllers.png" alt="loci_loop_gain_comp_controllers.png" />
</p>
<p><span class="figure-number">Figure 8: </span>Root Locus</p>
</div>
</div>
</div>
<div id="outline-container-orgf48794a" class="outline-3">
<h3 id="orgf48794a"><span class="section-number-3">2.2.</span> Identification - New</h3>
<div class="outline-text-3" id="text-2-2">
<div class="org-src-container">
<pre class="src src-matlab">ur = load(<span class="org-string">'FJPUR_step_new.mat'</span>);
uh = load(<span class="org-string">'FJPUH_step_new.mat'</span>);
d = load(<span class="org-string">'FJPD_step_new.mat'</span>);
</pre>
</div>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-right" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-right">1</td>
<td class="org-left">dz311</td>
</tr>
<tr>
<td class="org-right">2</td>
<td class="org-left">dry311</td>
</tr>
<tr>
<td class="org-right">3</td>
<td class="org-left">drx311</td>
</tr>
<tr>
<td class="org-right">4</td>
<td class="org-left">dz111</td>
</tr>
<tr>
<td class="org-right">5</td>
<td class="org-left">dry111</td>
</tr>
<tr>
<td class="org-right">6</td>
<td class="org-left">drx111</td>
</tr>
<tr>
<td class="org-right">7</td>
<td class="org-left">fjpur</td>
</tr>
<tr>
<td class="org-right">8</td>
<td class="org-left">fjpuh</td>
</tr>
<tr>
<td class="org-right">9</td>
<td class="org-left">fjpd</td>
</tr>
<tr>
<td class="org-right">10</td>
<td class="org-left">bragg</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-matlab">ur.time = ur.time <span class="org-builtin">-</span> ur.time(1);
ur.allValues(<span class="org-builtin">:</span>, 1) = ur.allValues(<span class="org-builtin">:</span>, 1) <span class="org-builtin">-</span> mean(ur.allValues(ur.time<span class="org-builtin">&lt;</span>0.1, 1));
ur.allValues(<span class="org-builtin">:</span>, 2) = ur.allValues(<span class="org-builtin">:</span>, 2) <span class="org-builtin">-</span> mean(ur.allValues(ur.time<span class="org-builtin">&lt;</span>0.1, 2));
ur.allValues(<span class="org-builtin">:</span>, 3) = ur.allValues(<span class="org-builtin">:</span>, 3) <span class="org-builtin">-</span> mean(ur.allValues(ur.time<span class="org-builtin">&lt;</span>0.1, 3));
t_filt = ur.time <span class="org-builtin">&lt;</span> 5;
ur.u = ur.allValues(t_filt, 7);
ur.y_111 = [<span class="org-builtin">-</span>ur.allValues(t_filt, 1), ur.allValues(t_filt, 2), ur.allValues(t_filt, 3)];
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">uh.time = uh.time <span class="org-builtin">-</span> uh.time(1);
uh.allValues(<span class="org-builtin">:</span>, 1) = uh.allValues(<span class="org-builtin">:</span>, 1) <span class="org-builtin">-</span> mean(uh.allValues(uh.time<span class="org-builtin">&lt;</span>0.1, 1));
uh.allValues(<span class="org-builtin">:</span>, 2) = uh.allValues(<span class="org-builtin">:</span>, 2) <span class="org-builtin">-</span> mean(uh.allValues(uh.time<span class="org-builtin">&lt;</span>0.1, 2));
uh.allValues(<span class="org-builtin">:</span>, 3) = uh.allValues(<span class="org-builtin">:</span>, 3) <span class="org-builtin">-</span> mean(uh.allValues(uh.time<span class="org-builtin">&lt;</span>0.1, 3));
uh.u = uh.allValues(t_filt, 8);
uh.y_111 = [<span class="org-builtin">-</span>uh.allValues(t_filt, 1), uh.allValues(t_filt, 2), uh.allValues(t_filt, 3)];
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">d.time = d.time <span class="org-builtin">-</span> d.time(1);
d.allValues(<span class="org-builtin">:</span>, 1) = d.allValues(<span class="org-builtin">:</span>, 1) <span class="org-builtin">-</span> mean(d.allValues(d.time<span class="org-builtin">&lt;</span>0.1, 1));
d.allValues(<span class="org-builtin">:</span>, 2) = d.allValues(<span class="org-builtin">:</span>, 2) <span class="org-builtin">-</span> mean(d.allValues(d.time<span class="org-builtin">&lt;</span>0.1, 2));
d.allValues(<span class="org-builtin">:</span>, 3) = d.allValues(<span class="org-builtin">:</span>, 3) <span class="org-builtin">-</span> mean(d.allValues(d.time<span class="org-builtin">&lt;</span>0.1, 3));
d.u = d.allValues(t_filt, 9);
d.y_111 = [<span class="org-builtin">-</span>d.allValues(t_filt, 1), d.allValues(t_filt, 2), d.allValues(t_filt, 3)];
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">J_a_111 = [1, 0.14, <span class="org-builtin">-</span>0.0675
1, 0.14, 0.1525
1, <span class="org-builtin">-</span>0.14, 0.0425];
J_a_311 = [1, 0.14, <span class="org-builtin">-</span>0.1525
1, 0.14, 0.0675
1, <span class="org-builtin">-</span>0.14, <span class="org-builtin">-</span>0.0425];
ur.y = [J_a_311 <span class="org-builtin">*</span> ur.y_111<span class="org-builtin">'</span>]<span class="org-builtin">'</span>;
uh.y = [J_a_311 <span class="org-builtin">*</span> uh.y_111<span class="org-builtin">'</span>]<span class="org-builtin">'</span>;
d.y = [J_a_311 <span class="org-builtin">*</span> d.y_111<span class="org-builtin">'</span>]<span class="org-builtin">'</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Sampling Time and Frequency</span>
Ts = 1e<span class="org-builtin">-</span>4; <span class="org-comment-delimiter">% </span><span class="org-comment">[s]</span>
Fs = 1<span class="org-builtin">/</span>Ts; <span class="org-comment-delimiter">% </span><span class="org-comment">[Hz]</span>
<span class="org-comment-delimiter">% </span><span class="org-comment">Hannning Windows</span>
win = hanning(ceil(5<span class="org-builtin">*</span>Fs));
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% And we get the frequency vector</span>
[G_ur, f] = tfestimate(ur.u, ur.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[G_uh, <span class="org-builtin">~</span>] = tfestimate(uh.u, uh.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[G_d, <span class="org-builtin">~</span>] = tfestimate(d.u, d.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">[coh_ur, <span class="org-builtin">~</span>] = mscohere(ur.u, ur.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[coh_uh, <span class="org-builtin">~</span>] = mscohere(uh.u, uh.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[coh_d, <span class="org-builtin">~</span>] = mscohere(d.u, d.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Previously used controller</span>
load(<span class="org-string">'X_tal_cage_PID.mat'</span>, <span class="org-string">'K'</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Controller design</span>
s = tf(<span class="org-string">'s'</span>);
<span class="org-comment-delimiter">% </span><span class="org-comment">Lead</span>
a = 4; <span class="org-comment-delimiter">% </span><span class="org-comment">Amount of phase lead / width of the phase lead / high frequency gain</span>
wc = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>20; <span class="org-comment-delimiter">% </span><span class="org-comment">Frequency with the maximum phase lead [rad/s]</span>
<span class="org-comment-delimiter">% </span><span class="org-comment">Low Pass Filter</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>100; <span class="org-comment-delimiter">% </span><span class="org-comment">Cut-off frequency [rad/s]</span>
xi = 0.4; <span class="org-comment-delimiter">% </span><span class="org-comment">Damping Ratio</span>
Kb = eye(3)<span class="org-builtin">*</span>(2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>20)<span class="org-builtin">^</span>2<span class="org-builtin">/</span>(s<span class="org-builtin">^</span>2) <span class="org-builtin">*</span>1<span class="org-builtin">/</span>(sqrt(a))<span class="org-builtin">*</span> (1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(wc<span class="org-builtin">/</span>sqrt(a)))<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(wc<span class="org-builtin">*</span>sqrt(a))) <span class="org-builtin">*</span> 1<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>xi<span class="org-builtin">/</span>w0<span class="org-builtin">*</span>s <span class="org-builtin">+</span> s<span class="org-builtin">^</span>2<span class="org-builtin">/</span>w0<span class="org-builtin">^</span>2);;
</pre>
</div>
<p>
Compare Sensitivity functions
</p>
<div id="orgf885697" class="figure">
<p><img src="figs/sensitivity_comp.png" alt="sensitivity_comp.png" />
</p>
<p><span class="figure-number">Figure 9: </span>Comparison of sensitivity functions</p>
</div>
<div class="org-src-container">
<pre class="src src-matlab">L = zeros(3, 3, length(f));
Lb = zeros(3, 3, length(f));
<span class="org-keyword">for</span> <span class="org-variable-name">i_f</span> = <span class="org-constant">1:length(f)</span>
L(<span class="org-builtin">:</span>,<span class="org-builtin">:</span>,i_f) = [G_ur(i_f,<span class="org-builtin">:</span>); G_uh(i_f,<span class="org-builtin">:</span>); G_d(i_f,<span class="org-builtin">:</span>)]<span class="org-builtin">*</span>freqresp(K , f(i_f), <span class="org-string">'Hz'</span>);
Lb(<span class="org-builtin">:</span>,<span class="org-builtin">:</span>,i_f) = [G_ur(i_f,<span class="org-builtin">:</span>); G_uh(i_f,<span class="org-builtin">:</span>); G_d(i_f,<span class="org-builtin">:</span>)]<span class="org-builtin">*</span>freqresp(Kb, f(i_f), <span class="org-string">'Hz'</span>);
<span class="org-keyword">end</span>
</pre>
</div>
<div id="org70c85f2" class="figure">
<p><img src="figs/loci_loop_gain_comp_controllers.png" alt="loci_loop_gain_comp_controllers.png" />
</p>
<p><span class="figure-number">Figure 10: </span>Root Locus</p>
</div>
</div>
</div>
<div id="outline-container-org60d766d" class="outline-3">
<h3 id="org60d766d"><span class="section-number-3">2.3.</span> Identification - White noise</h3>
<div class="outline-text-3" id="text-2-3">
<div class="org-src-container">
<pre class="src src-matlab">ur = load(<span class="org-string">'fjpur_white_noise.mat'</span>);
uh = load(<span class="org-string">'fjpuh_white_noise.mat'</span>);
d = load(<span class="org-string">'fjpd_white_noise.mat'</span>);
</pre>
</div>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-right" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-right">1</td>
<td class="org-left">dz111</td>
</tr>
<tr>
<td class="org-right">2</td>
<td class="org-left">dry111</td>
</tr>
<tr>
<td class="org-right">3</td>
<td class="org-left">drx111</td>
</tr>
<tr>
<td class="org-right">4</td>
<td class="org-left">fjpur</td>
</tr>
<tr>
<td class="org-right">5</td>
<td class="org-left">fjpuh</td>
</tr>
<tr>
<td class="org-right">6</td>
<td class="org-left">fjpd</td>
</tr>
<tr>
<td class="org-right">7</td>
<td class="org-left">bragg</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-matlab">ur.time = ur.time <span class="org-builtin">-</span> ur.time(1);
ur.drx = ur.drx <span class="org-builtin">-</span> mean(ur.drx);
ur.dry = ur.dry <span class="org-builtin">-</span> mean(ur.dry);
ur.dz = ur.dz <span class="org-builtin">-</span> mean(ur.dz);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">uh.time = uh.time <span class="org-builtin">-</span> uh.time(1);
uh.drx = uh.drx <span class="org-builtin">-</span> mean(uh.drx);
uh.dry = uh.dry <span class="org-builtin">-</span> mean(uh.dry);
uh.dz = uh.dz <span class="org-builtin">-</span> mean(uh.dz);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">d.time = d.time <span class="org-builtin">-</span> d.time(1);
d.drx = d.drx <span class="org-builtin">-</span> mean(d.drx);
d.dry = d.dry <span class="org-builtin">-</span> mean(d.dry);
d.dz = d.dz <span class="org-builtin">-</span> mean(d.dz);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">J_a_111 = [1, 0.14, <span class="org-builtin">-</span>0.0675
1, 0.14, 0.1525
1, <span class="org-builtin">-</span>0.14, 0.0425];
ur.y = [J_a_111 <span class="org-builtin">*</span> [<span class="org-builtin">-</span>ur.dz, ur.dry, ur.drx]<span class="org-builtin">'</span>]<span class="org-builtin">'</span>;
uh.y = [J_a_111 <span class="org-builtin">*</span> [<span class="org-builtin">-</span>uh.dz, uh.dry, uh.drx]<span class="org-builtin">'</span>]<span class="org-builtin">'</span>;
d.y = [J_a_111 <span class="org-builtin">*</span> [<span class="org-builtin">-</span>d.dz, d.dry, d.drx]<span class="org-builtin">'</span>]<span class="org-builtin">'</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Sampling Time and Frequency</span>
Ts = 1e<span class="org-builtin">-</span>4; <span class="org-comment-delimiter">% </span><span class="org-comment">[s]</span>
Fs = 1<span class="org-builtin">/</span>Ts; <span class="org-comment-delimiter">% </span><span class="org-comment">[Hz]</span>
<span class="org-comment-delimiter">% </span><span class="org-comment">Hannning Windows</span>
win = hanning(ceil(0.5<span class="org-builtin">*</span>Fs));
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% And we get the frequency vector</span>
[G_ur, f] = tfestimate(ur.fjpur, ur.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[G_uh, <span class="org-builtin">~</span>] = tfestimate(uh.fjpuh, uh.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[G_d, <span class="org-builtin">~</span>] = tfestimate(d.fjpd, d.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">[coh_ur, <span class="org-builtin">~</span>] = mscohere(ur.fjpur, ur.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[coh_uh, <span class="org-builtin">~</span>] = mscohere(uh.fjpuh, uh.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
[coh_d, <span class="org-builtin">~</span>] = mscohere(d.fjpd, d.y, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
<div id="org006c732" class="figure">
<p><img src="figs/coherence_ident_noise.png" alt="coherence_ident_noise.png" />
</p>
<p><span class="figure-number">Figure 11: </span>description</p>
</div>
<div id="org82515d7" class="figure">
<p><img src="figs/bode_plot_ident_noise.png" alt="bode_plot_ident_noise.png" />
</p>
<p><span class="figure-number">Figure 12: </span>Bode Plot of the DCM dynamics in the frame of the fast jack.</p>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Previously used controller</span>
load(<span class="org-string">'X_tal_cage_PID.mat'</span>, <span class="org-string">'K'</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Controller design</span>
s = tf(<span class="org-string">'s'</span>);
<span class="org-comment-delimiter">% </span><span class="org-comment">Lead</span>
a = 8; <span class="org-comment-delimiter">% </span><span class="org-comment">Amount of phase lead / width of the phase lead / high frequency gain</span>
wc = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>20; <span class="org-comment-delimiter">% </span><span class="org-comment">Frequency with the maximum phase lead [rad/s]</span>
<span class="org-comment-delimiter">% </span><span class="org-comment">Low Pass Filter</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>80; <span class="org-comment-delimiter">% </span><span class="org-comment">Cut-off frequency [rad/s]</span>
xi = 0.4; <span class="org-comment-delimiter">% </span><span class="org-comment">Damping Ratio</span>
Kb = eye(3)<span class="org-builtin">*</span>(2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>20)<span class="org-builtin">^</span>2<span class="org-builtin">/</span>(s<span class="org-builtin">^</span>2) <span class="org-builtin">*</span>1<span class="org-builtin">/</span>(sqrt(a))<span class="org-builtin">*</span> (1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(wc<span class="org-builtin">/</span>sqrt(a)))<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(wc<span class="org-builtin">*</span>sqrt(a))) <span class="org-builtin">*</span> 1<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>xi<span class="org-builtin">/</span>w0<span class="org-builtin">*</span>s <span class="org-builtin">+</span> s<span class="org-builtin">^</span>2<span class="org-builtin">/</span>w0<span class="org-builtin">^</span>2);;
</pre>
</div>
<div id="org601fb53" class="figure">
<p><img src="figs/loop_gain_dcm_contr_simple.png" alt="loop_gain_dcm_contr_simple.png" />
</p>
<p><span class="figure-number">Figure 13: </span>Loop gain</p>
</div>
<div id="orgb442ea7" class="figure">
<p><img src="figs/loop_gain_diag_old_new_contr.png" alt="loop_gain_diag_old_new_contr.png" />
</p>
<p><span class="figure-number">Figure 14: </span>Loop gain</p>
</div>
<p>
Compare Sensitivity functions
</p>
<div id="org55d152a" class="figure">
<p><img src="figs/sensitivity_comp.png" alt="sensitivity_comp.png" />
</p>
<p><span class="figure-number">Figure 15: </span>Comparison of sensitivity functions</p>
</div>
<div class="org-src-container">
<pre class="src src-matlab">L = zeros(3, 3, length(f));
Lb = zeros(3, 3, length(f));
<span class="org-keyword">for</span> <span class="org-variable-name">i_f</span> = <span class="org-constant">1:length(f)</span>
L(<span class="org-builtin">:</span>,<span class="org-builtin">:</span>,i_f) = [G_ur(i_f,<span class="org-builtin">:</span>); G_uh(i_f,<span class="org-builtin">:</span>); G_d(i_f,<span class="org-builtin">:</span>)]<span class="org-builtin">*</span>freqresp(K , f(i_f), <span class="org-string">'Hz'</span>);
Lb(<span class="org-builtin">:</span>,<span class="org-builtin">:</span>,i_f) = [G_ur(i_f,<span class="org-builtin">:</span>); G_uh(i_f,<span class="org-builtin">:</span>); G_d(i_f,<span class="org-builtin">:</span>)]<span class="org-builtin">*</span>freqresp(Kb, f(i_f), <span class="org-string">'Hz'</span>);
<span class="org-keyword">end</span>
</pre>
</div>
<div id="orgdc493de" class="figure">
<p><img src="figs/loci_loop_gain_comp_controllers.png" alt="loci_loop_gain_comp_controllers.png" />
</p>
<p><span class="figure-number">Figure 16: </span>Root Locus</p>
</div>
</div>
</div>
<div id="outline-container-org31395a9" class="outline-3">
<h3 id="org31395a9"><span class="section-number-3">2.4.</span> Test</h3>
<div class="outline-text-3" id="text-2-4">
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Notch</span>
gm = 0.015;
xi = 0.1;
wn = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>208;
K_notch = (s<span class="org-builtin">^</span>2 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>gm<span class="org-builtin">*</span>xi<span class="org-builtin">*</span>wn<span class="org-builtin">*</span>s <span class="org-builtin">+</span> wn<span class="org-builtin">^</span>2)<span class="org-builtin">/</span>(s<span class="org-builtin">^</span>2 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>xi<span class="org-builtin">*</span>wn<span class="org-builtin">*</span>s <span class="org-builtin">+</span> wn<span class="org-builtin">^</span>2);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Double integrator</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>40;
K_int = (w0<span class="org-builtin">^</span>2)<span class="org-builtin">/</span>(s<span class="org-builtin">^</span>2);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Lead</span>
a = 3; <span class="org-comment-delimiter">% </span><span class="org-comment">Amount of phase lead / width of the phase lead / high frequency gain</span>
K_lead = 1<span class="org-builtin">/</span>(sqrt(a))<span class="org-builtin">*</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(w0<span class="org-builtin">/</span>sqrt(a)))<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(w0<span class="org-builtin">*</span>sqrt(a)));
K_lead = K_lead<span class="org-builtin">*</span>K_lead;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Low Pass Filter</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>120; <span class="org-comment-delimiter">% </span><span class="org-comment">Cut-off frequency [rad/s]</span>
xi = 0.3; <span class="org-comment-delimiter">% </span><span class="org-comment">Damping Ratio</span>
K_lpf = 1<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>xi<span class="org-builtin">/</span>w0<span class="org-builtin">*</span>s <span class="org-builtin">+</span> s<span class="org-builtin">^</span>2<span class="org-builtin">/</span>w0<span class="org-builtin">^</span>2);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Diagonal controller</span>
Kb = 0.8<span class="org-builtin">*</span>eye(3)<span class="org-builtin">*</span>K_notch<span class="org-builtin">*</span>K_int<span class="org-builtin">*</span>K_lead<span class="org-builtin">*</span>K_lpf;
</pre>
</div>
</div>
</div>
<div id="outline-container-orgf58cff7" class="outline-3">
<h3 id="orgf58cff7"><span class="section-number-3">2.5.</span> New controller - Higher bandwidth</h3>
<div class="outline-text-3" id="text-2-5">
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Previously used controller</span>
load(<span class="org-string">'X_tal_cage_PID.mat'</span>, <span class="org-string">'K'</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Current Controller design</span>
<span class="org-comment-delimiter">% </span><span class="org-comment">Lead</span>
a = 8; <span class="org-comment-delimiter">% </span><span class="org-comment">Amount of phase lead / width of the phase lead / high frequency gain</span>
wc = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>20; <span class="org-comment-delimiter">% </span><span class="org-comment">Frequency with the maximum phase lead [rad/s]</span>
<span class="org-comment-delimiter">% </span><span class="org-comment">Low Pass Filter</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>80; <span class="org-comment-delimiter">% </span><span class="org-comment">Cut-off frequency [rad/s]</span>
xi = 0.4; <span class="org-comment-delimiter">% </span><span class="org-comment">Damping Ratio</span>
Kb_old = eye(3)<span class="org-builtin">*</span>(2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>20)<span class="org-builtin">^</span>2<span class="org-builtin">/</span>(s<span class="org-builtin">^</span>2) <span class="org-builtin">*</span>1<span class="org-builtin">/</span>(sqrt(a))<span class="org-builtin">*</span> (1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(wc<span class="org-builtin">/</span>sqrt(a)))<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(wc<span class="org-builtin">*</span>sqrt(a))) <span class="org-builtin">*</span> 1<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>xi<span class="org-builtin">/</span>w0<span class="org-builtin">*</span>s <span class="org-builtin">+</span> s<span class="org-builtin">^</span>2<span class="org-builtin">/</span>w0<span class="org-builtin">^</span>2);;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Notch</span>
gm = 0.015;
xi = 0.2;
wn = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>208;
K_notch = (s<span class="org-builtin">^</span>2 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>gm<span class="org-builtin">*</span>xi<span class="org-builtin">*</span>wn<span class="org-builtin">*</span>s <span class="org-builtin">+</span> wn<span class="org-builtin">^</span>2)<span class="org-builtin">/</span>(s<span class="org-builtin">^</span>2 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>xi<span class="org-builtin">*</span>wn<span class="org-builtin">*</span>s <span class="org-builtin">+</span> wn<span class="org-builtin">^</span>2);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Double integrator</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>40;
K_int = (w0<span class="org-builtin">^</span>2)<span class="org-builtin">/</span>(s<span class="org-builtin">^</span>2);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Lead</span>
a = 3; <span class="org-comment-delimiter">% </span><span class="org-comment">Amount of phase lead / width of the phase lead / high frequency gain</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>40;
K_lead = 1<span class="org-builtin">/</span>(sqrt(a))<span class="org-builtin">*</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(w0<span class="org-builtin">/</span>sqrt(a)))<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(w0<span class="org-builtin">*</span>sqrt(a)));
K_lead = K_lead<span class="org-builtin">*</span>K_lead;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Low Pass Filter</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>120; <span class="org-comment-delimiter">% </span><span class="org-comment">Cut-off frequency [rad/s]</span>
xi = 0.3; <span class="org-comment-delimiter">% </span><span class="org-comment">Damping Ratio</span>
K_lpf = 1<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>xi<span class="org-builtin">/</span>w0<span class="org-builtin">*</span>s <span class="org-builtin">+</span> s<span class="org-builtin">^</span>2<span class="org-builtin">/</span>w0<span class="org-builtin">^</span>2);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Diagonal controller</span>
Kb = 0.9<span class="org-builtin">*</span>eye(3)<span class="org-builtin">*</span>K_notch<span class="org-builtin">*</span>K_int<span class="org-builtin">*</span>K_lead<span class="org-builtin">*</span>K_lpf;
</pre>
</div>
<div id="org9e271c2" class="figure">
<p><img src="figs/loop_gain_compare.png" alt="loop_gain_compare.png" />
</p>
<p><span class="figure-number">Figure 17: </span>description</p>
</div>
<div class="org-src-container">
<pre class="src src-matlab">L = zeros(3, 3, length(f));
Lb = zeros(3, 3, length(f));
Lb_new = zeros(3, 3, length(f));
<span class="org-keyword">for</span> <span class="org-variable-name">i_f</span> = <span class="org-constant">1:length(f)</span>
L(<span class="org-builtin">:</span>,<span class="org-builtin">:</span>,i_f) = [G_ur(i_f,<span class="org-builtin">:</span>); G_uh(i_f,<span class="org-builtin">:</span>); G_d(i_f,<span class="org-builtin">:</span>)]<span class="org-builtin">*</span>freqresp(K , f(i_f), <span class="org-string">'Hz'</span>);
Lb(<span class="org-builtin">:</span>,<span class="org-builtin">:</span>,i_f) = [G_ur(i_f,<span class="org-builtin">:</span>); G_uh(i_f,<span class="org-builtin">:</span>); G_d(i_f,<span class="org-builtin">:</span>)]<span class="org-builtin">*</span>freqresp(Kb_old, f(i_f), <span class="org-string">'Hz'</span>);
Lb_new(<span class="org-builtin">:</span>,<span class="org-builtin">:</span>,i_f) = [G_ur(i_f,<span class="org-builtin">:</span>); G_uh(i_f,<span class="org-builtin">:</span>); G_d(i_f,<span class="org-builtin">:</span>)]<span class="org-builtin">*</span>freqresp(Kb, f(i_f), <span class="org-string">'Hz'</span>);
<span class="org-keyword">end</span>
</pre>
</div>
<div id="org8647e61" class="figure">
<p><img src="figs/nyquist_compare.png" alt="nyquist_compare.png" />
</p>
<p><span class="figure-number">Figure 18: </span>n</p>
</div>
<div id="org9640964" class="figure">
<p><img src="figs/sensitivity_function_compare.png" alt="sensitivity_function_compare.png" />
</p>
<p><span class="figure-number">Figure 19: </span>description</p>
</div>
</div>
</div>
<div id="outline-container-org3141035" class="outline-3">
<h3 id="org3141035"><span class="section-number-3">2.6.</span> Added gain</h3>
<div class="outline-text-3" id="text-2-6">
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Notch</span>
gm = 0.015;
xi = 0.2;
wn = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>208;
K_notch = (s<span class="org-builtin">^</span>2 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>gm<span class="org-builtin">*</span>xi<span class="org-builtin">*</span>wn<span class="org-builtin">*</span>s <span class="org-builtin">+</span> wn<span class="org-builtin">^</span>2)<span class="org-builtin">/</span>(s<span class="org-builtin">^</span>2 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>xi<span class="org-builtin">*</span>wn<span class="org-builtin">*</span>s <span class="org-builtin">+</span> wn<span class="org-builtin">^</span>2);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Double integrator</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>40;
K_int = (w0<span class="org-builtin">^</span>2)<span class="org-builtin">/</span>(s<span class="org-builtin">^</span>2);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Lead</span>
a = 3; <span class="org-comment-delimiter">% </span><span class="org-comment">Amount of phase lead / width of the phase lead / high frequency gain</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>40;
K_lead = 1<span class="org-builtin">/</span>(sqrt(a))<span class="org-builtin">*</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(w0<span class="org-builtin">/</span>sqrt(a)))<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>(w0<span class="org-builtin">*</span>sqrt(a)));
K_lead = K_lead<span class="org-builtin">*</span>K_lead;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Low Pass Filter</span>
w0 = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>120; <span class="org-comment-delimiter">% </span><span class="org-comment">Cut-off frequency [rad/s]</span>
xi = 0.3; <span class="org-comment-delimiter">% </span><span class="org-comment">Damping Ratio</span>
K_lpf = 1<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>xi<span class="org-builtin">/</span>w0<span class="org-builtin">*</span>s <span class="org-builtin">+</span> s<span class="org-builtin">^</span>2<span class="org-builtin">/</span>w0<span class="org-builtin">^</span>2);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">gm = 10;
xi = 0.02;
wn = 2<span class="org-builtin">*</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>15;
H = (s<span class="org-builtin">^</span>2 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>gm<span class="org-builtin">*</span>xi<span class="org-builtin">*</span>wn<span class="org-builtin">*</span>s <span class="org-builtin">+</span> wn<span class="org-builtin">^</span>2)<span class="org-builtin">/</span>(s<span class="org-builtin">^</span>2 <span class="org-builtin">+</span> 2<span class="org-builtin">*</span>xi<span class="org-builtin">*</span>wn<span class="org-builtin">*</span>s <span class="org-builtin">+</span> wn<span class="org-builtin">^</span>2);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Diagonal controller</span>
Kb_gain = 0.9<span class="org-builtin">*</span>eye(3)<span class="org-builtin">*</span>H<span class="org-builtin">*</span>K_notch<span class="org-builtin">*</span>K_int<span class="org-builtin">*</span>K_lead<span class="org-builtin">*</span>K_lpf;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">Lb_gain = zeros(3, 3, length(f));
<span class="org-keyword">for</span> <span class="org-variable-name">i_f</span> = <span class="org-constant">1:length(f)</span>
Lb_gain(<span class="org-builtin">:</span>,<span class="org-builtin">:</span>,i_f) = [G_ur(i_f,<span class="org-builtin">:</span>); G_uh(i_f,<span class="org-builtin">:</span>); G_d(i_f,<span class="org-builtin">:</span>)]<span class="org-builtin">*</span>freqresp(Kb_gain, f(i_f), <span class="org-string">'Hz'</span>);
<span class="org-keyword">end</span>
</pre>
</div>
<div id="org222e04a" class="figure">
<p><img src="figs/loop_gain_compare_added_gain.png" alt="loop_gain_compare_added_gain.png" />
</p>
<p><span class="figure-number">Figure 20: </span>description</p>
</div>
<div id="org4a20f29" class="figure">
<p><img src="figs/sensitivity_new_gain_compare.png" alt="sensitivity_new_gain_compare.png" />
</p>
<p><span class="figure-number">Figure 21: </span>description</p>
</div>
<div id="orgab54e70" class="figure">
<p><img src="figs/nyquist_after_gain_frequency.png" alt="nyquist_after_gain_frequency.png" />
</p>
<p><span class="figure-number">Figure 22: </span>nyquist plot</p>
</div>
</div>
</div>
</div>
<div id="outline-container-orgf483f30" class="outline-2">
<h2 id="orgf483f30"><span class="section-number-2">3.</span> Noise Budgeting</h2>
<div class="outline-text-2" id="text-3">
</div>
<div id="outline-container-org186fa6a" class="outline-3">
<h3 id="org186fa6a"><span class="section-number-3">3.1.</span> No Displacement</h3>
<div class="outline-text-3" id="text-3-1">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-right" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-right">1</td>
<td class="org-left">dz311</td>
</tr>
<tr>
<td class="org-right">2</td>
<td class="org-left">dry311</td>
</tr>
<tr>
<td class="org-right">3</td>
<td class="org-left">drx311</td>
</tr>
<tr>
<td class="org-right">4</td>
<td class="org-left">dz111</td>
</tr>
<tr>
<td class="org-right">5</td>
<td class="org-left">dry111</td>
</tr>
<tr>
<td class="org-right">6</td>
<td class="org-left">drx111</td>
</tr>
<tr>
<td class="org-right">7</td>
<td class="org-left">fjpur</td>
</tr>
<tr>
<td class="org-right">8</td>
<td class="org-left">fjpuh</td>
</tr>
<tr>
<td class="org-right">9</td>
<td class="org-left">fjpd</td>
</tr>
<tr>
<td class="org-right">10</td>
<td class="org-left">bragg</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-matlab">data_10_deg = load(<span class="org-string">'no_mov_10.mat'</span>);
data_70_deg = load(<span class="org-string">'no_mov_70.mat'</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">data_10_deg = extractDatData(<span class="org-string">'no_mov_10.mat'</span>, <span class="org-comment-delimiter">.</span><span class="org-comment">..</span>
{<span class="org-string">"dz311"</span>, <span class="org-string">"dry311"</span>, <span class="org-string">"drx311"</span>, <span class="org-string">"dz"</span>, <span class="org-string">"dry"</span>, <span class="org-string">"drx"</span>, <span class="org-string">"fjpur"</span>, <span class="org-string">"fjpuh"</span>, <span class="org-string">"fjpd"</span>, <span class="org-string">"bragg"</span>}, <span class="org-comment-delimiter">.</span><span class="org-comment">..</span>
[1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>8, 1e<span class="org-builtin">-</span>8, 1e<span class="org-builtin">-</span>8, <span class="org-matlab-math">pi</span><span class="org-builtin">/</span>180]);
data_10_deg = processMeasData(data_10_deg);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">Ts = 1e<span class="org-builtin">-</span>4;
t = Ts<span class="org-builtin">*</span>[1<span class="org-builtin">:</span>length(data_10_deg.bragg)];
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">data_10_deg.dz = data_10_deg.allValues(<span class="org-builtin">:</span>,4) <span class="org-builtin">-</span> mean(data_10_deg.allValues(<span class="org-builtin">:</span>,4));
data_10_deg.dry = data_10_deg.allValues(<span class="org-builtin">:</span>,5) <span class="org-builtin">-</span> mean(data_10_deg.allValues(<span class="org-builtin">:</span>,5));
data_10_deg.drx = data_10_deg.allValues(<span class="org-builtin">:</span>,6) <span class="org-builtin">-</span> mean(data_10_deg.allValues(<span class="org-builtin">:</span>,6));
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Compute motion error in the frame of the fast jack</span>
J_a_111 = [1, 0.14, <span class="org-builtin">-</span>0.1525
1, 0.14, 0.0675
1, <span class="org-builtin">-</span>0.14, 0.0425];
de_111 = [data_10_deg.dz<span class="org-builtin">'</span>; data_10_deg.dry<span class="org-builtin">'</span>; data_10_deg.drx<span class="org-builtin">'</span>];
de_fj = J_a_111<span class="org-builtin">*</span>de_111;
data_10_deg.fj_ur = de_fj(1,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>;
data_10_deg.fj_uh = de_fj(2,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>;
data_10_deg.fj_d = de_fj(3,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>;
de_111 = [data_70_deg.dz<span class="org-builtin">'</span>; data_70_deg.dry<span class="org-builtin">'</span>; data_70_deg.drx<span class="org-builtin">'</span>];
de_fj = J_a_111<span class="org-builtin">*</span>de_111;
data_70_deg.fj_ur = de_fj(1,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>;
data_70_deg.fj_uh = de_fj(2,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>;
data_70_deg.fj_d = de_fj(3,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">win = hanning(ceil(1<span class="org-builtin">/</span>Ts));
[pxx_10_ur, f] = pwelch(data_10_deg.fj_ur, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_70_ur, <span class="org-builtin">~</span>] = pwelch(data_70_deg.fj_ur, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_10_uh, <span class="org-builtin">~</span>] = pwelch(data_10_deg.fj_uh, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_70_uh, <span class="org-builtin">~</span>] = pwelch(data_70_deg.fj_uh, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_10_d, <span class="org-builtin">~</span>] = pwelch(data_10_deg.fj_d, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_70_d, <span class="org-builtin">~</span>] = pwelch(data_70_deg.fj_d, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">CPS_10_ur = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_10_ur)));
CPS_10_uh = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_10_uh)));
CPS_10_d = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_10_d)));
CPS_70_ur = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_70_ur)));
CPS_70_uh = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_70_uh)));
CPS_70_d = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_70_d)));
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(f, sqrt(CPS_10_ur), <span class="org-string">'-'</span> , <span class="org-string">'color'</span>, colors(1, <span class="org-builtin">:</span>), <span class="org-string">'DisplayName'</span>, <span class="org-string">'10 deg - $u_r$'</span>)
<span class="org-builtin">plot</span>(f, sqrt(CPS_70_ur), <span class="org-string">'--'</span>, <span class="org-string">'color'</span>, colors(1, <span class="org-builtin">:</span>), <span class="org-string">'DisplayName'</span>, <span class="org-string">'70 deg - $u_r$'</span>)
<span class="org-builtin">plot</span>(f, sqrt(CPS_10_uh), <span class="org-string">'-'</span> , <span class="org-string">'color'</span>, colors(2, <span class="org-builtin">:</span>), <span class="org-string">'DisplayName'</span>, <span class="org-string">'10 deg - $u_h$'</span>)
<span class="org-builtin">plot</span>(f, sqrt(CPS_70_uh), <span class="org-string">'--'</span>, <span class="org-string">'color'</span>, colors(2, <span class="org-builtin">:</span>), <span class="org-string">'DisplayName'</span>, <span class="org-string">'70 deg - $u_h$'</span>)
<span class="org-builtin">plot</span>(f, sqrt(CPS_10_d), <span class="org-string">'-'</span> , <span class="org-string">'color'</span>, colors(3, <span class="org-builtin">:</span>), <span class="org-string">'DisplayName'</span>, <span class="org-string">'10 deg - $d$'</span>)
<span class="org-builtin">plot</span>(f, sqrt(CPS_70_d), <span class="org-string">'--'</span>, <span class="org-string">'color'</span>, colors(3, <span class="org-builtin">:</span>), <span class="org-string">'DisplayName'</span>, <span class="org-string">'70 deg - $d$'</span>)
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">off;</span>
<span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'XScale'</span>, <span class="org-string">'log'</span>); <span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'YScale'</span>, <span class="org-string">'log'</span>);
<span class="org-builtin">xlabel</span>(<span class="org-string">'Frequency [Hz]'</span>); <span class="org-builtin">ylabel</span>(<span class="org-string">'ASD [$\frac{nrad}{\sqrt{Hz}}$]'</span>);
<span class="org-builtin">legend</span>(<span class="org-string">'location'</span>, <span class="org-string">'northwest'</span>);
<span class="org-builtin">xlim</span>([1, 1e3]);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(f, sqrt(pxx_10_ur))
<span class="org-builtin">plot</span>(f, sqrt(pxx_70_ur))
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">off;</span>
<span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'XScale'</span>, <span class="org-string">'log'</span>); <span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'YScale'</span>, <span class="org-string">'log'</span>);
<span class="org-builtin">xlabel</span>(<span class="org-string">'Frequency [Hz]'</span>); <span class="org-builtin">ylabel</span>(<span class="org-string">'ASD [$\frac{nrad}{\sqrt{Hz}}$]'</span>);
<span class="org-builtin">legend</span>(<span class="org-string">'location'</span>, <span class="org-string">'northwest'</span>);
<span class="org-builtin">xlim</span>([1, 1e3]);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">data_70_deg.dz = data_70_deg.allValues(<span class="org-builtin">:</span>,4) <span class="org-builtin">-</span> mean(data_70_deg.allValues(<span class="org-builtin">:</span>,4));
data_70_deg.dry = data_70_deg.allValues(<span class="org-builtin">:</span>,5) <span class="org-builtin">-</span> mean(data_70_deg.allValues(<span class="org-builtin">:</span>,5));
data_70_deg.drx = data_70_deg.allValues(<span class="org-builtin">:</span>,6) <span class="org-builtin">-</span> mean(data_70_deg.allValues(<span class="org-builtin">:</span>,6));
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">win = hanning(ceil(1<span class="org-builtin">/</span>Ts));
[pxx_10_drx, f] = pwelch(data_10_deg.drx, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_70_drx, <span class="org-builtin">~</span>] = pwelch(data_70_deg.drx, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_10_dry, <span class="org-builtin">~</span>] = pwelch(data_10_deg.dry, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_70_dry, <span class="org-builtin">~</span>] = pwelch(data_70_deg.dry, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_10_dz, <span class="org-builtin">~</span>] = pwelch(data_10_deg.dz, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_70_dz, <span class="org-builtin">~</span>] = pwelch(data_70_deg.dz, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(f, sqrt(pxx_10_drx))
<span class="org-builtin">plot</span>(f, sqrt(pxx_70_drx))
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">off;</span>
<span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'XScale'</span>, <span class="org-string">'log'</span>); <span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'YScale'</span>, <span class="org-string">'log'</span>);
<span class="org-builtin">xlabel</span>(<span class="org-string">'Frequency [Hz]'</span>); <span class="org-builtin">ylabel</span>(<span class="org-string">'ASD [$\frac{nrad}{\sqrt{Hz}}$]'</span>);
<span class="org-builtin">legend</span>(<span class="org-string">'location'</span>, <span class="org-string">'northwest'</span>);
<span class="org-builtin">xlim</span>([1, 1e3]);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(f, sqrt(pxx_10_dry))
<span class="org-builtin">plot</span>(f, sqrt(pxx_70_dry))
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">off;</span>
<span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'XScale'</span>, <span class="org-string">'log'</span>); <span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'YScale'</span>, <span class="org-string">'log'</span>);
<span class="org-builtin">xlabel</span>(<span class="org-string">'Frequency [Hz]'</span>); <span class="org-builtin">ylabel</span>(<span class="org-string">'ASD [$\frac{nrad}{\sqrt{Hz}}$]'</span>);
<span class="org-builtin">legend</span>(<span class="org-string">'location'</span>, <span class="org-string">'northwest'</span>);
<span class="org-builtin">xlim</span>([1, 1e3]);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(f, sqrt(pxx_10_dz))
<span class="org-builtin">plot</span>(f, sqrt(pxx_70_dz))
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">off;</span>
<span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'XScale'</span>, <span class="org-string">'log'</span>); <span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'YScale'</span>, <span class="org-string">'log'</span>);
<span class="org-builtin">xlabel</span>(<span class="org-string">'Frequency [Hz]'</span>); <span class="org-builtin">ylabel</span>(<span class="org-string">'ASD [$\frac{nm}{\sqrt{Hz}}$]'</span>);
<span class="org-builtin">legend</span>(<span class="org-string">'location'</span>, <span class="org-string">'northwest'</span>);
<span class="org-builtin">xlim</span>([1, 1e3]);
</pre>
</div>
</div>
</div>
<div id="outline-container-org64f1438" class="outline-3">
<h3 id="org64f1438"><span class="section-number-3">3.2.</span> Scans</h3>
<div class="outline-text-3" id="text-3-2">
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<colgroup>
<col class="org-right" />
<col class="org-left" />
</colgroup>
<tbody>
<tr>
<td class="org-right">1</td>
<td class="org-left">dz311</td>
</tr>
<tr>
<td class="org-right">2</td>
<td class="org-left">dry311</td>
</tr>
<tr>
<td class="org-right">3</td>
<td class="org-left">drx311</td>
</tr>
<tr>
<td class="org-right">4</td>
<td class="org-left">dz111</td>
</tr>
<tr>
<td class="org-right">5</td>
<td class="org-left">dry111</td>
</tr>
<tr>
<td class="org-right">6</td>
<td class="org-left">drx111</td>
</tr>
<tr>
<td class="org-right">7</td>
<td class="org-left">fjpur</td>
</tr>
<tr>
<td class="org-right">8</td>
<td class="org-left">fjpuh</td>
</tr>
<tr>
<td class="org-right">9</td>
<td class="org-left">fjpd</td>
</tr>
<tr>
<td class="org-right">10</td>
<td class="org-left">bragg</td>
</tr>
</tbody>
</table>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Load Data</span>
data_10_70_deg = extractDatData(<span class="org-string">'thtraj_10_70.mat'</span>, <span class="org-comment-delimiter">.</span><span class="org-comment">..</span>
{<span class="org-string">"dz311"</span>, <span class="org-string">"dry311"</span>, <span class="org-string">"drx311"</span>, <span class="org-string">"dz"</span>, <span class="org-string">"dry"</span>, <span class="org-string">"drx"</span>, <span class="org-string">"fjur"</span>, <span class="org-string">"fjuh"</span>, <span class="org-string">"fjd"</span>, <span class="org-string">"bragg"</span>}, <span class="org-comment-delimiter">.</span><span class="org-comment">..</span>
[1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>8, 1e<span class="org-builtin">-</span>8, 1e<span class="org-builtin">-</span>8, <span class="org-matlab-math">pi</span><span class="org-builtin">/</span>180]);
Ts = 1e<span class="org-builtin">-</span>4;
t = Ts<span class="org-builtin">*</span>[1<span class="org-builtin">:</span>length(data_10_70_deg.bragg)];
<span class="org-matlab-cellbreak">%% Actuator Jacobian</span>
J_a_111 = [1, 0.14, <span class="org-builtin">-</span>0.0675
1, 0.14, 0.1525
1, <span class="org-builtin">-</span>0.14, 0.0425];
data_10_70_deg.ddz = 10.5e<span class="org-builtin">-</span>3<span class="org-builtin">./</span>(2<span class="org-builtin">*</span>cos(data_10_70_deg.bragg)) <span class="org-builtin">-</span> data_10_70_deg.dz;
<span class="org-matlab-cellbreak">%% Computation of the position of the FJ as measured by the interferometers</span>
error = J_a_111 <span class="org-builtin">*</span> [data_10_70_deg.ddz, data_10_70_deg.dry, data_10_70_deg.drx]<span class="org-builtin">'</span>;
data_10_70_deg.fjur_e = error(1,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>; <span class="org-comment-delimiter">% </span><span class="org-comment">[m]</span>
data_10_70_deg.fjuh_e = error(2,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>; <span class="org-comment-delimiter">% </span><span class="org-comment">[m]</span>
data_10_70_deg.fjd_e = error(3,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>; <span class="org-comment-delimiter">% </span><span class="org-comment">[m]</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Load Data</span>
data_70_10_deg = extractDatData(<span class="org-string">'thtraj_70_10.mat'</span>, <span class="org-comment-delimiter">.</span><span class="org-comment">..</span>
{<span class="org-string">"dz311"</span>, <span class="org-string">"dry311"</span>, <span class="org-string">"drx311"</span>, <span class="org-string">"dz"</span>, <span class="org-string">"dry"</span>, <span class="org-string">"drx"</span>, <span class="org-string">"fjur"</span>, <span class="org-string">"fjuh"</span>, <span class="org-string">"fjd"</span>, <span class="org-string">"bragg"</span>}, <span class="org-comment-delimiter">.</span><span class="org-comment">..</span>
[1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>8, 1e<span class="org-builtin">-</span>8, 1e<span class="org-builtin">-</span>8, <span class="org-matlab-math">pi</span><span class="org-builtin">/</span>180]);
<span class="org-matlab-cellbreak">%% Actuator Jacobian</span>
J_a_111 = [1, 0.14, <span class="org-builtin">-</span>0.0675
1, 0.14, 0.1525
1, <span class="org-builtin">-</span>0.14, 0.0425];
data_70_10_deg.ddz = 10.5e<span class="org-builtin">-</span>3<span class="org-builtin">./</span>(2<span class="org-builtin">*</span>cos(data_70_10_deg.bragg)) <span class="org-builtin">-</span> data_70_10_deg.dz;
<span class="org-matlab-cellbreak">%% Computation of the position of the FJ as measured by the interferometers</span>
error = J_a_111 <span class="org-builtin">*</span> [data_70_10_deg.ddz, data_70_10_deg.dry, data_70_10_deg.drx]<span class="org-builtin">'</span>;
data_70_10_deg.fjur_e = error(1,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>; <span class="org-comment-delimiter">% </span><span class="org-comment">[m]</span>
data_70_10_deg.fjuh_e = error(2,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>; <span class="org-comment-delimiter">% </span><span class="org-comment">[m]</span>
data_70_10_deg.fjd_e = error(3,<span class="org-builtin">:</span>)<span class="org-builtin">'</span>; <span class="org-comment-delimiter">% </span><span class="org-comment">[m]</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">win = hanning(ceil(1<span class="org-builtin">/</span>Ts));
[pxx_10_70_ur, f] = pwelch(data_10_70_deg.fjur_e(t<span class="org-builtin">&lt;</span>100), win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_70_10_ur, <span class="org-builtin">~</span>] = pwelch(data_70_10_deg.fjur_e(t<span class="org-builtin">&lt;</span>100), win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_10_70_uh, <span class="org-builtin">~</span>] = pwelch(data_10_70_deg.fjuh_e(t<span class="org-builtin">&lt;</span>100), win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_70_10_uh, <span class="org-builtin">~</span>] = pwelch(data_70_10_deg.fjuh_e(t<span class="org-builtin">&lt;</span>100), win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_10_70_d, <span class="org-builtin">~</span>] = pwelch(data_10_70_deg.fjd_e(t<span class="org-builtin">&lt;</span>100), win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_70_10_d, <span class="org-builtin">~</span>] = pwelch(data_70_10_deg.fjd_e(t<span class="org-builtin">&lt;</span>100), win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">CPS_10_70_ur = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_10_70_ur)));
CPS_10_70_uh = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_10_70_uh)));
CPS_10_70_d = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_10_70_d)));
CPS_70_10_ur = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_70_10_ur)));
CPS_70_10_uh = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_70_10_uh)));
CPS_70_10_d = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_70_10_d)));
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(f, 1e9<span class="org-builtin">*</span>sqrt(CPS_10_70_ur))
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">off;</span>
<span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'XScale'</span>, <span class="org-string">'log'</span>); <span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'YScale'</span>, <span class="org-string">'log'</span>);
<span class="org-builtin">xlabel</span>(<span class="org-string">'Frequency [Hz]'</span>); <span class="org-builtin">ylabel</span>(<span class="org-string">'ASD [$\frac{nrad}{\sqrt{Hz}}$]'</span>);
<span class="org-builtin">legend</span>(<span class="org-string">'location'</span>, <span class="org-string">'northwest'</span>);
<span class="org-builtin">xlim</span>([1, 1e3]);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(f, sqrt(pxx_10_70_ur))
<span class="org-builtin">plot</span>(f, sqrt(pxx_70_10_ur))
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">off;</span>
<span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'XScale'</span>, <span class="org-string">'log'</span>); <span class="org-builtin">set</span>(<span class="org-variable-name">gca</span>, <span class="org-string">'YScale'</span>, <span class="org-string">'log'</span>);
<span class="org-builtin">xlabel</span>(<span class="org-string">'Frequency [Hz]'</span>); <span class="org-builtin">ylabel</span>(<span class="org-string">'ASD [$\frac{nrad}{\sqrt{Hz}}$]'</span>);
<span class="org-builtin">legend</span>(<span class="org-string">'location'</span>, <span class="org-string">'northwest'</span>);
<span class="org-builtin">xlim</span>([1, 1e3]);
</pre>
</div>
</div>
</div>
<div id="outline-container-org60807a5" class="outline-3">
<h3 id="org60807a5"><span class="section-number-3">3.3.</span> Noise budgeting - No rotation</h3>
<div class="outline-text-3" id="text-3-3">
<p>
First, we look at the position errors when the bragg axis is not moving
</p>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Load Measurement Data</span>
ol_data = load(<span class="org-string">'FJPUR_step.mat'</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Pre-processing</span>
ol_time = ol_data.time <span class="org-builtin">-</span> ol_data.time(1);
ol_drx = ol_data.allValues(ol_time <span class="org-builtin">&lt;</span> 45, 6);
ol_dry = ol_data.allValues(ol_time <span class="org-builtin">&lt;</span> 45, 5);
ol_dz = ol_data.allValues(ol_time <span class="org-builtin">&lt;</span> 45, 4);
ol_drx = ol_drx <span class="org-builtin">-</span> mean(ol_drx);
ol_dry = ol_dry <span class="org-builtin">-</span> mean(ol_dry);
ol_dz = ol_dz <span class="org-builtin">-</span> mean(ol_dz);
ol_time = ol_time(ol_time <span class="org-builtin">&lt;</span> 45);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">plot</span>(ol_time, ol_drx)
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Parameters for Spectral Analysis</span>
Ts = 1e<span class="org-builtin">-</span>4;
win = hanning(ceil(1<span class="org-builtin">/</span>Ts));
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Computation of the PSD</span>
[pxx_ol_drx, f] = pwelch(ol_drx, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_ol_dry, <span class="org-builtin">~</span>] = pwelch(ol_dry, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_ol_dz, <span class="org-builtin">~</span>] = pwelch(ol_dz, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
<div id="orgf7417b6" class="figure">
<p><img src="figs/noise_budget_no_mov_asd.png" alt="noise_budget_no_mov_asd.png" />
</p>
<p><span class="figure-number">Figure 23: </span>Amplitude Spectral Density</p>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Cumulative Spectral Density</span>
CPS_drx = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_ol_drx)));
CPS_dry = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_ol_dry)));
CPS_dz = flip(<span class="org-builtin">-</span>cumtrapz(flip(f), flip(pxx_ol_dz)));
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Cumulative Spectral Density</span>
CPS_drx = cumtrapz(f, pxx_ol_drx);
CPS_dry = cumtrapz(f, pxx_ol_dry);
CPS_dz = cumtrapz(f, pxx_ol_dz);
</pre>
</div>
<div id="org7a0878c" class="figure">
<p><img src="figs/noise_budget_no_mov_cas.png" alt="noise_budget_no_mov_cas.png" />
</p>
<p><span class="figure-number">Figure 24: </span>Cumulative Amplitude Spectrum</p>
</div>
</div>
</div>
<div id="outline-container-orgf1f9c40" class="outline-3">
<h3 id="orgf1f9c40"><span class="section-number-3">3.4.</span> Noise budgeting - Bragg rotation</h3>
</div>
</div>
<div id="outline-container-orge12a029" class="outline-2">
<h2 id="orge12a029"><span class="section-number-2">4.</span> Test Mode C</h2>
<div class="outline-text-2" id="text-4">
</div>
<div id="outline-container-org9173ef5" class="outline-3">
<h3 id="org9173ef5"><span class="section-number-3">4.1.</span> Mode B and Mode C</h3>
<div class="outline-text-3" id="text-4-1">
<div class="org-src-container">
<pre class="src src-matlab">data_B = extractDatData(sprintf(<span class="org-string">"/home/thomas/mnt/data_id21/22Jan/blc13491/id21/test_regul_220119/%s"</span>,<span class="org-string">"lut_const_fj_vel_19012022_1450.dat"</span>), <span class="org-comment-delimiter">.</span><span class="org-comment">..</span>
{<span class="org-string">"bragg"</span>, <span class="org-string">"dz"</span>, <span class="org-string">"dry"</span>, <span class="org-string">"drx"</span>, <span class="org-string">"fjur"</span>, <span class="org-string">"fjuh"</span>, <span class="org-string">"fjd"</span>}, <span class="org-comment-delimiter">.</span><span class="org-comment">..</span>
[<span class="org-matlab-math">pi</span><span class="org-builtin">/</span>180, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>8, 1e<span class="org-builtin">-</span>8, 1e<span class="org-builtin">-</span>8]);
data_B = processMeasData(data_B);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">data_C = extractDatData(sprintf(<span class="org-string">"/home/thomas/mnt/data_id21/22Jan/blc13491/id21/test_regul_220119/%s"</span>,<span class="org-string">"lut_const_fj_vel_19012022_1454.dat"</span>), <span class="org-comment-delimiter">.</span><span class="org-comment">..</span>
{<span class="org-string">"bragg"</span>, <span class="org-string">"dz"</span>, <span class="org-string">"dry"</span>, <span class="org-string">"drx"</span>, <span class="org-string">"fjur"</span>, <span class="org-string">"fjuh"</span>, <span class="org-string">"fjd"</span>}, <span class="org-comment-delimiter">.</span><span class="org-comment">..</span>
[<span class="org-matlab-math">pi</span><span class="org-builtin">/</span>180, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>9, 1e<span class="org-builtin">-</span>8, 1e<span class="org-builtin">-</span>8, 1e<span class="org-builtin">-</span>8]);
data_C = processMeasData(data_C);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(180<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>data_B.bragg, 1e9<span class="org-builtin">*</span>data_B.drx)
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">off;</span>
<span class="org-builtin">xlabel</span>(<span class="org-string">'Bragg Angle [deg]'</span>); <span class="org-builtin">ylabel</span>(<span class="org-string">'DRX [nrad]'</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(180<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>data_B.bragg, 1e9<span class="org-builtin">*</span>data_B.fjur_e_filt)
<span class="org-builtin">plot</span>(180<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>data_C.bragg, 1e9<span class="org-builtin">*</span>data_C.fjur_e_filt)
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">off;</span>
<span class="org-builtin">xlabel</span>(<span class="org-string">'Bragg Angle [deg]'</span>); <span class="org-builtin">ylabel</span>(<span class="org-string">'FJUR Error [nm]'</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(180<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>data_B.bragg, 1e9<span class="org-builtin">*</span>data_B.fjur_e)
<span class="org-builtin">plot</span>(180<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>data_C.bragg, 1e9<span class="org-builtin">*</span>data_C.fjur_e)
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">off;</span>
<span class="org-builtin">xlabel</span>(<span class="org-string">'Bragg Angle [deg]'</span>); <span class="org-builtin">ylabel</span>(<span class="org-string">'FJUR Error [nm]'</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% FIR Filter</span>
Fs = 1e4; <span class="org-comment-delimiter">% </span><span class="org-comment">Sampling Frequency [Hz]</span>
fir_order = 5000; <span class="org-comment-delimiter">% </span><span class="org-comment">Filter's order</span>
delay = fir_order<span class="org-builtin">/</span>2; <span class="org-comment-delimiter">% </span><span class="org-comment">Delay induced by the filter</span>
B_fir = firls(5000, <span class="org-comment-delimiter">.</span><span class="org-comment">.. % Filter's order</span>
[0 5<span class="org-builtin">/</span>(Fs<span class="org-builtin">/</span>2) 10<span class="org-builtin">/</span>(Fs<span class="org-builtin">/</span>2) 1], <span class="org-comment-delimiter">.</span><span class="org-comment">.. % Frequencies [Hz]</span>
[1 1 0 0]); <span class="org-comment-delimiter">% </span><span class="org-comment">Wanted Magnitudes</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-matlab-cellbreak">%% Filtering all measured Fast Jack Position using the FIR filter</span>
data_B.drx_filter = filter(B_fir, 1, data_B.drx);
data_B.drx_filter(1<span class="org-builtin">:</span>end<span class="org-builtin">-</span>delay) = data_B.drx_filter(delay<span class="org-builtin">+</span>1<span class="org-builtin">:</span>end);
data_C.drx_filter = filter(B_fir, 1, data_C.drx);
data_C.drx_filter(1<span class="org-builtin">:</span>end<span class="org-builtin">-</span>delay) = data_C.drx_filter(delay<span class="org-builtin">+</span>1<span class="org-builtin">:</span>end);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab"><span class="org-builtin">figure</span>;
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">on;</span>
<span class="org-builtin">plot</span>(180<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>data_B.bragg, 1e9<span class="org-builtin">*</span>data_B.drx_filter)
<span class="org-builtin">plot</span>(180<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">*</span>data_C.bragg, 1e9<span class="org-builtin">*</span>data_C.drx_filter)
<span class="org-builtin">hold</span> <span class="org-matlab-commanddual-string">off;</span>
<span class="org-builtin">xlabel</span>(<span class="org-string">'Bragg Angle [deg]'</span>); <span class="org-builtin">ylabel</span>(<span class="org-string">'DRX [nrad]'</span>);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">Ts = 1e<span class="org-builtin">-</span>4;
win = hanning(ceil(1<span class="org-builtin">/</span>Ts));
[pxx_B_drx, f] = pwelch(data_B.drx, win, [], [], 1<span class="org-builtin">/</span>Ts);
[pxx_C_drx, <span class="org-builtin">~</span>] = pwelch(data_C.drx, win, [], [], 1<span class="org-builtin">/</span>Ts);
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-org0482355" class="outline-2">
<h2 id="org0482355"><span class="section-number-2">5.</span> Export numerator and denominator</h2>
<div class="outline-text-2" id="text-5">
</div>
<div id="outline-container-orga946414" class="outline-3">
<h3 id="orga946414"><span class="section-number-3">5.1.</span> Export</h3>
<div class="outline-text-3" id="text-5-1">
<div class="org-src-container">
<pre class="src src-matlab">K_order = 10;
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">load(<span class="org-string">'X_tal_cage_PID.mat'</span>, <span class="org-string">'K'</span>);
K_order = order(K(1,1));
Kz = c2d(K(1,1)<span class="org-builtin">*</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>2<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">/</span>2e3)<span class="org-builtin">^</span>(9<span class="org-builtin">-</span>K_order)<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>2<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">/</span>2e3)<span class="org-builtin">^</span>(9<span class="org-builtin">-</span>K_order), 1e<span class="org-builtin">-</span>4);
[num, den] = tfdata(Kz, <span class="org-string">'v'</span>);
formatSpec = <span class="org-string">'%.18e %.18e %.18e %.18e %.18e %.18e %.18e %.18e %.18e %.18e\n'</span>;
fileID = fopen(<span class="org-string">'X_tal_cage_PID.dat'</span>, <span class="org-string">'w'</span>);
fprintf(fileID, formatSpec, [num; den]<span class="org-builtin">'</span>);
fclose(fileID);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">load(<span class="org-string">'X_tal_cage_PID_20Hz.mat'</span>, <span class="org-string">'K'</span>);
K_order = order(K(1,1));
Kz = c2d(K(1,1)<span class="org-builtin">*</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>2<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">/</span>2e3)<span class="org-builtin">^</span>(9<span class="org-builtin">-</span>K_order)<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>2<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">/</span>2e3)<span class="org-builtin">^</span>(9<span class="org-builtin">-</span>K_order), 1e<span class="org-builtin">-</span>4);
[num, den] = tfdata(Kz, <span class="org-string">'v'</span>);
formatSpec = <span class="org-string">'%.18e %.18e %.18e %.18e %.18e %.18e %.18e %.18e %.18e %.18e\n'</span>;
fileID = fopen(<span class="org-string">'X_tal_cage_PID_20Hz.dat'</span>, <span class="org-string">'w'</span>);
fprintf(fileID, formatSpec, [num; den]<span class="org-builtin">'</span>);
fclose(fileID);
</pre>
</div>
<div class="org-src-container">
<pre class="src src-matlab">load(<span class="org-string">'X_tal_cage_PID_40Hz.mat'</span>, <span class="org-string">'K'</span>);
K_order = order(K(1,1));
Kz = c2d(K(1,1)<span class="org-builtin">*</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>2<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">/</span>2e3)<span class="org-builtin">^</span>(9<span class="org-builtin">-</span>K_order)<span class="org-builtin">/</span>(1 <span class="org-builtin">+</span> s<span class="org-builtin">/</span>2<span class="org-builtin">/</span><span class="org-matlab-math">pi</span><span class="org-builtin">/</span>2e3)<span class="org-builtin">^</span>(9<span class="org-builtin">-</span>K_order), 1e<span class="org-builtin">-</span>4);
[num, den] = tfdata(Kz, <span class="org-string">'v'</span>);
formatSpec = <span class="org-string">'%.18e %.18e %.18e %.18e %.18e %.18e %.18e %.18e %.18e %.18e\n'</span>;
fileID = fopen(<span class="org-string">'X_tal_cage_PID_40Hz.dat'</span>, <span class="org-string">'w'</span>);
fprintf(fileID, formatSpec, [num; den]<span class="org-builtin">'</span>);
fclose(fileID);
</pre>
</div>
</div>
</div>
<div id="outline-container-org8ed08fd" class="outline-3">
<h3 id="org8ed08fd"><span class="section-number-3">5.2.</span> Verify</h3>
<div class="outline-text-3" id="text-5-2">
<div class="org-src-container">
<pre class="src src-matlab">K_data = importdata(<span class="org-string">'X_tal_cage_PID_20Hz.dat'</span>);
K = tf(K_data(1,<span class="org-builtin">:</span>), K_data(2,<span class="org-builtin">:</span>), 1e<span class="org-builtin">-</span>4)
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Author: Dehaeze Thomas</p>
<p class="date">Created: 2022-02-15 mar. 14:15</p>
</div>
</body>
</html>