Other topics about Sample Programs
The program listed in this section is a sample program that demonstrates how to configure measurement conditions.
The sample program puts the instrument into the preset state, configures it as shown in table below, and saves the settings to a file named sample.sta.
See Setting up Analyzer for this programming.
Target settings
Item |
Setting |
||
Window Layout |
Channel 1 in the upper window (2/3 of the screen height) and channel 2 in the lower window (1/3 of the screen height) |
||
Channel 1 |
Sweep type |
Segment |
|
Sweep range |
See Segment table. |
||
Number of measurement points |
|||
IF bandwidth |
|||
Power |
|||
Number of traces |
4 |
||
Graph Layout |
Four graphs at upper left, upper right, lower left, and lower right. |
||
Trace 1 |
Measurement parameter |
S11 |
|
Data format |
Smith chart (Lin) |
||
Full-scale value |
2 |
||
Trace 2 |
Measurement parameter |
S21 |
|
Data format |
Log magnitude |
||
Reference division line number |
9 |
||
Reference division line value |
2 |
||
Scale per division |
10 dBm |
||
Trace 3 |
Measurement parameter |
S12 |
|
Data format |
Log magnitude |
||
Reference division line number |
9 |
||
Reference division line value |
2 |
||
Scale per division |
10 dBm |
||
Trace 4 |
Measurement parameter |
S22 |
|
Data format |
Smith chart (Lin) |
||
Full-scale value |
2 |
||
Channel 2 |
Sweep type |
Linear |
|
Sweep range |
Center value |
1.9 GHz |
|
Span value |
500 MHz |
||
Number of measurement points |
101 |
||
IF bandwidth |
70 kHz |
||
Power |
0 dBm |
||
Number of traces |
2 |
||
Graph Layout |
Two graphs at left and right |
||
Trace 1 |
Measurement parameter |
S21 |
|
Data format |
Log magnitude |
||
Reference division line number |
9 |
||
Reference division line value |
2 |
||
Scale per division |
10 dBm |
||
Trace 2 |
Measurement parameter |
S22 |
|
Data format |
Smith chart (Lin) |
||
Full-scale value |
2 |
Segment table for channel 1
Segment Number |
Start value |
Stop value |
Number of measurement points |
IF bandwidth |
Power |
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 |
Sub Setup()
'
'
' *** The variables of the resource manager and the instrument I/O are declared.
Dim ioMgr As VisaComLib.ResourceManager
Dim Ena As VisaComLib.FormattedIO488
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) = "S21" ' Ch.2 Trace1: S21
Para2(2) = "S22" ' Trace2: S22
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
'
'*** 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. Sets the GPIB address.
Set Ena.IO = ioMgr.Open("GPIB0::17::INSTR")
Ena.IO.timeout = 10000 ' TimeOut time should be greater than the measurement time.
'
Ena.WriteString ":SYST:PRES", True
Ena.WriteString ":DISP:SPL D1_1_2", True 'Allocate Channel
Ena.WriteString ":INIT1:CONT ON", True 'Turn on Continuous Activation mode for channel 1
Ena.WriteString ":INIT2:CONT ON", True 'Turn on Continuous Activation mode for channel 2
' ===============
' Setup Channel 1
' ===============
Ena.WriteString ":SENS1:SWE:TYPE SEGM", True '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
Ena.WriteString ":SENS1:SEGM:DATA " + SendData, True
'
Ena.WriteString ":CALC1:PAR:COUN " & CStr(NumOfTr1), True 'Set number of traces
Ena.WriteString ":DISP:WIND1:SPL " & Allocate1, True 'Set graph layout
For i = 1 To NumOfTr1
Ena.WriteString ":CALC1:PAR" & CStr(i) & ":DEF " & Para1(i), True 'Set measurement parameter
Ena.WriteString ":CALC1:PAR" & CStr(i) & ":SEL", True ' Make trace active
Ena.WriteString ":CALC1:FORM " & Fmt1(i), True ' 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
Ena.WriteString ":DISP:WIND1:TRAC" & CStr(i) & ":Y:PDIV " + CStr(Scale1(i)), True
Case Else
' If data format is Smith chart or polar, set full-scale value
Ena.WriteString ":DISP:WIND1:TRAC" & CStr(i) & ":Y:RPOS " & CStr(RefPos1(i)), True
Ena.WriteString ":DISP:WIND1:TRAC" & CStr(i) & ":Y:RLEV " & CStr(RefLev1(i)), True
Ena.WriteString ":DISP:WIND1:TRAC" & CStr(i) & ":Y:PDIV " & CStr(Scale1(i)), True
End Select
Next i
' ===============
' Setup Channel 2
' ===============
Ena.WriteString ":SENS2:SWE:TYPE LIN ", True ' Set sweep type to linear
Ena.WriteString ":SENS2:FREQ:CENT " + CStr(Cent2), True ' Set center frequency
Ena.WriteString ":SENS2:FREQ:SPAN " + CStr(Span2), True ' Set span frequency
Ena.WriteString ":SENS2:SWE:POIN " + CStr(Nop2), True ' Set number of points
Ena.WriteString ":SENS2:BAND " + CStr(IfBw2), True ' Set IFBW
Ena.WriteString ":SOUR2:POW " + CStr(Power2), True ' Set power level
Ena.WriteString ":CALC2:PAR:COUN " & CStr(NumOfTr2), True ' Set number of traces
Ena.WriteString ":DISP:WIND2:SPL " & Allocate2, True 'Set graph layout
For i = 1 To NumOfTr2
Ena.WriteString ":CALC2:PAR" & CStr(i) & ":DEF " & Para2(i), True 'Set measurement parameter
Ena.WriteString ":CALC2:PAR" & CStr(i) & ":SEL", True ' Make trace active
Ena.WriteString ":CALC2:FORM " & Fmt2(i), True ' 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
Ena.WriteString ":DISP:WIND2:TRAC" & CStr(i) & ":Y:PDIV " + CStr(Scale2(i)), True
Case Else
' If data format is Smith chart or polar, set full-scale value
Ena.WriteString ":DISP:WIND2:TRAC" & CStr(i) & ":Y:RPOS " & CStr(RefPos2(i)), True
Ena.WriteString ":DISP:WIND2:TRAC" & CStr(i) & ":Y:RLEV " & CStr(RefLev2(i)), True
Ena.WriteString ":DISP:WIND2:TRAC" & CStr(i) & ":Y:PDIV " & CStr(Scale2(i)), True
End Select
Next i
'
Ena.WriteString ":MMEM:STOR """ & StaFileName & """", True ' Save ENA settings to file
' Close IO
Ena.IO.Close
End Sub