R3267 Series Spectrum Analyzer Operation Manual (Vol.1)
5.2.10 Example Programs
5-57
For i = 1 To cnt Step 1
Rdbuff = Space(81)
’ Allocate a total of 81 bytes: 19
×
4 bytes real number (Max.) + ’,’
’
×
3 + CRLF.
Call ibrd(spa, Rdbuff)
’ Read the data.
sep1 = InStr(1, Rdbuff, ",", 0)
’ Search for the item separator (this is a comma) from the head of
’ the buffer.
LOF = Left(Rdbuff, sep1 - 1)
’ Read the character strings between the head of the buffer and the
’ separator.
sep2 = InStr(sep1 + 1, Rdbuff, ",", 0)
’ Search for the next item separator (this is a comma).
LOL = Mid(Rdbuff, sep1 + 1, sep2 - sep1 - 1) ’ Read the strings between the separators.
sep1 = InStr(sep2 + 1, Rdbuff, ",", 0)
’ Search for the next item separator (this is a comma).
UPF = Mid(Rdbuff, sep2 + 1, sep1 - sep2 - 1)
’ Read the strings between the separators.
sep2 = InStr(sep1, Rdbuff, Chr(13), 0)
’ Search for the next item separator (this is the CR).
UPL = Mid(Rdbuff, sep1 + 1, sep2 - sep1 - 1)
’ Read the strings between the separators.
RichTextBox1.Text = LOF & " Hz: " & LOL & vbCrLf & UPF & " Hz: " & UPL & vbCrLf
’ Output the screen.
DoEvents
Next i
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 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.