DECLARE SUB gp3zero (id%) DECLARE SUB gp3getbav (id%, b!, sb!) DECLARE SUB gpibclr () DECLARE SUB gpibclrdev (addr$) DECLARE SUB gpibin (addr$, msg$) DECLARE SUB gpibout (addr$, cmd$) DECLARE SUB gpibterm (termin$, termout$) DECLARE SUB gp3getb (id%, b!) DECLARE SUB gp3setrange (id%, r%) '**************************************************************************** 'Module GP3 'This module contains subroutines to read the Group3 teslameter. ' 'Zachary Wolf '6/12/94, 12/11/95 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /gp3/ gpibinP%, gpiboutP%, gp3addrP$, gp31addrP$, gp32addrP$, gp33addrP$ 'Semi-permanent parameters CONST gp3terminP$ = "LF EOI" CONST gp3termoutP$ = "LF EOI" SUB gp3getb (id%, b!) '**************************************************************************** 'This subroutine has the Group3 teslameter measure the magnetic field. ' 'Input: ' id%, probe ID number ' 'Output: ' b!, the measured magnetic field strength in Tesla ' 'Zachary Wolf '6/12/94, 12/11/95 '**************************************************************************** 'Check the probe ID IF id% = 1 THEN gp3addrP$ = gp31addrP$ ELSEIF id% = 2 THEN gp3addrP$ = gp32addrP$ ELSEIF id% = 3 THEN gp3addrP$ = gp33addrP$ ELSE PRINT PRINT "!!! Problem in GP3GETB" b! = 0! EXIT SUB END IF 'Set the GPIB terminators CALL gpibterm(gp3terminP$, gp3termoutP$) 'Get the reading CALL gpibout(gp3addrP$, "F") CALL gpibin(gp3addrP$, b$) 'PRINT "b$ = "; b$ IF b$ = "OVER RANGE" THEN PRINT "GP3: over range" b! = 0! ELSE b! = VAL(b$) END IF END SUB SUB gp3getbav (id%, b!, sb!) '**************************************************************************** 'This subroutine finds the average field reading from repeated measurements. ' 'Input: ' id%, Hall probe ID number ' 'Output: ' b!, average field value (T) ' sb!, standard deviation b! (T) ' 'Zachary Wolf '1/22/98 '**************************************************************************** 'Check the probe ID IF id% = 1 THEN gp3addrP$ = gp31addrP$ ELSEIF id% = 2 THEN gp3addrP$ = gp32addrP$ ELSEIF id% = 3 THEN gp3addrP$ = gp33addrP$ ELSE PRINT PRINT "!!! Problem in GP3GETBAV" b! = 0! sb! = 0! EXIT SUB END IF 'Simplify the notation nm% = 4 'Initialize data arrays DIM bmeas!(1 TO nm%) 'Loop over measurements for averaging FOR j% = 1 TO nm% 'Get the field reading CALL gp3getb(id%, bmeas!(j%)) 'End averaging loop NEXT j% 'Compute the average of the measurements b! = 0! FOR j% = 1 TO nm% b! = b! + bmeas!(j%) NEXT j% b! = b! / nm% 'Compute the standard deviation of the measurements sb! = 0! FOR j% = 1 TO nm% sb! = sb! + (bmeas!(j%) - b!) ^ 2 NEXT j% sb! = SQR(sb! / nm%) END SUB SUB gp3init (id%) '**************************************************************************** 'This subroutine initializes the Group3 teslameter. ' 'Input: ' id%, probe ID number ' 'Zachary Wolf '6/12/94, 12/11/95 '**************************************************************************** 'Check the probe ID IF id% = 1 THEN gp3addrP$ = gp31addrP$ ELSEIF id% = 2 THEN gp3addrP$ = gp32addrP$ ELSEIF id% = 3 THEN gp3addrP$ = gp33addrP$ ELSE PRINT PRINT "!!! Problem in GP3INIT" EXIT SUB END IF 'Set the GPIB terminators CALL gpibterm(gp3terminP$, gp3termoutP$) 'Message PRINT PRINT "Resetting Group3 teslameter "; LTRIM$(STR$(id%)); "..." 'Clear the gp3 CALL gpibclrdev(gp3addrP$) 'Reset the gp3 CALL gpibout(gp3addrP$, CHR$(24)) SLEEP 3 'Allow time to finish CALL gpibin(gp3addrP$, rst$) PRINT rst$ 'Clear any GPIB extender boxes after the reset CALL gpibclr 'Put DTM in DC measurement mode CALL gpibout(gp3addrP$, "GD") 'Measure continuously CALL gpibout(gp3addrP$, "GC") 'Turn off digital filtering CALL gpibout(gp3addrP$, "D0") 'Use the normal display mode CALL gpibout(gp3addrP$, "NN") 'Send field readings only when requested CALL gpibout(gp3addrP$, "SM0") 'Do not send units CALL gpibout(gp3addrP$, "SU0") 'Set the units to Tesla CALL gpibout(gp3addrP$, "UFT") 'Display status information CALL gpibout(gp3addrP$, "IG") CALL gpibin(gp3addrP$, ig$) CALL gpibout(gp3addrP$, "IN") CALL gpibin(gp3addrP$, in$) CALL gpibout(gp3addrP$, "IR") CALL gpibin(gp3addrP$, ir$) PRINT "Status: "; ig$ + ", " + in$ + ", " + ir$ END SUB SUB gp3setpar (gpibinf%, gpiboutf%, gp31addr$, gp32addr$, gp33addr$) '**************************************************************************** 'This subroutine initializes the Group 3 Gaussmeter. ' 'Input: ' gpibinf%, gpib input file number ' gpiboutf%, gpib output file number ' gp31addr$, gpib address in a string for probe 1 ' gp32addr$, gpib address in a string for probe 2 ' gp33addr$, gpib address in a string for probe 3 ' 'Zachary Wolf '12/11/95, 2/8/98 '**************************************************************************** 'Make sure the input parameters have reasonable values IF gpibinf% < 0 OR gpibinf% > 100 THEN PRINT "GP3: GPIB problem" EXIT SUB END IF IF gpiboutf% < 0 OR gpiboutf% > 100 THEN PRINT "GP3: GPIB problem" EXIT SUB END IF IF gp31addr$ = "" THEN PRINT "GP3: GPIB problem" EXIT SUB END IF IF gp32addr$ = "" THEN PRINT "GP3: GPIB problem" EXIT SUB END IF IF gp33addr$ = "" THEN PRINT "GP3: GPIB problem" EXIT SUB END IF 'Save the GPIB information in a common block for future use gpibinP% = gpibinf% gpiboutP% = gpiboutf% gp31addrP$ = gp31addr$ gp32addrP$ = gp32addr$ gp33addrP$ = gp33addr$ END SUB SUB gp3setrange (id%, r%) '**************************************************************************** 'This subroutine sets the range of the Group3 teslameter. ' 'Input: ' id%, probe ID number ' r%, the range number, Ranges: 0 = 0.3 T, 1 = 0.6 T, 2 = 1.2 T, 3 = 3.0 T ' 'Zachary Wolf '6/14/94 '**************************************************************************** 'Check the probe ID IF id% = 1 THEN gp3addrP$ = gp31addrP$ ELSEIF id% = 2 THEN gp3addrP$ = gp32addrP$ ELSEIF id% = 3 THEN gp3addrP$ = gp33addrP$ ELSE PRINT PRINT "!!! Problem in GP3SETRANGE" EXIT SUB END IF 'Set the GPIB terminators CALL gpibterm(gp3terminP$, gp3termoutP$) 'Set the measurement range setrange: IF r% >= 0 AND r% <= 3 THEN CALL gpibout(gp3addrP$, "R" + LTRIM$(STR$(r%))) ELSE PRINT PRINT "GP3: Inproper Hall probe range requested." PRINT "What range do you want for the Group 3 Hall probe? (0, 1, 2, 3) " INPUT "Ranges: 0 = 0.3 T, 1 = 0.6 T, 2 = 1.2 T, 3 = 3.0 T >> ", r% GOTO setrange END IF 'Allow time for the meter to change ranges SLEEP 2 END SUB SUB gp3user '**************************************************************************** 'This routine gives Hall probe information from the probe requested by 'the user. ' 'Zachary Wolf '2/8/98 '**************************************************************************** 'Get the Hall probe ID number from the user gp3hallprobe: PRINT INPUT "Enter the Group 3 Hall probe ID number to report on (0 to end): ", id$ IF id$ = "end" OR id$ = "END" OR id$ = "quit" OR id$ = "QUIT" OR id$ = "0" THEN EXIT SUB id% = VAL(id$) 'Check IF id% < 1 OR id% > 3 THEN PRINT "The Hall probe ID number must be between 1 and 3." GOTO gp3hallprobe END IF 'See what the user wants to do begingp3: PRINT PRINT "Type" PRINT " M to measure" PRINT " R to set range" PRINT " Z to zero" PRINT " Q to quit" INPUT ">", cmd$ 'Message PRINT PRINT "Group 3 Hall probe ID number:"; id% 'Do as the user requested IF cmd$ = "M" OR cmd$ = "m" THEN CALL gp3getbav(id%, b!, sb!) PRINT "Field reading: "; b!; " +- "; sb!; " T" ELSEIF cmd$ = "R" OR cmd$ = "r" THEN INPUT "Enter a range (0, 1, 2, or 3): ", rval$ rval% = VAL(rval$) CALL gp3setrange(id%, rval%) ELSEIF cmd$ = "Z" OR cmd$ = "z" THEN CALL gp3zero(id%) ELSEIF cmd$ = "Q" OR cmd$ = "q" THEN GOTO endgp3 ELSE PRINT "Unknown command." END IF GOTO begingp3 'Done endgp3: 'Return to beginning of loop GOTO gp3hallprobe END SUB SUB gp3zero (id%) '**************************************************************************** 'This subroutine zeros the Group3 teslameter. ' 'Input: ' id%, probe ID number ' 'Zachary Wolf '6/14/94, 12/11/95 '**************************************************************************** 'Check the probe ID IF id% = 1 THEN gp3addrP$ = gp31addrP$ ELSEIF id% = 2 THEN gp3addrP$ = gp32addrP$ ELSEIF id% = 3 THEN gp3addrP$ = gp33addrP$ ELSE PRINT PRINT "!!! Problem in GP3ZERO" EXIT SUB END IF 'Set the GPIB terminators CALL gpibterm(gp3terminP$, gp3termoutP$) 'Message PRINT PRINT "Group 3 Hall Probe Zero" PRINT "Please place the Hall probe into a 0 Gauss chamber." INPUT "Press ENTER when ready. ", a$ PRINT "Zeroing the Group3 teslameter..." PRINT "This will take about 20 seconds." 'Get the present range CALL gpibout(gp3addrP$, "IR") CALL gpibin(gp3addrP$, range$) range% = VAL(range$) 'Zero the teslameter on all ranges FOR i% = 0 TO 3 CALL gp3setrange(id%, i%) CALL gpibout(gp3addrP$, "Z") SLEEP 3 'Allow time to finish NEXT i% 'Set the meter back to its original range CALL gp3setrange(id%, range%) 'Message PRINT "The Hall probe is zeroed." END SUB