DECLARE SUB fileheader () DECLARE SUB fileopen (path$, run$) DECLARE SUB fileprot () DECLARE SUB gettestparam () DECLARE SUB measure () DECLARE SUB logheader (logfile$, mn$, op$, ts$, dv$, rn$, cm$) DECLARE SUB logopen (logfile$) DECLARE SUB logsumm (logfile$, i0!, vt0!, svt0!, i1!, vt1!, svt1!, i2!, vt2!, svt2!) DECLARE SUB logvt (logfile$, m%, i1!, i2!, nave%, vtp!(), vtn!()) DECLARE SUB imagmeas (c%, vperi!, imag!) DECLARE SUB imagramp (rr!, iperv!, ifin!) DECLARE SUB vcoilcntvt (c%, n%, t!, nave%, vtp!(), vtn!(), vt!, sigvt!) 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 CALL gettestparam 'Open the log and data files and write headers path$ = "" CALL fileopen(path$, runP$) CALL fileheader 'Write a .bat file to write protect the data file CALL fileprot '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!, imagpervdacP!, 0!) 'Message PRINT "The cross calibration is complete." END SUB fileheader '**************************************************************************** 'This subroutine writes the headers of the files. ' 'Input from the /testparam/ common block: ' magnameP$, magnet name ' teststandP$, the teststand ' operatorP$, operator name ' runP$, the run number ' commentP$, a comment about the test ' 'Input from the /filenames/ common block: ' logfileP$, the log file ' 'Zachary Wolf '4/16/94 '**************************************************************************** 'Write the header of the log file CALL logheader(logfileP$, magnameP$, operatorP$, teststandP$, "PEP Coils 0, 1, and 2", runP$, commentP$) END SUB SUB fileopen (path$, run$) '**************************************************************************** 'This subroutine opens the files that the program uses. ' 'Input: ' path$, subdirectory where the files are to be created ' run$, run number, used to distinguish files ' 'Output placed in the /filenames/ common block: ' logfileP$, name, including the path, of the log file ' 'Zachary Wolf '4/16/94 '**************************************************************************** 'Make the file extension r% = VAL(run$) IF r% < 10 THEN ext$ = "ru" + run$ IF r% >= 10 THEN ext$ = "r" + run$ 'Open the log file logfile$ = "xcallog." + ext$ CALL logopen(logfile$) PRINT logfile$; " created" 'Store the file name logfileP$ = logfile$ END SUB SUB fileprot '**************************************************************************** 'This subroutine makes a .bat file which is used to set the attributes 'of the data files so they can not be written over. ' 'Inputs from param.inc: ' logfileP$, path and name of the log file ' 'Zachary Wolf '5/14/94 '**************************************************************************** 'Create the .bat file filenum% = FREEFILE OPEN "xcalprot.bat" FOR OUTPUT AS filenum% 'Make the data files for magnet 1 read only PRINT #filenum%, "attrib +r "; logfileP$ 'Close the bat file CLOSE filenum% END SUB 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 ' 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 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 operator's name(s) PRINT "Enter the operator(s) name(s): ["; operatorP$; "]"; INPUT operator$ IF operator$ <> "" THEN operatorP$ = operator$ '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$; "]"; 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..." 'Simplify the notation n% = vcoilnptsP% t! = vcoildeltatP! nave% = vcoilnaveP% 'Initialize data arrays DIM vtp!(1 TO nave%) 'holds +vt values during averaging DIM vtn!(1 TO nave%) 'holds -vt values during averaging 'Get the parameters for the teststand being used IF teststandP$ = "D0" THEN c% = coil0chanP% ELSEIF teststandP$ = "D1" THEN c% = coil1chanP% ELSEIF teststandP$ = "D2" THEN c% = coil2chanP% 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! > 800! THEN PRINT "The current must be in the range 0 < I < 800 A" GOTO current: END IF 'Message PRINT PRINT "Ramping to "; inom!; " Amps..." 'Ramp to the desired current CALL imagramp(imagramprateP!, imagpervdacP!, inom!) 'Loop over the three measuring coils FOR m% = 0 TO 2 'Have the correct coil placed in the magnet PRINT PRINT "Please place measurement coil "; m%; " in the magnet." INPUT "Press ENTER when ready.", a$ 'Message PRINT PRINT "Measuring the integrated voltage using coil "; m%; "..." 'Measure the current before the coil measurement CALL imagmeas(imagchanP%, vtransperimagP!, ibef!) 'Measure the voltage integral CALL vcoilcntvt(c%, n%, t!, nave%, vtp!(), vtn!(), vt!, sigvt!) 'Measure the current after the coil measurement CALL imagmeas(imagchanP%, vtransperimagP!, iaft!) 'Write the voltage integrals to the log file CALL logvt(logfileP$, m%, ibef!, iaft!, nave%, vtp!(), vtn!()) 'Message PRINT "The integrated voltage is "; vt!; " +- "; sigvt!; " Vs" 'Store the results IF m% = 0 THEN i0! = (ibef! + iaft!) / 2 vt0! = vt! sigvt0! = sigvt! ELSEIF m% = 1 THEN i1! = (ibef! + iaft!) / 2 vt1! = vt! sigvt1! = sigvt! ELSEIF m% = 2 THEN i2! = (ibef! + iaft!) / 2 vt2! = vt! sigvt2! = sigvt! END IF 'End loop over coils NEXT m% 'Write the results to the log file CALL logsumm(logfileP$, i0!, vt0!, sigvt0!, i1!, vt1!, sigvt1!, i2!, vt2!, sigvt2!) END SUB