• 易迪拓培训,专注于微波、射频、天线设计工程师的培养

分析仪设置

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

  • 在Excel VBA中的样本程序

  • 在HT Basic中的样本程序


概述

本部分所列的程序是示范如何配置测量条件的样本程序。

样本程序将仪器置于预置状态,如下表所示将其配置,并将设置保存到名为sample.sta的文件中。

有关此程序的详情,请参见分析仪设置。

目标设置

项目

设置

窗口布局

通道1在窗口上方(屏幕高度的2/3),通道2在窗口下方(屏幕高度的1/3)

通道1

扫描类型

分段

扫描范围

参见分段表

测量点的数量

中频带宽

功率

迹线数量

4

图形布局

4个图形分布在左上方、右上方、左下方和右下方。

迹线1

测量参数

S11

数据格式

Smith图形(Lin)

满量程值

2

迹线2

测量参数

S21

数据格式

对数幅度

参考间隔行号

9

参考间隔行的值

2

每间隔的量程

10 dBm

迹线3

测量参数

S12

测量参数

对数幅度

参考间隔行号

9

参考间隔行的值

2

每间隔的量程

10 dBm

迹线4

测量参数

S22

数据格式

Smith图形(Lin)

满量程值

2

通道2

扫描类型

线性

扫描范围

中间值

1.9 GHz

扫宽值

500 MHz

测量点的数量

101

中频带宽

70 kHz

功率

0 dBm

迹线数量

4

图形布局

两个图形分布在左,两个图形分布在右

迹线1

测量参数

S21

数据格式

对数幅度

参考间隔行号

9

参考间隔行的值

2

每间隔量程

10 dBm

迹线2

测量参数

S22

数据格式

Smith图形Lin)

满量程值

2

通道1的分段表

分段数量

起始值

终止值

测量点的数量

中频带宽

功率

1

1.7 GHz

1.9 GHz

21

50 kHz

0 dBm

2

1.9 GHz

2 GHz

101

10 kHz

-10 dBm

3

2 GHz

2.2 GHz

21

50 kHz

0 dBm

