0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 clear
0012
0013
0014 Fc = 1000;
0015
0016
0017
0018
0019 if ispc
0020
0021
0022
0023 i = 2;
0024 FileName = sprintf('C:\\greg\\Matlab\\machine\\ALS\\BoosterData\\123INJ\\PowerSupplies\\BQFQD_ramping_20070111\\coordinated_ramp_B_QF_QD_20070111_4kHz_%d.txt', i);
0025
0026 else
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 Directory = '/home/als/physdata/matlab/srdata/powersupplies/BQFQD_ramping_20070124/';
0038 d = dir(Directory);
0039 FileName = [Directory d(end).name]
0040 end
0041
0042 LineType = 'g';
0043
0044 fid = fopen(FileName,'r');
0045 if fid == -1
0046 fprintf(' File open error.\n');
0047 return;
0048 end
0049 f = fscanf(fid, '%f\n', 1);
0050 N = fscanf(fid, '%f\n', 1);
0051 Data = fscanf(fid, '%f %f %f', [3 inf]);
0052 fclose(fid);
0053
0054 Data = Data';
0055 Data(:,1) = 60 * Data(:,1);
0056 Data(:,2) = 60 * Data(:,2);
0057 Data(:,3) = 125 * Data(:,3);
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 fs = 4000;
0070 t = (0:(size(Data,1)-1)) / fs;
0071
0072
0073
0074 QFratio = Data(:,1)./Data(:,3);
0075 QDratio = Data(:,2)./Data(:,3);
0076
0077
0078 if 1
0079 TimeFlag = 1;
0080 x = t;
0081 xLabelString = 'Time [Seconds]';
0082 else
0083 TimeFlag = 0;
0084 x = Data(:,3);
0085 xLabelString = 'BEND Current [Amps]';
0086 end
0087
0088
0089 figure(1);
0090
0091 subplot(4,1,1);
0092 plot(x, Data);
0093 legend('QF', 'QD', 'BEND', 'Location', 'NorthWest');
0094 axis tight;
0095 grid on;
0096 ylabel('[Amps]');
0097 title('New Bend, QF Compensation');
0098
0099 subplot(4,1,2);
0100 plot(x, QFratio, LineType);
0101 hold on;
0102 plot([min(x) max(x)],[.520 .520],'r');
0103 hold off;
0104 ylabel('QF/BEND (Goal .520)');
0105 axis tight;
0106 yaxis([.45 .6]);
0107 grid on;
0108
0109 orient tall
0110
0111
0112 figure(2);
0113
0114 subplot(4,1,1);
0115 plot(x, Data);
0116 legend('QF', 'QD', 'BEND', 'Location', 'NorthWest');
0117 axis tight;
0118 grid on;
0119 title('New Bend, QD Compensation');
0120
0121 subplot(4,1,2);
0122 plot(x, QDratio, LineType);
0123 hold on;
0124 plot([min(x) max(x)],[.535 .535],'r');
0125 hold off;
0126 ylabel('QD/BEND (Goal .535)');
0127 axis tight;
0128 yaxis([.45 .6]);
0129 grid on;
0130
0131 orient tall
0132
0133
0134
0135 w = 2 * pi * 10;
0136 sys = tf(1,[1/w 1]);
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153 sysinv = tf([1/w 1],conv([1/Fc 1],[1/Fc 1]));
0154
0155
0156
0157 QFErr = QFratio - .520;
0158 QDErr = QDratio - .535;
0159
0160
0161 i = find(t < .01);
0162 QFErr(i) = 0;
0163 QDErr(i) = 0;
0164
0165
0166 i = find(t > .85);
0167 QFErr(i) = linspace(QFErr(i(1)),0,length(i));
0168 QDErr(i) = linspace(QDErr(i(1)),0,length(i));
0169
0170 [QFcommand, tinv, xinv] = lsim(sysinv, -QFErr, t);
0171 [QDcommand, tinv, xinv] = lsim(sysinv, -QDErr, t);
0172
0173
0174
0175 [QFsim, t1, x1] = lsim(sys, QFcommand, t);
0176 [QDsim, t1, x1] = lsim(sys, QDcommand, t);
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186 figure(1);
0187 subplot(4,1,3);
0188 plot(x,[QFratio-.520 QFcommand QFsim QFratio-.535+QFsim]);
0189 ylabel('QF/BEND Error');
0190 legend('QF/BEND-.520', '\DeltaQFcommand', '\DeltaQFsim', 'QF/BEND-.535+\DeltaQFsim', 'Location', 'SouthWest');
0191 axis tight;
0192
0193 grid on;
0194
0195 subplot(4,1,4);
0196 plot(x, Data(:,3) .* QFcommand);
0197 ylabel('\DeltaQF [Amps]');
0198 xlabel(xLabelString);
0199 axis tight;
0200
0201 grid on;
0202
0203
0204 figure(2);
0205 subplot(4,1,3);
0206
0207 plot(x, [QDratio-.535 QDcommand QDsim QDratio-.535+QDsim]);
0208 ylabel('QD/BEND Error');
0209 legend('QD/BEND-.535', '\DeltaQDcommand', '\DeltaQDsim', 'QD/BEND-.535+\DeltaQDsim', 'Location', 'SouthWest');
0210 axis tight;
0211
0212 grid on;
0213
0214 subplot(4,1,4);
0215 plot(x, Data(:,3) .* QDcommand);
0216 ylabel('\DeltaQD [Amps]');
0217 xlabel(xLabelString);
0218 axis tight;
0219
0220 grid on;
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243