DECLARE SUB fileheader (logfile$, mn$, op$, ts$, dv$, rn$, cm$) DECLARE SUB fileinitl (test$, run$, logfile$, ok$) DECLARE SUB gettestparam () DECLARE SUB measure () DECLARE SUB logsumm (logfile$, i0!, vt0!, svt0!, i1!, vt1!, svt1!, i2!, vt2!, svt2!) DECLARE SUB imagmeas (imag!) DECLARE SUB imagramp (rr!, ifin!) DECLARE SUB vcoilcvt (coil%, nave%, vtp!(), vtn!(), vt!, sigvt!) DECLARE SUB vcoillogvt (logfile$, c%, i1!, i2!, nave%, vtp!(), vtn!(), vt!, sigvt!) DECLARE SUB fileheader1 (logfile$, mn$, op$, ts$, dv$, rn$, cm$) DECLARE SUB fileopenout (file$, ok$) DECLARE SUB fileprot (file$) DECLARE SUB gpibinit () DECLARE SUB dac488hrinit () DECLARE SUB dac488hrsetupv () DECLARE SUB hp3457init () '**************************************************************************** 'Program HERDXCAL 'This program is used to cross calibrate the three coils used for 'the B-Factory high energy ring dipoles. ' 'Zachary Wolf '5/14/94 '**************************************************************************** 'Include the constants used in the program REM $INCLUDE: 'param.inc' 'Prepare the screen CLS 'Initialize the GPIB CALL gpibinit 'Initialize the DAC CALL dac488hrinit CALL dac488hrsetupv 'Initialize the HP3457 CALL hp3457init 'Print a message about the program PRINT PRINT "Program HERDXCAL" PRINT "This program is used to cross calibrate the three coils used" PRINT "on the B-Factory high energy ring dipoles. The three coils will" PRINT "be placed in the same magnet, one after the other. In this way," PRINT "the relative coil constants can be determined." PRINT 'Get test parameters from the operator testparam: CALL gettestparam 'Open the log file CALL fileinitl("xcal", runP$, logfileP$, ok$) IF ok$ <> "y" THEN PRINT : PRINT "Problem opening the log file. Try a different run number.": PRINT GOTO testparam: END IF 'Write a header to the log file CALL fileheader(logfileP$, magnameP$, operatorP$, teststandP$, "PEP Coils 0, 1, and 2", runP$, commentP$) 'Write a .bat file to write protect the data file CALL fileprot(logfileP$) 'Measure the integrated field strength as a function of current CALL measure 'Message PRINT PRINT "Ramping to 0 Amps." 'Ramp to 0 amps CALL imagramp(imagramprateP!, 0!) 'Message PRINT "The cross calibration is complete." END SUB gettestparam '**************************************************************************** 'This subroutine prompts the operator for the magnet name and other 'parameters of the test. ' 'Outputs put in the /testparam/ common block: ' magnameP$, name of magnet 1 ' operatorP$, name of the operator doing the test ' teststandP$, the teststand being used ' runP$, run number ' commentP$, comment about the test ' 'Zachary Wolf '4/16/94 '**************************************************************************** begin: 'Get the name of the magnet PRINT "What is the name of the magnet being used for this measurement?" PRINT "(8 characters or less): ["; magnameP$; "]"; INPUT magname$ magname$ = UCASE$(magname$) IF magname$ <> "" THEN magnameP$ = magname$ 'Get the operator's name(s) PRINT "Enter the operator(s) name(s): ["; operatorP$; "]"; INPUT operator$ IF operator$ <> "" THEN operatorP$ = operator$ 'Get the name of the test stand stand: PRINT "Enter which test stand is being used (D0, D1, or D2): ["; teststandP$; "]"; INPUT teststand$ teststand$ = UCASE$(teststand$) IF teststand$ <> "" THEN teststandP$ = teststand$ IF teststand$ <> "" AND teststand$ <> "D0" AND teststand$ <> "D1" AND teststand$ <> "D2" THEN GOTO stand IF teststandP$ = "" GOTO stand 'Get the name of the measurement coil 'meascoil: 'PRINT "Enter the name of the measurement coil (COIL0, COIL1, or COIL2): ["; coilP$; "]"; 'INPUT coil$ 'coil$ = UCASE$(coil$) 'IF coil$ <> "" THEN coilP$ = coil$ 'IF coil$ <> "" AND coil$ <> "COIL0" AND coil$ <> "COIL1" AND coil$ <> "COIL2" THEN GOTO meascoil 'IF coilP$ = "" GOTO meascoil 'Get the run number PRINT "What is the run number (1, 2, 3, ...): ["; runP$; "]"; INPUT run$ IF run$ <> "" THEN runP$ = run$ 'Get a comment PRINT "Enter any comment about the run: ["; commentP$; "]"; LINE INPUT comment$ IF comment$ <> "" THEN commentP$ = comment$ 'See if everything was entered correctly PRINT INPUT "Do you wish to make any changes to the values entered (Y or N): ", yn$ IF yn$ = "Y" OR yn$ = "y" THEN GOTO begin END SUB SUB measure '**************************************************************************** 'This subroutine controls the measurement of the integrated field strength 'as a function of current for the B-Factory high energy ring dipoles. 'Constants come from param.inc. ' 'Zachary Wolf '4/16/94 '**************************************************************************** 'Message PRINT PRINT "Beginning the measurement cycle..." 'Initialize data arrays, redimension upon use DIM vtp!(1 TO 2) 'holds +vt values during averaging DIM vtn!(1 TO 2) 'holds -vt values during averaging 'Get the parameters for the teststand being used IF teststandP$ = "D0" THEN ts% = 0 ELSEIF teststandP$ = "D1" THEN ts% = 1 ELSEIF teststandP$ = "D2" THEN ts% = 2 ELSE PRINT "Unknown test stand. Program ending." STOP END IF 'Get the test current PRINT current: INPUT "What current do you wish to perform the measurement at? (Amps) ", inom! IF inom! < 0 OR inom! > 1000! THEN PRINT "The current must be in the range 0 < I < 1000 A" GOTO current: END IF 'Message PRINT PRINT "Ramping to "; inom!; " Amps..." 'Ramp to the desired current CALL imagramp(imagramprateP!, inom!) 'Loop over the three measuring coils FOR c% = 0 TO 2 'Have the correct coil placed in the magnet PRINT PRINT "Please place measurement coil "; c%; " in the magnet." INPUT "Press ENTER when ready.", a$ 'Message PRINT PRINT "Measuring the integrated voltage using coil "; c%; "..." 'Measure the current before the coil measurement CALL imagmeas(ibef!) 'Measure the voltage integral 'The coil channel number comes from the teststand number ts% CALL vcoilcvt(ts%, nave%, vtp!(), vtn!(), vt!, sigvt!) 'Measure the current after the coil measurement CALL imagmeas(iaft!) 'Write the voltage integrals to the log file CALL vcoillogvt(logfileP$, c%, ibef!, iaft!, nave%, vtp!(), vtn!(), vt!, sigvt!) 'Message PRINT "The integrated voltage is "; vt!; " +- "; sigvt!; " Vs" 'Store the results IF c% = 0 THEN i0! = (ibef! + iaft!) / 2 vt0! = vt! sigvt0! = sigvt! ELSEIF c% = 1 THEN i1! = (ibef! + iaft!) / 2 vt1! = vt! sigvt1! = sigvt! ELSEIF c% = 2 THEN i2! = (ibef! + iaft!) / 2 vt2! = vt! sigvt2! = sigvt! END IF 'End loop over coils NEXT c% 'Write the results to the log file CALL logsumm(logfileP$, i0!, vt0!, sigvt0!, i1!, vt1!, sigvt1!, i2!, vt2!, sigvt2!) END SUB