在Excel VBA中的样本程序

 Sub Setup()

     '

    Dim defrm As Long          

    Dim vi As Long

    Const TimeOutTime = 20000

    

    Dim Allocate1 As String, Allocate2 As String, File As String

    Dim Para1(4) As String, Para2(2) As String

    Dim Fmt1(4) As String, Fmt2(2) As String

    Dim Star1(3) As String, Stop1(3) As String

    Dim IfBw1(3) As Double, IfBw2 As Double

    Dim Power1(3) As Double, Power2 As Double

    Dim Cent2 As Double, Span2 As Double

    Dim RefLev1(4) As Double, RefLev2(2) As Double, Scale1(4) As Double, Scale2(2) As Double

    Dim Segm As Integer, Nop1(3) As Integer, Nop2 As Integer

    Dim NumOfTr1 As Integer, NumOfTr2 As Integer

    Dim RefPos1(4) As Integer, RefPos2(2) As Integer

    Dim SendData As String

    '

    Segm = 3 ' Number of Segment Ch.1 : 3

    Star1(1) = "1.7E9"      ' Start Frequency Ch.1 Segm.1: 1.7 GHz

    Star1(2) = "1.9E9"      ' Segm.2: 1.9 GHz

    Star1(3) = "2E9"        ' Segm.3: 2 GHz

    Stop1(1) = "1.9E9"      ' Stop Frequency Ch.1 Segm.1: 1.9 GHz

    Stop1(2) = "2E9"        ' Segm.2: 2 GHz

    Stop1(3) = "2.2E9"      ' Segm.3: 2.2 GHz

    Cent2 = 1900000000#     ' Center Frequency Ch.2 : 1.9 GHz

    Span2 = 500000000#      ' Span Ch.2 : 500 MHz

    Nop1(1) = 21            ' Number of points Segm.1: 21

    Nop1(2) = 101           '               Segm.2: 101

    Nop1(3) = 21            '               Segm.3: 21

    Nop2 = 101              '       Ch.2 : 101

    IfBw1(1) = 50000#       ' IFBW  Ch.1    Segm.1: 50 kHz

    IfBw1(2) = 10000#       '               Segm.2: 10 kHz

    IfBw1(3) = 50000#       '               Segm.3: 50 kHz

    IfBw2 = 70000#          '       Ch.2 : 70 kHz

    Power1(1) = 0           ' Power Ch.1    Segm.1: 0 dBm

    Power1(2) = -10         '               Segm.2: -10 dBm

    Power1(3) = 0           '               Segm.3: 0 dBm

    Power2 = 0              '       Ch.2 : 0 dBm

    NumOfTr1 = 4            ' Number of Trace Ch.1 : 4

    NumOfTr2 = 2            ' Ch.2 : 2

    Allocate1 = "D12_34"    ' Allocate Traces Ch.1 : D12_34

    Allocate2 = "D12"       ' Ch.2 : D12

    Para1(1) = "S11"        ' Measurement Ch.1 Trace1: S11

    Para1(2) = "S21"        ' Parameter Trace2: S21

    Para1(3) = "S12"        ' Trace3: S12

    Para1(4) = "S22"        ' Trace4: S22

    Para2(1) = "S31"        ' Ch.2 Trace1: S31

    Para2(2) = "S33"        ' Trace2: S33

    Fmt1(1) = "SLIN"        ' Data Format Ch.1 Trace1: Smith(Lin/Phase)

    Fmt1(2) = "MLOG"        ' Trace2: Log Mag

    Fmt1(3) = "MLOG"        ' Trace3: Log Mag

    Fmt1(4) = "SLIN"        ' Trace4: Smith(Lin/Phase)

    Fmt2(1) = "MLOG"        ' Ch.2 Trace1: Log Mag

    Fmt2(2) = "SLIN"        ' Trace2: Smith(Lin/Phase)

    RefPos1(1) = 9          ' Reference Ch.1 Trace2: 9

    RefPos1(2) = 9          ' Position Trace3: 9

    RefPos2(1) = 9          ' Ch.2 Trace1: 9

    RefLev1(1) = 0          ' Reference Level Ch.1 Trace2: 0 dBm

    RefLev1(2) = 0          ' Trace3: 0 dBm

    RefLev2(1) = 0          ' Ch.2 Trace1: 0 dBm

    Scale1(1) = 2           ' Scale Ch.1 Trace1: 2

    Scale1(2) = 10          ' Trace2: 10 dBm

    Scale1(3) = 10          ' Trace3: 10 dBm

    Scale1(4) = 2           ' Trace4: 2

    Scale2(1) = 10          ' Ch.2 Trace1: 10 dBm

    Scale2(2) = 2           ' Trace2: 2

    StaFileName = "sample.sta" ' Save File Name : sample.sta

    '

    ' Assigns a GPIB address to the I/O pass.

    Call viOpenDefaultRM(defrm)

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

    Call viSetAttribute(vi, VI_ATTR_TMO_VALUE, TimeOutTime) ' Set time out

    '

    Call viVPrintf(vi, ":SYST:PRES" + vbLf, 0)

    Call viVPrintf(vi, ":DISP:SPL D1_1_2" + vbLf, 0) 'Allocate Channel

    Call viVPrintf(vi, ":INIT1:CONT ON" + vbLf, 0) 'Turn on Continuous Activation mode for channel 1

    Call viVPrintf(vi, ":INIT2:CONT ON" + vbLf, 0) 'Turn on Continuous Activation mode for channel 2

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

    ' Setup Channel 1

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

    Call viVPrintf(vi, ":SENS1:SWE:TYPE SEGM" + vbLf, 0) 'Sets channel 1 sweep type to segment

    '

    ' Create the data string for Segment Table

    SendData = "5,0,1,1,0,0," & Str(Segm)

    For i = 1 To Segm

        SendData = SendData + "," & Star1(i) & "," + Stop1(i) & "," & CStr(Nop1(i)) & "," & CStr(IfBw1(i)) & "," & CStr(Power1(i))

    Next i

    Call viVPrintf(vi, ":SENS1:SEGM:DATA " + SendData + vbLf, 0)

    '

    Call viVPrintf(vi, ":CALC1:PAR:COUN " & CStr(NumOfTr1) & vbLf, 0) 'Set number of traces

    Call viVPrintf(vi, ":DISP:WIND1:SPL " & Allocate1 & vbLf, 0) 'Set graph layout

    

    For i = 1 To NumOfTr1

        Call viVPrintf(vi, ":CALC1:PAR" & CStr(i) & ":DEF " & Para1(i) & vbLf, 0) 'Set measurement parameter

        Call viVPrintf(vi, ":CALC1:PAR" & CStr(i) & ":SEL" & vbLf, 0) ' Make trace active

        Call viVPrintf(vi, ":CALC1:FORM " & Fmt1(i) & vbLf, 0) ' Set data format

        '

        Select Case Fmt1(i)

        Case "SLIN", "SLOG", "SCOM", "SMIT", "SADM", "PLIN", "PLOG", "POL"

        ' If data format is neither Smith chart nor polar, sets reference division line number and scale per division

            Call viVPrintf(vi, ":DISP:WIND1:TRAC" & CStr(i) & ":Y:PDIV " + CStr(Scale1(i)) + vbLf, 0)

        Case Else

        ' If data format is Smith chart or polar, set full-scale value

            Call viVPrintf(vi, ":DISP:WIND1:TRAC" & CStr(i) & ":Y:RPOS " & CStr(RefPos1(i)) & vbLf, 0)

            Call viVPrintf(vi, ":DISP:WIND1:TRAC" & CStr(i) & ":Y:RLEV " & CStr(RefLev1(i)) & vbLf, 0)

            Call viVPrintf(vi, ":DISP:WIND1:TRAC" & CStr(i) & ":Y:PDIV " & CStr(Scale1(i)) & vbLf, 0)

        End Select

    Next i

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

    ' Setup Channel 2

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

    Call viVPrintf(vi, ":SENS2:SWE:TYPE LIN " + vbLf, 0) ' Set sweep type to linear

    Call viVPrintf(vi, ":SENS2:FREQ:CENT " + CStr(Cent2) + vbLf, 0) ' Set center frequency

    Call viVPrintf(vi, ":SENS2:FREQ:SPAN " + CStr(Span2) + vbLf, 0) ' Set span frequency

    Call viVPrintf(vi, ":SENS2:SWE:POIN " + CStr(Nop2) + vbLf, 0) ' Set number of points

    Call viVPrintf(vi, ":SENS2:BAND " + CStr(IfBw2) + vbLf, 0) ' Set IFBW

    Call viVPrintf(vi, ":SOUR2:POW " + CStr(Power2) + vbLf, 0) ' Set power level

    Call viVPrintf(vi, ":CALC2:PAR:COUN " & CStr(NumOfTr2) & vbLf, 0) ' Set number of traces

    Call viVPrintf(vi, ":DISP:WIND2:SPL " & Allocate2 & vbLf, 0) 'Set graph layout

    

    For i = 1 To NumOfTr2

        Call viVPrintf(vi, ":CALC2:PAR" & CStr(i) & ":DEF " & Para2(i) & vbLf, 0) 'Set measurement parameter

        Call viVPrintf(vi, ":CALC2:PAR" & CStr(i) & ":SEL" & vbLf, 0) ' Make trace active

        Call viVPrintf(vi, ":CALC2:FORM " & Fmt2(i) & vbLf, 0) ' Set data format

        '

        Select Case Fmt2(i)

        Case "SLIN", "SLOG", "SCOM", "SMIT", "SADM", "PLIN", "PLOG", "POL"

        ' If data format is neither Smith chart nor polar, sets reference division line number and scale per division

            Call viVPrintf(vi, ":DISP:WIND2:TRAC" & CStr(i) & ":Y:PDIV " + CStr(Scale2(i)) + vbLf, 0)

        Case Else

        ' If data format is Smith chart or polar, set full-scale value

            Call viVPrintf(vi, ":DISP:WIND2:TRAC" & CStr(i) & ":Y:RPOS " & CStr(RefPos2(i)) & vbLf, 0)

            Call viVPrintf(vi, ":DISP:WIND2:TRAC" & CStr(i) & ":Y:RLEV " & CStr(RefLev2(i)) & vbLf, 0)

            Call viVPrintf(vi, ":DISP:WIND2:TRAC" & CStr(i) & ":Y:PDIV " & CStr(Scale2(i)) & vbLf, 0)

        End Select

    Next i

    '

    Call viVPrintf(vi, ":MMEM:STOR """ & StaFileName & """" & vbLf, 0) ' Save ENA settings to file

    ' Close IO

    Call viClose(vi)

    Call viClose(defrm)

        

End Sub

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

10 DIM Allocate1$[9],Allocate2$[9],File$[20]

20 DIM Para1$(1:4)[9],Para2$(1:2)[9],Fmt1$(1:4)[9],Fmt2$(1:2)[9]

30 REAL Star1(1:3),Stop1(1:3),Pow1(1:3),Cent2,Span2,Pow2

40 REAL Ref_rev1(1:4),Ref_rev2(1:2),Scale1(1:4),Scale2(1:2)

50 INTEGER Segm,Nop1(1:3),Nop2,Num_of_tr1,Num_of_tr2

60 INTEGER Ref_pos1(1:4),Ref_pos2(1:2),I

70 ASSIGN @Agte507x TO 717

80 !

90 Segm=3 ! Number of Segment Ch.1 : 3

100 Star1(1)=1.7E+9 ! Start Frequency Ch.1 Segm.1: 1.7 GHz

110 Star1(2)=1.9E+9 ! Segm.2: 1.9 GHz

120 Star1(3)=2.E+9 ! Segm.3: 2 GHz

130 Stop1(1)=1.9E+9 ! Stop Frequency Ch.1 Segm.1: 1.9 GHz

140 Stop1(2)=2.E+9 ! Segm.2: 2 GHz

150 Stop1(3)=2.2E+9 ! Segm.3: 2.2 GHz

160 Cent2=1.9E+9 ! Center Frequency Ch.2 : 1.9 GHz

170 Span2=5.00E+8 ! Span Ch.2 : 500 MHz

180 Nop1(1)=21 ! Number Ch.1 Segm.1: 21

190 Nop1(2)=101 ! of Points Segm.2: 101

200 Nop1(3)=21 ! Segm.3: 21

210 Nop2=101 ! Ch.2 : 101

220 If_bw1(1)=5.0E+4 ! IF Bandwidth    Ch.1 Segm.1: 50 kHz

230 If_bw1(2)=1.0E+4 ! Segm.2: 10 kHz

240 If_bw1(3)=5.0E+4 ! Segm.3: 50 kHz

250 If_bw2=7.0E+4 ! Ch.2 : 70 kHz

260 Pow1(1)=0 ! Power Ch.1 Segm.1: 0 dBm

270 Pow1(2)=-10 ! Segm.2: -10 dBm

280 Pow1(3)=0 ! Segm.3: 0 dBm

290 Pow2=0 ! Ch.2 : 0 dBm

300 Num_of_tr1=4 ! Number Ch.1 : 4

310 Num_of_tr2=2 ! of Traces Ch.2 : 2

320 Allocate1$="D12_34" ! Allocate Traces Ch.1 : D12_34

330 Allocate2$="D12" ! Ch.2 : D12

340 Para1$(1)="S11" ! Measurement Ch.1 Trace1: S11

350 Para1$(2)="S21" ! Parameter Trace2: S21

360 Para1$(3)="S12" ! Trace3: S12

370 Para1$(4)="S22" ! Trace4: S22

380 Para2$(1)="S31" ! Ch.2 Trace1: S31

390 Para2$(2)="S33" ! Trace2: S33

400 Fmt1$(1)="SLIN" ! Data Format Ch.1 Trace1: Smith(Lin/Phase)

410 Fmt1$(2)="MLOG" ! Trace2: Log Mag

420 Fmt1$(3)="MLOG" ! Trace3: Log Mag

430 Fmt1$(4)="SLIN" ! Trace4: Smith(Lin/Phase)

440 Fmt2$(1)="MLOG" ! Ch.2 Trace1: Log Mag

450 Fmt2$(2)="SLIN" ! Trace2: Smith(Lin/Phase)

460 Ref_pos1(2)=9 ! Reference Ch.1 Trace2: 9

470 Ref_pos1(3)=9 ! Position Trace3: 9

480 Ref_pos2(1)=9 ! Ch.2 Trace1: 9

490 Ref_lev1(2)=0 ! Reference Level Ch.1 Trace2: 0 dBm

500 Ref_lev1(3)=0 ! Trace3: 0 dBm

510 Ref_lev2(1)=0 ! Ch.2 Trace1: 0 dBm

520 Scale1(1)=2 ! Scale Ch.1 Trace1: 2

530 Scale1(2)=10 ! Trace2: 10 dBm

540 Scale1(3)=10 ! Trace3: 10 dBm

550 Scale1(4)=2 ! Trace4: 2

560 Scale2(1)=10 ! Ch.2 Trace1: 10 dBm

570 Scale2(2)=2 ! Trace2: 2

580 File$="sample.sta" ! Save File Name : sample.sta

590 !

600 OUTPUT @Agte507x;":SYST:PRES"

610 !

620 OUTPUT @Agte507x;":DISP:SPL D1_1_2"

630 OUTPUT @Agte507x;":INIT1:CONT ON"

640 OUTPUT @Agte507x;":INIT2:CONT ON"

650 !

660 ! Channel 1

670 !

680 OUTPUT @Agte507x;":SENS1:SWE:TYPE SEGM"

690 OUTPUT @Agte507x;":SENS1:SEGM:DATA 5,0,1,1,0,0,";Segm;",";

700 FOR I=1 TO Segm-1

710 OUTPUT @Agte507x;Star1(I);",";Stop1(I);",";Nop1(I);",";If_bw1 (I);",";Pow1(I);",";

720 NEXT I

730 OUTPUT @Agte507x;Star1(Segm);",";Stop1(Segm);",";Nop1(Segm);"," ;If_bw1(Segm);",";Pow(Segm)

740 !

750 OUTPUT @Agte507x;":CALC1:PAR:COUN ";Num_of_tr1

760 OUTPUT @Agte507x;":DISP:WIND1:SPL "&Allocate1$

770 FOR I=1 TO Num_of_tr1

780 OUTPUT @Agte507x;":CALC1:PAR"&VAL$(I)&":DEF "&Para1$(I)

790 OUTPUT @Agte507x;":CALC1:PAR"&VAL$(I)&":SEL"

800 OUTPUT @Agte507x;":CALC1:FORM "&Fmt1$(I)

810 SELECT Fmt1$(I)

820 CASE "SLIN","SLOG","SCOM","SMIT","SADM","PLIN","PLOG","POL"

830 OUTPUT @Agte507x;":DISP:WIND1:TRAC"&VAL$(I)&":Y:PDIV "; Scale1(I)

840 CASE ELSE

850 OUTPUT @Agte507x;":DISP:WIND1:TRAC"&VAL$(I)&":Y:RPOS "; Ref_pos1(I)

860 OUTPUT @Agte507x;":DISP:WIND1:TRAC"&VAL$(I)&":Y:RLEV "; Ref_rev1(I)

870 OUTPUT @Agte507x;":DISP:WIND1:TRAC"&VAL$(I)&":Y:PDIV "; Scale1(I)

880 END SELECT

890 NEXT I

900 !

910 ! Channel 2

920 !

930 OUTPUT @Agte507x;":SENS2:SWE:TYPE LIN"

940 OUTPUT @Agte507x;":SENS2:FREQ:CENT ";Cent2

950 OUTPUT @Agte507x;":SENS2:FREQ:SPAN ";Span2

960 OUTPUT @Agte507x;":SENS2:SWE:POIN ";Nop2

970 OUTPUT @Agte507x;":SENS2:BAND ";If_bw2

980 OUTPUT @Agte507x;":SOUR2:POW ";Pow2

990 !

1000 OUTPUT @Agte507x;":CALC2:PAR:COUN ";Num_of_tr2

1010 OUTPUT @Agte507x;":DISP:WIND2:SPL "&Allocate2$

1020 FOR I=1 TO Num_of_tr2

1030 OUTPUT @Agte507x;":CALC2:PAR"&VAL$(I)&":DEF "&Para2$(I)

1040 OUTPUT @Agte507x;":CALC2:PAR"&VAL$(I)&":SEL"

1050 OUTPUT @Agte507x;":CALC2:FORM "&Fmt2$(I)

1060 SELECT Fmt2$(I)

1070 CASE "SLIN","SLOG","SCOM","SMIT","SADM","PLIN","PLOG","POL"

1080 OUTPUT @Agte507x;":DISP:WIND2:TRAC"&VAL$(I)&":Y:PDIV "; Scale2(I)

1090 CASE ELSE

1100 OUTPUT @Agte507x;":DISP:WIND2:TRAC"&VAL$(I)&":Y:RPOS "; Ref_pos2(I)

1110 OUTPUT @Agte507x;":DISP:WIND2:TRAC"&VAL$(I)&":Y:RLEV "; Ref_rev2(I)

1120 OUTPUT @Agte507x;":DISP:WIND2:TRAC"&VAL$(I)&":Y:PDIV "; Scale2(I)

1130 END SELECT

1140 NEXT I

1150 !

1160 OUTPUT @Agte507x;":MMEM:STOR """&File$&""""

1170 END

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

上一篇:时域
下一篇:保存文件

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

  网站地图