DECLARE SUB mtoolsethallrng () DECLARE SUB mtoolsetnmrrng () DECLARE SUB znmrhcheckpar (ok$) DECLARE SUB znmrhdatbl (logfile$, bl!) DECLARE SUB znmrhdatbvsz (logfile$, i%, z!, imag!, bhall!, bnmr!, bmap!) DECLARE SUB znmrhlogbl (logfile$, bl!) DECLARE SUB znmrhpltbvsz (logfile$, i%, z!, bhall!, bnmr!, bmap!) DECLARE SUB mtoolgetbnmrh (bhall!, bnmr!) DECLARE SUB mtoolmovez (z!) DECLARE SUB mtooltrapint (ns%, x!(), y!(), iydx!) DECLARE SUB ls450setrange (r%) DECLARE SUB gp3setrange (r%) DECLARE SUB pt2025search () DECLARE SUB imaggeti (imag!) '**************************************************************************** 'Module ZMAPNMRH 'This module performs NMR and Hall probe measurements along a magnet. ' 'Zachary Wolf '12/7/95 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /zmapnmrh/ logfileP$, datfileP$, pltfileP$, nzposP%, zposP!() SUB znmrhbvsz '**************************************************************************** 'This subroutine controls NMR and Hall probe measurements of B along a 'magnet. The integrated field strength is calculated. ' 'Zachary Wolf '12/7/95 '**************************************************************************** 'Make sure required parameters have been defined CALL znmrhcheckpar(ok$) IF ok$ <> "y" THEN PRINT "ZMAPNMRH: parameter problem" EXIT SUB END IF 'Set the Hall probe range CALL mtoolsethallrng 'NMR coarse adjust CALL mtoolsetnmrrng 'Save the field measurements to calculate BL DIM bmap!(1 TO nzposP%) 'Prepare the screen CLS PRINT PRINT " Z Field Map" PRINT PRINT " Z Imag Bhall Bnmr Bmap " PRINT " # (m) (A) (T) (T) (T) " PRINT "----- --------- --------- --------- --------- ---------" currpos% = 6 'Loop over z positions FOR i% = 1 TO nzposP% 'Allow run to end if there is a problem IF INKEY$ = CHR$(27) THEN EXIT SUB 'Move to the the z position CALL mtoolmovez(zposP!(i%)) 'Measure the current CALL imaggeti(imag!) 'Measure the field strength CALL mtoolgetbnmrh(bhall!, bnmr!) 'Use the NMR value, if available, for the field map IF bnmr! > 0 THEN bmap!(i%) = bnmr! ELSE bmap!(i%) = bhall! END IF 'Write the results to the screen VIEW PRINT 7 TO 20 currpos% = currpos% + 1 IF currpos% > 20 THEN currpos% = 20 LOCATE currpos% PRINT USING "#####"; i%; PRINT USING " ####.####"; zposP!(i%) / 100!; PRINT USING " #####.###"; imag!; PRINT USING " ##.######"; bhall!; PRINT USING " ##.######"; bnmr!; PRINT USING " ##.######"; bmap!(i%) 'Write the measured values to the dat file CALL znmrhdatbvsz(datfileP$, i%, zposP!(i%), imag!, bhall!, bnmr!, bmap!(i%)) 'Write the measurements to the plot file CALL znmrhpltbvsz(pltfileP$, i%, zposP!(i%), bhall!, bnmr!, bmap!(i%)) 'End loop over z positions NEXT i% 'Integrate the Bmap field strengths CALL mtooltrapint(nzposP%, zposP!(), bmap!(), bl!) 'Convert BL from Tcm to Tm bl! = bl! / 100! 'Write the field integral to the data and log files CALL znmrhdatbl(datfileP$, bl!) CALL znmrhlogbl(logfileP$, bl!) 'Message VIEW PRINT 21 TO 24 CLS PRINT PRINT "Done." 'Reset the screen viewing area VIEW PRINT LOCATE 24 END SUB SUB znmrhcheckpar (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$, datfileP$, pltfileP$ IF logfileP$ = "" OR datfileP$ = "" OR pltfileP$ = "" THEN PRINT "ZMAPNMRH: required file not defined" EXIT SUB END IF 'If we made it this far, all parameters have values ok$ = "y" END SUB SUB znmrhdatbl (logfile$, bl!) '**************************************************************************** 'This subroutine writes a summary to the log file. ' 'Inputs: ' logfile$, the name of the log file ' bl!, the measured integrated field strength ' 'Zachary Wolf '6/22/94 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Write a header PRINT #filenum%, PRINT #filenum%, "Integrated Field Strength:" 'Write the values PRINT #filenum%, "The integrated field strength BL = "; bl!; " Tm" 'Close the log file CLOSE filenum% END SUB SUB znmrhdatbvsz (logfile$, i%, z!, imag!, bhall!, bnmr!, bmap!) '**************************************************************************** 'This subroutine writes a summary to the data file. ' 'Inputs: ' logfile$, the name of the log file ' i%, index for the z position ' z!, the z position ' imag!, the measured magnet current ' bhall!, the measured magnetic field strength from the Hall probe ' bnmr!, the measured magnetic field strength from the NMR probe ' bmap!, the magnetic field at each point used for the map ' 'Zachary Wolf '12/23/95 '**************************************************************************** 'Keep track of the number of times called STATIC ncall% ncall% = ncall% + 1 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Start a new page for a new series of measurements IF ncall% > 1 AND i% = 1 THEN PRINT #filenum%, CHR$(12) END IF 'Write a header on the first measurement IF i% = 1 THEN PRINT #filenum%, PRINT #filenum%, " NMR and Hall Probe Measurements" 'Write the header PRINT #filenum%, " Zpos I Bhall Bnmr Bmap " PRINT #filenum%, " # (m) (A) (T) (T) (T) " PRINT #filenum%, " ----- --------- --------- --------- --------- ---------" END IF 'Write the values PRINT #filenum%, USING " #####"; i%; PRINT #filenum%, USING " ###.#####"; z! / 100!; PRINT #filenum%, USING " #####.###"; imag!; PRINT #filenum%, USING " ##.######"; bhall!; PRINT #filenum%, USING " ##.######"; bnmr!; PRINT #filenum%, USING " ##.######"; bmap! 'Close the log file CLOSE filenum% END SUB SUB znmrhlogbl (logfile$, bl!) '**************************************************************************** 'This subroutine logs the calculated integrated field strength. ' 'Input: ' logfile$, the name of the log file ' bl!, the integrated field strength (Tm) ' 'Zachary Wolf '12/23/95 '**************************************************************************** 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Print the results PRINT #filenum%, TIME$; " Integrated Field Strength BL = "; bl!; " Tm" 'Close the log file CLOSE filenum% END SUB SUB znmrhpltbvsz (logfile$, i%, z!, bhall!, bnmr!, bmap!) '**************************************************************************** 'This subroutine writes a field measurement to the plot file. ' 'Inputs: ' logfile$, name of data file ' i%, index for the z position ' z!, z position the measurement was taken at (cm) ' bhall!, hall probe measurement (T) ' bnmr!, nmr probe measurement (T) ' bmap!, field value used to do the map (T) ' 'Zachary Wolf '12/11/95 '**************************************************************************** 'Keep track of the number of times called STATIC ncall% ncall% = ncall% + 1 'Open the log file filenum% = FREEFILE OPEN logfile$ FOR APPEND AS filenum% 'Insert a new line before a new series of measurements IF ncall% > 1 AND i% = 1 THEN PRINT #filenum%, END IF 'Write a header on the first measurement IF i% = 1 THEN PRINT #filenum%, ";z(m), Bhall(T), Bnmr(T), Bmap(T)" END IF 'Write the values PRINT #filenum%, USING "#####.####"; z! / 100!; PRINT #filenum%, USING " ###.######"; bhall!; PRINT #filenum%, USING " ###.######"; bnmr!; PRINT #filenum%, USING " ###.######"; bmap! 'Close the log file CLOSE filenum% END SUB SUB znmrhsetpar (logfile$, datfile$, pltfile$, nzpos%, zpos!()) '**************************************************************************** 'This subroutine sets the parameters for the XY mapping module. ' 'Input: ' logfile$, name of the log file ' datfile$, name of the data file ' pltfile$, name of the plot file ' nzpos%, number of z positions to make measurements at ' zpos!(1 to nzpos%), the z positions to make measurements at ' 'Zachary Wolf '12/11/95 '**************************************************************************** 'Save the parameters in a common block for future use logfileP$ = logfile$ datfileP$ = datfile$ pltfileP$ = pltfile$ nzposP% = nzpos% DIM zposP!(1 TO nzposP%) FOR i% = 1 TO nzposP% zposP!(i%) = zpos!(i%) NEXT i% END SUB