'**************************************************************************** 'Module SR770 'This module contains subroutines to control the SR770 FFT Network 'Analyzer. ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Common area for shared parameters COMMON SHARED /sr770/ gpibinP%, gpiboutP%, sr770addrP$ 'Semi-permanent parameters CONST sr770terminP$ = "LF" CONST sr770termoutP$ = "LF" SUB sr770autorange '**************************************************************************** 'This subroutine performs an autorange on the input of the SR770. ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr770terminP$, sr770termoutP$) 'Autorange CALL gpibout(sr770addrP$, "ARNG1") END SUB SUB sr770autoscale (trace%) '**************************************************************************** 'This subroutine performs an auto scale on a given trace of the SR770. ' 'Input: ' trace%, trace number, 0, 1, or -1 (active trace) ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr770terminP$, sr770termoutP$) 'Auto Scale CALL gpibout(sr770addrP$, "AUTS" + LTRIM$(STR$(trace%))) END SUB SUB sr770getdat (trace%, spectrum!()) '**************************************************************************** 'This subroutine gets the 400 data points in the trace of interest from 'the spectrum analyzer. ' 'Input: ' trace%, trace number, 0, 1, or -1 (active trace) ' 'Output: ' spectrum!(0 to 399), array for the data values ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr770terminP$, sr770termoutP$) 'Loop over the data points FOR i% = 0 TO 399 CALL gpibout(sr770addrP$, "SPEC" + LTRIM$(STR$(trace%)) + "," + LTRIM$(STR$(i%))) CALL gpibin(sr770addrP$, value$) spectrum!(i%) = VAL(value$) NEXT i% END SUB SUB sr770init '**************************************************************************** 'This subroutine initializes the SR770. ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr770terminP$, sr770termoutP$) 'Message PRINT PRINT "Resetting the SR770 FFT Network Analyzer..." 'Reset the Analyzer CALL gpibout(sr770addrP$, "*RST") SLEEP 2 'Set the output interface to GPIB CALL gpibout(sr770addrP$, "OUTP1") 'Allow the front panel controls to continue to function CALL gpibout(sr770addrP$, "OVRM1") 'Display the instrument ID CALL gpibout(sr770addrP$, "*IDN?") CALL gpibin(sr770addrP$, msg$) PRINT msg$ END SUB SUB sr770pausecont '**************************************************************************** 'This subroutine pauses measurements by the SR770. The next time it is 'called, it continues the measurements. It does the equivalent of toggling 'the pause/continue switch on the front panel. ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr770terminP$, sr770termoutP$) 'Pause CALL gpibout(sr770addrP$, "STCO") END SUB SUB sr770setpar (gpibin%, gpibout%, sr770addr$) '**************************************************************************** 'This subroutine initializes the SR770. ' 'Input: ' gpibin%, gpib input file number ' gpibout%, gpib output file number ' sr770addr$, gpib address in a string ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Make sure the input parameters have reasonable values IF gpibin% < 0 OR gpibin% > 100 THEN PRINT "SR770: GPIB problem" EXIT SUB END IF IF gpibout% < 0 OR gpibout% > 100 THEN PRINT "SR770: GPIB problem" EXIT SUB END IF IF sr770addr$ = "" THEN PRINT "SR770: GPIB problem" EXIT SUB END IF 'Save the GPIB information in a common block for future use gpibinP% = gpibin% gpiboutP% = gpibout% sr770addrP$ = sr770addr$ END SUB SUB sr770setupdisp (atrace%, format%) '**************************************************************************** 'This subroutine sets the display settings for the SR770. ' 'Input: ' atrace%, active trace number, 0, 1 ' format%, integer giving the display format, 0 = single, 1 = up/dwn ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr770terminP$, sr770termoutP$) 'Set the active trace CALL gpibout(sr770addrP$, "ACTG" + LTRIM$(STR$(atrace%))) 'Set the display format CALL gpibout(sr770addrP$, "FMTS" + LTRIM$(STR$(format%))) END SUB SUB sr770setupfreq (span%, startf!) '**************************************************************************** 'This subroutine sets the frequency settings for the SR770. ' 'Input: ' span%, integer giving the span setting, see p. 6-4 of the manual ' startf!, start frequency of the span ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr770terminP$, sr770termoutP$) 'Set the span CALL gpibout(sr770addrP$, "SPAN" + LTRIM$(STR$(span%))) 'Set the start frequency CALL gpibout(sr770addrP$, "STRF" + LTRIM$(STR$(startf!))) END SUB SUB sr770setupinput (config%, gnd%, coupl%, rngdbv%) '**************************************************************************** 'This subroutine sets the scale settings for the SR770. ' 'Input: ' config%, input configuration, 0 = A, 1 = A-B ' gnd%, ground configuration, 0 = float, 1 = ground ' coupl%, input coupling, 0 = AC, 1 = DC ' rngdbv%, input range in dBV, -60 to 34 ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr770terminP$, sr770termoutP$) 'Set the input configuration CALL gpibout(sr770addrP$, "ISRC" + LTRIM$(STR$(config%))) 'Set the input ground configuration CALL gpibout(sr770addrP$, "IGND" + LTRIM$(STR$(gnd%))) 'Set the input coupling CALL gpibout(sr770addrP$, "ICPL" + LTRIM$(STR$(coupl%))) 'Set the input range CALL gpibout(sr770addrP$, "IRNG" + LTRIM$(STR$(rngdbv%))) 'Perform an offset adjustment PRINT PRINT "Performing an input offset calibration..." PRINT "This will take about 10 seconds." CALL gpibout(sr770addrP$, "AOFF") SLEEP 11 'Turn off auto offset CALL gpibout(sr770addrP$, "AOFM0") END SUB SUB sr770setupmeas (trace%, meas%, disp%, units%, wndo%) '**************************************************************************** 'This subroutine sets the measurement settings for the SR770. ' 'Input: ' trace%, trace number, 0, 1, or -1 (active trace) ' meas%, integer giving the measurement type, see p. 6-5 of the manual ' disp%, integer giving the display type, see p. 6-5 of the manual ' units%, integer giving the display units, see p. 6-5 of the manual ' wndo%, integer giving the window type, see p. 6-5 of the manual ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr770terminP$, sr770termoutP$) 'Set the measurement type CALL gpibout(sr770addrP$, "MEAS" + LTRIM$(STR$(trace%)) + "," + LTRIM$(STR$(meas%))) 'Set the display type CALL gpibout(sr770addrP$, "DISP" + LTRIM$(STR$(trace%)) + "," + LTRIM$(STR$(disp%))) 'Set the units CALL gpibout(sr770addrP$, "UNIT" + LTRIM$(STR$(trace%)) + "," + LTRIM$(STR$(units%))) 'Set the window type CALL gpibout(sr770addrP$, "WNDO" + LTRIM$(STR$(trace%)) + "," + LTRIM$(STR$(wndo%))) END SUB SUB sr770setupscale (trace%, yperdiv!, topval!) '**************************************************************************** 'This subroutine sets the scale settings for the SR770. ' 'Input: ' trace%, trace number, 0, 1, or -1 (active trace) ' yperdiv!, vertical scale units per division ' topval!, vertical scale top value ' 'Zachary Wolf '2/27/96 '**************************************************************************** 'Set the GPIB terminators CALL gpibterm(sr770terminP$, sr770termoutP$) 'Set the Y units per division CALL gpibout(sr770addrP$, "YDIV" + LTRIM$(STR$(trace%)) + "," + LTRIM$(STR$(yperdiv!))) 'Set the upper value of the Y scale CALL gpibout(sr770addrP$, "TREF" + LTRIM$(STR$(trace%)) + "," + LTRIM$(STR$(topval!))) END SUB