DECLARE SUB pt2025spoll (spoll$) DECLARE SUB pt2025status (s1$, s2$, s3$, s4$) '**************************************************************************** 'Module PT2025 'This module contains subroutines to read the PT2025 NMR teslameter. ' 'The following parameters are required in param.inc. ' gpibinP%, the GPIB input file number ' gpiboutP%, the GPIB output file number ' pt2025addrP%, the GPIB address of the PT2025 NMR teslameter ' 'Zachary Wolf '6/12/94 '**************************************************************************** REM $INCLUDE: 'param.inc' SUB pt2025getb (b!) '**************************************************************************** 'PT2025GETB 'This subroutine has the PT2025 NMR teslameter measure the magnetic field. ' 'Output: ' b!, the measured magnetic field strength in Tesla ' 'Input from param.inc: ' gpibinP%, the GPIB input file number ' gpiboutP%, the GPIB output file number ' pt2025addrP%, the GPIB address of the teslameter ' 'Zachary Wolf '6/12/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the PT2025 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% pt2025addr% = pt2025addrP% 'Put the address number into a string pt2025addr$ = STR$(pt2025addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF EOI" PRINT #gpibout%, "TERM OUT CR LF EOI" 'Get the reading ntry% = 0 getb: ntry% = ntry% + 1 PRINT #gpibout%, "ENTER " + pt2025addr$ INPUT #gpibin%, 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%) '**************************************************************************** 'PT2025GETCOARSE 'This subroutine gets the oscillator frequency of the PT2025 NMR teslameter 'in terms of the DAC setting. ' 'Output: ' dac%, the DAC setting ' 'Input from param.inc: ' gpibinP%, the GPIB input file number ' gpiboutP%, the GPIB output file number ' pt2025addrP%, the GPIB address of the teslameter ' 'Zachary Wolf '6/22/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the PT2025 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% pt2025addr% = pt2025addrP% 'Put the address number into a string pt2025addr$ = STR$(pt2025addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF EOI" PRINT #gpibout%, "TERM OUT CR LF EOI" 'Read the DAC setting PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";S4" PRINT #gpibout%, "ENTER " + pt2025addr$ INPUT #gpibin%, s4$ 'dac% = s4% PRINT "Coarse DAC set to : "; s4$ END SUB SUB pt2025init '**************************************************************************** 'PT2025INIT 'This subroutine initializes the Metrolab PT2025 NMR teslameter. ' 'Input from param.inc: ' gpibinP%, the GPIB input file number ' gpiboutP%, the GPIB output file number ' pt2025addrP%, the GPIB address of the teslameter ' 'Zachary Wolf '6/14/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the PT2025 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% pt2025addr% = pt2025addrP% 'Put the address number into a string pt2025addr$ = STR$(pt2025addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF EOI" PRINT #gpibout%, "TERM OUT CR LF EOI" 'Message PRINT PRINT "Resetting the Metrolab PT2025 NMR teslameter..." 'Clear the pt2025 'PRINT #gpibout%, "CLEAR " + pt2025addr$ 'Go into auto mode PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";A1" CALL pt2025spoll(spoll$) 'Set the units to Tesla PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";D1" CALL pt2025spoll(spoll$) 'Set the field sence to + PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";F1" CALL pt2025spoll(spoll$) 'Use only 1 multiplexer channel PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";X1" CALL pt2025spoll(spoll$) 'Set the multiplexer channel to A PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";PA" CALL pt2025spoll(spoll$) 'Display status information CALL pt2025status(s1$, s2$, s3$, s4$) PRINT "Status: "; s1$ + ", " + s2$ + ", " + s3$ + ", " + s4$ END SUB SUB pt2025search '**************************************************************************** 'PT2025SEARCH 'This subroutine searches for a locked NMR signal. ' 'Input from param.inc: ' gpibinP%, the GPIB input file number ' gpiboutP%, the GPIB output file number ' pt2025addrP%, the GPIB address of the teslameter ' 'Zachary Wolf '6/23/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the PT2025 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% pt2025addr% = pt2025addrP% 'Put the address number into a string pt2025addr$ = STR$(pt2025addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF EOI" PRINT #gpibout%, "TERM OUT CR LF EOI" 'Set the search time PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";O3" CALL pt2025spoll(spoll$) 'Search over the entire probe range PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";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 #gpibout%, "OUTPUT " + pt2025addr$ + ";Q" CALL pt2025spoll(spoll$) 'Read back the DAC count 'PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";S4" 'PRINT #gpibout%, "ENTER " + pt2025addr$ 'LINE INPUT #gpibin%, s4$ 'PRINT "Coarse DAC set to : "; s4$ END SUB SUB pt2025setcoarse (b!) '**************************************************************************** 'PT2025SETCOARSE '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 ' 'Input from param.inc: ' gpibinP%, the GPIB input file number ' gpiboutP%, the GPIB output file number ' pt2025addrP%, the GPIB address of the teslameter ' 'Zachary Wolf '6/22/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the PT2025 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% pt2025addr% = pt2025addrP% 'Put the address number into a string pt2025addr$ = STR$(pt2025addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF EOI" PRINT #gpibout%, "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 #gpibout%, "OUTPUT " + pt2025addr$ + ";C" + LTRIM$(STR$(ndac%)) CALL pt2025spoll(spoll$) 'Read back the DAC count PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";S4" PRINT #gpibout%, "ENTER " + pt2025addr$ LINE INPUT #gpibin%, s4$ PRINT "Coarse DAC set to : "; s4$ END SUB SUB pt2025spoll (spoll$) '**************************************************************************** 'PT2025SPOLL 'This subroutine does a serial poll on the Metrolab PT2025 NMR teslameter.' ' 'Output: ' spoll$, the value returned by the serial poll ' 'Input from param.inc: ' gpibinP%, the GPIB input file number ' gpiboutP%, the GPIB output file number ' pt2025addrP%, the GPIB address of the teslameter ' 'Zachary Wolf '6/21/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the PT2025 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% pt2025addr% = pt2025addrP% 'Put the address number into a string pt2025addr$ = STR$(pt2025addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF EOI" PRINT #gpibout%, "TERM OUT CR LF EOI" 'Do the serial poll PRINT #gpibout%, "SPOLL " + pt2025addr$ INPUT #gpibin%, spoll$ 'Print the result 'PRINT spoll$ END SUB SUB pt2025status (s1$, s2$, s3$, s4$) '**************************************************************************** 'PT2025STATUS '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 ' 'Input from param.inc: ' gpibinP%, the GPIB input file number ' gpiboutP%, the GPIB output file number ' pt2025addrP%, the GPIB address of the teslameter ' 'Zachary Wolf '6/23/94 '**************************************************************************** 'Get the GPIB I/O file numbers and the PT2025 address from the parameters gpibin% = gpibinP% gpibout% = gpiboutP% pt2025addr% = pt2025addrP% 'Put the address number into a string pt2025addr$ = STR$(pt2025addr%) 'Set the GPIB terminators PRINT #gpibout%, "TERM IN CR LF EOI" PRINT #gpibout%, "TERM OUT CR LF EOI" 'Get the status information PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";S1" PRINT #gpibout%, "ENTER " + pt2025addr$ LINE INPUT #gpibin%, s1$ PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";S2" PRINT #gpibout%, "ENTER " + pt2025addr$ LINE INPUT #gpibin%, s2$ PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";S3" PRINT #gpibout%, "ENTER " + pt2025addr$ LINE INPUT #gpibin%, s3$ PRINT #gpibout%, "OUTPUT " + pt2025addr$ + ";S4" PRINT #gpibout%, "ENTER " + pt2025addr$ LINE INPUT #gpibin%, s4$ 'PRINT "Status: "; s1$ + ", " + s2$ + ", " + s3$ + ", " + s4$ END SUB