Home > ALS > StorageRing > srcycle.m

srcycle

PURPOSE ^

SRCYCLE - Storage ring cycle

SYNOPSIS ^

function FailFlag = srcycle(varargin)

DESCRIPTION ^

SRCYCLE - Storage ring cycle
  srcycle(SuperBendFlag {'Yes'/'No'}, ChicaneAndSkewQuadFlag {'Yes'/'No'})
  srcycle('SuperBend'  , 'ChicaneAndSkewQuad')
  srcycle('NoSuperBend', 'NoChicaneAndSkewQuad')  {Default}

  See also srramp setmachineconfig

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function FailFlag = srcycle(varargin)
0002 %SRCYCLE - Storage ring cycle
0003 %  srcycle(SuperBendFlag {'Yes'/'No'}, ChicaneAndSkewQuadFlag {'Yes'/'No'})
0004 %  srcycle('SuperBend'  , 'ChicaneAndSkewQuad')
0005 %  srcycle('NoSuperBend', 'NoChicaneAndSkewQuad')  {Default}
0006 %
0007 %  See also srramp setmachineconfig
0008 
0009 
0010 % Revision History
0011 %
0012 % 2001-05-15, Christoph Steier
0013 % Three major changes:
0014 % 1) Changed cycling routine (mostly for the 1.9 GeV case), to avoid damaging QF/QD power supplies.
0015 %    Old cycle: current status -> injection lattice -> max current -> zero -> injection -> production -> injection
0016 %    New cycle: current status -> injection lattice -> ramp to production -> ramp to injection -> ramp to production -> ramp to injection
0017 % 2) The vertical chicane are now included in cycling, since they now are always on.
0018 % 3) Included pause statements in old cycling routine (still used for 1.5 GeV) to reduce likelihood of power supply failures
0019 %
0020 % 2001-09-21, Tom Scarvie
0021 % Changed 1.9 GeV cycle so that superbend magnets are only ramped 1.5 -> 1.9 -> 1.5 once; they are skipped the second time around to speed up the cycle
0022 %
0023 % NOTE: Cycling for any energy except 1.9 GeV doesn't include the BSC, VCBSC, or QDA magnets yet.
0024 %
0025 % 2001-09-24, Tom Scarvie
0026 % Added SuperBendFlag argument to allow for not cycling the superbends
0027 %
0028 % 2001-10-19, T. Scarvie
0029 % Added setting the BSCramprate to 0.4 A/s initially for safety, now that ramping sets it to 0.8 A/s
0030 %
0031 % 2001-10-25, T.Scarvie
0032 % Changed routine so that skew quads and chicane magnets cycle simultaneously to speed up ramp
0033 %
0034 % 2002-04-29, T.Scarvie
0035 % Changed cycling so that the SR04 middle horizontal chicane (trim coil of motor chicane) does not cycle
0036 %
0037 % 2002-06-18, T.Scarvie
0038 % Added step to home the SR04 motor chicane magnets after cycling the outer chicane magnets
0039 % 2002-07-17, T.Scarvie
0040 % Added step to home the SR11 motor chicane magnets after cycling the outer chicane magnets
0041 %
0042 % 2002-08-21, T.Scarvie
0043 % Changed cycling so that the superbends cycle last if requested (additional cool-off time in case of a spindown)
0044 %
0045 % 2003-03-10, T.Scarvie
0046 % Changed to ramp superbends at 0.8 A/s if temperatures are normal (below 4.65 K for coils), 0.3 A/s otherwise
0047 %
0048 % 2003-04-25, C. Steier
0049 % Changed initial srload to use smaller ramprates for Superbends if their current was below
0050 % 150 A, when cycling was started (to avoid excessive heating in high inductance regime)
0051 %
0052 % 2003-05-28, C. Steier
0053 % disabled homing for motor 3 (translation) of chicane in sector 11 (translation stage is
0054 % currently broken and mechanically locked out)
0055 %
0056 % 2004-11-04, G. Portmann
0057 % Made middle layer compatible
0058 %
0059 % 2005-01-10, T. Scarvie
0060 % Made more changes to ensure middle layer compatibility (eg: getsp('BSCramprate') caused core dumps in Linux)
0061 %
0062 % 2005-11-08, G. Portmann
0063 % Added buildramptable so amp2k and k2amp are based the mini-cycle
0064 % The mini-cycle is done between RampTable.UpperLattice.Setpoint & RampTable.LowerLattice.Setpoint
0065 % not the Production and Injection lattices.  This allows for the 1.5 production lattice to be at 1.5 GeV.
0066 % Made more simulator compatible.
0067 
0068 
0069 %%%%%%%%%%%%%%
0070 % Initialize %
0071 %%%%%%%%%%%%%%
0072 
0073 
0074 % Input flags
0075 FailFlag = 0;
0076 SuperBendFlag = '';
0077 ChicaneAndSkewQuadFlag = '';
0078 DisplayFlag = 1;
0079 for i = length(varargin):-1:1
0080     if isstruct(varargin{i})
0081         % Ignor structures
0082     elseif iscell(varargin{i})
0083         % Ignor cells
0084     elseif strcmpi(varargin{i},'Display')
0085         DisplayFlag = 1;
0086         varargin(i) = [];
0087     elseif strcmpi(varargin{i},'NoDisplay')
0088         DisplayFlag = 0;
0089         varargin(i) = [];
0090     elseif any(strcmpi(varargin{i},{'Super Bend', 'SuperBend', 'Super Bends', 'SuperBends', 'SB'}))
0091         SuperBendFlag = 'Yes';
0092         varargin(i) = [];
0093     elseif any(strcmpi(varargin{i},{'No Super Bend', 'No SuperBend', 'NoSuperBend', 'No Super Bends', 'No SuperBends', 'NoSuperBends', 'NoSB'}))
0094         SuperBendFlag = 'No';
0095         varargin(i) = [];
0096     elseif any(strcmpi(varargin{i},{'Chicane', 'SkewQuad', 'ChicaneSkewQuad', 'ChicaneAndSkewQuad'}))
0097         ChicaneAndSkewQuadFlag = 'Yes';
0098         varargin(i) = [];
0099     elseif any(strcmpi(varargin{i},{'NoChicane', 'NoSkewQuad', 'NoChicaneSkewQuad', 'NoChicaneAndSkewQuad'}))
0100         ChicaneAndSkewQuadFlag = 'No';
0101         varargin(i) = [];
0102     end
0103 end
0104 
0105 
0106 %%%%%%%%%%%%%%%%%%
0107 % Input checking %
0108 %%%%%%%%%%%%%%%%%%
0109 if length(varargin) >= 1
0110     SuperBendFlag = varargin{1};
0111 end
0112 if isempty(SuperBendFlag)
0113     SuperBendFlag = 'No';
0114 end
0115 if strcmpi(SuperBendFlag,'Yes')
0116     fprintf('   The superbend magnets will be cycled.\n');
0117 elseif strcmpi(SuperBendFlag,'No')
0118     fprintf('   The superbend magnets will not be cycled.\n');
0119 else
0120     error('Superbend cycle input must be ''No'' or ''Yes''.  Cycle aborted.');
0121 end
0122 
0123 if length(varargin) >= 2
0124     ChicaneAndSkewQuadFlag = varargin{2};
0125 end
0126 if isempty(ChicaneAndSkewQuadFlag)
0127     ChicaneAndSkewQuadFlag = 'No';
0128 end
0129 if strcmpi(ChicaneAndSkewQuadFlag,'Yes')
0130     fprintf('   Chicane magnets will be cycled.\n');
0131 elseif strcmpi(ChicaneAndSkewQuadFlag,'No')
0132     fprintf('   Chicane magnets will not be cycled.\n');
0133 else
0134     error('Chicane cycle input must be ''No'' or ''Yes''.  Cycle aborted.');
0135 end
0136 
0137 
0138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0139 % Build the ramp tables & load the upper/lower hysteresis lattices %
0140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0141 
0142 % This updates the ramptables used in srcycle, amp2k, k2amp, etc.
0143 buildramptable;
0144 
0145 % Get the lattices from the new ramp table
0146 load([getfamilydata('Directory','OpsData'), 'alsrampup.mat']);
0147 UpperLattice = RampTable.UpperLattice.Setpoint;
0148 UpperLattice = RemoveSomeFamilies(UpperLattice);
0149 UpperLattice = RemoveSomeFields(UpperLattice);
0150 
0151 LowerLattice = RampTable.LowerLattice.Setpoint;
0152 LowerLattice = RemoveSomeFamilies(LowerLattice);
0153 LowerLattice = RemoveSomeFields(LowerLattice);
0154 
0155 % No superbend lattice
0156 UpperLatticeNoSB = UpperLattice;
0157 i = findrowindex([4 2;8 2;12 2], UpperLattice.BEND.Setpoint.DeviceList);
0158 UpperLatticeNoSB.BEND.Setpoint.Data(i) = [];
0159 UpperLatticeNoSB.BEND.Setpoint.DeviceList(i,:) = [];
0160 UpperLatticeNoSB.BEND.Setpoint.Status(i) = [];
0161 
0162 LowerLatticeNoSB = LowerLattice;
0163 i = findrowindex([4 2;8 2;12 2], LowerLattice.BEND.Setpoint.DeviceList);
0164 LowerLatticeNoSB.BEND.Setpoint.Data(i) = [];
0165 LowerLatticeNoSB.BEND.Setpoint.DeviceList(i,:) = [];
0166 LowerLatticeNoSB.BEND.Setpoint.Status(i) = [];
0167 
0168 
0169 %%%%%%%%%%%%%%%%%%%
0170 % Cycle if online %
0171 %%%%%%%%%%%%%%%%%%%
0172 if strcmpi(getmode('BEND'),'Online')
0173     try
0174 
0175         % Open ID's, zero FF channels, etc. ??
0176 
0177         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0178         % Set the superbend ramp rate limit %
0179         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0180         SuperBendCheck;
0181 
0182 
0183         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0184         % Zero trim & feed forward channels %
0185         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0186         setpv('HCM', 'Trim', 0);
0187         setpv('VCM', 'Trim', 0);
0188         setpv('HCM', 'FF1', 0);
0189         setpv('HCM', 'FF1', 0);
0190         setpv('VCM', 'FF2', 0);
0191         setpv('VCM', 'FF2', 0);
0192 
0193         setpv('QF', 'FF', 0);
0194         setpv('QD', 'FF', 0);
0195 
0196 
0197         if 1   % getenergy('Production') == 1.89??
0198             fprintf('   Starting a cycle for the %s operational mode.\n', getfamilydata('OperationalMode'));
0199 
0200             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0201             % Start from the injection lattice with superbends %
0202             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0203             % Note: Superbends are always included here (even if SuperBendFlag = 'No')!
0204             fprintf('   Loading the injection lattice ... ');
0205             setmachineconfig('Injection');
0206             pause(5);
0207             a = clock; fprintf('Completed %s %d:%d:%.0f\n', date, a(4), a(5), a(6));
0208 
0209 
0210             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0211             % Cycle the chicanes and skew quadrupoles %
0212             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0213             if strcmp(ChicaneAndSkewQuadFlag, 'Yes')
0214                 % Cycle chicane and skew quadrupoles
0215                 CycleChicaneAndSkewQuadrupoles;
0216 
0217                 % Home the motor chicane
0218                 fprintf('   Homing the SR04, SR06, and SR11 motor chicane magnets ..');
0219                 HomeMotorChicanes;
0220                 a = clock; fprintf(' Completed %s %d:%d:%.0f\n', date, a(4), a(5), a(6));
0221             end
0222 
0223 
0224             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0225             % Mini-Cycle without ramping the superbends %
0226             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0227 
0228             % Ramp to upper lattice without ramping the superbends
0229             fprintf('   Ramping to upper hysteresis lattice without superbends.\n');
0230             srramp('Upper', 'NoSuperBend');
0231             %setmachineconfig(UpperLatticeNoSB);
0232             pause(5);
0233             a = clock; fprintf('   Completed %s %d:%d:%.0f\n', date, a(4), a(5), a(6));
0234 
0235             % Ramp to lower lattice without ramping the superbends
0236             fprintf('   Ramping to lower hysteresis lattice without superbends.\n');
0237             srramp('Lower', 'NoSuperBend');
0238             %setmachineconfig(LowerLatticeNoSB);
0239             pause(5);
0240             a = clock; fprintf('   Completed %s %d:%d:%.0f\n', date, a(4), a(5), a(6));
0241 
0242 
0243             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0244             % For the second ramp cycle, only cycle the superbends if requested %
0245             %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0246 
0247             % Ramp to high lattice, then load it
0248             if strcmpi(SuperBendFlag,'No')
0249                 fprintf('   Ramping to upper hysteresis lattice without superbends.\n');
0250                 srramp('Upper', 'NoSuperBend');
0251                 %setmachineconfig(UpperLatticeNoSB);
0252             elseif strcmpi(SuperBendFlag,'Yes')
0253                 fprintf('   Ramping to upper hysteresis lattice including the superbends.\n');
0254                 FailFlag = srramp('Upper');
0255                 if FailFlag
0256                     error('Superbends over temperature.');
0257                 end
0258             end
0259             pause(5);
0260             a = clock; fprintf('   Completed %s %d:%d:%.0f\n', date, a(4), a(5), a(6));
0261 
0262             % Ramp down to low lattice, then load the injection lattice
0263             if strcmpi(SuperBendFlag,'No')
0264                 fprintf('   Ramping to lower hysteresis lattice without superbends.\n');
0265                 srramp('Lower', 'NoSuperBend');
0266                 %setmachineconfig(LowerLatticeNoSB);
0267             elseif strcmpi(SuperBendFlag,'Yes')
0268                 fprintf('   Ramping to lower hysteresis lattice including the superbends.\n');
0269                 FailFlag = srramp('Lower');
0270                 if FailFlag
0271                     error('Superbends over temperature.');
0272                 end
0273             end
0274             a = clock; fprintf('   Completed %s %d:%d:%.0f\n', date, a(4), a(5), a(6));
0275             
0276             fprintf('   Loading the injection lattice ... ');
0277             setmachineconfig('Injection');
0278             pause(2);
0279             a = clock; fprintf('Completed %s %d:%d:%.0f\n', date, a(4), a(5), a(6));
0280 
0281             fprintf('   Storage ring cycle completed.');
0282 
0283         else
0284 
0285             % The ALS does not do this max/min cycle anymore!!!!!!!!!!!!!!!!!!!
0286 
0287             fprintf('   Performing old cycling (all energies except 1.5 and 1.9 GeV) !\n');
0288             fprintf('   This cycling routine cycles the superbends!\n');
0289 
0290             fprintf('   ...pausing for 20 seconds (hit "ctrl-C" to escape)...\n');
0291             pause(20);
0292 
0293 
0294             % Home the motor chicanes
0295             HomeMotorChicanes;
0296 
0297             % Load max sp, with skew quads zero
0298             fprintf('  Going to maximum setpoints on BEND, QFA, SF, SD, QF, QD, and chicane magnets.\n');
0299             % Superbend max ???
0300             BENDsp = 911;
0301             QFAsp = [550; 550; 550; 550];
0302             SFsp = 378;
0303             SDsp = 378;
0304             % taken out on Aug. 7, 2000 because of multiple power supply failures
0305             %QFsp = 100;
0306             %QDsp = 100;
0307             QFsp = 95;
0308             QDsp = 98;
0309 
0310 
0311             % Set all magnets without waiting for rampflag
0312             setsp('HCMCHICANE', [-50;-50;50], [], 0);
0313             setsp('BEND', BENDsp, [1 1], 0);
0314             setsp('QFA', QFAsp, [], 0);
0315             setsp('SF', SFsp, [], 0);
0316             setsp('SD', SDsp, [], 0);
0317             setsp('QF', QFsp, [], 0);
0318             setsp('QD', QDsp, [], 0);
0319 
0320             % Check for rampflag complete
0321             setsp('HCMCHICANE', [-50;-50;50;], [], -2);
0322             setsp('BEND', BENDsp, [1 1], -2);
0323             setsp('QFA', QFAsp, [], -2);
0324             setsp('SF', SFsp, -2);
0325             setsp('SD', SDsp, -2);
0326             setsp('QF', QFsp, [], -2);
0327             setsp('QD', QDsp, [], -2);
0328 
0329             [tmp, iQF] = max(abs(getam('QF')-QFsp));
0330             [tmp, iQD] = max(abs(getam('QD')-QDsp));
0331             qfaam = getam('QFA');
0332             fprintf('  Setpoints:  BEND=%5.1f QFA=%5.1f,%5.1f,%5.1f,%5.1f SF=%5.1f SD=%5.1f QF(%d)=%5.1f QD(%d)=%5.1f amps\n', BENDsp, QFAsp(1), QFAsp(2), QFAsp(3), QFAsp(4), SFsp, SDsp, iQF, QFsp, iQD, QDsp);
0333             fprintf('  Monitors:   BEND=%5.1f QFA=%5.1f,%5.1f,%5.1f,%5.1f SF=%5.1f SD=%5.1f QF(%d)=%5.1f QD(%d)=%5.1f amps\n', getam('BEND'), qfaam(1), qfaam(2), qfaam(3), qfaam(4), getam('SF'), getam('SD'), iQF, getam('QF',iQF), iQD, getam('QD',iQD));
0334 
0335             fprintf('    pausing for 30 seconds ...\n');
0336             pause(30);
0337 
0338 
0339             % Load zero SP
0340             fprintf('  Going to minimum setpoints on BEND, QFA, SF, SD, QF, QD, and chicane magnets.\n');
0341             BENDsp = 0;
0342             QFAsp = [0;0;0;0];
0343             SFsp = 0;
0344             SDsp = 0;
0345             QFsp = 0;
0346             QDsp = 0;
0347 
0348             % Set all magnets without waiting for rampflag
0349             setsp('HCMCHICANE', [50;50;-50;], [], 0);
0350             setsp('BEND', BENDsp, [1 1], 0);
0351             setsp('QFA', QFAsp, [], 0);
0352             setsp('SF', SFsp, 1, 0);
0353             setsp('SD', SDsp, 1, 0);
0354             setsp('QF', QFsp, [], 0);
0355             setsp('QD', QDsp, [], 0);
0356 
0357             % Check for rampflag complete
0358             setsp('HCMCHICANE', [50;50;-50;], [], -2);
0359             fprintf('  Going to zero on the chicane magnets.\n');
0360             setsp('HCMCHICANE', [0;0;0;], [], 0);
0361             setsp('BEND', BENDsp, [1 1], -2);
0362             setsp('QFA', QFAsp, [], -2);
0363             setsp('SF', SFsp, -2);
0364             setsp('SD', SDsp, -2);
0365             setsp('QF', QFsp, [], -2);
0366             setsp('QD', QDsp, [], -2);
0367 
0368             [tmp, iQF] = max(abs(getam('QF')-QFsp));
0369             [tmp, iQD] = max(abs(getam('QD')-QDsp));
0370             qfaam = getam('QFA');
0371             fprintf('  Setpoints:  BEND=%5.1f QFA=%5.1f,%5.1f,%5.1f,%5.1f SF=%5.1f SD=%5.1f QF(%d)=%5.1f QD(%d)=%5.1f amps\n', BENDsp, QFAsp(1), QFAsp(2), QFAsp(3), QFAsp(4), SFsp, SDsp, iQF, QFsp, iQD, QDsp);
0372             fprintf('  Monitors:   BEND=%5.1f QFA=%5.1f,%5.1f,%5.1f,%5.1f SF=%5.1f SD=%5.1f QF(%d)=%5.1f QD(%d)=%5.1f amps\n', getam('BEND'), qfaam(1), qfaam(2), qfaam(3), qfaam(4), getam('SF'), getam('SD'), iQF, getam('QF',iQF), iQD, getam('QD',iQD));
0373 
0374             fprintf('    pausing for 30 seconds ...\n');
0375             pause(30);
0376             setsp('HCMCHICANE', [0;0;0;], [], -2);
0377 
0378 
0379             % Turn down the superbend ramp rate since no temperature check are done in setmachineconfig ???
0380             setpv('BEND', 'RampRate', 0.3, [4 2;8 2;12 2]);
0381 
0382 
0383             % Load injection lattice
0384             setmachineconfig('Injection');
0385             pause(5);
0386 
0387             % Load production lattice
0388             setmachineconfig('Production');
0389             pause(5);
0390 
0391             % load injection lattice
0392             setmachineconfig('Injection');
0393         end
0394 
0395     catch
0396         fprintf('\n  **********************\n');
0397         fprintf(  '  **  Cycle aborted!  **\n');
0398         fprintf(  '  **********************\n\n');
0399         sound tada
0400         %fprintf('\n   %s\n', lasterr);
0401         error(lasterr);
0402     end
0403 end
0404 
0405 
0406 
0407 %%%%%%%%%%%%%%%
0408 % Subroutines %
0409 %%%%%%%%%%%%%%%
0410 
0411 function BSCramprate = SuperBendCheck
0412 % This function protects the superbends on the first load to the injection lattice
0413 %
0414 % Set the superbend ramprate to 0.8A/s if the coil temps are acceptable
0415 
0416 Templimit = 4.45;
0417 [BSCcoiltemps, BSCcoilnames] = getsuperbendtemperatures;
0418 if any(BSCcoiltemps > Templimit)
0419     BSCramprate = 0.3;
0420 
0421     bscnum = (find(BSCcoiltemps > Templimit));
0422     sound tada;
0423     fprintf('   The temperature of one of the superbend magnets is too high.\n');
0424     for i=1:length(bscnum)
0425         fprintf('   The Coil Temperature of %s is %.2f K.  It should be below %.2f K.\n', BSCcoilnames{bscnum(i)}, BSCcoiltemps(bscnum(i)), Templimit);
0426     end
0427     fprintf('   A reduced ramp rate will be used for the cycle.  However, if a temperature\n');
0428     fprintf('   warning persists, there may be a problem with one of the superbends!\n');
0429 else
0430     BSCramprate = 0.8;
0431 end
0432 
0433 % In case the current is small, heating is much worse because of large magnet inductance at small field -> reduce ramprates
0434 if min(getsp('BEND',[4 2;8 2;12 2])) < 150     % changed to min (G. Portmann 11-18-2005)
0435     if BSCramprate > 0.6
0436         BSCramprate = .4;
0437     else
0438         BSCramprate = .2;
0439     end
0440 end
0441 
0442 setpv('BEND', 'RampRate', BSCramprate, [4 2;8 2;12 2]);
0443 fprintf('   The superbend ramp rate is being set to %.2f A/s.\n', BSCramprate);
0444 return
0445 
0446 
0447 function CycleChicaneAndSkewQuadrupoles
0448 
0449 % Disable cycling for skew quadrupoles which are not switched on
0450 % SQSDlist = getlist('SQSD');
0451 % SQSFlist = getlist('SQSF');
0452 % SQSDon=getam('SQSDon');
0453 % SQSFon=getam('SQSFon');
0454 % SQSDindex=find(SQSDon==1);
0455 % SQSFindex=find(SQSFon==1);
0456 % SQSDlist=SQSDlist(SQSDindex,:);
0457 % SQSFlist=SQSFlist(SQSFindex,:);
0458 
0459 % cycle skew quads and chicanes simultaneously
0460 fprintf('   Going to maximum on the chicane and skew quad magnets ... ');
0461 Amps = 6;
0462 setsp('SQSD', Amps, [], 0);
0463 setsp('SQSF', Amps, [], 0);
0464 setsp('HCMCHICANE', [-50;-50;50], [], 0);
0465 %setsp('VCMCHICANE', [50;0;50;0;0], [], 0);
0466 
0467 % Check for rampflags complete
0468 setsp('SQSD', Amps, []);
0469 setsp('SQSF', Amps, []);
0470 setsp('HCMCHICANE', [-50;-50;50;], [], -2);
0471 %setsp('VCMCHICANE', [50;0;50;0;0], [], -2);
0472 pause(2);
0473 a = clock; fprintf('Completed %s %d:%d:%.0f\n', date, a(4), a(5), a(6));
0474 
0475 
0476 fprintf('   Going to negative maximum on the chicane and skew quadrupole magnets ... ');
0477 Amps = -6;
0478 setsp('SQSD', Amps, [], 0);
0479 setsp('SQSF', Amps, [], 0);
0480 setsp('HCMCHICANE', [50;50;-50;], [], 0);
0481 %setsp('VCMCHICANE', [-50;0;-50;0;0], [], 0);
0482 
0483 % Check for rampflags complete
0484 setsp('SQSD', Amps, [], -2);
0485 setsp('SQSF', Amps, [], -2);
0486 setsp('HCMCHICANE', [50;50;-50;], [], -2);
0487 %setsp('VCMCHICANE', [-50;0;-50;0;0], [], -2);
0488 pause(2);
0489 a = clock; fprintf('Completed %s %d:%d:%.0f\n', date, a(4), a(5), a(6));
0490 
0491 
0492 fprintf('   Going to zero on the chicane and skew quadrupole magnets ... ');
0493 Amps = 0;
0494 setsp('SQSD', Amps, [], 0);
0495 setsp('SQSF', Amps, [], 0);
0496 setsp('HCMCHICANE', [0;0;0], [], 0);
0497 %setsp('VCMCHICANE', [0;0;0;0;0], [], 0);
0498 
0499 % Check for rampflags complete
0500 setsp('SQSD', Amps, [], -2);
0501 setsp('SQSF', Amps, [], -2);
0502 setsp('HCMCHICANE', [0;0;0], [], -2);
0503 %setsp('VCMCHICANE', [0;0;0;0;0], [], -2);
0504 pause(2);
0505 a = clock; fprintf('Completed %s %d:%d:%.0f\n', date, a(4), a(5), a(6));
0506 return;
0507 
0508 
0509 
0510 function HomeMotorChicanes
0511 
0512 % Home the motor chicane
0513 setpv('SR04U___HCM2M1_BC00.VAL',1);
0514 setpv('SR04U___HCM2M2_BC00.VAL',1);
0515 %setpv('SR04U___HCM2M3_BC00.VAL',1);  % Drive is off
0516 setpv('SR06U___HCM2M1_BC00.VAL',1);
0517 setpv('SR06U___HCM2M2_BC00.VAL',1);
0518 setpv('SR11U___HCM2M1_BC00.VAL',1);
0519 setpv('SR11U___HCM2M2_BC00.VAL',1);
0520 %    setpv('SR11U___HCM2M3_BC00.VAL',1); % horizontal drive not enabled for this chicane
0521 
0522 % Print dots until it's done
0523 t0=gettime;
0524 while getpv('SR04U___HCM2M1_BC00.VAL')~=0 | getpv('SR04U___HCM2M2_BC00.VAL')~=0 | ...  % getpv('SR04U___HCM2M3_BC00.VAL')~=0 |...
0525         getpv('SR06U___HCM2M1_BC00.VAL')~=0 | getpv('SR06U___HCM2M2_BC00.VAL')~=0 | ...
0526         getpv('SR11U___HCM2M1_BC00.VAL')~=0 | getpv('SR11U___HCM2M2_BC00.VAL')~=0      % | getpv('SR11U___HCM2M3_BC00.VAL')~=0
0527     fprintf('.');
0528     pause(4);
0529     if (gettime-t0)>120
0530         fprintf('\n\n   There is a problem homing the chicanes! A likely solution is rebooting the appropriate IOC crate.\n');
0531         error('(SR04 Chicane: crate srioc040.als.lbl.gov, SR06 Chicane: crate srioc06u03, SR11 Chicane: srioc110.als.lbl.gov)');
0532     end
0533 end
0534 pause(2);
0535 
0536 if getam('SR04U___HCM2M1_BM00.VAL')==1
0537     fprintf('   There was a problem homing SR04 chicane magnet motor 1!\n');
0538 end
0539 if getam('SR04U___HCM2M2_BM00.VAL')==1
0540     fprintf('   There was a problem homing SR04 chicane magnet motor 2!\n');
0541 end
0542 %if getam('SR04U___HCM2M3_BM00.VAL')==1
0543 %    fprintf('   There was a problem homing SR04 chicane magnet motor 3!\n');
0544 %end
0545 if getam('SR06U___HCM2M1_BM00.VAL')==1
0546     fprintf('   There was a problem homing SR06 chicane magnet motor 1!\n');
0547 end
0548 if getam('SR06U___HCM2M2_BM00.VAL')==1
0549     fprintf('   There was a problem homing SR06 chicane magnet motor 2!\n');
0550 end
0551 if getam('SR11U___HCM2M1_BM00.VAL')==1
0552     fprintf('   There was a problem homing SR11 chicane magnet motor 1!\n');
0553 end
0554 if getam('SR11U___HCM2M2_BM00.VAL')==1
0555     fprintf('   There was a problem homing SR11 chicane magnet motor 2!\n');
0556 end
0557 %    if getam('SR11U___HCM2M3_BM00.VAL')==1
0558 %        fprintf('   There was a problem homing SR11 chicane magnet motor 3!\n');
0559 %    end
0560 
0561 if getam('SR04U___HCM2M1_BM00.VAL')==0 & getam('SR04U___HCM2M2_BM00.VAL')==0  & getpv('SR04U___HCM2M1_BC00.VAL')==0 & getpv('SR04U___HCM2M2_BC00.VAL')==0 & getpv('SR04U___HCM2M3_BC00.VAL')==0
0562     %& getam('SR04U___HCM2M3_BM00.VAL')==0
0563     %fprintf('   The SR04 motor chicane magnet has been homed; the proper values will be loaded with the lattice.\n');
0564 else
0565     fprintf('   There was a problem homing the SR04 motor chicane magnet.\n');
0566 end
0567 if getam('SR06U___HCM2M1_BM00.VAL')==0 & getam('SR06U___HCM2M2_BM00.VAL')==0 & getpv('SR06U___HCM2M1_BC00.VAL')==0 & getpv('SR06U___HCM2M2_BC00.VAL')==0
0568     %fprintf('   The SR06 motor chicane magnet has been homed; the proper values will be loaded with the lattice.\n');
0569 else
0570     fprintf('   There was a problem homing the SR06 motor chicane magnet.\n');
0571 end
0572 if getam('SR11U___HCM2M1_BM00.VAL')==0 & getam('SR11U___HCM2M2_BM00.VAL')==0 & getpv('SR11U___HCM2M1_BC00.VAL')==0 & getpv('SR11U___HCM2M2_BC00.VAL')==0
0573     % & getpv('SR11U___HCM2M3_BC00.VAL')==0
0574     % getam('SR11U___HCM2M3_BM00.VAL')==0 &...
0575     %fprintf('   The SR11 motor chicane magnet has been homed; the proper values will be loaded with the lattice.\n');
0576 else
0577     fprintf('   There was a problem homing the SR11 motor chicane magnet.\n');
0578 end
0579 
0580 pause(2);
0581 return;
0582 
0583 
0584 function Lattice = RemoveSomeFamilies(Lattice)
0585 % Remove families
0586 RemoveFamilyNames = {'HCMCHICANE','HCMCHICANEM','VCMCHICANE','SQEPU','SQSF','SQSD','RF','GeV','DCCT'};
0587 j = find(isfield(Lattice, RemoveFamilyNames));
0588 Lattice = rmfield(Lattice, RemoveFamilyNames(j));
0589 return
0590 
0591 
0592 function Lattice  = RemoveSomeFields(Lattice);
0593 % Remove fields
0594 RemoveFieldNames = {'RampRate','TimeConstant','DAC','Trim','FF1','FF2'};
0595 Fields = fieldnames(Lattice);
0596 for i = 1:length(Fields)
0597     j = find(isfield(Lattice.(Fields{i}), RemoveFieldNames));
0598     Lattice.(Fields{i}) = rmfield(Lattice.(Fields{i}), RemoveFieldNames(j));
0599 end
0600 return

Generated on Thu 02-Aug-2007 13:16:07 by m2html © 2003