带宽搜索

E5071C

带宽搜索

有关样本程序的其他主题

概述

样本程序示范了如何执行带宽搜索。

此样本程序将标记移动到最大值的位置,然后检索并显示带宽搜索的结果。

有关此程序的详情,请参见带宽搜索

在Excel VBA中的样本程序

Sub Bandwid_click()

    Dim vi As Long

    Dim defrm As Long

    Dim Threshhold As Long

    Dim Result As String * 1000

    Dim Bdata As Variant

    Const TimeOutTime = 10000

    Call viOpenDefaultRM(defrm)

    Call viOpen(defrm, "GPIB0::17::INSTR", 0, 0, vi)

    Call viSetAttribute(vi, VI_ATTR_TMO_VALUE, TimeOutTime)

    Threshhold = -3

    Call viVPrintf(vi, ":SENS1:FREQ:CENT 947.5E6" & vbLf, 0)

    Call viVPrintf(vi, ":SENS1:FREQ:SPAN 200E6" & vbLf, 0)

    Call viVPrintf(vi, ":CALC1:PAR1:DEF S21" & vbLf, 0)

    Call viVPrintf(vi, ":DISP:WIND1:TRAC1:Y:AUTO" & vbLf, 0)

    Call viVPrintf(vi, ":CALC1:PAR1:SEL" & vbLf, 0)

    Call viVPrintf(vi, ":CALC1:MARK1:FUNC:TYPE MAX" & vbLf, 0)

    Call viVPrintf(vi, ":CALC1:MARK1:FUNC:EXEC" & vbLf, 0)

    Call viVPrintf(vi, ":CALC1:MARK1:BWID:THR " + CStr(Threshhold) & vbLf, 0)

    Call viVPrintf(vi, ":CALC1:MARK1:BWID:DATA?" & vbLf, 0)

    Call viVScanf(vi, "%t", Result)

    Bdata = Split(Result, ",")

    Call ErrorCheck(vi)

    Cells(5, 2).Value = Val(Bdata(0))

    Cells(6, 2).Value = Val(Bdata(1))

    Cells(7, 2).Value = Val(Bdata(2))

    Cells(8, 2).Value = Val(Trim(Bdata(3)))

    Call viClose(vi)

    Call viClose(defrm)

 

End Sub

Sub ErrorCheck(vi)

    Dim err As String * 50, ErrNo As Variant, Response

    Call viVQueryf(vi, ":SYST:ERR?" & vbLf, "%t", err)

    ErrNo = Split(err, ",")

    If Val(ErrNo(0)) <> 0 Then

        Response = MsgBox(CStr(ErrNo(1)), vbOKOnly)

    End If

End Sub

在HT Basic中的样本程序(带宽.htb)

10 DIM Buff$[9],Err_msg$[100]

20 REAL Threshold,Bwid,Cent,Q,Loss

30 INTEGER Err_no

40 !

50 ASSIGN @Agte507x TO 717

60 Threshold=-3

70 !

80 OUTPUT @Agte507x;"*ESE 60"

90 OUTPUT @Agte507x;"*SRE 32"

100 OUTPUT @Agte507x;"*CLS"

110 OUTPUT @Agte507x;"*OPC?"

120 ENTER @Agte507x;Buff$

130 ON INTR 7 GOTO Err

140 ENABLE INTR 7;2

150 !

160 OUTPUT @Agte507x;":CALC1:PAR1:SEL"

170 OUTPUT @Agte507x;":CALC1:MARK1:FUNC:TYPE MAX"

180 OUTPUT @Agte507x;":CALC1:MARK1:FUNC:EXEC"

190 OUTPUT @Agte507x;":CALC1:MARK1:BWID:THR ";Threshold

200 OUTPUT @Agte507x;":CALC1:MARK1:BWID:DATA?"

210 WAIT .5

220 ENTER @Agte507x;Bwid,Cent,Q,Loss

230 !

240 PRINT "## Bandwidth Search ##"

250 PRINT "Bandwidth : ",Bwid

260 PRINT "Center Frequency: ",Cent

270 PRINT "Q : ",Q

280 PRINT "Loss : ",Loss

290 !

300 GOTO No_err

310 Err: OFF INTR 7

320 OUTPUT @Agte507x;";:SYST:ERR?"

330 ENTER @Agte507x;Err_no,Err_msg$

340 PRINT "Error occurred!!"

350 PRINT " No:";Err_no,"Description: "&Err_msg$

360 No_err: OFF INTR 7

370 END