6146/6156 DC Voltage/Current Generators Operation Manual
5.9.4 Program Example 3-Sweep Operation and Voltage/Current Measurement
5-65
5.9.4.2 Program Example Using USB
Option Explicit ' Clearly declares all variables.
Public blnUSBComErr As Boolean ' USB transmission and reception error generated
Private Const OK As Integer = 0 ' Declares a constant "OK."
Private Const lngVIGID As Long = 1 ' Sets the VIG USB ID to 1.
Private Const lngDMMID As Long = 2 ' Sets the DMM USB ID to 2.
Private Const lngTimeOut As Long = 10 ' USB time out [s]
Private Const lngStaRow As Long = 1 ' Start row to store data
Private Const lngMeaNoCol As Long = 1 ' Column to store the measurement number
Private Const lngSrcLimitCol As Long = 2 ' Column to store the VIG limiter activation
Private Const lngSrcDataCol As Long = 3 ' Column to store the VIG source value
Private Const lngVDataCol As Long = 4 ' Column to store the measured voltage
Private Const lngIDataCol As Long = 5 ' Column to store the measured current
Public Sub SweepAndMeasure_USB()
Dim lngVIGHdl As Long ' VIG USB handle
Dim lngDMMHdl As Long ' DMM USB handle
Dim strRecvStr As String ' Data reception buffer
Dim strSrcLimit As String ' VIG limiter activation
Dim strSrcData As String ' Current VIG source value
Dim strMeasVData As String ' Measured voltage
Dim strMeasIData As String ' Measured current
Dim lngMeasCnt As Long ' Number of measurement
Dim lngRowNo As Long ' Row to store the measured data
Dim lngDMMSTB As Long ' DMM STB value
Dim lngVIGDSR As Long ' VIG DSR value
Dim blnRDYb As Boolean ' READY Out Bit
Dim blnSWEb As Boolean ' Sweep End Bit
Dim blnLMHb As Boolean ' Limiter High Bit
Dim blnLMLb As Boolean ' Limiter Low Bit
lngRowNo = lngStaRow ' Start row to store data
Call aUSBSta(lngTimeOut) ' USB driver initialization
' Device (instrument) open and handle acquisition
Call aUSBOpn(lngVIGHdl, lngVIGID) ' VIG open
Call aUSBOpn(lngDMMHdl, lngDMMID) ' DMM open
If blnUSBComErr = True Then ' USB error check
GoTo ErrExit
End If
' Device clear and parameter initialization
Call aUSBWrt(lngVIGHdl, "C,*RST")
Call aUSBWrt(lngDMMHdl, "C,*RST")
' VIG setting
Call aUSBWrt(lngVIGHdl, "VF") ' Voltage source function
Call aUSBWrt(lngVIGHdl, "MD2") ' Sweep source mode
Call aUSBWrt(lngVIGHdl, "SCM1") ' Single sweep
Call aUSBWrt(lngVIGHdl, "SP0.5") ' Sets the sweep step time to 0.5 s.
Call aUSBWrt(lngVIGHdl, "SN0,3,0.01") ' Start: 0 V, stop: 3 V, step: 10 mv
Call aUSBWrt(lngVIGHdl, "SB0") ' Sets the bias value to 0 V.
Call aUSBWrt(lngVIGHdl, "LMI 0.01") ' Sets the current limit to 10 mA.
Call aUSBWrt(lngVIGHdl, "ROD0") ' Sets the READY signal delay time to 10 ms.