• 易迪拓培训,专注于微波、射频、天线设计工程师的培养
首页 > 测试测量 > 网络分析仪使用手册 > E5071C > 读出二进制格式的数据

读出二进制格式的数据

录入:edatop.com    点击:
  • 概述

  • 在Excel VBA中的样本程序

  • 在HT Basic中的样本程序


概述

这个样本程序说明如何获取二进制交换格式的格式化数据序列。

这个程序保持通道1上扫描,然后获取并显示激励序列。

参见这个程序的检索测量结果。

在Excel VBA中的样本程序

Sub read_bin_Click()

    Dim defrm As Long

    Dim vi As Long

    Dim Result As String * 10000

    Dim Res() As Double

    Dim Nop As Long

    Const TimeOutTime = 10000

    ' Open Analyzer

    Call viOpenDefaultRM(defrm)

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

    Call viSetAttribute(vi, VI_ATTR_TMO_VALUE, TimeOutTime)

    '

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

    Call viVPrintf(vi, ":INIT1:CONT OFF" + vbLf, 0)

    Call viVPrintf(vi, ":ABOR" + vbLf, 0)

    '

    ' Reading out Measurement Frequency Data in Binary transfer format

    Call viVPrintf(vi, ":FORM:DATA REAL" + vbLf, 0)

    Call viVPrintf(vi, ":CALC1:DATA:FDAT?" + vbLf, 0)

    Call Scpi_read_binary_double_array(vi, Res, Nop)

    '

    ' Write data in cells of Excel

    Range("A6:D1607").Clear

    For i = 0 To Nop - 1

        j = i Mod 2

        k = i 2

        Cells(k + 6, j + 3).Value = Res(i)

    Next i

    '

    ' Read out Measurement Frequency Data in Binary transfer format

    Call viVPrintf(vi, ":SENS1:FREQ:DATA?" + vbLf, 0)

    Call Scpi_read_binary_double_array(vi, Res, Nop)

    '

    ' Write data in cells of Excel

    For i = 0 To Nop - 1

        Cells(i + 6, 1) = i + 1

        Cells(i + 6, 2).Value = Res(i)

    Next i

    ' Close

    Call viClose(vi)

    Call viClose(defrm)

End Sub

    '===================================

    ' BinaryAry Read Subroutine

    '===================================

Sub Scpi_read_binary_double_array(vi As Long, data() As Double, Nop As Long)

    Dim dblArray(10000) As Double

    Dim paramsArray(3) As Long

    Dim err As Long

    Dim i As Long

    Dim lf_eoi As String * 1

    

    Nop = UBound(dblArray) - LBound(dblArray) + 1

    paramsArray(0) = VarPtr(Nop)

    paramsArray(1) = VarPtr(dblArray(0))

    err = viVScanf(vi, "%#Zb%1t", paramsArray(0))

    If err <> 0 Then MsgBox "Binary Error"

    

    ReDim data(Nop - 1)

    For i = 0 To Nop - 1

        data(i) = dblArray(i)

    Next

End Sub

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

10 REAL Fdata(1:1601,1:2),Freq(1:1601)

20 DIM Buff$[9],Img$[30]

30 INTEGER Nop,I

40 !

50 ASSIGN @Agte507x TO 717

60 ASSIGN @Binary TO 717;FORMAT OFF

70 !

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

90 OUTPUT @Agte507x;":INIT1:CONT OFF"

100 OUTPUT @Agte507x;":ABOR"

110 OUTPUT @Agte507x;":SENS1:SWE:POIN?"

120 ENTER @Agte507x;Nop

130 REDIM Fdata(1:Nop,1:2),Freq(1:Nop)

140 !

150 ! Reading out in binary transfer format

160 !

170 OUTPUT @Agte507x;":FORM:DATA REAL"

180 !

190 OUTPUT @Agte507x;":CALC1:DATA:FDAT?"

200 ENTER @Agte507x USING "#,8A";Buff$

210 ENTER @Binary;Fdata(*)

220 ENTER @Agte507x USING "#,1A";Buff$

230 OUTPUT @Agte507x;":SENS1:FREQ:DATA?"

240 ENTER @Agte507x USING "#,8A";Buff$

250 ENTER @Binary;Freq(*)

260 ENTER @Agte507x USING "#,1A";Buff$

270 !

280 ! Displaying

290 !

300 OUTPUT @Agte507x;":CALC1:FORM?"

310 ENTER @Agte507x;Fmt$

320 SELECT Fmt$

330 CASE "MLOG","PHAS","GDEL","MLIN","SWR","REAL","IMAG","UPH"

340 Img$="MD.4DE,2X,MD.6DE"

350 PRINT " Frequency Data"

360 FOR I=1 TO Nop

370 PRINT USING Img$;Freq(I),Fdata(I,1)

380 NEXT I

390 CASE ELSE

400 Img$="MD.4DE,2X,MD.6DE,2X,MD.6DE"

410 PRINT " Frequency Data1 Data2"

420 FOR I=1 TO Nop

430 PRINT USING Img$;Freq(I),Fdata(I,1),Fdata(I,2)

440 NEXT I

450 END SELECT

460 !

470 END

矢量网络分析仪使用培训教程套装,让你快速掌握网分使用

上一篇:读/写差错系数
下一篇:读出ASCII格式的数据

微波射频测量操作培训课程详情>>
射频和天线工程师培训课程详情>>

  网站地图