DECLARE SUB mtoolgetbcoil (btrans!, th!) DECLARE SUB mtoolmovez (z!) DECLARE SUB imaggeti (imag!) DECLARE SUB zcoilcheckpar (ok$) DECLARE SUB zcoildatbvsz (logfile$, i%, z!, imag!, btrans!, th!, bx!, by!) DECLARE SUB zcoilpltbvsz (logfile$, i%, z!, btrans!, th!, bx!, by!) '**************************************************************************** 'Module ZMAPCOIL 'This module performs rotating coil measurements of Btransverse along 'a magnet. ' 'Zachary Wolf '12/27/95 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /zmapcoil/ datfileP$, pltfileP$, nzposP%, zposP!() SUB zcoilbvsz '**************************************************************************** 'This subroutine controls the rotating coil measurements of Btransverse 'along a magnet. ' 'Zachary Wolf '12/27/95 '**************************************************************************** 'Make sure required parameters have been defined CALL zcoilcheckpar(ok$) IF ok$ <> "y" THEN PRINT "ZMAPCOIL: parameter problem" EXIT SUB END IF 'Prepare the screen CLS PRINT PRINT " Transverse Field Map" PRINT PRINT " Z Imag Btrans Angle " PRINT " # (m) (A) (G) (deg) " 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%)) 'Message PRINT "Measuring..." 'Measure the current CALL imaggeti(imag!) 'Measure the field strength CALL mtoolgetbcoil(btrans!, th!) 'Erase message CLS '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 " #####.###"; btrans! * 10000!; PRINT USING " #####.###"; th! 'Compute Bx and By bx! = btrans! * COS(3.141593 * th! / 180!) by! = btrans! * SIN(3.141593 * th! / 180!) 'Write the measured values to the dat file CALL zcoildatbvsz(datfileP$, i%, zposP!(i%), imag!, btrans!, th!, bx!, by!) 'Write the measurements to the plot file CALL zcoilpltbvsz(pltfileP$, i%, zposP!(i%), btrans!, th!, bx!, by!) 'End loop over z positions NEXT i% 'Message VIEW PRINT 21 TO 24 CLS PRINT PRINT "Done." 'Reset the screen viewing area VIEW PRINT LOCATE 24 END SUB SUB zcoilcheckpar (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" 'datfileP$, pltfileP$ IF datfileP$ = "" OR pltfileP$ = "" THEN PRINT "ZMAPH: required file not defined" EXIT SUB END IF 'If we made it this far, all parameters have values ok$ = "y" END SUB SUB zcoildatbvsz (logfile$, i%, z!, imag!, btrans!, th!, bx!, by!) '**************************************************************************** 'This subroutine writes a summary to the data file. ' 'Inputs: ' logfile$, the name of the log file ' i%, index of the z position ' z!, the z position (cm) ' imag!, the measured magnet current (A) ' btrans!, the magnitude of the transverse field (T) ' th!, the field angle wrt the index pulse (deg) ' bx!, the x component of the field (T) ' by!, the y component of the field (T) ' 'Zachary Wolf '12/27/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%, " Transverse Field Measurements" 'Write the header PRINT #filenum%, " Zpos I Btrans Angle Bx By " PRINT #filenum%, " # (m) (A) (G) (deg) (G) (G) " PRINT #filenum%, " ----- -------- -------- -------- -------- -------- --------" END IF 'Write the values PRINT #filenum%, USING " #####"; i%; PRINT #filenum%, USING " ###.####"; z! / 100!; PRINT #filenum%, USING " #####.##"; imag!; PRINT #filenum%, USING " #####.##"; btrans! * 10000!; PRINT #filenum%, USING " #####.##"; th!; PRINT #filenum%, USING " #####.##"; bx! * 10000!; PRINT #filenum%, USING " #####.##"; by! * 10000! 'Close the log file CLOSE filenum% END SUB SUB zcoilpltbvsz (logfile$, i%, z!, btrans!, th!, bx!, by!) '**************************************************************************** '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 (m) ' btrans!, the magnitude of the transverse field (T) ' th!, the field angle (deg) ' bx!, the x component of the field (T) ' by!, the y component of the field (T) ' 'Zachary Wolf '12/27/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 an empty line for a new series of measurements IF ncall% > 1 AND i% = 1 THEN PRINT #filenum%, END IF 'Write a header on the first call IF ncall% = 1 THEN PRINT #filenum%, ";z(m), Btrans(G), Angle(deg), Bx(G), By(G)" END IF 'Write the values PRINT #filenum%, USING "#####.####"; z!; PRINT #filenum%, USING " #####.###"; btrans! * 10000!; PRINT #filenum%, USING " #####.###"; th!; PRINT #filenum%, USING " #####.###"; bx! * 10000!; PRINT #filenum%, USING " #####.###"; by! * 10000! 'Close the log file CLOSE filenum% END SUB SUB zcoilsetpar (datfile$, pltfile$, nzpos%, zpos!()) '**************************************************************************** 'This subroutine sets the parameters for the XY mapping module. ' 'Input: ' 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 datfileP$ = datfile$ pltfileP$ = pltfile$ nzposP% = nzpos% DIM zposP!(1 TO nzposP%) FOR i% = 1 TO nzposP% zposP!(i%) = zpos!(i%) NEXT i% END SUB