R3132 Series Spectrum Analyzer Operation Manual
4.2.10 Example Programs
4-58
Example VB-14: Read the trace data in ASCII format
Dim tr(1000) As String ’ Allocate an array in the buffer for 1001 points.
Dim i As Integer
Dim res As String
Call ibclr(spa) ’ Perform a device clear.
Call ibwrt(spa, "DL0") ’ CR LF EOI
Call ibwrt(spa, "DET NEG") ’ Set it to the negative detector.
Call ibwrt(spa, "TAA?")
For i = 0 To 1000 Step 1 ’ Repeat the operation for 1001 points.
tr(i) = Space(7) ’ Allocate a total of 7 bytes (5 bytes for the data, and 2 bytes for
’ delimiters).
Call ibrd(spa, tr(i)) ’ Read the data.
’ Output it to the screen.
res = res & "tr(" & Str(i) & ") = " & Left(tr(i), 5) & vbCrLf
DoEvents
Next i
RichTextBox1.Text = res
Example VB-15: Read the A memory data in binary format
Dim tr(1000) As Integer ’ Allocates an array in the buffer for 1001 points.
Dim i As Integer
Dim res As String
Call ibclr(spa) ’ Performs a device clear.
Call ibconfig(0, IbcEndBitIsNormal, 0) ’ Sets the GPIB-board software so that the End bit of the Ibsta
’ variables is set to 1 only when EOI has been received.
Call ibconfig(spa, IbcReadAdjust, 1) ’ Sets the spectrum analyzer so that the upper byte is swapped for
’ the lower byte during a read operation.
Call ibwrt(spa, "DL2") ’ Sets the delimiter to EOI only.
Call ibwrt(spa, "DET NEG") ’ Sets it to the negative detector.
Call ibwrt(spa, "TBA?") ’ Query for Trace A in binary data
Call ibrdi(spa, tr(), 1001 * 2) ’ Reads binary data for 1001 points.
For i = 0 To 1000 Step 1 ’ Repeats the operation for 1001 points.
res = res & Str(tr(i)) & vbCrLf ’ Outputs it to the screen.
DoEvents
Next i
RichTextBox1.Text = res
Call ibwrt(spa, "DL0") ’ Sets the delimiter to the CR, LF and EOI.
Call ibconfig(0, IbcEndBitIsNormal, 1) ’ Resets the GPIB software to the standard settings.
Call ibconfig(spa, IbcReadAdjust, 0)