6146/6156 DC Voltage/Current Generators Operation Manual
5.9.2 Program Example 1-DC Voltage Source and Voltage/Current Measurement
5-49
(Execution result examples)
DCV_ +05.0361E+00 DCI_ +005.034E-03
5.9.2.1 Program Example Using GPIB
Option Explicit ' Clearly declares all variables.
Private Const intIFBoardAdr As Integer = 0 ' Sets the GPIB board address to 0.
Private Const intVIGAdr As Integer = 1 ' Sets the VIG address to 1.
Private Const intDMMAdr As Integer = 2 ' Sets the DMM address to 2.
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_GPIB()
Dim intVIGDes As Integer ' VIG device descriptor
Dim intDMMDes As Integer ' DMM device descriptor
Dim strRecvStr As String ' Received data
Dim lngVIGDSR As Long ' VIG DSR value
Dim lngDMMSTB As Long ' DMM STB value
' Opens the devices (VIG, DMM) and executes initialization (timeout 10 s).
Call ibdev(intIFBoardAdr, intVIGAdr, 0, T10s, 1, 0, intVIGDes)
Call ibdev(intIFBoardAdr, intDMMAdr, 0, T10s, 1, 0, intDMMDes)
' Sets addresses in each transmission and reception
Call ibconfig(intVIGDes, IbcUnAddr, 1)
Call ibconfig(intDMMDes, IbcUnAddr, 1)
' Device clear and parameter initialization.
Call gpibwrt(intVIGDes, "C,*RST")
Call gpibwrt(intDMMDes, "C,*RST")
' VIG setting
Call gpibwrt(intVIGDes, "VF") ' Voltage source function
Call gpibwrt(intVIGDes, "SOV+5V") ' Sets the source voltage to 5 V. (auto range)
' DMM setting
Call gpibwrt(intDMMDes, "F1") ' Voltage measurement function
Call gpibwrt(intDMMDes, "PR3") ' Sets the sampling rate to SLOW1.
Call gpibwrt(intDMMDes, "TRS3") ' Sets the trigger to BUS.
Call gpibwrt(intDMMDes, "H1") ' Header ON
Call gpibwrt(intDMMDes, "*CLS" ' Status clear
' VIG operation
Call gpibwrt(intVIGDes, "OPR") ' Sets the VIG output to ON.
Do
Call gpibwrt(intVIGDes, "DSR?") ' DSR query
Call gpibrd(intVIGDes, strRecvStr) ' Data reception
lngVIGDSR = CLng(strRecvStr) ' DSR value storing
lngVIGDSR = lngVIGDSR And 1024 ' AND operation on the READY OUT bit
Loop Until lngVIGDSR = 1024 ' Repeats until the READY OUT bit is set.
' DMM operation
Call gpibwrt(intDMMDes, "*TRG") ' Sends the trigger and starts measurement.
Do
Call gpibwrt(intDMMDes, "*STB?") ' STB query