R3132 Series Spectrum Analyzer Operation Manual
4.2.10 Example Programs
4-60
4.2.10.4 Example program using the TS (Take Sweep) command
Example VB-17:
An ACP measuremant is taken and then the measurement result is read (using the TS
command).
Dim state As Integer
Dim sep1 As Integer, sep2 As Integer
Dim i As Integer, j As Integer
Dim cnt As Integer
Dim LvlH As String, LvlL As String
Dim FrqH As String, FrqL As String
Call ibclr(spa)
’A device clear is carried out.
Call ibwrt(spa, "SI")
’Set the single mode.
Call ibwrt(spa, "CF 1500MZ")
’Set the center frequency to 1500 MHz.
Call ibwrt(spa, "SP 250KZ")
’Set the frequency span to 250 kHz.
Call ibwrt(spa, "RB 1KZ")
’Set RBW to 1 kHz.
Call ibwrt(spa, "VB 3KZ")
’Set VBW to 3 kHz.
Call ibwrt(spa, "ST 20SC")
’Set the sweep time to 20 sec.
Call ibwrt(spa, "CSBSDEL")
’Clear the channel space and bandwidth previously set.
Call ibwrt(spa, "CSBSIN 50KZ,21KZ")
’Set CS to 50 kHz, and BS to 21 kHz.
Call ibwrt(spa, "OPR 256")
’The Avereaging bit of the operation register is set
’to ENABLE.
Call ibwrt(spa, "*CLS")
’Clear STATUS byte
Call ibwrt(spa, "S0")
’SRQ is enabled.
Call ibwrt(spa, "ACP ON")
’Start the ACP measurement.
For j = 1 To 10 Step 1
Call ibwrt(spa, "TS")
’Execute one sweep.
Call ibwrt(spa, "ACP?")
’The ACP measurement result has been requested.
Rdbuff = Space(3)
’Assign an area for 1 byte of integer and 2 bytes of delimiter prior
to reading the result.
Call ibrd(spa, Rdbuff)
’Read the data.
cnt = CInt(Rdbuff)
’Convert the contents of the buffer into integer type data.
For i = 1 To cnt Step 1
Rdbuff = Space(81)
’Assign an area of 81 bytes (Real number x 4 + ’,’ x 3 + CRLF).
Call ibrd(spa, Rdbuff)
’Read the data.
sep1 = InStr(1, Rdbuff, ",", 0)
’Search for the first comma starting from the top of the buffer.
FrqL = Left(Rdbuff, sep1 - 1)
’Read the string between the top and the character string.
sep2 = InStr(sep1 + 1, Rdbuff, ",", 0)
’Search for the next comma.
LvlL = Mid(Rdbuff, sep1 + 1, sep2 - sep1 - 1)
’Read the string between the first and second separators (com-
mas).
sep1 = InStr(sep2 + 1, Rdbuff, ",", 0)
’Search for the third comma.
FrqH = Mid(Rdbuff, sep2 + 1, sep1 - sep2 - 1)
’Read the string between the second and third separators (com-
mas).
sep2 = InStr(sep1, Rdbuff, Chr(13), 0)
’Search for the terminator (CR).
LvlL = Mid(Rdbuff, sep1 + 1, sep2 - sep1 - 1)
’Read the string between the separators (third comma and CR).
’Displays the result on the screen.
RichTextBox1.Text = RichTextBox1.Text & FrqL & "Hz;" & LvlL & vbCrLf
RichTextBox1.Text = RichTextBox1.Text & FrqH & "Hz;" & LvlL & vbCrLf
Next i
DoEvents
Next j