DECLARE SUB b9900comm (cmd$, msg$) DECLARE SUB b9900notbusy () DECLARE SUB gpibtrigger (addr$) DECLARE SUB b9900ready () DECLARE SUB gpibin (addr$, msg$) DECLARE SUB gpibout (addr$, cmd$) DECLARE SUB gpibspoll (addr$, msg$) DECLARE SUB gpibterm (termin$, termout$) DECLARE SUB gpibclr () '**************************************************************************** 'Module B9900 'This module contains subroutines to read the F. W. Bell model 9900 'gaussmeter. ' 'Note! This module assumes one Hall probe in channel 1 of the Gaussmeter. 'It needs to be upgraded for multiple probes or a different channel. ' 'Zachary Wolf '2/7/96 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /b9900/ gpibinP%, gpiboutP%, b9900addrP$ 'Semi-permanent parameters CONST b9900terminP$ = "CR EOI" CONST b9900termoutP$ = "CR EOI" SUB b9900comm (cmd$, msg$) '**************************************************************************** 'This subroutine sends a command to the Bell 9900 Gaussmeter. ' 'Input: ' cmd$, command to send to the Gaussmeter ' 'Output: ' msg$, message returned by the Gaussmeter ' 'Zachary Wolf '2/29/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(b9900terminP$, b9900termoutP$) 'Make sure the Gaussmeter is not busy CALL b9900notbusy 'Send the command to the Gaussmeter CALL gpibout(b9900addrP$, cmd$) 'Send a trigger signal to execute the command CALL gpibtrigger(b9900addrP$) 'Wait until the Gaussmeter has finished processing the command and is ready to send its reply CALL b9900ready 'Read the reply sent by the Gaussmeter CALL gpibin(b9900addrP$, msg$) 'PRINT msg$ 'Clear the GPIB system after serial polls in case extender boxes are being used 'CALL gpibclr END SUB SUB b9900getb (b!) '**************************************************************************** 'This subroutine has the Bell model 9900 teslameter measure the 'magnetic field. ' 'Output: ' b!, the measured magnetic field strength in Tesla ' 'Zachary Wolf '2/22/96 '**************************************************************************** 'Get the reading from the Gaussmeter CALL b9900comm(CHR$(27) + "ME100000000", msg$) 'Check the header header$ = MID$(msg$, 1, 4) IF header$ <> "ME10" THEN PRINT PRINT "B9900: Problem reading the Gaussmeter: header = " + header$ b! = 0! EXIT SUB END IF 'Check the range range$ = MID$(msg$, 5, 1) range% = VAL(range$) IF range% < 1 OR range% > 7 THEN PRINT PRINT "B9900: Problem reading the Gaussmeter: range = " + range$ b! = 0! EXIT SUB END IF 'Get the field multiplier from the range IF range% = 1 THEN multiplier! = 1E-08 IF range% = 2 THEN multiplier! = .0000001 IF range% = 3 THEN multiplier! = .000001 IF range% = 4 THEN multiplier! = .00001 IF range% = 5 THEN multiplier! = .0001 IF range% = 6 THEN multiplier! = .001 IF range% = 7 THEN multiplier! = .01 'Check the sign sign$ = MID$(msg$, 6, 1) IF sign$ <> "+" AND sign$ <> "-" AND sign$ <> " " THEN PRINT PRINT "B9900: Problem reading the Gaussmeter: sign = " + sign$ b! = 0! EXIT SUB END IF 'Extract the reading from the message string bstr$ = MID$(msg$, 6, 6) bstr! = VAL(bstr$) IF ABS(bstr!) > 29999! THEN PRINT PRINT "B9900: The Gaussmeter is overloaded. The field reading is set to 0." b! = 0! EXIT SUB END IF b! = bstr! * multiplier! END SUB SUB b9900init '**************************************************************************** 'This subroutine initializes the F. W. Bell 9900 series Gaussmeter. ' 'Zachary Wolf '12/11/95 '**************************************************************************** 'Message PRINT PRINT "Resetting the F. W. Bell 9900 series Gaussmeter..." PRINT "This will take about 1 minute." 'Set the communications format CALL b9900comm(CHR$(27) + "CO1" + b9900addrP$ + "00", msg$) PRINT msg$ 'All operations below refer to channel 1 'Put the Gaussmeter in DC measurement mode, units Tesla CALL b9900comm(CHR$(27) + "MO14", msg$) PRINT msg$ 'Reset max-hold 'CALL b9900comm(CHR$(27) + "PE13", msg$) 'PRINT msg$ 'Turn on max-hold 'CALL b9900comm(CHR$(27) + "PE12", msg$) 'PRINT msg$ 'Turn off max-hold CALL b9900comm(CHR$(27) + "PE11", msg$) PRINT msg$ 'Set front display format, everything on CALL b9900comm(CHR$(27) + "DI1222", msg$) PRINT msg$ 'Turn off classifiers CALL b9900comm(CHR$(27) + "CL111-000006+29999", msg$) PRINT msg$ 'Turn off relative mode CALL b9900comm(CHR$(27) + "RE1110000000", msg$) PRINT msg$ 'Let the meter finish its internal calibration SLEEP 10 END SUB SUB b9900notbusy '**************************************************************************** 'This subroutine checks to make sure the 9900 is ready for a command. 'If the 9900 is not ready, the routine waits until it is. ' 'Zachary Wolf '2/22/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(b9900terminP$, b9900termoutP$) 'Do a serial poll of the Gaussmeter spollnr: CALL gpibspoll(b9900addrP$, msg$) byt% = VAL(msg$) 'PRINT "B9900NOTBUSY, SPOLL = "; msg$; ", BYT = "; byt% 'See if bit 1 is set (busy); if it is, wait until it is not IF (byt% AND 1) <> 0 THEN 'Bit 1 is position 8 ' PRINT "SPOLL = "; msg$ SLEEP 1 GOTO spollnr END IF END SUB SUB b9900ready '**************************************************************************** 'This subroutine checks to make sure the 9900 has finished processing 'a command and is ready to send its message in reply. 'If the 9900 is not ready, the routine waits until it is. ' 'Zachary Wolf '2/22/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(b9900terminP$, b9900termoutP$) 'Do a serial poll of the Gaussmeter spoll: CALL gpibspoll(b9900addrP$, msg$) byt% = VAL(msg$) 'PRINT "B9900READY, SPOLL = "; msg$; ", BYT = "; byt% 'See if bit 7 is set (ready); if it is not, wait until it is IF (byt% AND 64) <> 64 THEN 'Bit 1 is position 8 ' PRINT "SPOLL = "; msg$ SLEEP 1 GOTO spoll END IF END SUB SUB b9900setpar (gpibinf%, gpiboutf%, b9900addr$) '**************************************************************************** 'This subroutine initializes the F. W. Bell 9900 series Gaussmeter. ' 'Input: ' gpibinf%, gpib input file number ' gpiboutf%, gpib output file number ' b9900addr$, gpib address in a string ' 'Zachary Wolf '12/11/95 '**************************************************************************** 'Make sure the input parameters have reasonable values IF gpibinf% < 0 OR gpibinf% > 100 THEN PRINT "B9900: GPIB problem" EXIT SUB END IF IF gpiboutf% < 0 OR gpiboutf% > 100 THEN PRINT "B9900: GPIB problem" EXIT SUB END IF IF b9900addr$ = "" THEN PRINT "B9900: GPIB problem" EXIT SUB END IF 'Save the GPIB information in a common block for future use gpibinP% = gpibinf% gpiboutP% = gpiboutf% b9900addrP$ = b9900addr$ END SUB SUB b9900setrange (r%) '**************************************************************************** 'This subroutine sets the range of the Bell 9900 Gaussmeter. ' 'Input: ' r%, the range number, 1 = 300 muT, 2 = 3 mT, 3 = 30 mT, 4 = 300 mT, 5 = 3 T, 6 = 30 T, 7 = 300 T, 8 = Auto Tesla ' 'Zachary Wolf '12/11/95 '**************************************************************************** 'Set the measurement range for channel 1 setrange: IF r% >= 1 AND r% <= 8 THEN CALL b9900comm(CHR$(27) + "RA1" + LTRIM$(STR$(r%)), msg$) ELSE PRINT PRINT "B9900: Inproper Hall probe range requested." PRINT "What range do you want for the Bell 9900 Hall probe? (1, 2, ..., 8) " PRINT "Ranges: 1 = 300 muT, 2 = 3 mT, 3 = 30 mT, 4 = 300 mT " INPUT " 5 = 3 T, 6 = 30 T, 7 = 300 T, 8 = Auto T >> ", r% GOTO setrange END IF END SUB SUB b9900zero '**************************************************************************** 'This subroutine zeros the Bell 9900 Gaussmeter. ' 'Zachary Wolf '12/11/95 '**************************************************************************** 'Message PRINT PRINT "Bell 9900 Gaussmeter Zero" PRINT "Please place the Hall probe in a zero Gauss chamber." INPUT "Press ENTER when ready. ", a$ PRINT "Zeroing the Bell 9900 Gaussmeter..." PRINT "This will take about 20 seconds." 'Zero the Gaussmeter zero: CALL b9900comm(CHR$(27) + "ZE10", msg$) 'Check that the zeroing was successful IF msg$ <> "ZE10" THEN PRINT PRINT "B9900: There was an error zeroing the Bell 9900 Gaussmeter: " + msg$ PRINT "Try again..." SLEEP 5 GOTO zero END IF 'Message PRINT "The Hall probe is zeroed." END SUB