6146/6156 DC Voltage/Current Generators Operation Manual
5.9.3 Program Example 2-Memory Setting, Scan Operation and Voltage/Source Measurement
5-57
5.9.3.2 Program Example Using USB
Option Explicit ' Clearly declares all variables.
' Instrument and interface setting
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]
' Operation setting parameter
Private Const dblVMin As Double = 0 ' Start (minimum) voltage [V]
Private Const dblVMax As Double = 5 ' Peak (maximum) voltage [V]
Private Const dblVStep As Double = 0.1 ' Voltage step value [V]
Private Const intRepSet As Integer = 2 ' Number of repetition
' Sets the sheet to store data.
Private Const lngStaRow As Long = 1 ' Start row to store data
Private Const lngRepCntCol As Long = 1 ' Column to store the number of repetition
Private Const lngMeasNoCol As Long = 2 ' Column to store the number of measurement
Private Const lngMemNoCol As Long = 3 ' Column to store the memory number
Private Const lngGenerateVCol As Long = 4 ' Column to store the source voltage
Private Const lngVDataCol As Long = 5 ' Column to store the measured voltage
Private Const lngIDataCol As Long = 6 ' Column to store the measured current
Public blnUSBComErr As Boolean ' USB transmission and reception error generated
Private Const OK As Integer = 0 ' Declares a constant "OK."
Public Sub SetMemAndMeasure_USB()
Dim lngVIGHdl As Long ' VIG USB handle
Dim lngDMMHdl As Long ' DMM USB handle
Dim strRecvStr As String ' Data reception buffer
Dim strSendCmd As String ' Memory setting command character string
Dim dblGParam As Double ' Source value parameter
Dim intMemNo As Integer ' Memory number
Dim blnMemNoDec As Boolean ' Peak flag of the setting value
Dim lngVIGDSR As Long ' VIG DSR value
Dim blnRDYb As Boolean ' READY OUT bit
Dim blnSWEb As Boolean ' Sweep End bit
Dim lngDMMSTB As Long ' DMM STB value
Dim lngRowNo As Long ' Row to store the measured data
Dim lngMeasCnt As Long ' Number of measurement
Dim intNowRepCnt As Integer ' Current number of repetition
Dim intNowMemNo As Integer ' Current VIG memory number
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")