DECLARE SUB gpibclr () DECLARE SUB gpibclrdev (addr$) DECLARE SUB pt2025delay () DECLARE SUB gpibspoll (addr$, value$) DECLARE SUB gpibin (addr$, msg$) DECLARE SUB gpibout (addr$, cmd$) DECLARE SUB gpibterm (termin$, termout$) DECLARE SUB pt2025getb (b!) DECLARE SUB pt2025search () DECLARE SUB pt2025setcoarse (b!) DECLARE SUB pt2025spoll (spoll$) DECLARE SUB pt2025status (s1$, s2$, s3$, s4$) '**************************************************************************** 'Module PT2025 'This module contains subroutines to read the PT2025 NMR teslameter. ' 'Zachary Wolf '6/12/94, 12/11/95 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /pt2025/ gpibinP%, gpiboutP%, pt2025addrP$ 'Semi-permanent parameters '!!! Important: Switch 8 should be set to 0. Otherwire two CR LFs are 'inserted causing Data Sequence errors. CONST terminP$ = "CR LF EOI" 'GPIB input terminator CONST termoutP$ = "CR LF EOI" 'GPIB output terminator SUB pt2025getb (b!) '**************************************************************************** 'This subroutine has the PT2025 NMR teslameter measure the magnetic field. ' 'Output: ' b!, the measured magnetic field strength in Tesla ' 'Zachary Wolf '6/12/94, 12/11/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Get the reading ntry% = 0 getb: ntry% = ntry% + 1 CALL gpibin(pt2025addrP$, b$) 'Make sure the NMR was locked, if not, get another reading, max 5 IF MID$(b$, 1, 1) <> "L" THEN IF ntry% > 5 THEN b! = 0! EXIT SUB END IF GOTO getb: END IF 'Take off the "L" b$ = MID$(b$, 2) 'Make sure the units are Tesla n% = LEN(b$) IF MID$(b$, n%, 1) <> "T" THEN PRINT "PT2025GETB: problem with the NMR reading: "; b$ EXIT SUB END IF 'Remove the units n% = LEN(b$) b$ = MID$(b$, 1, n% - 1) 'Extract the value b! = VAL(b$) END SUB SUB pt2025init '**************************************************************************** 'This subroutine initializes the Metrolab PT2025 NMR teslameter. ' 'Zachary Wolf '6/14/94, 12/11/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Message PRINT PRINT "Resetting the Metrolab PT2025 NMR teslameter..." 'Set up the service request mask CALL gpibout(pt2025addrP$, "M77") 'Go into auto mode CALL gpibout(pt2025addrP$, "A1") 'Set the units to Tesla CALL gpibout(pt2025addrP$, "D1") 'Set the field sence to + CALL gpibout(pt2025addrP$, "F1") 'Use only 1 multiplexer channel CALL gpibout(pt2025addrP$, "X1") 'Set the multiplexer channel to A CALL gpibout(pt2025addrP$, "PA") 'Display status information CALL pt2025status(s1$, s2$, s3$, s4$) PRINT "Status: "; s1$ + ", " + s2$ + ", " + s3$ + ", " + s4$ END SUB SUB pt2025search '**************************************************************************** 'This subroutine searches for a locked NMR signal. ' 'Zachary Wolf '6/23/94, 12/11/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Set the search time CALL gpibout(pt2025addrP$, "O3") 'Search over the entire probe range CALL gpibout(pt2025addrP$, "H") 'Message PRINT PRINT "The NMR is searching for the field value." INPUT "Press ENTER when the NMR has locked on the the field. ", a$ 'End the search CALL gpibout(pt2025addrP$, "Q") 'Read back the DAC count 'call gpibout(pt2025addrP$, "S4") 'call gpibin(s4$) 'PRINT "Coarse DAC set to : "; s4$ END SUB SUB pt2025setcoarse (b!) '**************************************************************************** 'This subroutine sets the oscillator frequency of the PT2025 NMR teslameter. 'This is the same function as the coarse potentiometer. 'This subroutine only works with a range 5 probe. ' 'Input: ' b!, the expected field strength ' 'Zachary Wolf '6/22/94, 12/11/95, 2/24/98 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Convert the field strength to a DAC count, Probe 2 '.1 T = 1024 '.26 T = 4096 'Assume the response is linear 'm! = (.26 - .1) / (4096! - 1024!) 'b=.1 T + m*(ndac-1024) 'ndac% = 1024 + (b! - .1) / m! 'Convert the field strength to a DAC count, Probe 5 '1.0 T = 1344 '1.5 T = 2620 'Assume the response is linear m! = (1.5 - 1!) / (2620! - 1344!) 'b=.1 T + m*(ndac-1024) ndac% = 2620 + (b! - 1.5) / m! 'Set the DAC count CALL gpibout(pt2025addrP$, "C" + LTRIM$(STR$(ndac%))) 'Read back the DAC count CALL gpibout(pt2025addrP$, "S4") CALL gpibin(pt2025addrP$, s4$) 'PRINT "Coarse DAC set to : "; s4$ 'Give the PT2025 time to lock on to the signal SLEEP 5 END SUB SUB pt2025setpar (gpibinf%, gpiboutf%, pt2025addr$) '**************************************************************************** 'This subroutine initializes the Metrolab PT2025 Teslameter. ' 'Input: ' gpibinf%, gpib input file number ' gpiboutf%, gpib output file number ' pt2025addr$, 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 "PT2025: GPIB problem" EXIT SUB END IF IF gpiboutf% < 0 OR gpiboutf% > 100 THEN PRINT "PT2025: GPIB problem" EXIT SUB END IF IF pt2025addr$ = "" THEN PRINT "PT2025: GPIB problem" EXIT SUB END IF 'Save the GPIB information in a common block for future use gpibinP% = gpibinf% gpiboutP% = gpiboutf% pt2025addrP$ = pt2025addr$ END SUB SUB pt2025status (s1$, s2$, s3$, s4$) '**************************************************************************** 'This subroutine displays the status of the Metrolab PT2025 NMR teslameter. ' 'Output: ' s1$, contents of status register 1 ' s2$, contents of status register 2 ' s3$, contents of status register 3 ' s4$, contents of status register 4 ' 'Zachary Wolf '6/23/94, 12/11/95 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(terminP$, termoutP$) 'Get the status information CALL gpibout(pt2025addrP$, "S1") CALL gpibin(pt2025addrP$, s1$) CALL gpibout(pt2025addrP$, "S2") CALL gpibin(pt2025addrP$, s2$) CALL gpibout(pt2025addrP$, "S3") CALL gpibin(pt2025addrP$, s3$) CALL gpibout(pt2025addrP$, "S4") CALL gpibin(pt2025addrP$, s4$) 'PRINT "Status: "; s1$ + ", " + s2$ + ", " + s3$ + ", " + s4$ END SUB SUB pt2025user '**************************************************************************** 'This routine allows the user to use the NMR. ' 'Zachary Wolf '2/8/98 '**************************************************************************** 'See what the user wants to do beginpt2025: PRINT PRINT "Type" PRINT " M to measure" PRINT " R to set coarse range" PRINT " S to search the entire range for a signal" PRINT " Q to quit" INPUT ">", cmd$ 'Do as the user requested IF cmd$ = "M" OR cmd$ = "m" THEN CALL pt2025getb(b!) PRINT "Field reading: "; b!; " T" ELSEIF cmd$ = "R" OR cmd$ = "r" THEN INPUT "Enter a field value to search around: ", bval$ bval! = VAL(bval$) CALL pt2025setcoarse(bval!) ELSEIF cmd$ = "S" OR cmd$ = "s" THEN CALL pt2025search ELSEIF cmd$ = "Q" OR cmd$ = "q" THEN GOTO endpt2025 ELSE PRINT "Unknown command." END IF GOTO beginpt2025 'Done endpt2025: END SUB