6146/6156 DC Voltage/Current Generators Operation Manual
5.9.2 Program Example 1-DC Voltage Source and Voltage/Current Measurement
5-50
Call gpibrd(intDMMDes, strRecvStr) ' Data reception
lngDMMSTB = CLng(strRecvStr) ' STB value storing
lngDMMSTB = lngDMMSTB And 16 ' AND operation on the Message Available bit
Loop Until lngDMMSTB = 16 ' Repeats until the measurement is compete.
Call gpibrd(intDMMDes, strRecvStr) ' Receives the measured data.
' Assigns the measured data to the specified cell.
ActiveSheet.Cells(lngStaRow, lngVDataCol).value = strRecvStr
Call gpibwrt(intDMMDes, "F5") ' Current measurement function
Call gpibwrt(intDMMDes, "*TRG") ' Sends the trigger and starts measurement.
Do
Call gpibwrt(intDMMDes, "*STB?") ' STB query
Call gpibrd(intDMMDes, strRecvStr) ' Data reception
lngDMMSTB = CLng(strRecvStr) ' STB value storing
lngDMMSTB = lngDMMSTB And 16 ' AND operation on the Message Available bit
Loop Until lngDMMSTB = 16 ' Repeats until the measurement is compete.
Call gpibrd(intDMMDes, strRecvStr) ' Receives the measured data.
' Assigns the measured data to the specified cell.
ActiveSheet.Cells(lngStaRow, lngIDataCol).value = strRecvStr
Call gpibwrt(intVIGDes, "SBY") ' Sets the VIG output to OFF.
Call ibonl(intVIGDes, 0) ' Sets VIG offline.
Call ibonl(intDMMDes, 0) ' Sets DMM offline.
End Sub
5.9.2.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 ' Row to store the measured data
Private Const lngVDataCol As Long = 1 ' Column to store the measured voltage
Private Const lngIDataCol As Long = 2 ' Column to store the measured current
Public Sub DCGenerateAndMeasure_USB()
Dim lngVIGHdl As Long ' VIG USB handle
Dim lngDMMHdl As Long ' DMM USB handle
Dim strRecvStr As String ' Data reception buffer
Dim lngVIGDSR As Long ' VIG DSR value
Dim lngDMMSTB As Long ' DMM STB value
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