R3132 Series Spectrum Analyzer Operation Manual
4.2.10 Example Programs
4-53
Example VB-10:
Reading the level and display unit and displaying them
Dim sep As Integer
Call ibclr(spa)
’ Performs a Device Clear.
Call ibwrt(spa, "RL?")
’ Query command for the reference level.
Rdbuff = Space(30)
’ Allocate the buffer memory space to 30 bytes.
Call ibrd(spa, Rdbuff)
’ Read the data (30 bytes Max.) from the spectrum analyzer.
sep = InStr(1, Rdbuff, vbCrLf, 0)
’ Check the number of characters prior to the delimiter.
RichTextBox1.Text = "RefLevel = " & Left(Rdbuff, sep - 1)
’ Display the data on the screen.
Call ibwrt(spa, "AUNITS?")
’ Query command for the level unit
Rdbuff = Space(3)
Call ibrd(spa, Rdbuff)
sep = InStr(1, Rdbuff, vbCrLf, 0)
’ Check the number of characters prior to the delimiter.
RichTextBox1.Text = RichTextBox1.Text & vbCrLf & "UNIT = " & Left(Rdbuff, sep - 1)
’ Display the previous result, followed by a return mark and the
’ most recent result.
An example display:
RefLevel = +0.00000000
UNIT = 0
Example VB-11:
Executing the 6 dB-down operation, reading the frequency and level and displaying
them
Dim sep As Integer
Call ibclr(spa)
’ Performs a Device Clear.
Call ibwrt(spa, "CF 30MZ")
’ Set the parameter.
Call ibwrt(spa, "SP 20MZ")
Call ibwrt(spa, "MKBW 6DB")
’ Set a 6 dB down measurement.
Call ibwrt(spa, "PS")
’ Peak search.
Call ibwrt(spa, "XDB")
’ Perform the 6 dB down measurement.
Call ibwrt(spa, "MFL?")
’ Query command for the marker level and frequency.
Rdbuff = Space(50)
’ Allocate the buffer memory space to 50 bytes.
Call ibrd(spa, Rdbuff)
’ Read the data (50 bytes Max.) from the spectrum analyzer.
sep = InStr(1, Rdbuff, vbCrLf, 0)
’ Check the number of characters prior to the delimiter.
RichTextBox1.Text = "Marker Freq & Level = " & Left(Rdbuff, sep - 1)
’ Display the data on the screen.
An example display:
Marker Freq & Level = +2.00000005, +1.02343700