Other topics about Sample Programs
The sample program demonstrates how to perform Bandwidth Search.
The sample program moves the marker to the maximum value position and then retrieves and displays the results of Bandwidth Search.
Dim ioMgr As VisaComLib.ResourceManager
Dim Ena As VisaComLib.FormattedIO488
Sub Bandwid_Click()
Dim Bdata As Variant
Dim Dummy As Integer
Const Threshhold = -3
'
'*** The memory area of the resource manager and the instrument I/O are acquired.
Set ioMgr = New VisaComLib.ResourceManager
Set Ena = New VisaComLib.FormattedIO488
'
'*** Open the instrument.
Set Ena.IO = ioMgr.Open("GPIB0::17::INSTR")
Ena.IO.timeout = 10000
'
Ena.WriteString ":SYST:PRES", True ' Preset
'
Ena.WriteString ":SENS1:FREQ:CENT 947.5E6", True ' Set the center frequency
Ena.WriteString ":SENS1:FREQ:SPAN 200E6", True ' Set the span
Ena.WriteString ":CALC1:PAR1:DEF S21", True ' Set the measurement parameter
Ena.WriteString ":CALC1:PAR1:SEL", True ' Select trace 1
Ena.WriteString ":INIT1:CONT ON", True ' Set the trigger mode at continuous
Ena.WriteString ":TRIG:SOUR BUS", True ' Set the trigger source at BUS
'
Ena.WriteString ":TRIG:SING", True ' Make a single trigger
Ena.WriteString "*OPC?", True ' Wait the measurement end
Dummy = Ena.ReadNumber
'
Ena.WriteString ":DISP:WIND1:TRAC1:Y:AUTO", True ' Execute auto scale for trace 1
Ena.WriteString ":CALC1:MARK1 ON", True ' Activate Marker 1
Ena.WriteString ":CALC1:MARK1:FUNC:TYPE MAX", True ' Set marker search type at max
Ena.WriteString ":CALC1:MARK1:FUNC:EXEC", True ' Execute market search to move the marker at the maximum point
Ena.WriteString ":CALC1:MARK1:BWID:THR " + CStr(Threshhold), True ' Set bandwidth value
Ena.WriteString ":CALC1:MARK:BWID ON", True ' Turn on bandwidth
Ena.WriteString ":CALC1:MARK1:BWID:DATA?", True ' Read bandwidth result
Bdata = Ena.ReadList(ASCIIType_R8, ",")
'
Call ErrorCheck
'
Cells(5, 2).Value = Bdata(0)
Cells(6, 2).Value = Bdata(1)
Cells(7, 2).Value = Bdata(2)
Cells(8, 2).Value = Bdata(3)
Ena.IO.Close
End Sub
Sub ErrorCheck()
Dim Err As Variant
Dim Response As String
Ena.WriteString ":SYST:ERR?", True
Err = Ena.ReadList
If Val(Err(0)) <> 0 Then
Response = MsgBox(CStr(Err(1)), vbOKOnly)
End If
End Sub