1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
---|
3 | <html> |
---|
4 | <head> |
---|
5 | <title>Description of measidfftable</title> |
---|
6 | <meta name="keywords" content="measidfftable"> |
---|
7 | <meta name="description" content="FFGETTBL - Measures an insertion device feed forward table for the vertical gap"> |
---|
8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
9 | <meta name="generator" content="m2html © 2003 Guillaume Flandin"> |
---|
10 | <meta name="robots" content="index, follow"> |
---|
11 | <link type="text/css" rel="stylesheet" href="../m2html.css"> |
---|
12 | </head> |
---|
13 | <body> |
---|
14 | <a name="_top"></a> |
---|
15 | <div><a href="../index.html">Home</a> > <a href="index.html">mml</a> > measidfftable.m</div> |
---|
16 | |
---|
17 | <!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td> |
---|
18 | <td align="right"><a href="index.html">Index for mml <img alt=">" border="0" src="../right.png"></a></td></tr></table>--> |
---|
19 | |
---|
20 | <h1>measidfftable |
---|
21 | </h1> |
---|
22 | |
---|
23 | <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
24 | <div class="box"><strong>FFGETTBL - Measures an insertion device feed forward table for the vertical gap</strong></div> |
---|
25 | |
---|
26 | <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
27 | <div class="box"><strong>function ffgettbl(Sector, BPMFlag) </strong></div> |
---|
28 | |
---|
29 | <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
30 | <div class="fragment"><pre class="comment">FFGETTBL - Measures an insertion device feed forward table for the vertical gap |
---|
31 | ffgettbl(Sector, BPMFlag (0=Bergoz BPMs, else=All BPMs)) |
---|
32 | |
---|
33 | This function generates the feed forward tables necessary for insertion device compensation. |
---|
34 | |
---|
35 | This function is under development</pre></div> |
---|
36 | |
---|
37 | <!-- crossreference --> |
---|
38 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
39 | This function calls: |
---|
40 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
41 | <li><a href="dev2elem.html" class="code" title="function Output = dev2elem(Family, DevList)">dev2elem</a> DEV2ELEM - Converts an element list to a device list</li><li><a href="getam.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getam(varargin)">getam</a> GETAM - Gets monitor channels</li><li><a href="getenergy.html" class="code" title="function [Energy, HCMEnergy] = getenergy(varargin)">getenergy</a> GETENERGY - Returns the beam energy base on the bend magnet</li><li><a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a> GETFAMILYDATA - Gets data associated with the accelerator control</li><li><a href="getproductionlattice.html" class="code" title="function [ConfigSetpoint, ConfigMonitor, FileName] = getproductionlattice(varargin)">getproductionlattice</a> GETPRODUCTIONLATTICE - Read the Golden lattice from file GoldenLattice</li><li><a href="getpv.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getpv(varargin)">getpv</a> GETPV - Returns a variable from the online system or the model</li><li><a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a> GETSP - Gets setpoint channels</li><li><a href="getspos.html" class="code" title="function S = getspos(Family, DeviceList)">getspos</a> GETSPOS - Returns the longitudinal position in meters</li><li><a href="gettuneresp.html" class="code" title="function [TuneMatrix, FileName] = gettuneresp(varargin)">gettuneresp</a> GETTUNERESP - Loads the tune response vector (or matrix) for multiple quadrupole families</li><li><a href="measidfftable.html" class="code" title="function ffgettbl(Sector, BPMFlag)">measidfftable</a> FFGETTBL - Measures an insertion device feed forward table for the vertical gap</li><li><a href="plotidfftable.html" class="code" title="function FigureHandles = plotidfftable(Sector, GeV)">plotidfftable</a> PLOTIDFFTABLE - Plots various information about the feed forward tables</li><li><a href="setpv.html" class="code" title="function ErrorFlag = setpv(varargin)">setpv</a> SETPV - Setpoint change of the online system or model</li><li><a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a> SETSP - Makes an absolute setpoint change to the 'Setpoint' field</li></ul> |
---|
42 | This function is called by: |
---|
43 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
44 | <li><a href="measidfftable.html" class="code" title="function ffgettbl(Sector, BPMFlag)">measidfftable</a> FFGETTBL - Measures an insertion device feed forward table for the vertical gap</li></ul> |
---|
45 | <!-- crossreference --> |
---|
46 | |
---|
47 | |
---|
48 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
49 | <div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function ffgettbl(Sector, BPMFlag)</a> |
---|
50 | 0002 <span class="comment">%FFGETTBL - Measures an insertion device feed forward table for the vertical gap</span> |
---|
51 | 0003 <span class="comment">% ffgettbl(Sector, BPMFlag (0=Bergoz BPMs, else=All BPMs))</span> |
---|
52 | 0004 <span class="comment">%</span> |
---|
53 | 0005 <span class="comment">% This function generates the feed forward tables necessary for insertion device compensation.</span> |
---|
54 | 0006 <span class="comment">%</span> |
---|
55 | 0007 <span class="comment">% This function is under development</span> |
---|
56 | 0008 |
---|
57 | 0009 |
---|
58 | 0010 <span class="comment">% 2002-04-05 T.Scarvie</span> |
---|
59 | 0011 <span class="comment">% modified to perform a tune FF correction after each move and prior to each orbit correction</span> |
---|
60 | 0012 <span class="comment">% to produce FF tables that are more accurate while running orbit FB</span> |
---|
61 | 0013 <span class="comment">%</span> |
---|
62 | 0014 <span class="comment">% 2003-04-25 C. Steier</span> |
---|
63 | 0015 <span class="comment">% IDBPMs in sectors 1 and 3 are not used anymore since they are noisy at low beam current</span> |
---|
64 | 0016 <span class="comment">% and therefore compromise the FF tables.</span> |
---|
65 | 0017 <span class="comment">%</span> |
---|
66 | 0018 <span class="comment">% 2004-07-06 T.Scarvie</span> |
---|
67 | 0019 <span class="comment">% made tune FF correction active for 5W as well as other gaps because 5W FF table no longer</span> |
---|
68 | 0020 <span class="comment">% includes quadrupoles - all tune FF is handled by orbit feedback</span> |
---|
69 | 0021 <span class="comment">%</span> |
---|
70 | 0022 <span class="comment">% 2004-10-18 T. Scarvie</span> |
---|
71 | 0023 <span class="comment">% removed quad generation option from routine - tune compensation is handled by orbit feedback algorithm now</span> |
---|
72 | 0024 <span class="comment">%</span> |
---|
73 | 0025 <span class="comment">% 2005-02-06 G. Portmann</span> |
---|
74 | 0026 <span class="comment">% Upgrate to new middlelayer format</span> |
---|
75 | 0027 <span class="comment">% To do: 1. Slow/fast correctors?</span> |
---|
76 | 0028 <span class="comment">% 2. Use FF channels?</span> |
---|
77 | 0029 <span class="comment">% 3. Use center chicane BPMs and correctors?</span> |
---|
78 | 0030 |
---|
79 | 0031 |
---|
80 | 0032 <span class="comment">% Initialization</span> |
---|
81 | 0033 |
---|
82 | 0034 <span class="comment">% Need to change this to a question dialog to allow for local tune compensation; hard-coded for now - 2004-07-06, T.Scarvie</span> |
---|
83 | 0035 FFTypeFlag = <span class="string">'Global'</span>; |
---|
84 | 0036 |
---|
85 | 0037 <span class="keyword">if</span> nargin < 2 |
---|
86 | 0038 BPMFlag = []; |
---|
87 | 0039 <span class="keyword">end</span> |
---|
88 | 0040 <span class="keyword">if</span> isempty(BPMFlag) |
---|
89 | 0041 BPMFlag = 0; <span class="comment">% menu1('Which BPM family to use for table generation?','96 arc sector BPMs only.','Straight section IDBPMs only.','Exit program.');</span> |
---|
90 | 0042 <span class="keyword">end</span> |
---|
91 | 0043 |
---|
92 | 0044 |
---|
93 | 0045 |
---|
94 | 0046 IDFF.GapVelocity = 3.33; |
---|
95 | 0047 IDFF.GeV = <a href="getenergy.html" class="code" title="function [Energy, HCMEnergy] = getenergy(varargin)">getenergy</a>; |
---|
96 | 0048 |
---|
97 | 0049 |
---|
98 | 0050 disp([<span class="string">' '</span>]); disp(<span class="string">' '</span>); |
---|
99 | 0051 disp([<span class="string">' INSERTION DEVICE FEED FORWARD TABLE GENERATION APPLICATION'</span>]); |
---|
100 | 0052 disp([<span class="string">' '</span>]); |
---|
101 | 0053 disp([<span class="string">' This program will generate a feed forward table at '</span>,num2str(IDFF.GeV), <span class="string">' GeV.'</span>]); |
---|
102 | 0054 disp(<span class="string">' Before continuing, make sure the following conditions are true. '</span>); |
---|
103 | 0055 disp(<span class="string">' 1. Multi-bunch mode.'</span>); |
---|
104 | 0056 disp(<span class="string">' 2. FF disabled.'</span>); |
---|
105 | 0057 disp(<span class="string">' 3. Gap Control disabled.'</span>); |
---|
106 | 0058 disp(<span class="string">' 4. Current range: typically 35-45 mAmps, but any current should be OK.'</span>); |
---|
107 | 0059 disp(<span class="string">' 5. Production corrector magnet set.'</span>); |
---|
108 | 0060 disp(<span class="string">' 6. Bumps off and BTS 3 and 4 set to zero current.'</span>); |
---|
109 | 0061 disp(<span class="string">' 7. Set the insertion device Velocity Profiling off (0) (just for speed).'</span>); |
---|
110 | 0062 disp(<span class="string">' 8. Slow orbit feedback off.'</span>); |
---|
111 | 0063 <span class="keyword">if</span> BPMFlag |
---|
112 | 0064 disp(<span class="string">' 9. BPMs calibrated.'</span>); |
---|
113 | 0065 <span class="keyword">end</span> |
---|
114 | 0066 |
---|
115 | 0067 |
---|
116 | 0068 <span class="keyword">if</span> nargin < 1 |
---|
117 | 0069 SectorIn = menu(str2mat(sprintf(<span class="string">'%.1f GeV Feed Forward Generation'</span>,IDFF.GeV),<span class="string">'Feed forward must be off!'</span>,<span class="string">' '</span>,<span class="string">'Which insertion device?'</span>),<span class="string">'4-vertical'</span>,<span class="string">'4-longitudinal'</span>,<span class="string">'5'</span>,<span class="string">'7'</span>,<span class="string">'8'</span>,<span class="string">'9'</span>,<span class="string">'10'</span>,<span class="string">'11-vertical'</span>,<span class="string">'11-longitudinal'</span>,<span class="string">'12'</span>,<span class="string">'Cancel'</span>); |
---|
118 | 0070 <span class="keyword">if</span> SectorIn == 1 |
---|
119 | 0071 <span class="comment">% Sector 4 vertical using new feedforward method</span> |
---|
120 | 0072 Sector = 4; |
---|
121 | 0073 ffgettblepugap(Sector); |
---|
122 | 0074 <span class="keyword">return</span> |
---|
123 | 0075 <span class="keyword">elseif</span> SectorIn == 2 |
---|
124 | 0076 <span class="comment">% Sector 4 longitudinal using new feedforward method</span> |
---|
125 | 0077 Sector = 4; |
---|
126 | 0078 ffgettblepushift(Sector); |
---|
127 | 0079 <span class="comment">%ffgettblepu; % old method</span> |
---|
128 | 0080 <span class="keyword">return</span> |
---|
129 | 0081 <span class="keyword">elseif</span> SectorIn == 3 |
---|
130 | 0082 Sector = 5; |
---|
131 | 0083 <span class="keyword">elseif</span> SectorIn == 4 |
---|
132 | 0084 Sector = 7; |
---|
133 | 0085 <span class="keyword">elseif</span> SectorIn == 5 |
---|
134 | 0086 Sector = 8; |
---|
135 | 0087 <span class="keyword">elseif</span> SectorIn == 6 |
---|
136 | 0088 Sector = 9; |
---|
137 | 0089 <span class="keyword">elseif</span> SectorIn == 7 |
---|
138 | 0090 Sector = 10; |
---|
139 | 0091 <span class="keyword">elseif</span> SectorIn == 8 |
---|
140 | 0092 <span class="comment">% Sector 11 vertical using new feedforward method</span> |
---|
141 | 0093 Sector = 11; |
---|
142 | 0094 ffgettblepugap(Sector); |
---|
143 | 0095 <span class="keyword">return</span> |
---|
144 | 0096 <span class="keyword">elseif</span> SectorIn == 9 |
---|
145 | 0097 <span class="comment">% Sector 11 longitudinal using new feedforward method</span> |
---|
146 | 0098 Sector = 11; |
---|
147 | 0099 ffgettblepushift(Sector); |
---|
148 | 0100 <span class="keyword">return</span> |
---|
149 | 0101 <span class="keyword">elseif</span> SectorIn == 10 |
---|
150 | 0102 Sector = 12; |
---|
151 | 0103 <span class="keyword">elseif</span> SectorIn == 11 |
---|
152 | 0104 disp(<span class="string">' ffgettbl aborted. No changes to correctors or insertion device.'</span>); |
---|
153 | 0105 <span class="keyword">return</span> |
---|
154 | 0106 <span class="keyword">end</span> |
---|
155 | 0107 <span class="keyword">end</span> |
---|
156 | 0108 disp(<span class="string">' '</span>); |
---|
157 | 0109 <span class="keyword">if</span> Sector == 0 |
---|
158 | 0110 disp(<span class="string">' ffgettbl aborted. No changes to correctors or insertion device.'</span>); |
---|
159 | 0111 <span class="keyword">return</span>; |
---|
160 | 0112 <span class="keyword">end</span> |
---|
161 | 0113 |
---|
162 | 0114 |
---|
163 | 0115 |
---|
164 | 0116 <span class="comment">%%%%%%%%%%%%%</span> |
---|
165 | 0117 <span class="comment">% BPM Setup %</span> |
---|
166 | 0118 <span class="comment">%%%%%%%%%%%%%</span> |
---|
167 | 0119 IDFF.BPMxFamily = <span class="string">'BPMx'</span>; |
---|
168 | 0120 IDFF.BPMyFamily = <span class="string">'BPMy'</span>; |
---|
169 | 0121 |
---|
170 | 0122 <span class="keyword">if</span> BPMFlag |
---|
171 | 0123 <span class="comment">% Use all BPMs</span> |
---|
172 | 0124 BPMTol = .005; |
---|
173 | 0125 BPMIter = 5; |
---|
174 | 0126 IDFF.BPMxList = getbpmlist(<span class="string">'x'</span>); |
---|
175 | 0127 IDFF.BPMyList = getbpmlist(<span class="string">'y'</span>); |
---|
176 | 0128 <span class="keyword">else</span> |
---|
177 | 0129 <span class="comment">% Only use Bergoz BPMs</span> |
---|
178 | 0130 BPMTol = .0003; |
---|
179 | 0131 BPMIter = 5; |
---|
180 | 0132 IDFF.BPMxList = getbpmlist(<span class="string">'x'</span>, <span class="string">'Bergoz'</span>, <span class="string">'1 2 3 4 5 6 7 8 9 10'</span>); <span class="comment">% 11 12 ???</span> |
---|
181 | 0133 IDFF.BPMyList = getbpmlist(<span class="string">'y'</span>, <span class="string">'Bergoz'</span>, <span class="string">'1 2 3 4 5 6 7 8 9 10'</span>); |
---|
182 | 0134 <span class="keyword">end</span> |
---|
183 | 0135 |
---|
184 | 0136 <span class="comment">% Remove the BPMs in the sector where the ID is located</span> |
---|
185 | 0137 iRemove = findrowindex([Sector-1 10; Sector-1 11; Sector-1 12; Sector 1], IDFF.BPMxList); |
---|
186 | 0138 IDFF.BPMxList(iRemove,:) = []; |
---|
187 | 0139 |
---|
188 | 0140 iRemove = findrowindex([Sector-1 10; Sector-1 11; Sector-1 12; Sector 1], IDFF.BPMyList); |
---|
189 | 0141 IDFF.BPMyList(iRemove,:) = []; |
---|
190 | 0142 |
---|
191 | 0143 <span class="comment">% % Remove the BPMs in sectors 1 and 3 which are noisy at low current).</span> |
---|
192 | 0144 <span class="comment">% iRemove = findrowindex([12 9; 1 2], BPMlist);</span> |
---|
193 | 0145 <span class="comment">% BPMlist(iRemove,:) = [];</span> |
---|
194 | 0146 |
---|
195 | 0147 |
---|
196 | 0148 <span class="comment">%%%%%%%%%%%%%%%%%%%</span> |
---|
197 | 0149 <span class="comment">% Corrector Setup %</span> |
---|
198 | 0150 <span class="comment">%%%%%%%%%%%%%%%%%%%</span> |
---|
199 | 0151 IDFF.HCMFamily = <span class="string">'HCM'</span>; |
---|
200 | 0152 IDFF.VCMFamily = <span class="string">'VCM'</span>; |
---|
201 | 0153 |
---|
202 | 0154 |
---|
203 | 0155 <span class="comment">% Corrector magnet and BPM lists</span> |
---|
204 | 0156 <span class="keyword">if</span> Sector == 6 & IDDeviceList(1,2) == 1 <span class="comment">% ???</span> |
---|
205 | 0157 IDFF.HCMList = [Sector-1 8; |
---|
206 | 0158 Sector-1 10]; |
---|
207 | 0159 IDFF.VCMList = [Sector-1 8; |
---|
208 | 0160 Sector-1 10]; |
---|
209 | 0161 <span class="keyword">else</span> |
---|
210 | 0162 IDFF.HCMList = [Sector-1 8; |
---|
211 | 0163 Sector 1]; |
---|
212 | 0164 IDFF.VCMList = [Sector-1 8; |
---|
213 | 0165 Sector 1]; |
---|
214 | 0166 <span class="keyword">end</span> |
---|
215 | 0167 |
---|
216 | 0168 |
---|
217 | 0169 <span class="comment">% Fast setpoints</span> |
---|
218 | 0170 HCMRampRate0 = <a href="getpv.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getpv(varargin)">getpv</a>(IDFF.HCMFamily, <span class="string">'RampRate'</span>, IDFF.HCMList); |
---|
219 | 0171 VCMRampRate0 = <a href="getpv.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getpv(varargin)">getpv</a>(IDFF.VCMFamily, <span class="string">'RampRate'</span>, IDFF.VCMList); |
---|
220 | 0172 <a href="setpv.html" class="code" title="function ErrorFlag = setpv(varargin)">setpv</a>(IDFF.HCMFamily, <span class="string">'RampRate'</span>, 1000, IDFF.HCMList, 0); |
---|
221 | 0173 <a href="setpv.html" class="code" title="function ErrorFlag = setpv(varargin)">setpv</a>(IDFF.VCMFamily, <span class="string">'RampRate'</span>, 1000, IDFF.VCMList, 0); |
---|
222 | 0174 |
---|
223 | 0175 |
---|
224 | 0176 <span class="comment">%%%%%%%%%%%%%%%%%</span> |
---|
225 | 0177 <span class="comment">% End ALS Setup %</span> |
---|
226 | 0178 <span class="comment">%%%%%%%%%%%%%%%%%</span> |
---|
227 | 0179 |
---|
228 | 0180 |
---|
229 | 0181 |
---|
230 | 0182 <span class="comment">% Multiple FF-tables</span> |
---|
231 | 0183 <span class="keyword">if</span> size(Sector,1) ~= 1 |
---|
232 | 0184 <span class="keyword">for</span> iSector = 1:size(Sector,1) |
---|
233 | 0185 <a href="measidfftable.html" class="code" title="function ffgettbl(Sector, BPMFlag)">measidfftable</a>(Sector(iSector,:), BPMFlag); |
---|
234 | 0186 <span class="keyword">end</span> |
---|
235 | 0187 <span class="keyword">return</span>; |
---|
236 | 0188 <span class="keyword">end</span> |
---|
237 | 0189 |
---|
238 | 0190 |
---|
239 | 0191 <span class="comment">% Minimum and maximum gap</span> |
---|
240 | 0192 [IDFF.GAPmin, IDFF.GAPmax] = gaplimit(Sector); |
---|
241 | 0193 |
---|
242 | 0194 |
---|
243 | 0195 disp([<span class="string">' The insertion device for sector '</span>,num2str(Sector),<span class="string">' has been selected.'</span>]); |
---|
244 | 0196 disp([<span class="string">' Maximum Gap = '</span>,num2str(IDFF.GAPmax),<span class="string">' mm'</span>]); |
---|
245 | 0197 disp([<span class="string">' Mimimum Gap = '</span>,num2str(IDFF.GAPmin),<span class="string">' mm'</span>]); |
---|
246 | 0198 |
---|
247 | 0199 |
---|
248 | 0200 disp([<span class="string">' Data collection started. Figures 1 and 2 show the difference orbits between the maximum'</span>]); |
---|
249 | 0201 disp([<span class="string">' gap and the current gap position after the feed forward correction has been applied.'</span>]); |
---|
250 | 0202 disp([<span class="string">' Ideally, these plots should be a straight line thru zero, however, due to orbit drift, BPM'</span>]); |
---|
251 | 0203 disp([<span class="string">' noise, and feed forward imperfections one can expect 10 or 20 microns of combined errors'</span>]); |
---|
252 | 0204 disp([<span class="string">' to accumulate before minimum gap is reached (hopefully not any more than that).'</span>]); |
---|
253 | 0205 disp([<span class="string">' '</span>]); |
---|
254 | 0206 |
---|
255 | 0207 |
---|
256 | 0208 <span class="comment">% Setup figures</span> |
---|
257 | 0209 Buffer = .01; |
---|
258 | 0210 HeightBuffer = .05; |
---|
259 | 0211 |
---|
260 | 0212 h1 = gcf; |
---|
261 | 0213 set(h1,<span class="string">'units'</span>,<span class="string">'normal'</span>,<span class="string">'position'</span>,[.0+Buffer .5+Buffer .5-2*Buffer .5-2*Buffer-HeightBuffer]); |
---|
262 | 0214 |
---|
263 | 0215 |
---|
264 | 0216 <span class="comment">% Set gap to maximum, set velocity to maximum, velocity profile off, FF off,</span> |
---|
265 | 0217 setff([], 0, 0); |
---|
266 | 0218 setid(Sector, IDFF.GAPmax, IDFF.GapVelocity, 1, 0); |
---|
267 | 0219 |
---|
268 | 0220 |
---|
269 | 0221 <span class="comment">% Load and set QF and QD setpoints from the golden lattice</span> |
---|
270 | 0222 ConfigSetpoint = <a href="getproductionlattice.html" class="code" title="function [ConfigSetpoint, ConfigMonitor, FileName] = getproductionlattice(varargin)">getproductionlattice</a>; |
---|
271 | 0223 <a href="setpv.html" class="code" title="function ErrorFlag = setpv(varargin)">setpv</a>(ConfigSetpoint.QF.Setpoint); |
---|
272 | 0224 <a href="setpv.html" class="code" title="function ErrorFlag = setpv(varargin)">setpv</a>(ConfigSetpoint.QD.Setpoint); |
---|
273 | 0225 QFsp = ConfigSetpoint.QF.Setpoint.Data; |
---|
274 | 0226 QDsp = ConfigSetpoint.QD.Setpoint.Data; |
---|
275 | 0227 |
---|
276 | 0228 |
---|
277 | 0229 <span class="comment">% Setbumps w/o sextupole correctors</span> |
---|
278 | 0230 setbumps(Sector, 1); |
---|
279 | 0231 |
---|
280 | 0232 |
---|
281 | 0233 <span class="comment">% Starting orbit and corrector magnet</span> |
---|
282 | 0234 IDFF.Xmax = <a href="getam.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getam(varargin)">getam</a>(IDFF.BPMxFamily, IDFF.BPMxList, <span class="string">'Struct'</span>); |
---|
283 | 0235 IDFF.Ymax = <a href="getam.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getam(varargin)">getam</a>(IDFF.BPMyFamily, IDFF.BPMyList, <span class="string">'Struct'</span>); |
---|
284 | 0236 BPMxs = <a href="getspos.html" class="code" title="function S = getspos(Family, DeviceList)">getspos</a>(IDFF.Xmax); |
---|
285 | 0237 BPMys = <a href="getspos.html" class="code" title="function S = getspos(Family, DeviceList)">getspos</a>(IDFF.Ymax); |
---|
286 | 0238 |
---|
287 | 0239 IDFF.HCM = <a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a>(IDFF.HCMFamily, IDFF.HCMList, <span class="string">'Struct'</span>); |
---|
288 | 0240 IDFF.VCM = <a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a>(IDFF.VCMFamily, IDFF.VCMList, <span class="string">'Struct'</span>); |
---|
289 | 0241 HCM0 = IDFF.HCM.Data; |
---|
290 | 0242 VCM0 = IDFF.VCM.Data; |
---|
291 | 0243 QF0 = <a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a>(<span class="string">'QF'</span>); |
---|
292 | 0244 QD0 = <a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a>(<span class="string">'QD'</span>); |
---|
293 | 0245 |
---|
294 | 0246 |
---|
295 | 0247 <span class="comment">% Main loop</span> |
---|
296 | 0248 i=1; |
---|
297 | 0249 IDFF.GapMonitor(i,1) = getid(Sector); |
---|
298 | 0250 hcm(i,:) = (<a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a>(IDFF.HCMFamily, IDFF.HCMList)-HCM0)'; <span class="comment">% First entry is zero</span> |
---|
299 | 0251 vcm(i,:) = (<a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a>(IDFF.VCMFamily, IDFF.VCMList)-VCM0)'; |
---|
300 | 0252 |
---|
301 | 0253 X(:,i) = IDFF.Xmax.Data; |
---|
302 | 0254 Y(:,i) = IDFF.Ymax.Data; |
---|
303 | 0255 Xrms(i) = std(IDFF.Xmax.Data - X(:,i)); |
---|
304 | 0256 Yrms(i) = std(IDFF.Ymax.Data - Y(:,i)); |
---|
305 | 0257 IterOut(i) = 1; |
---|
306 | 0258 |
---|
307 | 0259 |
---|
308 | 0260 <span class="keyword">if</span> IDFF.GAPmin < 14 |
---|
309 | 0261 Gaps = [(IDFF.GAPmax-10):-10:60 56:-4:36 34.5:-1.5:19.5 19:-.5:15 14.75:-.25:IDFF.GAPmin]; |
---|
310 | 0262 <span class="keyword">elseif</span> IDFF.GAPmin < 17 |
---|
311 | 0263 Gaps = [(IDFF.GAPmax-10):-10:60 56:-4:36 34.5:-1.5:19.5 19:-.5:IDFF.GAPmin]; |
---|
312 | 0264 <span class="keyword">elseif</span> IDFF.GAPmin < 34 |
---|
313 | 0265 Gaps = [(IDFF.GAPmax-10):-10:60 56:-4:36 34.5:-1.5:IDFF.GAPmin]; |
---|
314 | 0266 <span class="keyword">elseif</span> IDFF.GAPmin < 55 |
---|
315 | 0267 Gaps = [(IDFF.GAPmax-10):-10:60 56:-4:IDFF.GAPmin]; |
---|
316 | 0268 <span class="keyword">else</span> |
---|
317 | 0269 Gaps = [(IDFF.GAPmax-10):-10:IDFF.GAPmin]; |
---|
318 | 0270 <span class="keyword">end</span> |
---|
319 | 0271 |
---|
320 | 0272 <span class="keyword">if</span> Gaps(length(Gaps)) > IDFF.GAPmin |
---|
321 | 0273 Gaps = [Gaps IDFF.GAPmin]; |
---|
322 | 0274 <span class="keyword">end</span> |
---|
323 | 0275 |
---|
324 | 0276 TUNEresp = <a href="gettuneresp.html" class="code" title="function [TuneMatrix, FileName] = gettuneresp(varargin)">gettuneresp</a>; |
---|
325 | 0277 |
---|
326 | 0278 <span class="keyword">for</span> i = 2:length(Gaps)+1 |
---|
327 | 0279 g = Gaps(i-1); |
---|
328 | 0280 |
---|
329 | 0281 <span class="comment">% Set gap</span> |
---|
330 | 0282 setid(Sector, g, IDFF.GapVelocity); |
---|
331 | 0283 |
---|
332 | 0284 <span class="comment">% Set to old table first</span> |
---|
333 | 0285 <span class="comment">%setsp(IDFF.HCMFamily, HCM0+Xtableold(i,2:3)', IDFF.HCMList); % this does not seem to be a good idea</span> |
---|
334 | 0286 <span class="comment">%setsp(IDFF.VCMFamily, VCM0+Ytableold(i,2:3)', IDFF.VCMList); % need to linear fit the data if you do use this???</span> |
---|
335 | 0287 |
---|
336 | 0288 <span class="comment">% Change Quads via Tune FF to simulate conditions during production</span> |
---|
337 | 0289 <span class="comment">% using tune feed forward code from orbit feedback</span> |
---|
338 | 0290 |
---|
339 | 0291 <span class="comment">% Change in tune and [QF;QD] from maximum gap</span> |
---|
340 | 0292 <span class="keyword">if</span> strcmpi(<a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a>(<span class="string">'OperationalMode'</span>), <span class="string">'1.9 GeV, High Tune'</span>) |
---|
341 | 0293 <span class="keyword">if</span> i==2 |
---|
342 | 0294 fprintf(<span class="string">' Generating feedforward table for %s mode\n'</span>, <a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a>(<span class="string">'OperationalMode'</span>)); |
---|
343 | 0295 <span class="keyword">end</span> |
---|
344 | 0296 |
---|
345 | 0297 |
---|
346 | 0298 <span class="keyword">if</span> strcmp(FFTypeFlag,<span class="string">'Local'</span>) |
---|
347 | 0299 disp(<span class="string">' Using local tune compensation.'</span>); |
---|
348 | 0300 |
---|
349 | 0301 addQFsp = zeros(24,1); |
---|
350 | 0302 addQDsp = zeros(24,1); |
---|
351 | 0303 |
---|
352 | 0304 <span class="comment">% Change in tune and [QF;QD] from maximum gap</span> |
---|
353 | 0305 actualgap = getid(Sector); |
---|
354 | 0306 <span class="keyword">if</span> actualgap < (IDFF.GAPmin-1) |
---|
355 | 0307 actualgap = IDFF.GAPmax; |
---|
356 | 0308 <span class="keyword">end</span> |
---|
357 | 0309 DeltaNuY = gap2tune(Sector, actualgap); |
---|
358 | 0310 fraccorr = 1.15*DeltaNuY./gap2tune(5,13.23,1.9); |
---|
359 | 0311 |
---|
360 | 0312 <span class="comment">% Find which quads to change</span> |
---|
361 | 0313 QuadList = [Sector-1 1;Sector-1 2;Sector 1;Sector 2]; |
---|
362 | 0314 QuadElem = <a href="dev2elem.html" class="code" title="function Output = dev2elem(Family, DevList)">dev2elem</a>(<span class="string">'QF'</span>,QuadList); |
---|
363 | 0315 |
---|
364 | 0316 <span class="keyword">if</span> (Sector==7) | (Sector==10) | (Sector==11) |
---|
365 | 0317 QFfac=(fraccorr.*([2.227520/2.237111;2.239570/2.237111;2.239570/2.237111;2.227520/2.237111]-1)); |
---|
366 | 0318 QDfac=(fraccorr.*([2.432264/2.511045;2.543089/2.511045;2.54308/2.511045;2.432264/2.511045]-1)); |
---|
367 | 0319 <span class="keyword">elseif</span> (Sector==5) | (Sector==9) |
---|
368 | 0320 QFfac=(fraccorr.*([2.208418/2.219784;2.225926/2.219784;2.231777/2.237111;2.233775/2.237111]-1)); |
---|
369 | 0321 QDfac=(fraccorr.*([2.386512/2.483259;2.545907/2.483259;2.474571/2.511045;2.491079/2.511045]-1)); |
---|
370 | 0322 <span class="keyword">elseif</span> (Sector==4) | (Sector==8) | (Sector==12) |
---|
371 | 0323 QFfac=(fraccorr.*([2.233775/2.237111;2.231777/2.237111;2.225926/2.219784;2.208418/2.219784]-1)); |
---|
372 | 0324 QDfac=(fraccorr.*([2.491079/2.511045;2.474571/2.511045;2.545907/2.483259;2.386512/2.483259]-1)); |
---|
373 | 0325 <span class="keyword">else</span> |
---|
374 | 0326 QFfac=zeros(4,1); |
---|
375 | 0327 QDfac=zeros(4,1); |
---|
376 | 0328 <span class="keyword">end</span> |
---|
377 | 0329 |
---|
378 | 0330 addQFsp(QuadElem) = addQFsp(QuadElem)+QFfac.*QFsp(QuadElem); |
---|
379 | 0331 addQDsp(QuadElem) = addQDsp(QuadElem)+QDfac.*QDsp(QuadElem); |
---|
380 | 0332 |
---|
381 | 0333 <span class="keyword">elseif</span> strcmp(FFTypeFlag,<span class="string">'Global'</span>) |
---|
382 | 0334 |
---|
383 | 0335 addQFsp = zeros(24,1); |
---|
384 | 0336 addQDsp = zeros(24,1); |
---|
385 | 0337 |
---|
386 | 0338 <span class="comment">% Change in tune and [QF;QD] from maximum gap</span> |
---|
387 | 0339 actualgap = getid(Sector); |
---|
388 | 0340 <span class="keyword">if</span> actualgap < (IDFF.GAPmin-1) |
---|
389 | 0341 actualgap = IDFF.GAPmax; |
---|
390 | 0342 <span class="keyword">end</span> |
---|
391 | 0343 DeltaNuY = gap2tune(Sector, actualgap); |
---|
392 | 0344 DeltaNuX = 0; |
---|
393 | 0345 fraccorr = DeltaNuY./gap2tune(5,13.23,1.9); |
---|
394 | 0346 |
---|
395 | 0347 <span class="comment">% Find which quads to change</span> |
---|
396 | 0348 QuadList = [Sector-1 2;Sector 1]; |
---|
397 | 0349 QuadElem = <a href="dev2elem.html" class="code" title="function Output = dev2elem(Family, DevList)">dev2elem</a>(<span class="string">'QF'</span>,QuadList); |
---|
398 | 0350 |
---|
399 | 0351 DeltaAmps = inv(TUNEresp) * [(fraccorr*6.23e-4)-DeltaNuX;fraccorr*(-0.05301)]; <span class="comment">% DelAmps = [QF; QD];</span> |
---|
400 | 0352 addQFsp = addQFsp+DeltaAmps(1,1); |
---|
401 | 0353 addQDsp = addQDsp+DeltaAmps(2,1); |
---|
402 | 0354 |
---|
403 | 0355 <span class="keyword">if</span> (Sector==7) | (Sector==10) | (Sector==11) |
---|
404 | 0356 QFfac=(fraccorr.*([2.243127/2.237111;2.243127/2.237111]-1)); |
---|
405 | 0357 QDfac=(fraccorr.*([2.556392/2.511045;2.556392/2.511045]-1)); |
---|
406 | 0358 <span class="keyword">elseif</span> (Sector==5) | (Sector==9) |
---|
407 | 0359 QFfac=(fraccorr.*([2.225965/2.219784;2.243096/2.237111]-1)); |
---|
408 | 0360 QDfac=(fraccorr.*([2.528950/2.483259;2.556345/2.511045]-1)); |
---|
409 | 0361 <span class="keyword">elseif</span> (Sector==4) | (Sector==8) | (Sector==12) |
---|
410 | 0362 QFfac=(fraccorr.*([2.243096/2.237111;2.225965/2.219784]-1)); |
---|
411 | 0363 QDfac=(fraccorr.*([2.556345/2.511045;2.528950/2.483259]-1)); |
---|
412 | 0364 <span class="keyword">else</span> |
---|
413 | 0365 QFfac=zeros(4,1); |
---|
414 | 0366 QDfac=zeros(4,1); |
---|
415 | 0367 <span class="keyword">end</span> |
---|
416 | 0368 |
---|
417 | 0369 addQFsp(QuadElem) = addQFsp(QuadElem)+QFfac.*QFsp(QuadElem); |
---|
418 | 0370 addQDsp(QuadElem) = addQDsp(QuadElem)+QDfac.*QDsp(QuadElem); |
---|
419 | 0371 |
---|
420 | 0372 <span class="keyword">else</span> |
---|
421 | 0373 error(<span class="string">'Unknown type selected for tune FF'</span>); |
---|
422 | 0374 <span class="keyword">end</span> |
---|
423 | 0375 |
---|
424 | 0376 AmpsQF = QFsp+addQFsp; |
---|
425 | 0377 AmpsQD = QDsp+addQDsp; |
---|
426 | 0378 |
---|
427 | 0379 <span class="comment">% Set quadrupoles</span> |
---|
428 | 0380 <a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a>(<span class="string">'QF'</span>, AmpsQF,[], 0); |
---|
429 | 0381 <a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a>(<span class="string">'QD'</span>, AmpsQD,[], 0); |
---|
430 | 0382 |
---|
431 | 0383 |
---|
432 | 0384 <span class="keyword">else</span> |
---|
433 | 0385 |
---|
434 | 0386 <span class="comment">% Change in tune and [QF;QD] from maximum gap</span> |
---|
435 | 0387 actualgap = getid(Sector); |
---|
436 | 0388 <span class="keyword">if</span> actualgap < (IDFF.GAPmin-1) |
---|
437 | 0389 actualgap = IDFF.GAPmax; |
---|
438 | 0390 <span class="keyword">end</span> |
---|
439 | 0391 DeltaNuY = gap2tune(Sector, actualgap); |
---|
440 | 0392 |
---|
441 | 0393 <span class="keyword">if</span> (Sector==7) | (Sector==10) | (Sector==11) |
---|
442 | 0394 DeltaAmps = inv(TUNEresp/12) * [0; -DeltaNuY]; <span class="comment">% DelAmps = [QF; QD];</span> |
---|
443 | 0395 DeltaAmpsQF=[DeltaAmps(1,1);DeltaAmps(1,1)]; |
---|
444 | 0396 DeltaAmpsQD=[DeltaAmps(2,1);DeltaAmps(2,1)]; |
---|
445 | 0397 <span class="keyword">elseif</span> (Sector==5) | (Sector==9) |
---|
446 | 0398 DeltaAmpsQF=DeltaNuY/0.0181*0.37*[-1.0637;-0.5132]; |
---|
447 | 0399 DeltaAmpsQD=DeltaNuY/0.0181*0.37*[-6.6328;-3.3434]; |
---|
448 | 0400 <span class="keyword">elseif</span> (Sector==4) | (Sector==8) | (Sector==12) |
---|
449 | 0401 DeltaAmpsQF=DeltaNuY/0.0181*0.37*[-0.5132;-1.0637]; |
---|
450 | 0402 DeltaAmpsQD=DeltaNuY/0.0181*0.37*[-3.3434;-6.6328]; |
---|
451 | 0403 <span class="keyword">else</span> |
---|
452 | 0404 DeltaAmpsQF=[0;0]; |
---|
453 | 0405 DeltaAmpsQD=[0;0]; |
---|
454 | 0406 <span class="keyword">end</span> |
---|
455 | 0407 |
---|
456 | 0408 <span class="comment">% Find which quads to change</span> |
---|
457 | 0409 QuadList = [Sector-1 1;Sector 2]; |
---|
458 | 0410 QuadElem = <a href="dev2elem.html" class="code" title="function Output = dev2elem(Family, DevList)">dev2elem</a>(<span class="string">'QF'</span>,QuadList); |
---|
459 | 0411 AmpsQF = QFsp(QuadElem) + DeltaAmpsQF; |
---|
460 | 0412 AmpsQD = QDsp(QuadElem) + DeltaAmpsQD; |
---|
461 | 0413 |
---|
462 | 0414 <span class="comment">% Set quadrupoles</span> |
---|
463 | 0415 <a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a>(<span class="string">'QF'</span>, AmpsQF, QuadList, 0); |
---|
464 | 0416 <a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a>(<span class="string">'QD'</span>, AmpsQD, QuadList, 0); |
---|
465 | 0417 |
---|
466 | 0418 <span class="keyword">end</span> |
---|
467 | 0419 |
---|
468 | 0420 |
---|
469 | 0421 pause(1); |
---|
470 | 0422 |
---|
471 | 0423 |
---|
472 | 0424 <span class="comment">% Correct orbit</span> |
---|
473 | 0425 [STDfinal, IterOut(i,1)] = setbpm(IDFF.HCMFamily, IDFF.Xmax.Data, IDFF.HCMList, IDFF.BPMxList, <span class="keyword">...</span> |
---|
474 | 0426 IDFF.VCMFamily, IDFF.Ymax.Data, IDFF.VCMList, IDFF.BPMyList, BPMIter, BPMTol); |
---|
475 | 0427 |
---|
476 | 0428 <span class="comment">% Record the gap AM</span> |
---|
477 | 0429 IDFF.GapMonitor(i,1) = getid(Sector); |
---|
478 | 0430 |
---|
479 | 0431 |
---|
480 | 0432 <span class="comment">% Record data</span> |
---|
481 | 0433 hcm(i,:) = (<a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a>(IDFF.HCMFamily, IDFF.HCMList)-HCM0)'; |
---|
482 | 0434 vcm(i,:) = (<a href="getsp.html" class="code" title="function [SP, tout, DataTime, ErrorFlag] = getsp(Family, varargin)">getsp</a>(IDFF.VCMFamily, IDFF.VCMList)-VCM0)'; |
---|
483 | 0435 X(:,i) = <a href="getam.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getam(varargin)">getam</a>(IDFF.BPMxFamily, IDFF.BPMxList); |
---|
484 | 0436 Y(:,i) = <a href="getam.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getam(varargin)">getam</a>(IDFF.BPMyFamily, IDFF.BPMyList); |
---|
485 | 0437 |
---|
486 | 0438 |
---|
487 | 0439 <span class="comment">% Statistics</span> |
---|
488 | 0440 Xrms(i) = std(IDFF.Xmax.Data - X(:,i)); |
---|
489 | 0441 Yrms(i) = std(IDFF.Ymax.Data - Y(:,i)); |
---|
490 | 0442 |
---|
491 | 0443 |
---|
492 | 0444 <span class="comment">% plot results</span> |
---|
493 | 0445 figure(h1); |
---|
494 | 0446 plot(BPMxs,(X(:,i)-IDFF.Xmax.Data)*1000,<span class="string">'r'</span>, BPMys,(Y(:,i)-IDFF.Ymax.Data)*1000,<span class="string">'g'</span>); |
---|
495 | 0447 title([<span class="string">'BPM Orbit Error at a '</span>, num2str(IDFF.GapMonitor(i,1)),<span class="string">' mm Gap'</span>]); |
---|
496 | 0448 ylabel(<span class="string">'X (red), Y (grn) Error [microns]'</span>); |
---|
497 | 0449 xlabel(<span class="string">'BPM Position [meters]'</span>); |
---|
498 | 0450 pause(0); |
---|
499 | 0451 <span class="keyword">end</span> |
---|
500 | 0452 |
---|
501 | 0453 |
---|
502 | 0454 <span class="comment">% Minimum gap orbits</span> |
---|
503 | 0455 IDFF.Xmin = <a href="getam.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getam(varargin)">getam</a>(IDFF.BPMxFamily, IDFF.BPMxList, <span class="string">'Struct'</span>); |
---|
504 | 0456 IDFF.Ymin = <a href="getam.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getam(varargin)">getam</a>(IDFF.BPMyFamily, IDFF.BPMyList, <span class="string">'Struct'</span>); |
---|
505 | 0457 |
---|
506 | 0458 |
---|
507 | 0459 <span class="comment">% Make the FF-tables</span> |
---|
508 | 0460 Xtable = [IDFF.GapMonitor hcm(:,1)-hcm(1,1) hcm(:,2)-hcm(1,2)]; |
---|
509 | 0461 Ytable = [IDFF.GapMonitor vcm(:,1)-vcm(1,1) vcm(:,2)-vcm(1,2)]; |
---|
510 | 0462 tableQ = []; |
---|
511 | 0463 |
---|
512 | 0464 |
---|
513 | 0465 <span class="comment">% Go to max gap</span> |
---|
514 | 0466 disp(<span class="string">' The insertion device gap, quads, and correctors are being reset.'</span>); |
---|
515 | 0467 setid(Sector, IDFF.GAPmax, IDFF.GapVelocity); |
---|
516 | 0468 |
---|
517 | 0469 <span class="comment">% Reset to maximum gap values</span> |
---|
518 | 0470 <a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a>(IDFF.HCMFamily, HCM0, IDFF.HCMList, 0); |
---|
519 | 0471 <a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a>(IDFF.VCMFamily, VCM0, IDFF.VCMList, 0); |
---|
520 | 0472 <a href="setpv.html" class="code" title="function ErrorFlag = setpv(varargin)">setpv</a>(ConfigSetpoint.QF.Setpoint, 0); |
---|
521 | 0473 <a href="setpv.html" class="code" title="function ErrorFlag = setpv(varargin)">setpv</a>(ConfigSetpoint.QD.Setpoint, 0); |
---|
522 | 0474 |
---|
523 | 0475 <span class="comment">% Then wait on setpoints</span> |
---|
524 | 0476 <a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a>(IDFF.HCMFamily, HCM0, IDFF.HCMList, -1); |
---|
525 | 0477 <a href="setsp.html" class="code" title="function ErrorFlag = setsp(Family, varargin)">setsp</a>(IDFF.VCMFamily, VCM0, IDFF.VCMList, -1); |
---|
526 | 0478 <a href="setpv.html" class="code" title="function ErrorFlag = setpv(varargin)">setpv</a>(ConfigSetpoint.QF.Setpoint, -1); |
---|
527 | 0479 <a href="setpv.html" class="code" title="function ErrorFlag = setpv(varargin)">setpv</a>(ConfigSetpoint.QD.Setpoint, -1); |
---|
528 | 0480 |
---|
529 | 0481 |
---|
530 | 0482 <span class="comment">% Ending orbits</span> |
---|
531 | 0483 IDFF.XmaxEnd = <a href="getam.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getam(varargin)">getam</a>(IDFF.BPMxFamily, IDFF.BPMxList, <span class="string">'Struct'</span>); |
---|
532 | 0484 IDFF.YmaxEnd = <a href="getam.html" class="code" title="function [AM, tout, DataTime, ErrorFlag] = getam(varargin)">getam</a>(IDFF.BPMyFamily, IDFF.BPMyList, <span class="string">'Struct'</span>); |
---|
533 | 0485 |
---|
534 | 0486 |
---|
535 | 0487 <span class="comment">% Structure output</span> |
---|
536 | 0488 IDFF.Sector = Sector; |
---|
537 | 0489 IDFF.Gaps = Gaps; |
---|
538 | 0490 IDFF.Xtable = Xtable; |
---|
539 | 0491 IDFF.Ytable = Ytable; |
---|
540 | 0492 IDFF.tableQ = tableQ; |
---|
541 | 0493 IDFF.BPMFlag = BPMFlag; |
---|
542 | 0494 IDFF.Xrms = Xrms; |
---|
543 | 0495 IDFF.Yrms = Yrms; |
---|
544 | 0496 IDFF.IterOut = IterOut; |
---|
545 | 0497 IDFF.TimeStamp = clock; |
---|
546 | 0498 IDFF.GeV = <a href="getenergy.html" class="code" title="function [Energy, HCMEnergy] = getenergy(varargin)">getenergy</a>; |
---|
547 | 0499 IDFF.DataDescriptor = <span class="string">'ID Feed Forward Table'</span>; |
---|
548 | 0500 IDFF.CreatedBy = <span class="string">'measidfftable'</span>; |
---|
549 | 0501 |
---|
550 | 0502 |
---|
551 | 0503 |
---|
552 | 0504 <span class="comment">% Change to DataRoot/ID/FeedForward directory</span> |
---|
553 | 0505 DirStart = pwd; |
---|
554 | 0506 DataRoot = <a href="getfamilydata.html" class="code" title="function [Data, ErrorFlag] = getfamilydata(Family, Field1, Field2, DeviceList)">getfamilydata</a>(<span class="string">'Directory'</span>,<span class="string">'DataRoot'</span>); |
---|
555 | 0507 DirectoryName = [DataRoot, <span class="string">'ID'</span>, filesep, <span class="string">'FeedForward'</span>, filesep]; |
---|
556 | 0508 [DirectoryName, ErrorFlag] = gotodirectory(DirectoryName); |
---|
557 | 0509 FileName = sprintf(<span class="string">'id%02de%2.0f'</span>, Sector, 10*<a href="getenergy.html" class="code" title="function [Energy, HCMEnergy] = getenergy(varargin)">getenergy</a>); |
---|
558 | 0510 FileName = appendtimestamp(FileName); |
---|
559 | 0511 save(FileName, <span class="string">'IDFF'</span>); |
---|
560 | 0512 fprintf(<span class="string">' Insertion device feed forward table saved to %s.mat\n'</span>, [DirectoryName FileName]); |
---|
561 | 0513 <span class="keyword">if</span> ErrorFlag |
---|
562 | 0514 fprintf(<span class="string">' Warning: %s was not the desired directory\n'</span>, DirectoryName); |
---|
563 | 0515 <span class="keyword">end</span> |
---|
564 | 0516 FileName = [DirectoryName FileName]; |
---|
565 | 0517 cd(DirStart); |
---|
566 | 0518 |
---|
567 | 0519 |
---|
568 | 0520 <span class="comment">% Close figures</span> |
---|
569 | 0521 close(h1); |
---|
570 | 0522 FigureHandles = <a href="plotidfftable.html" class="code" title="function FigureHandles = plotidfftable(Sector, GeV)">plotidfftable</a>(FileName); |
---|
571 | 0523 |
---|
572 | 0524 fprintf(<span class="string">' Measurement complete. The gap position and correctors have been set back to their original setpoints.'</span>); |
---|
573 | 0525 fprintf(<span class="string">' A new table has been generated and saved to directory %s\n'</span>, FileName); |
---|
574 | 0526 fprintf(<span class="string">' Figure '</span>, num2str(FigureHandles(1)),<span class="string">' -> Corrector strength verses gap position.'</span>); |
---|
575 | 0527 fprintf(<span class="string">' Figure '</span>, num2str(FigureHandles(2)),<span class="string">' -> RMS orbit distortion verses gap position.'</span>); |
---|
576 | 0528 fprintf(<span class="string">' -> Orbit drift during table generation verses BPM position.'</span>); |
---|
577 | 0529 fprintf(<span class="string">' Figure '</span>, num2str(FigureHandles(3)),<span class="string">' -> Rate of Change of the Corrector Magnets.'</span>); |
---|
578 | 0530 fprintf(<span class="string">' Insertion device feedforward table generation complete.\n'</span>); |
---|
579 | 0531 |
---|
580 | 0532 |
---|
581 | 0533 <span class="comment">% ALS resets</span> |
---|
582 | 0534 |
---|
583 | 0535 CPTableFlag = questdlg(sprintf(<span class="string">'Copy %.1f GeV Table to the IOC?'</span>,IDFF.GeV),<span class="string">'Feed Forward Table Complete'</span>,<span class="string">'Yes'</span>,<span class="string">'No'</span>,<span class="string">'No'</span>); |
---|
584 | 0536 <span class="keyword">if</span> strcmp(CPTableFlag,<span class="string">'No'</span>) |
---|
585 | 0537 fprintf(<span class="string">' Use ffcopy(%d,%.1f) to copy the table over to the feed forward program.\n'</span>, Sector, IDFF.GeV); |
---|
586 | 0538 fprintf(<span class="string">' Use ffread(%d) (or the "Undulator Server" application) to force the IOC to read the new table.\n'</span>, Sector); |
---|
587 | 0539 <span class="keyword">else</span> |
---|
588 | 0540 ffcopy(textfn1); |
---|
589 | 0541 fprintf(<span class="string">' For the IOC to read the new table use the "Undulator Server"\n'</span>); |
---|
590 | 0542 fprintf(<span class="string">' application or run ffread(%d) from Matlab.\n'</span>, Sector); |
---|
591 | 0543 <span class="keyword">end</span> |
---|
592 | 0544 |
---|
593 | 0545 <span class="comment">% Switch correctors to slow mode</span> |
---|
594 | 0546 <a href="setpv.html" class="code" title="function ErrorFlag = setpv(varargin)">setpv</a>(IDFF.HCMFamily, <span class="string">'RampRate'</span>, HCMRampRate0, IDFF.HCMList, 0); |
---|
595 | 0547 <a href="setpv.html" class="code" title="function ErrorFlag = setpv(varargin)">setpv</a>(IDFF.VCMFamily, <span class="string">'RampRate'</span>, VCMRampRate0, IDFF.VCMList, 0);</pre></div> |
---|
596 | <hr><address>Generated on Mon 21-May-2007 15:29:18 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
597 | </body> |
---|
598 | </html> |
---|