Other topics about Sample Programs
The sample program performs calibration with the specified calibration type. The following subroutine are provided.
See Calibration for this programming.
'*** The variables of the resource manager and the instrument I/O are declared.
Dim ioMgr As VisaComLib.ResourceManager
Dim Ena As VisaComLib.FormattedIO488
Sub main()
Dim Ch As String
Dim CalKit As Integer
Dim Port As String
Dim Isolation As String
'
Set ioMgr = New VisaComLib.ResourceManager
Set Ena = New VisaComLib.FormattedIO488
'*** Open the instrument.
Set Ena.IO = ioMgr.Open("GPIB0::17::INSTR")
Ena.IO.timeout = 10000
Const Cal85032F = 4 'cal kit number.
Ch = Cells(5, 5) 'Select channel
Port = Cells(3, 6) 'Sets the select port 1.
Isolation = Cells(3, 7) 'Sets the select port 1.
CalKit = Cal85032F 'Sets cal kit (85032F)
Ena.WriteString ":SENS" & Ch & ":CORR:COLL:CKIT " & CalKit, True 'Select the calibration kit
Select Case Cells(3, 5)
Case "Response (Open)" 'Perform response calibration (OPEN).
Call OpenShortResponse(Ch, Port, "Open", Isolation)
Case "Response (Short)" 'Perform response calibration (SHORT).
Call OpenShortResponse(Ch, Port, "Open", Isolation)
Case "Response (Thru)" 'Perform response calibration (Thru).
Call ThruResponse(Ch, Port, Isolation)
Case "Full 1 Port" 'Perform 1-port calibration.
Call SOLT(Ch, 1, Port, Isolation)
Case "Full 2 Port" 'Perform full 2-port calibration.
Call SOLT(Ch, 2, Port, Isolation)
End Select
Ena.IO.Close
End Sub
Sub ThruResponse(Ch As String, ThruDirection As String, Isolation As String)
Dim Dummy As Variant 'Variant to receive the result
With Ena
Select Case ThruDirection
Case "1 to 2"
.WriteString ":SENS" & Ch & ":CORR:COLL:METH:THRU 1, 2", True
MsgBox ("Set Thur to Port 1 and 2. then click [OK] button") 'Display the message box.
.WriteString ":SENS" & Ch & ":CORR:COLL:THRU 1, 2", True 'Measurement the calibration data.
Case "2 to 1"
.WriteString ":SENS" & Ch & ":CORR:COLL:METH:THRU 2, 1", True
MsgBox ("Set Thur to Port 1 and 2. then click [OK] button") 'Display the message box.
.WriteString ":SENS" & Ch & ":CORR:COLL:THRU 2, 1", True 'Measurement the calibration data.
Case Else
MsgBox ("Select ""1 to 2"" or ""2 to 1"".") 'Display the message box.
End
End Select
.WriteString "*OPC?", True 'Reads the *OPC? result to wait the calibration end
Dummy = .ReadNumber
' *** Isolation Calibration
If Isolation = "Yes" Then
Select Case ThruDirection
Case "1 to 2"
.WriteString ":SENS" & Ch & ":CORR:COLL:LOAD 2", True
Case "2 to 1"
.WriteString ":SENS" & Ch & ":CORR:COLL:LOAD 1", True
End Select
End If
.WriteString "*OPC?", True 'Reads the *OPC? result to wait the calibration end
Dummy = .ReadNumber
'
'
.WriteString ":SENS" & Ch & ":CORR:COLL:SAVE", True 'Calculating the calibration coefficients.
End With
End Sub
Sub OpenShortResponse(Ch As String, Port As String, OpenOrShort As String, Load As String)
Dim Dummy As Variant 'Variant to receive the result
If Port = "1 to 2" Or Port = "2 to 1" Then
MsgBox ("Select 1 or 2.") 'Display the message box.
End
End If
With Ena
Select Case OpenOrShort
Case "Open"
.WriteString ":SENS" & Ch & ":CORR:COLL:METH:OPEN " & Port, True
MsgBox ("Set Open to " & Port & ", then click [OK] button") 'Display the message box.
.WriteString ":SENS" & Ch & ":CORR:COLL:OPEN " & Port, True
Case "Short"
.WriteString ":SENS" & Ch & ":CORR:COLL:METH:SHOR " & Port, True
MsgBox ("Set Open to " & Port & ", then click [OK] button") 'Display the message box.
.WriteString ":SENS" & Ch & ":CORR:COLL:SHOR " & Port, True
End Select
.WriteString "*OPC?", True 'Reads the *OPC? result to wait the calibration end
Dummy = .ReadNumber
' *** Isolation Calibration
If Load = "Yes" Then
MsgBox ("Set Load to " & Port & ", then click [OK] button") 'Display the message box.
.WriteString ":SENS" & Ch & ":CORR:COLL:LOAD " & Port, True
.WriteString "*OPC?", True 'Reads the *OPC? result to wait the calibration end
Dummy = .ReadNumber
End If
.WriteString ":SENS" & Ch & ":CORR:COLL:SAVE", True 'Calculating the calibration coefficients.
'
End With
End Sub
Sub SOLT(Ch As String, NumPort As String, Port As String, Isolation As String)
Dim Dummy
Dim i As Integer, j As Integer
With Ena
Select Case NumPort
Case 1
.WriteString ":SENS" & Ch & ":CORR:COLL:METH:SOLT1 " & Port, True 'Set the 1-port calibration type.
Case 2
.WriteString ":SENS" & Ch & ":CORR:COLL:METH:SOLT2 1, 2", True 'Set the full 2-port calibration type.
End Select
' *** Reflection
If NumPort = 2 Then Port = 1
For i = 1 To NumPort
MsgBox ("Set Open to Port " & Port & ". then click [OK] button") 'Display the message box.
.WriteString ":SENS" & Ch & ":CORR:COLL:OPEN " & Port, True 'Measurement the OPEN calibration.
.WriteString "*OPC?", True 'Reads the *OPC? result to wait the calibration end
Dummy = .ReadNumber
MsgBox ("Set Short to Port " & Port & ". then click [OK] button") 'Display the message box.
.WriteString ":SENS" & Ch & ":CORR:COLL:SHORT " & Port, True 'Measurement the SHORT calibration.
.WriteString "*OPC?", True 'Reads the *OPC? result to wait the calibration end
Dummy = .ReadNumber
MsgBox ("Set Load to Port " & Port & ". then click [OK] button") 'Display the message box.
.WriteString ":SENS" & Ch & ":CORR:COLL:LOAD " & Port, True 'Measurement the LOAD calibration.
.WriteString "*OPC?", True 'Reads the *OPC? result to wait the calibration end
Dummy = .ReadNumber
Port = 2
Next i
' *** Transmission
If NumPort = 2 Then
MsgBox ("Set Thru to Ports 1 and 2. then click [OK] button") 'Display the message box.
.WriteString ":SENS" & Ch & ":CORR:COLL:THRU 1,2", True 'Measurement the THRU calibration.
.WriteString "*OPC?", True 'Reads the *OPC? result to wait the calibration end
Dummy = .ReadNumber
.WriteString ":SENS" & Ch & ":CORR:COLL:THRU 2,1", True 'Measurement the THRU calibration.
.WriteString "*OPC?", True 'Reads the *OPC? result to wait the calibration end
Dummy = .ReadNumber
End If
' *** Isolation Calibration
If Isolation = "Yes" And NumPort = 2 Then
MsgBox ("Set Loads on Ports 1 and 2. then click [OK] button") 'Display the message box.
.WriteString ":SENS" & Ch & ":CORR:COLL:METH:SOLT2 1,2", True
.WriteString ":SENS" & Ch & ":CORR:COLL:ISOL 1,2", True
.WriteString "*OPC?", True 'Reads the *OPC? result to wait the calibration end
Dummy = .ReadNumber
.WriteString ":SENS" & Ch & ":CORR:COLL:METH:SOLT2 2,1", True
.WriteString ":SENS" & Ch & ":CORR:COLL:ISOL 2,1", True
.WriteString "*OPC?", True 'Reads the *OPC? result to wait the calibration end
Dummy = .ReadNumber
End If
.WriteString ":SENS" & Ch & ":CORR:COLL:SAVE", True 'Calculating the calibration coefficients
End With
End Sub