DECLARE SUB dwlogbl (logfile$, bl!, sbl!) DECLARE SUB dwcalcbl (dx!, vt!, svt!, bl!, sbl!) DECLARE SUB dwcheckpar (ok$) DECLARE SUB dwdatblvsi (logfile$, imag!, simag!, bl!, sbl!) DECLARE SUB dwdatblvsx (logfile$, x0!, dx!, nturns%, imag!, simag!, vt!, svt!, bl!, sbl!) DECLARE SUB dwpltblvsi (logfile$, imag!, simag!, bl!, sbl!) DECLARE SUB dwpltblvsx (logfile$, magname$, run$, x!, bl!, sbl!) DECLARE SUB vtwgetvtav (x0!, dx!, vt!, svt!) DECLARE SUB vtwmoveabs (x!) DECLARE SUB imaggetiav (imag!, simag!) DECLARE SUB imagramp (inom!) '**************************************************************************** 'Module DWIRE.BAS ' 'These subroutines perform calculations related to dipole magnet 'stretched wire measurements. ' 'Zachary Wolf '3/8/95 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /dwire/ logfileP$, datfileP$, pltfileP$, magnameP$, runP$, dxcmP!, nx0P%, x0P!(), nturnsP%, nimagtestP%, imagtestP!() SUB dwblvsi '**************************************************************************** 'This subroutine loops over the test currents and performs a wire scan 'at each current. ' 'Zachary Wolf '5/16/95 '**************************************************************************** 'Make sure all parameters have been initialized CALL dwcheckpar(ok$) IF ok$ <> "y" THEN PRINT "DW: the parameters in dwblvsi have a problem" EXIT SUB END IF 'Loop over currents FOR i% = 1 TO nimagtestP% 'Ramp to the desired current CALL imagramp(imagtestP!(i%)) 'Measure the current CALL imaggetiav(imag!, simag!) 'Message PRINT PRINT "Beginning the stretched wire measurement cycle..." 'Measure the voltage integral in the center of the magnet aperture x0! = 0! CALL vtwgetvtav(x0!, dxcmP!, vt!, svt!) 'Calculate the integrated field strength CALL dwcalcbl(dxcmP!, vt!, svt!, bl!, sbl!) 'Message PRINT "The integrated field strength is BL = "; bl!; " +- "; sbl!; " Tm" 'Log the result CALL dwlogbl(logfileP$, bl!, sbl!) 'Move the wire back to the home position CALL vtwmoveabs(0!) 'Record the result in the data file CALL dwdatblvsi(datfileP$, imag!, simag!, bl!, sbl!) 'Plot the results CALL dwpltblvsi(pltfileP$, imag!, simag!, bl!, sbl!) 'End current loop NEXT i% END SUB SUB dwblvsx '**************************************************************************** 'This subroutine supervises the wire measurements and integrate field strength 'calculation. ' 'Zachary Wolf '3/8/95 '**************************************************************************** 'Make sure all parameters have been initialized CALL dwcheckpar(ok$) IF ok$ <> "y" THEN PRINT "DW: the parameters in dwblvsx have a problem" EXIT SUB END IF 'Get the test current from the operator PRINT INPUT "What current do you wish to perform the measurement at? (Amps) ", inom! 'Ramp to the desired current CALL imagramp(inom!) 'Message PRINT PRINT "Beginning the stretched wire measurement cycle..." 'Loop over x positions FOR i% = 1 TO nx0P% 'Measure the magnet current CALL imaggetiav(imag!, simag!) 'Message PRINT PRINT "Measuring at X0 = "; x0P!(i%); " cm..." 'Get the voltage integral at this position CALL vtwgetvtav(x0P!(i%), dxcmP!, vt!, svt!) 'Compute the integrated field strength CALL dwcalcbl(dxcmP!, vt!, svt!, bl!, sbl!) 'Message PRINT "The integrated field strength is BL = "; bl!; " +- "; sbl!; " Tm" 'Log the result CALL dwlogbl(logfileP$, bl!, sbl!) 'Write the result to the dat file CALL dwdatblvsx(datfileP$, x0P!(i%), dxcmP!, nturnsP%, imag!, simag!, vt!, svt!, bl!, sbl!) 'Write the result to the plt file CALL dwpltblvsx(pltfileP$, magnameP$, runP$, x0P!(i%), bl!, sbl!) 'End loop over x positions NEXT i% 'Message PRINT PRINT "Moving back to the home position..." 'Move the wire back to the home position CALL vtwmoveabs(0!) END SUB SUB dwcalcbl (dx!, vt!, svt!, bl!, sbl!) '**************************************************************************** 'This subroutine calculates the integrated field strength from the measurements 'of the integrated voltage. ' 'Input: ' dx!, the distance the wire moves for each motion (in cm) ' vt!, the integrated voltage ' svt!, the standard deviation of vt ' 'Output: ' bl!, the integrated field strength ' sbl!, the standard deviation of bl ' 'Zachary Wolf '3/8/95 '**************************************************************************** 'Compute the integrated field strength and error bl! = vt! / (dx! / 100!) / nturnsP% 'use dx in meters sbl! = svt! / (dx! / 100!) / nturnsP% END SUB SUB dwcheckpar (ok$) '**************************************************************************** 'This subroutine checks that all required parameters have been assigned 'values. ' 'Output: ' ok$, "y" if parameter assignments are ok, "n" otherwise ' 'Zachary Wolf '9/18/95 '**************************************************************************** 'Default value ok$ = "n" 'logfileP$ IF logfileP$ = "" THEN PRINT "DWIRE: log file not defined" EXIT SUB END IF 'datfileP$ IF logfileP$ = "" THEN PRINT "DWIRE: dat file not defined" EXIT SUB END IF 'pltfileP$ IF logfileP$ = "" THEN PRINT "DWIRE: plt file not defined" EXIT SUB END IF 'magnameP$ IF magnameP$ = "" THEN PRINT "DWIRE: magnet name not defined" EXIT SUB END IF 'runP$ IF logfileP$ = "" THEN PRINT "DWIRE: run number not defined" EXIT SUB END IF 'dxcmP! IF dxcmP! <= 0! OR dxcmP! > 10! THEN PRINT "DWIRE: dxcm has improper value" EXIT SUB END IF 'nx0P% IF nx0P% <= 0 OR nx0P% > 50 THEN PRINT "DWIRE: nx0 has improper value" EXIT SUB END IF 'nturnsP% IF nturnsP% <= 0 OR nturnsP% > 200 THEN PRINT "DWIRE: nturns has improper value" EXIT SUB END IF 'nimagtestP% IF nimagtestP% <= 0 OR nimagtestP% > 50 THEN PRINT "DWIRE: nimagtest has improper value" EXIT SUB END IF 'If we made it this far, all parameters have values ok$ = "y" END SUB SUB dwdatblvsi (logfile$, imag!, simag!, bl!, sbl!) '**************************************************************************** 'This subroutine writes the calculated integrated field strength of the magnet. ' 'Input: ' logfile$, the name of the log file ' bl!, the integrated field strength of the magnet ' sbl!, the standard deviation of BL ' 'Zachary Wolf '1/14/95 '**************************************************************************** 'Keep track of Ncall for the header STATIC ncall% ncall% = ncall% + 1 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write the header IF ncall% = 1 THEN PRINT #filenum%, PRINT #filenum%, PRINT #filenum%, PRINT #filenum%, " INTEGRATED FIELD STRENGTH VS CURRENT" PRINT #filenum%, PRINT #filenum%, " Imag sImag BL sBL " PRINT #filenum%, " (A) (A) (Tm) (Tm) " PRINT #filenum%, "----------+---------- -----------+-----------" END IF 'Calculated Results PRINT #filenum%, USING "######.###"; imag!; PRINT #filenum%, USING " ######.###"; simag!; PRINT #filenum%, USING " ###.#######"; bl!; PRINT #filenum%, USING " ###.#######"; sbl! 'Close the log file CLOSE filenum% END SUB SUB dwdatblvsx (logfile$, x0!, dx!, nturns%, imag!, simag!, vt!, svt!, bl!, sbl!) '**************************************************************************** 'This subroutine writes a summary of the VT and BL vs X measurements. ' 'Input: ' logfile$, the name of the log file ' x0!, the x-position of the center of the wire motion ' dx!, the distance the wire is moved ' nturns%, number of turns of wire ' imag!, the magnet current ' simag!, the standard deviation of imag ' vt!, the voltage integral for the wire motion ' svt!, the standard deviation of VT ' bl!, the integrated field strength ' sbl!, the standard deviation of BL ' 'Zachary Wolf '3/8/95 '**************************************************************************** 'Keep track of Ncall for the header STATIC ncall% ncall% = ncall% + 1 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'On the first call, write a header IF ncall% = 1 THEN PRINT #filenum%, PRINT #filenum%, PRINT #filenum%, " STRETCHED WIRE" PRINT #filenum%, " INTEGRATED VOLTAGE AND FIELD STRENGTH VS X" PRINT #filenum%, PRINT #filenum%, "Distance wire moved, Delta X = "; dx!; " cm" PRINT #filenum%, "# turns of wire, Nturns = "; nturns% PRINT #filenum%, PRINT #filenum%, " X0 IMAG sigIMAG VT sigVT BL sigBL " PRINT #filenum%, " (cm) (A) (A) (VS) (VS) (Tm) (Tm) " PRINT #filenum%, " -------- ---------+--------- ----------+---------- ----------+----------" END IF 'Write the results of the measurements PRINT #filenum%, USING " ##.#####"; x0!; PRINT #filenum%, USING " ####.####"; imag!; PRINT #filenum%, USING " ####.####"; simag!; PRINT #filenum%, USING " ##.#######"; vt!; PRINT #filenum%, USING " ##.#######"; svt!; PRINT #filenum%, USING " ##.#######"; bl!; PRINT #filenum%, USING " ##.#######"; sbl! 'Close the log file CLOSE filenum% END SUB SUB dwlogbl (logfile$, bl!, sbl!) '**************************************************************************** 'This subroutine writes a BL measurement result to the log file. ' 'Input: ' logfile$, the name of the log file ' bl!, the integrated field strength of the magnet ' sbl!, the standard deviation of BL ' 'Zachary Wolf '12/18/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write the result PRINT #filenum%, TIME$; " The integrated field strength is BL = "; bl!; " +- "; sbl!; " Tm" 'Close the log file CLOSE filenum% END SUB SUB dwpltblvsi (logfile$, imag!, simag!, bl!, sbl!) '**************************************************************************** 'This subroutine writes the calculated integrated field strength of the magnet. ' 'Input: ' logfile$, the name of the log file ' bl!, the integrated gradi of the magnet ' sbl!, the standard deviation of BL ' 'Zachary Wolf '1/14/95 '**************************************************************************** 'Keep track of Ncall for the header STATIC ncall% ncall% = ncall% + 1 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write the header IF ncall% = 1 THEN PRINT #filenum%, ";I sI BL sBL" END IF 'Calculated Results PRINT #filenum%, USING "#####.###"; imag!; PRINT #filenum%, USING " #####.###"; simag!; PRINT #filenum%, USING " ##.######"; bl!; PRINT #filenum%, USING " ##.######"; sbl! 'Close the log file CLOSE filenum% END SUB SUB dwpltblvsx (logfile$, magname$, run$, x!, bl!, sbl!) '**************************************************************************** 'This subroutine write a summary of the VT vs X measurements for plotting. ' 'Input: ' logfile$, the name of the log file ' magname$, the magnet name ' run$, the run number ' x!, the x position ' bl!, the integrated field strength ' sbl!, the standard deviation of bl ' 'Zachary Wolf '12/27/94 '**************************************************************************** 'Keep track of Ncall for the header STATIC ncall% ncall% = ncall% + 1 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'On the first call, write the title for plotting IF ncall% = 1 THEN PRINT #filenum%, "/et g '" + magname$ + ", Run " + run$ + "'" PRINT #filenum%, ";x bl sbl" END IF 'Write the values PRINT #filenum%, USING "##.####"; x!; PRINT #filenum%, USING " ###.#######"; bl!; PRINT #filenum%, USING " ###.#######"; sbl! 'Close the log file CLOSE filenum% END SUB SUB dwsetpar (logfile$, datfile$, pltfile$, magname$, run$, dxcm!, nx0%, x0!(), nturns%, nimagtest%, imagtest!()) '**************************************************************************** 'This subroutine sets parameters used in this module. ' 'Input: ' logfile$, name of the log file ' datfile$, name of the data file ' pltfile$, name of the plot file ' magname$, magnet name ' run$, run number ' dxcm!, distance to move the wire in a scan ' nx0%, number of x-positions at which to do wire scans ' x0!(1 to nx0%), array of x-postions ' nturnsP%, number of turns in the wire bundle ' nimagtest%, number of test currents ' imagtest!(1 to nimagtest%), test currents ' 'Zachary Wolf '9/21/95 '**************************************************************************** 'Save the parameters in the local common block for future use logfileP$ = logfile$ datfileP$ = datfile$ pltfileP$ = pltfile$ magnameP$ = magname$ runP$ = run$ dxcmP! = dxcm! nx0P% = nx0% DIM x0P!(1 TO nx0P%) FOR i% = 1 TO nx0P% x0P!(i%) = x0!(i%) NEXT i% nturnsP% = nturns% nimagtestP% = nimagtest% DIM imagtestP!(1 TO nimagtestP%) FOR i% = 1 TO nimagtestP% imagtestP!(i%) = imagtest!(i%) NEXT i% END SUB