R3267 Series Spectrum Analyzer Operation Manual (Vol.1)
5.2.10 Example Programs
5-56
5.2.10.4 Program Examples Using the Status Byte
Example VB-17: 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-18:Measure CW-ACP, and read the measurements (When not using SRQ signals)
Dim state As Integer
Dim sep1 As Integer, sep2 As Integer
Dim UPF As String, LOF As String, UPL As String, LOL As String
Dim i As Integer
Dim cnt As Integer
Call ibclr(spa)
’ Perform a device clear.
Call ibwrt(spa, "ACPST MNL")
’ Set ACP measurement conditions manually.
Call ibwrt(spa, "CF 1500MZ")
’ Set a center frequency of 1.5 GHz.
Call ibwrt(spa, "SP 250KZ")
’ Set a span of 250 kHz.
Call ibwrt(spa, "RB 1KZ")
’ Set an RBW of 1 kHz.
Call ibwrt(spa, "VB 3KZ")
’ Set a VBW of 3 kHz.
Call ibwrt(spa, "ST 20SC")
’ Set a sweep time of 20 sec.
Call ibwrt(spa, "CSBSDEL")
’ Clear the channel space and bandwidth previously set.
Call ibwrt(spa, "CSBSIN 50KZ,21KZ")
’ Set a channel space of 50 kHz and a bandwidth of 21 kHz.
Call ibwrt(spa, "OPR 16")
’ Set Measuring bit of Operation Status Register to Enabled.
Call ibwrt(spa, "*CLS")
’ Clear the status byte.
Call ibwrt(spa, "ACP ON")
’ Start the ACP measurement.
Do
Call ibwrt(spa, "*STB?")
’ Query for the status byte.
Rdbuff = Space(8)
’ Allocate 8 bytes.
DoEvents
Call ibrd(spa, Rdbuff)
’ Read the data.
state = Val(Rdbuff)
’ Convert the data in ASCII format into binary format.
DoEvents
’ Execute other events in Windows at this time.
Loop Until (state And 128)
’ Return to the Do statement until the Measuring bit is set to 1.
Call ibwrt(spa, "ACP?")
’ Query for an ACP measurement result.
Rdbuff = Space(3)
’ Allocate a total of 3 bytes: 1 byte for integer and 2 bytes for
’ delimiter.
Call ibrd(spa, Rdbuff)
’ Read the data.
cnt = CInt(Rdbuff)
’ Convert the buffer contents into integer-type data.