R3132 Series Spectrum Analyzer Operation Manual
4.2.10 Example Programs
4-61
4.2.10.5 Program Examples Using the Status Byte
Example VB-18:
Execute single sweeping and wait until its finished (when not using SRQ)
Dim state As Integer
Call ibclr(spa)
’ Performs a Device Clear.
Call ibwrt(spa, "SI")
’ Turn the single sweep mode on.
Call ibwrt(spa, "OPR8")
’ Enables Sweep-end bit of operation status register
Call ibwrt(spa, "*CLS")
’ Clear the status byte.
Call ibwrt(spa, "SI")
’ Begin sweeping.
Do
Call ibwrt(spa, "*STB?")
’ Query command to read the status byte.
Rdbuff = Space(8)
’ Reserve a maximum of 8 bytes including the delimiter.
Call ibrd(spa, Rdbuff)
’ Read the data.
state = Val(Rdbuff)
’ Convert the character string into numeric values.
DoEvents
’ Check the loop for other events currently taking place.
Loop Until (state And 128)
’ Exit from the loop if the sweep-end bit is set to 1.
Example VB-19:
Reading the peak frequency and level at the end of a single sweep (when using SRQ)
Dim boardID As Integer
Dim I As Integer
Dim res As Integer
Dim CFLEV As String
boardID = 0
’ Set the board ID.
Call ibclr(spa)
’ Performs a Device Clear.
Call ibwrt(spa, "SI")
’ Turn the single sweep mode on.
Call ibwrt(spa, "*CLS")
’ Clear the status byte.
Call ibwrt(spa, "OPR 8")
’ Enables the Sweep-end bit of the operation status register
Call ibwrt(spa, "*SRE 128")
’ Enables the Operation status bit of the status byte.
Call ibwrt(spa, "S0")
’ Specify Send mode for the SRQ signal.
For I = 1 To 10 Step 1
’ A loop of 10 times
Call ibwrt(spa, "SI")
’ Begin sweeping
Call WaitSRQ(boardID, res)
’ Wait until SRQ interruption occurs.
Call ibrsp(spa, res)
’ Execute serial polling.
Call ibwrt(spa, "PS")
’ Execute the peak search.
Call ibwrt(spa, "MFL?")
’ Query for marker frequency and level
Rdbuff = Space(43)
’ Reserve 43 bytes.
Call ibrd(spa, Rdbuff)
’ Read the data.
CFLEV = Left(Rdbuff, InStr(1, Rdbuff, Chr(13), 0) - 1)
RichTextBox1.Text = RichTextBox1.Text & "Freq ,Lebel = " & CFLEV & vbCrLf
’ Display data on the screen and start a new line.
DoEvents
’ Execute other events in Windows if any.
Next I