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$ 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 PRINT #gpiboutP%, "TERM IN CR LF EOI" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Get the reading ntry% = 0 getb: ntry% = ntry% + 1 PRINT #gpiboutP%, "ENTER " + pt2025addrP$ INPUT #gpibinP%, 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 CALL pt2025spoll(spoll$) 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 pt2025getcoarse (dac%) '**************************************************************************** 'This subroutine gets the oscillator frequency of the PT2025 NMR teslameter 'in terms of the DAC setting. ' 'Output: ' dac%, the DAC setting ' 'Zachary Wolf '6/22/94, 12/11/95 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF EOI" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Read the DAC setting PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";S4" PRINT #gpiboutP%, "ENTER " + pt2025addrP$ INPUT #gpibinP%, s4$ 'dac% = s4% PRINT "Coarse DAC set to : "; s4$ END SUB SUB pt2025init '**************************************************************************** 'This subroutine initializes the Metrolab PT2025 NMR teslameter. ' 'Zachary Wolf '6/14/94, 12/11/95 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF EOI" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Message PRINT PRINT "Resetting the Metrolab PT2025 NMR teslameter..." 'Clear the pt2025 'PRINT #gpiboutP%, "CLEAR " + pt2025addrP$ 'Go into auto mode PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";A1" CALL pt2025spoll(spoll$) 'Set the units to Tesla PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";D1" CALL pt2025spoll(spoll$) 'Set the field sence to + PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";F1" CALL pt2025spoll(spoll$) 'Use only 1 multiplexer channel PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";X1" CALL pt2025spoll(spoll$) 'Set the multiplexer channel to A PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";PA" CALL pt2025spoll(spoll$) '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 PRINT #gpiboutP%, "TERM IN CR LF EOI" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Set the search time PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";O3" CALL pt2025spoll(spoll$) 'Search over the entire probe range PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";H" CALL pt2025spoll(spoll$) '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 PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";Q" CALL pt2025spoll(spoll$) 'Read back the DAC count 'PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";S4" 'PRINT #gpiboutP%, "ENTER " + pt2025addrP$ 'LINE INPUT #gpibinP%, 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 2 probe. ' 'Input: ' b!, the expected field strength ' 'Zachary Wolf '6/22/94, 12/11/95 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF EOI" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Convert the field strength to a DAC count '.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! 'Set the DAC count PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";C" + LTRIM$(STR$(ndac%)) CALL pt2025spoll(spoll$) 'Read back the DAC count PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";S4" PRINT #gpiboutP%, "ENTER " + pt2025addrP$ LINE INPUT #gpibinP%, s4$ PRINT "Coarse DAC set to : "; s4$ 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 pt2025spoll (spoll$) '**************************************************************************** 'This subroutine does a serial poll on the Metrolab PT2025 NMR teslameter.' ' 'Output: ' spoll$, the value returned by the serial poll ' 'Zachary Wolf '6/21/94, 12/11/95 '**************************************************************************** 'Set the GPIB terminators PRINT #gpiboutP%, "TERM IN CR LF EOI" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Do the serial poll PRINT #gpiboutP%, "SPOLL " + pt2025addrP$ INPUT #gpibinP%, spoll$ 'Print the result 'PRINT spoll$ 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 PRINT #gpiboutP%, "TERM IN CR LF EOI" PRINT #gpiboutP%, "TERM OUT CR LF EOI" 'Get the status information PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";S1" PRINT #gpiboutP%, "ENTER " + pt2025addrP$ LINE INPUT #gpibinP%, s1$ PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";S2" PRINT #gpiboutP%, "ENTER " + pt2025addrP$ LINE INPUT #gpibinP%, s2$ PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";S3" PRINT #gpiboutP%, "ENTER " + pt2025addrP$ LINE INPUT #gpibinP%, s3$ PRINT #gpiboutP%, "OUTPUT " + pt2025addrP$ + ";S4" PRINT #gpiboutP%, "ENTER " + pt2025addrP$ LINE INPUT #gpibinP%, s4$ 'PRINT "Status: "; s1$ + ", " + s2$ + ", " + s3$ + ", " + s4$ END SUB