Other topics about Processing Measurement Results
The program listed in the below section is written in VISA-COM with Excel VBA. It can be executed from the external PC controller. The program demonstrates how to search peak.
Dim ioMgr As VisaComLib.ResourceManager
Dim Ana As VisaComLib.FormattedIO488
Sub PeakSearch_Click()
Range("B6:I30").Clear
Dim Excursion As Double
Dim Freq As Double, Resp As Variant, PeakPoint As Variant
Dim Poin As Long, Stat As Long, Dummy As Long
Excursion = 1
Set ioMgr = New VisaComLib.ResourceManager
Set Ana = New VisaComLib.FormattedIO488
'
'*** Open the instrument.
Set Ana.IO = ioMgr.Open("GPIB0::17::INSTR")
Ana.IO.timeout = 10000
'
' Setup Analyzer
Ana.WriteString ":INIT:CONT ON", True
Ana.WriteString ":TRIG:SOUR BUS", True
' Make a Measurement
Ana.WriteString ":TRIG:SING", True
Ana.WriteString "*OPC?", True
' Wait measurement end
Dummy = Ana.ReadNumber
' Auto scale
Ana.WriteString ":DISP:WIND1:TRAC1:Y:AUTO", True
' Example of Marker Peak Search
Ana.WriteString ":CALC1:MARK:FUNC:DOM ON", True
Ana.WriteString ":CALC1:MARK:FUNC:DOM:STAR 1E6", True
Ana.WriteString ":CALC1:MARK:FUNC:DOM:STOP 1E7", True
' Search type: peak
Ana.WriteString ":CALC1:MARK1:FUNC:TYPE PEAK", True
' Set peak excursion
Ana.WriteString ":CALC1:MARK1:FUNC:PEXC " & Str(Excursion), True
' Peak Polarity: Positive
Ana.WriteString ":CALC1:MARK1:FUNC:PPOL POS", True
' Execute search
Ana.WriteString ":CALC1:MARK1:FUNC:EXEC", True
' Call ErrorCheck
' Read marker stimulus value
Ana.WriteString ":CALC1:MARK1:X?", True
Freq = Ana.ReadNumber
' Read marker value
Ana.WriteString ":CALC1:MARK1:Y?", True
Resp = Ana.ReadList
Cells(6, 2).Value = Val(Freq)
' Display real part of result.
Cells(6, 3).Value = Resp(0)
'
' Example of All Peak Search
Ana.WriteString ":CALC1:FUNC:DOM ON", True
Ana.WriteString ":CALC1:FUNC:DOM:STAR 1E6", True
Ana.WriteString ":CALC1:FUNC:DOM:STOP 1E7", True
' Search type: all peak
Ana.WriteString ":CALC1:FUNC:TYPE APEAK", True
' Set peak excursion
Ana.WriteString ":CALC1:FUNC:PEXC " & Str(Excursion), True
' Peak Polarity: positive
Ana.WriteString ":CALC1:FUNC:PPOL POS", True
' Execute search
Ana.WriteString ":CALC1:FUNC:EXEC", True
Ana.WriteString "*OPC?", True
Dummy = Ana.ReadNumber
Call ErrorCheck
' Read value
Ana.WriteString ":CALC1:FUNC:POIN?", True
Poin = Ana.ReadNumber
' Read stimulus point number
Ana.WriteString ":CALC1:FUNC:DATA?", True
PeakPoint = Ana.ReadList '
j = 0
For i = 1 To Poin
Cells(5 + i, 5).Value = Val(PeakPoint(j))
Cells(5 + i, 6).Value = Val(PeakPoint(j + 1))
j = j + 2
Next i
'
' Example of Multi Peak Search
Ana.WriteString ":CALC1:MARK:FUNC:MULT:TYPE PEAK", True
Ana.WriteString ":CALC1:MARK:FUNC:MULT:PEXC " & Str(Excursion), True
Ana.WriteString ":CALC1:MARK:FUNC:MULT:PPOL POS", True
Ana.WriteString ":CALC1:MARK:FUNC:EXEC", True
Ana.WriteString "*OPC?", True
Dummy = Ana.ReadNumber
Call ErrorCheck
For i = 1 To 9
' Check if marker is active.
Ana.WriteString ":CALC1:MARK" & i & "?", True
Stat = Ana.ReadNumber
If Stat = 1 Then
' Read marker stimulus value
Ana.WriteString ":CALC1:MARK" & i & ":X?", True
Freq = Ana.ReadNumber
' Read marker value
Ana.WriteString ":CALC1:MARK" & i & ":Y?", True
Resp = Ana.ReadList
Cells(5 + i, 8).Value = Val(Freq)
Cells(5 + i, 9).Value = Resp(0)
End If
Next i
Ana.IO.Close
'
End Sub
Sub ErrorCheck()
Dim err As Variant
' Reads error message.
Ana.WriteString ":SYST:ERR?", True
err = Ana.ReadList
If Val(err(0)) <> 0 Then
' Display the message box.
Response = MsgBox(CStr(err(1)), vbOKOnly)
End If
End Sub