DECLARE SUB sr850errclear () DECLARE SUB sr850decrsens () DECLARE SUB gpibclrdev (addr$) DECLARE SUB gpibin (addr$, msg$) DECLARE SUB gpibout (addr$, cmd$) DECLARE SUB gpibspoll (addr$, msg$) DECLARE SUB gpibterm (termin$, termout$) DECLARE SUB sr850datready () DECLARE SUB sr850err (ynerr$) DECLARE SUB sr850ready () '**************************************************************************** 'Module SR850 'This module contains I/O subroutines for the Stanford Research 'Model 850 lock-in amplifier. ' 'Zachary Wolf '6/11/97 '**************************************************************************** 'Declare shared parameters DIM SHARED sr850addrP$ 'Semi-permanent parameters CONST sr850terminP$ = "LF" CONST sr850termoutP$ = "LF" SUB sr850automeasure '**************************************************************************** 'This subroutine has the SR850 lock-in amplifier perform an auto-measure 'sequence. ' 'Zachary Wolf '6/15/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Starting point 'Set the input sensitivity to the highest range (1 V) remeasure: CALL sr850ready CALL gpibout(sr850addrP$, "SENS26") 'Set the dynamic reserve to its maximum value CALL sr850ready CALL gpibout(sr850addrP$, "RMOD0") 'Let things settle SLEEP 1 'Use the auto functions to make changes to the starting point 'Auto-gain CALL sr850ready CALL gpibout(sr850addrP$, "AGAN") 'Auto-reserve CALL sr850ready CALL gpibout(sr850addrP$, "ARSV") 'Let things settle SLEEP 2 'Clear the LIA output overload status bit after auto-gain CALL sr850ready CALL gpibout(sr850addrP$, "LIAS?2") CALL sr850datready CALL gpibin(sr850addrP$, bitval$) 'Clear the LIA input/reserve overload status bit after auto-reserve CALL sr850ready CALL gpibout(sr850addrP$, "LIAS?0") CALL sr850datready CALL gpibin(sr850addrP$, bitval$) 'Auto-scale the top trace, R CALL sr850ready CALL gpibout(sr850addrP$, "ADSP1") CALL sr850ready CALL gpibout(sr850addrP$, "ASCL") 'Check for errors DIM ynerr$ CALL sr850err(ynerr$) 'If there is an error, first try to fix it, otherwise try again DIM ynerrs$ IF ynerr$ = "y" THEN CALL sr850decrsens CALL sr850err(ynerrs$) IF ynerrs$ = "y" THEN PRINT PRINT "SR850, problem detected, remeasuring..." GOTO remeasure ELSE PRINT "SR850, problem fixed, continuing..." END IF END IF 'Let things settle SLEEP 3 END SUB SUB sr850datready '**************************************************************************** 'This subroutine is used to verify that the SR850 is done processing and 'has data ready to return. It checks the serial poll bits and 'waits until the SR850 is ready to send its output. ' 'Zachary Wolf '6/21/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Check the status until the SR850 is ready to send data WHILE 1 'Perform a serial poll on the SR850 DIM spoll$ CALL gpibspoll(sr850addrP$, spoll$) 'Message for debugging 'PRINT "DEBUG, Datready, Spoll = "; spoll$ 'Convert spoll$ to an integer DIM spoll% spoll% = VAL(spoll$) 'Print a message if an error is detected 'Use for debugging, some steps set error bits which are later cleared IF (spoll% AND 1) = 1 THEN 'OK, no scan in progress END IF IF (spoll% AND 2) = 2 THEN 'OK, no command execution in progress END IF IF (spoll% AND 4) = 4 THEN 'PRINT "SR850DATREADY, ERR, error detected in SPOLL" END IF IF (spoll% AND 8) = 8 THEN 'PRINT "SR850DATRERADY, LIA, an LIA status bit has been set" END IF IF (spoll% AND 16) = 16 THEN 'OK, no error END IF IF (spoll% AND 32) = 32 THEN 'PRINT "SR850DATRERADY, ESB, a standard event status bit has been set" END IF IF (spoll% AND 64) = 64 THEN 'PRINT "SR850DATRERADY, SRQ, an SRQ has occurred" END IF IF (spoll% AND 128) = 128 THEN 'OK, unused END IF 'See if the data is ready 'Bit 1 (value 2) means that no command is in progress 'Bit 4 (value 16) means that data is ready IF (spoll% AND 18) = 18 THEN EXIT SUB ELSE SLEEP 1 END IF 'End while loop WEND END SUB SUB sr850decrsens '**************************************************************************** 'This subroutine has the SR850 lock-in amplifier decrease its sensitivity by 'one setting. ' 'Zachary Wolf '1/13/99 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Ask for the present sensitivity CALL sr850ready CALL gpibout(sr850addrP$, "SENS?") 'Get the present sensitivity CALL sr850datready DIM sens$ CALL gpibin(sr850addrP$, sens$) sens% = VAL(sens$) 'Message for debugging 'PRINT "DEBUG, Sens$ = "; sens$ 'PRINT "DEBUG, Sens% = "; sens% 'Decrease the sensitivity IF sens% < 26 THEN sens% = sens% + 1 END IF 'Set the new sensitivity CALL sr850ready CALL gpibout(sr850addrP$, "SENS" + LTRIM$(STR$(sens%))) 'Clear all errors CALL sr850errclear 'Let things settle SLEEP 1 END SUB SUB sr850err (ynerr$) '**************************************************************************** 'This subroutine is used to check for an error condition (overflow, command 'error, etc.). ' 'Output: ' ynerr$, "y" if there is an error, "n" if there is no error ' 'Zachary Wolf '6/21/97 '**************************************************************************** 'Default ynerr$ = "n" 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Declare variables DIM status$ DIM status% 'Read the serial poll status byte (NOT a serial poll) CALL sr850ready CALL gpibout(sr850addrP$, "*STB?") CALL sr850datready CALL gpibin(sr850addrP$, status$) 'Convert status$ to an integer and check its value status% = VAL(status$) 'Print a message if an error is detected IF (status% AND 1) = 1 THEN 'OK, no scan in progress END IF IF (status% AND 2) = 2 THEN 'OK, no command execution in progress END IF IF (status% AND 4) = 4 THEN PRINT "SR850ERR, ERR, error detected" ynerr$ = "y" END IF IF (status% AND 8) = 8 THEN PRINT "SR850ERR, LIA, an LIA status bit has been set" ynerr$ = "y" END IF IF (status% AND 16) = 16 THEN 'OK, data is ready END IF IF (status% AND 32) = 32 THEN PRINT "SR850ERR, ESB, a standard event status bit has been set" ynerr$ = "y" END IF IF (status% AND 64) = 64 THEN 'OK, taking care of SRQ END IF IF (status% AND 128) = 128 THEN 'OK, unused END IF 'Read the standard event status byte CALL sr850ready CALL gpibout(sr850addrP$, "*ESR?") CALL sr850datready CALL gpibin(sr850addrP$, status$) 'Convert status$ to an integer and check its value status% = VAL(status$) 'Print a message if an error is detected IF (status% AND 1) = 1 THEN PRINT "SR850ERR, input queue overflow" ynerr$ = "y" END IF IF (status% AND 2) = 2 THEN 'OK, unused END IF IF (status% AND 4) = 4 THEN PRINT "SR850ERR, output queue overflow" ynerr$ = "y" END IF IF (status% AND 8) = 8 THEN 'OK, unused END IF IF (status% AND 16) = 16 THEN PRINT "SR850ERR, command did not execute correctly, or parameter out of range" ynerr$ = "y" END IF IF (status% AND 32) = 32 THEN PRINT "SR850ERR, illegal command received" ynerr$ = "y" END IF IF (status% AND 64) = 64 THEN 'OK, bit not set END IF IF (status% AND 128) = 128 THEN 'OK, bit not set END IF 'Read the LIA status byte CALL sr850ready CALL gpibout(sr850addrP$, "LIAS?") CALL sr850datready CALL gpibin(sr850addrP$, status$) 'Convert status$ to an integer and check its value status% = VAL(status$) 'Print a message if an error is detected IF (status% AND 1) = 1 THEN PRINT "SR850ERR, input or reserve overload" ynerr$ = "y" END IF IF (status% AND 2) = 2 THEN PRINT "SR850ERR, filter overload" ynerr$ = "y" END IF IF (status% AND 4) = 4 THEN PRINT "SR850ERR, output overload" ynerr$ = "y" END IF IF (status% AND 8) = 8 THEN PRINT "SR850ERR, reference unlocked" ynerr$ = "y" END IF IF (status% AND 16) = 16 THEN 'OK, bit not set END IF IF (status% AND 32) = 32 THEN 'OK, bit not set END IF IF (status% AND 64) = 64 THEN 'OK, bit not set END IF IF (status% AND 128) = 128 THEN 'OK, bit not set END IF 'Read the error status byte CALL sr850ready CALL gpibout(sr850addrP$, "ERRS?") CALL sr850datready CALL gpibin(sr850addrP$, status$) 'Convert status$ to an integer and check its value status% = VAL(status$) 'Print a message if an error is detected IF (status% AND 1) = 1 THEN PRINT "SR850ERR, error during printing" ynerr$ = "y" END IF IF (status% AND 2) = 2 THEN PRINT "SR850ERR, battery backup has failed" ynerr$ = "y" END IF IF (status% AND 4) = 4 THEN PRINT "SR850ERR, RAM memory test failure" ynerr$ = "y" END IF IF (status% AND 8) = 8 THEN PRINT "SR850ERR, error during disk operation" ynerr$ = "y" END IF IF (status% AND 16) = 16 THEN PRINT "SR850ERR, ROM error" ynerr$ = "y" END IF IF (status% AND 32) = 32 THEN PRINT "SR850ERR, GPIB error" ynerr$ = "y" END IF IF (status% AND 64) = 64 THEN PRINT "SR850ERR, DSP error" ynerr$ = "y" END IF IF (status% AND 128) = 128 THEN PRINT "SR850ERR, math error" ynerr$ = "y" END IF END SUB SUB sr850errclear '**************************************************************************** 'This subroutine is used to clear the error registers. Device and command 'errors are reported. ' 'Zachary Wolf '1/13/99 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Declare variables DIM status$ DIM status% 'Read the serial poll status byte (NOT a serial poll) CALL sr850ready CALL gpibout(sr850addrP$, "*STB?") CALL sr850datready CALL gpibin(sr850addrP$, status$) 'Read the standard event status byte CALL sr850ready CALL gpibout(sr850addrP$, "*ESR?") CALL sr850datready CALL gpibin(sr850addrP$, status$) 'Convert status$ to an integer and check its value status% = VAL(status$) 'Print a message if an error is detected IF (status% AND 1) = 1 THEN PRINT "SR850ERR, input queue overflow" ynerr$ = "y" END IF IF (status% AND 2) = 2 THEN 'OK, unused END IF IF (status% AND 4) = 4 THEN PRINT "SR850ERR, output queue overflow" ynerr$ = "y" END IF IF (status% AND 8) = 8 THEN 'OK, unused END IF IF (status% AND 16) = 16 THEN PRINT "SR850ERR, command did not execute correctly, or parameter out of range" ynerr$ = "y" END IF IF (status% AND 32) = 32 THEN PRINT "SR850ERR, illegal command received" ynerr$ = "y" END IF IF (status% AND 64) = 64 THEN 'OK, bit not set END IF IF (status% AND 128) = 128 THEN 'OK, bit not set END IF 'Read the LIA status byte CALL sr850ready CALL gpibout(sr850addrP$, "LIAS?") CALL sr850datready CALL gpibin(sr850addrP$, status$) 'Read the error status byte CALL sr850ready CALL gpibout(sr850addrP$, "ERRS?") CALL sr850datready CALL gpibin(sr850addrP$, status$) 'Convert status$ to an integer and check its value status% = VAL(status$) 'Print a message if an error is detected IF (status% AND 1) = 1 THEN PRINT "SR850ERR, error during printing" ynerr$ = "y" END IF IF (status% AND 2) = 2 THEN PRINT "SR850ERR, battery backup has failed" ynerr$ = "y" END IF IF (status% AND 4) = 4 THEN PRINT "SR850ERR, RAM memory test failure" ynerr$ = "y" END IF IF (status% AND 8) = 8 THEN PRINT "SR850ERR, error during disk operation" ynerr$ = "y" END IF IF (status% AND 16) = 16 THEN PRINT "SR850ERR, ROM error" ynerr$ = "y" END IF IF (status% AND 32) = 32 THEN PRINT "SR850ERR, GPIB error" ynerr$ = "y" END IF IF (status% AND 64) = 64 THEN PRINT "SR850ERR, DSP error" ynerr$ = "y" END IF IF (status% AND 128) = 128 THEN PRINT "SR850ERR, math error" ynerr$ = "y" END IF END SUB SUB sr850getfreq (freq!) '**************************************************************************** 'This subroutine has the SR850 lock-in amplifier return the reference 'frequency. ' 'Output: ' freq!, reference frequency in Hz ' 'Zachary Wolf '6/21/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Ask for the reference frequency remeasurefreq: CALL sr850ready CALL gpibout(sr850addrP$, "FREQ?") 'Get the reference frequency CALL sr850datready DIM freq$ CALL gpibin(sr850addrP$, freq$) freq! = VAL(freq$) 'Message for debugging 'PRINT "DEBUG, Frequency$ = "; freq$; " Hz" 'PRINT "DEBUG, Frequency! = "; freq!; " Hz" 'Check for errors DIM ynerr$ CALL sr850err(ynerr$) IF ynerr$ <> "n" THEN PRINT "SR850GETFREQ: found error, remeasuring..." GOTO remeasurefreq END IF END SUB SUB sr850getphase (phase!) '**************************************************************************** 'This subroutine has the SR850 lock-in amplifier return the signal's 'phase angle with respect to the reference. ' 'Output: ' phase!, phase in degrees wrt the reference ' 'Zachary Wolf '6/21/97 '**************************************************************************** 'Convention 'The SR850 uses the following convention to define TH: 'V(t) = sqrt(2) R sin(wt + TH) 'R = rms amplitude 'TH = phase wrt the reference, which defines t=0 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Read the phase angle remeasurephase: CALL sr850ready CALL gpibout(sr850addrP$, "OUTP?4") CALL sr850datready DIM msg$ CALL gpibin(sr850addrP$, msg$) 'Extract the phase in degrees from the message phase! = VAL(msg$) 'Message for debugging 'PRINT "DEBUG, Phase info msg$ = "; msg$ 'PRINT "DEBUG, Phase info phase! = "; phase! 'Check for errors DIM ynerr$ CALL sr850err(ynerr$) IF ynerr$ <> "n" THEN PRINT "SR850GETPHASE: found error, remeasuring..." GOTO remeasurephase END IF END SUB SUB sr850getvrms (vrms!) '**************************************************************************** 'This subroutine has the SR850 lock-in amplifier return the rms magnitude 'of the input signal. ' 'Output: ' vrms!, the input signal magnitude in volts rms ' 'Zachary Wolf '6/21/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Ask for the signal magnitude remeasurevrms: CALL sr850ready CALL gpibout(sr850addrP$, "OUTP?3") 'Get the signal magnitude as a string CALL sr850datready DIM vrms$ CALL gpibin(sr850addrP$, vrms$) 'Extract the signal magnitude in Vrms vrms! = VAL(vrms$) 'Message for debugging 'PRINT "DEBUG, Vrms$ = "; vrms$; " V" 'PRINT "DEBUG, Vrms! = "; vrms!; " V" 'Check for errors CALL sr850err(ynerr$) IF ynerr$ <> "n" THEN PRINT "SR850GETVRMS: found error, remeasuring..." GOTO remeasurevrms END IF END SUB SUB sr850getvxrms (vxrms!) '**************************************************************************** 'This subroutine has the SR850 lock-in amplifier return the rms magnitude 'of the in-phase component of the input signal. ' 'Output: ' vxrms!, the in-phase input signal magnitude in volts rms ' 'Zachary Wolf '6/24/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Ask for the in-phase signal magnitude remeasurevxrms: CALL sr850ready CALL gpibout(sr850addrP$, "OUTP?1") 'Get the in-phase signal magnitude as a string CALL sr850datready DIM vxrms$ CALL gpibin(sr850addrP$, vxrms$) 'Extract the signal magnitude in Vrms vxrms! = VAL(vxrms$) 'Message for debugging 'PRINT "DEBUG, VXrms$ = "; vxrms$; " V" 'PRINT "DEBUG, VXrms! = "; vxrms!; " V" 'Check for errors DIM ynerr$ CALL sr850err(ynerr$) IF ynerr$ <> "n" THEN PRINT "SR850GETVXRMS: found error, remeasuring..." GOTO remeasurevxrms END IF END SUB SUB sr850getvyrms (vyrms!) '**************************************************************************** 'This subroutine has the SR850 lock-in amplifier return the rms magnitude 'of the quadrature component of the input signal. ' 'Output: ' vyrms!, the quadrature input signal magnitude in volts rms ' 'Zachary Wolf '6/24/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Ask for the quadrature signal magnitude remeasurevyrms: CALL sr850ready CALL gpibout(sr850addrP$, "OUTP?2") 'Get the quadrature signal magnitude as a string CALL sr850datready DIM vyrms$ CALL gpibin(sr850addrP$, vyrms$) 'Extract the signal magnitude in Vrms vyrms! = VAL(vyrms$) 'Message for debugging 'PRINT "DEBUG, VYrms$ = "; vyrms$; " V" 'PRINT "DEBUG, VYrms! = "; vyrms!; " V" 'Check for errors DIM ynerr$ CALL sr850err(ynerr$) IF ynerr$ <> "n" THEN PRINT "SR850GETVYRMS: found error, remeasuring..." GOTO remeasurevyrms END IF END SUB SUB sr850init '**************************************************************************** 'This subroutine initializes the SR850 lock-in amplifier. ' 'Zachary Wolf '6/11/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Message PRINT PRINT "Resetting the SR850 lock-in amplifier..." 'Clear all status registers CALL gpibout(sr850addrP$, "*CLS") 'Have the SR850 direct all output to the GPIB interface CALL sr850ready CALL gpibout(sr850addrP$, "OUTX1") 'Set the control to remote CALL sr850ready CALL gpibout(sr850addrP$, "LOCL1") 'Allow the front panel keys to stay in use CALL sr850ready CALL gpibout(sr850addrP$, "OVRM1") 'Enable the standard event status register, bits 0 2 4 5, 1+4+16+32=53 CALL sr850ready CALL gpibout(sr850addrP$, "*ESE53") 'Disable SRQs, will check for errors CALL sr850ready CALL gpibout(sr850addrP$, "*SRE0") 'Enable the error status register CALL sr850ready CALL gpibout(sr850addrP$, "ERRE255") 'Enable the lock-in status register, bits 0 1 2 3, 1+2+4+8=15 CALL sr850ready CALL gpibout(sr850addrP$, "LIAE15") 'Clear all errors and report device and command errors CALL sr850errclear 'Display the SR850 ID CALL sr850ready CALL gpibout(sr850addrP$, "*IDN?") CALL sr850datready CALL gpibin(sr850addrP$, msg$) PRINT msg$ 'Check for errors DIM ynerr$ CALL sr850err(ynerr$) END SUB SUB sr850ready '**************************************************************************** 'This subroutine is used to verify that the 850 is done processing a command 'and is ready for the next command. It checks the serial poll bits and 'waits until the 850 is ready for the next command. ' 'Zachary Wolf '6/11/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Check the status until the 850 is ready for a command WHILE 1 'Perform a serial poll on the 850 DIM spoll$ CALL gpibspoll(sr850addrP$, spoll$) 'Message for debugging 'PRINT "DEBUG, Ready, Spoll = "; spoll$ 'Convert spoll$ to an integer DIM spoll% spoll% = VAL(spoll$) 'Print a message if an error is detected 'Use for debugging, some steps set error bits which are later cleared IF (spoll% AND 1) = 1 THEN 'OK, no scan in progress END IF IF (spoll% AND 2) = 2 THEN 'OK, no command execution in progress END IF IF (spoll% AND 4) = 4 THEN 'PRINT "SR850READY, ERR, error detected in SPOLL" END IF IF (spoll% AND 8) = 8 THEN 'PRINT "SR850RERADY, LIA, an LIA status bit has been set" END IF IF (spoll% AND 16) = 16 THEN 'OK, no error END IF IF (spoll% AND 32) = 32 THEN 'PRINT "SR850RERADY, ESB, a standard event status bit has been set" END IF IF (spoll% AND 64) = 64 THEN 'PRINT "SR850RERADY, SRQ, an SRQ has occurred" END IF IF (spoll% AND 128) = 128 THEN 'OK, unused END IF 'Message for debugging 'PRINT "DEBUG, Ready, Spoll = "; spoll% 'See if we are ready for a new command 'Bit 0 true (1) means no scan in progress, ready 'Bit 1 true (1) means no command execution in progress, ready IF (spoll% AND 3) = 3 THEN EXIT SUB ELSE SLEEP 1 END IF 'End while loop WEND END SUB SUB sr850setharmonic (n%) '**************************************************************************** 'This subroutine sets the harmonic number that the lock-in measures. ' 'Input: ' n%, the desired harmonic number ' 'Zachary Wolf '6/25/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Set the harmonic number CALL sr850ready CALL gpibout(sr850addrP$, "HARM" + LTRIM$(STR$(n%))) 'Check for errors DIM ynerr$ CALL sr850err(ynerr$) END SUB SUB sr850setpar (sr850addr$) '**************************************************************************** 'This subroutine sets parameter values for the SR850 lock-in amplifier. ' 'Input: ' sr850addr$, the SR850 GPIB address in a string ' 'Zachary Wolf '6/21/97 '**************************************************************************** 'Make sure all GPIB parameters have reasonable values IF sr850addr$ = "" THEN PRINT "SR850: GPIB problem" EXIT SUB END IF 'Place the parameters in the global area for future use sr850addrP$ = sr850addr$ END SUB SUB sr850setsineout (a!, f!) '**************************************************************************** 'This subroutine sets the sine wave output amplitude and frequency. ' 'Input: ' a!, the sine wave amplitude (.004 to 5 V) ' f!, the sine wave frequency (.001 to 102000 Hz) ' 'Zachary Wolf '7/21/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Set the amplitude IF a! < .004 THEN a! = .004 IF a! > 5! THEN a! = 5! CALL sr850ready CALL gpibout(sr850addrP$, "SLVL" + LTRIM$(STR$(a!))) 'Set the frequency IF f! < .001 THEN f! = .001 IF f! > 102000! THEN f! = 102000! CALL sr850ready CALL gpibout(sr850addrP$, "FREQ" + LTRIM$(STR$(f!))) 'Check for errors DIM ynerr$ CALL sr850err(ynerr$) END SUB SUB sr850setupv1ext '**************************************************************************** 'This subroutine sets up the SR850 lock-in amplifier for dipole and solenoid 'measurements, ie. external TTL reference, first harmonic, etc. ' 'Zachary Wolf '6/11/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Reset to the default configuration 'See p. 5-2 of the manual for the default settings CALL sr850ready CALL gpibout(sr850addrP$, "*RST") '**Changes to the reference/phase settings** 'Use an external reference CALL sr850ready CALL gpibout(sr850addrP$, "FMOD2") 'Set the reference slope to TTL rising edge CALL sr850ready CALL gpibout(sr850addrP$, "RSLP1") 'Set the reference to a sine wave zero crossing 'CALL sr850ready 'CALL gpibout(sr850addrP$, "RSLP0") 'Allow time to lock before clearing the unlocked status bit SLEEP 2 'Clear the reference unlocked status bit after the reference has been changed CALL sr850ready CALL gpibout(sr850addrP$, "LIAS?3") CALL sr850datready DIM bitval$ CALL gpibin(sr850addrP$, bitval$) '**Changes to the input/filters settings** '**Changes to the gain/time constant settings** 'The .1 s time constant should be adequate in most cases 'Set the time constant to 1 sec 'CALL sr850ready 'CALL gpibout(sr850addrP$, "OFLT10") 'Turn on the synchronous filter (f < 200 Hz) CALL sr850ready CALL gpibout(sr850addrP$, "SYNC1") 'Allow things to settle before clearing the status bit SLEEP 1 'Clear the filter overload status bit after the filter has been changed CALL sr850ready CALL gpibout(sr850addrP$, "LIAS?1") CALL sr850datready CALL gpibin(sr850addrP$, bitval$) '**Changes to the output/offset settings** '**Changes to the trace/scan settings** '**Changes to the display/scale settings** 'Set the top display to trace 3 (R) CALL sr850ready CALL gpibout(sr850addrP$, "DTRC1,3") 'Scale the top display range to 0 to 1 V (R) CALL sr850ready CALL gpibout(sr850addrP$, "DSCL1,1.0") 'Set the bottom display to trace 4 (theta) CALL sr850ready CALL gpibout(sr850addrP$, "DTRC2,4") 'Scale the BOTTOM display range to -180 to +180 degrees (theta) CALL sr850ready CALL gpibout(sr850addrP$, "DSCL2,180.") '**Changes to the aux output settings** '**Changes to the math settings** '**Changes to the system setup** 'Check for errors DIM ynerr$ CALL sr850err(ynerr$) END SUB SUB sr850setupv1exts '**************************************************************************** 'This subroutine sets up the SR850 lock-in amplifier for dipole and solenoid 'measurements, ie. external TTL reference, first harmonic, etc. ' 'Zachary Wolf '6/11/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Reset to the default configuration 'See p. 5-2 of the manual for the default settings CALL sr850ready CALL gpibout(sr850addrP$, "*RST") '**Changes to the reference/phase settings** 'Use an external reference CALL sr850ready CALL gpibout(sr850addrP$, "FMOD2") 'Set the reference slope to TTL rising edge 'CALL sr850ready 'CALL gpibout(sr850addrP$, "RSLP1") 'Set the reference to a sine wave zero crossing CALL sr850ready CALL gpibout(sr850addrP$, "RSLP0") 'Clear the reference unlocked status bit after the reference has been changed CALL sr850ready CALL gpibout(sr850addrP$, "LIAS?3") CALL sr850datready DIM bitval$ CALL gpibin(sr850addrP$, bitval$) '**Changes to the input/filters settings** '**Changes to the gain/time constant settings** 'The .1 s time constant should be adequate in most cases 'Set the time constant to 1 sec 'CALL sr850ready 'CALL gpibout(sr850addrP$, "OFLT10") 'Turn on the synchronous filter (f < 200 Hz) 'CALL sr850ready 'CALL gpibout(sr850addrP$, "SYNC1") 'Clear the filter overload status bit after the filter has been changed CALL sr850ready CALL gpibout(sr850addrP$, "LIAS?1") CALL sr850datready CALL gpibin(sr850addrP$, bitval$) '**Changes to the output/offset settings** '**Changes to the trace/scan settings** '**Changes to the display/scale settings** 'Set the top display to trace 3 (R) CALL sr850ready CALL gpibout(sr850addrP$, "DTRC1,3") 'Scale the top display range to 0 to 1 V (R) CALL sr850ready CALL gpibout(sr850addrP$, "DSCL1,1.0") 'Set the bottom display to trace 4 (theta) CALL sr850ready CALL gpibout(sr850addrP$, "DTRC2,4") 'Scale the BOTTOM display range to -180 to +180 degrees (theta) CALL sr850ready CALL gpibout(sr850addrP$, "DSCL2,180.") '**Changes to the aux output settings** '**Changes to the math settings** '**Changes to the system setup** 'Check for errors DIM ynerr$ CALL sr850err(ynerr$) END SUB SUB sr850setupv1int '**************************************************************************** 'This subroutine sets up the SR850 lock-in amplifier for first harmonic 'measurements using the internal oscillator as the reference. ' 'Zachary Wolf '7/21/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Reset to the default configuration 'See p. 5-2 of the manual for the default settings CALL sr850ready CALL gpibout(sr850addrP$, "*RST") '**Changes to the reference/phase settings** 'Clear the reference unlocked status bit after the reference has been changed 'CALL sr850ready 'CALL gpibout(sr850addrP$, "LIAS?3") 'CALL sr850datready 'DIM bitval$ 'CALL gpibin(sr850addrP$, bitval$) '**Changes to the input/filters settings** '**Changes to the gain/time constant settings** 'The .1 s time constant should be adequate in most cases 'Set the time constant to 1 sec 'CALL sr850ready 'CALL gpibout(sr850addrP$, "OFLT10") 'Turn on the synchronous filter (f < 200 Hz) 'CALL sr850ready 'CALL gpibout(sr850addrP$, "SYNC1") 'Clear the filter overload status bit after the filter has been changed CALL sr850ready CALL gpibout(sr850addrP$, "LIAS?1") CALL sr850datready CALL gpibin(sr850addrP$, bitval$) '**Changes to the output/offset settings** '**Changes to the trace/scan settings** '**Changes to the display/scale settings** 'Set the top display to trace 3 (R) CALL sr850ready CALL gpibout(sr850addrP$, "DTRC1,3") 'Scale the top display range to 0 to 1 V (R) CALL sr850ready CALL gpibout(sr850addrP$, "DSCL1,1.0") 'Set the bottom display to trace 4 (theta) CALL sr850ready CALL gpibout(sr850addrP$, "DTRC2,4") 'Scale the BOTTOM display range to -180 to +180 degrees (theta) CALL sr850ready CALL gpibout(sr850addrP$, "DSCL2,180.") '**Changes to the aux output settings** '**Changes to the math settings** '**Changes to the system setup** 'Check for errors DIM ynerr$ CALL sr850err(ynerr$) END SUB SUB sr850v1reshigh '**************************************************************************** 'This subroutine is used to avoid overloading the input. It sets the input 'voltage range to 1V and the dynamic reserve to its maximum value. ' 'Zachary Wolf '8/19/97 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr850terminP$, sr850termoutP$) 'Set the input sensitivity to the highest range (1 V) CALL sr850ready CALL gpibout(sr850addrP$, "SENS26") 'Set the dynamic reserve to its maximum value CALL sr850ready CALL gpibout(sr850addrP$, "RMOD0") 'Let things settle SLEEP 1 END SUB