> Visual Basic
> This function can be called in a Visual Basic program. It performs an RF Calibration in Cable & Antenna Analyzer mode. Communication with the instrument uses USB protocol.
> Public Sub OnePortCalibrationInCAAMode()
> Const MAX_CNT = 200
> Dim stat As Variant
> Dim dfltRM As Variant
> Dim sesn As Variant
> Dim retCount As Long
> Dim Buffer As String * MAX_CNT
> Dim Response As String * VI_FIND_BUFLEN
> Dim sInputString As String
> Rem Begin by initializing the system
> stat = viOpenDefaultRM(dfltRM)
> If (stat < VI_SUCCESS) Then
> Rem Error initializing VISA...exiting
> Exit Sub
> End If
> Rem Open communication with USB Protocol
> Rem NOTE: For simplicity, we will not show error checking
> Rem 0x0B5B::0xFF60::32850021_76227-3_102 = Vendor id::Product id::dut usb id
> stat = viOpen(dfltRM, "USB0::0x0B5B::0xFF60::32850021_76227-3_102::INSTR", VI_NULL, VI_NULL, sesn)
> Rem Set some visa attributes
> stat = viSetAttribute(sesn, VI_ATTR_TMO_VALUE, 90000)
> stat = viSetAttribute(sesn, VI_ATTR_SEND_END_EN, VI_TRUE)
> stat = viSetAttribute(sesn, VI_ATTR_SUPPRESS_END_EN, VI_FALSE)
> stat = viClear(sesn)
> 'Switch to Cable-Antenna Analyzer Mode
> sInputString = ":INST:NSEL 2"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> Do
> Sleep (200)
> sInputString = ":INST:NSEL?"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> stat = viRead(sesn, Buffer, MAX_CNT, retCount)
> Loop Until Val(Buffer) = 2
> 'System preset
> sInputString = ":SYSTEM:PRESET"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> 'Wait for previous operation to be completed
> sInputString = "*OPC?"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> Buffer = ""
> stat = viRead(sesn, Buffer, MAX_CNT, retCount)
> 'Set start frequency
> sInputString = ":SENSe:FREQuency:STARt 2 MHz"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> 'Set stop frequency
> sInputString = "SENSe:FREQuency:STOP 4 GHz"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> 'Initiate One-port Calibration
> sInputString = "SENSe:CORRection:COLLect:TYPE RFP1"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> 'Wait for previous operation to be completed
> sInputString = "*OPC?"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> Buffer = ""
> stat = viRead(sesn, Buffer, MAX_CNT, retCount)
> sInputString = "SENSe:CORRection:COLLect:INITialize"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> 'Wait for previous operation to be completed
> sInputString = "*OPC?"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> Buffer = ""
> stat = viRead(sesn, Buffer, MAX_CNT, retCount)
> 'measure open
> MsgBox "Connect open at port 1"
> sInputString = ":SENSe:CORRection:COLLect:OPEN"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> Do
> Sleep (200)
> 'wait open measurement to complete and returns 1
> sInputString = ":SENSe:CORRection:COLLect:STATus? OPEN"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> stat = viRead(sesn, Buffer, MAX_CNT, retCount)
> Loop Until Val(Buffer) = 1
> 'measure short
> MsgBox "Connect short at port 1"
> sInputString = ":SENSe:CORRection:COLLect:SHORt"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> Do
> Sleep (200)
> 'wait short measurement to complete and returns 1
> sInputString = ":SENSe:CORRection:COLLect:STATus? SHORt"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> stat = viRead(sesn, Buffer, MAX_CNT, retCount)
> Loop Until Val(Buffer) = 1
> 'measure load
> MsgBox "Connect load at port 1"
> sInputString = ":SENSe:CORRection:COLLect:LOAD"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> Do
> Sleep (200)
> 'wait load measurement to complete and returns 1
> sInputString = ":SENSe:CORRection:COLLect:STATus? LOAD"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> stat = viRead(sesn, Buffer, MAX_CNT, retCount)
> Loop Until Val(Buffer) = 1
> 'Save and apply calibration
> sInputString = ":SENS:CORR:COLL:SAV"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> 'Wait for previous operation to be completed
> sInputString = "*OPC?"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> Buffer = ""
> stat = viRead(sesn, Buffer, MAX_CNT, retCount)
> 'read back the the cal type (i.e. Buffer = 1, RFP1 or one-port calibration)
> sInputString = ":SENS:CAL:STAT?"
> stat = viWrite(sesn, sInputString, Len(sInputString), retCount)
> Buffer = ""
> stat = viRead(sesn, Buffer, MAX_CNT, retCount)
> Rem Close down the system
> stat = viClose(sesn)
> stat = viClose(dfltRM)
> End Sub