6241A/6242 DC Voltage Current Source/Monitor Operation Manual
6.8 Sample Programs
6-41
6.8 Sample Programs
6.8.1 Programming Examples with GPIB
A basic program example to operate the 6241A/6242 from a computer via GPIB connection is introduced
below.
Operating Environment
Computer: DELL OPTIPLEX 170L (Pentium 4 CPU 2.80GHz)
GPIB hardware: GPIB-USB-HS (NATIONAL INSTRUMENTS)
Module: Niglobal.bas, Vbib-32.bas (the software included with GPIB-USB-HS)
Language: Microsoft Excel Visual Basic for Application
These programs perform the same operations as described in Section 2.2, “Basic Operation.”
• Program example 1: Example of DC Measurement introduced in Section 2.2.5
• Program example 2: Example of Pulse Measurement introduced in Section 2.2.6
• Program example 3: Example of Sweep Measurement introduced in Section 2.2.7
• Program example 4: Example of reading out measurement data from the measurement buffer
memory as fast as possible
NOTE: The GPIB address is set to 1 for the 6241A/6242.
6.8.1.1 Programming Example 1: DC Measurement
Option Explicit ’ Explicit declaration for all variables
Private Sub Sampl1 GPIB_Click() ’ Event procedure for the command button
Dim board As Integer ’ GPIB board address
Dim pad As Integer ’ 6241A/6242 address
Dim vig As Integer ’ 6241A/6242 device descriptor
Dim dt As String*20 ’ Data reception buffer
board=0 ’ GPIB board address 0
pad=1 ’ 6241A/6242 address 1
Call ibdev(board,pad,0,T10s,1,0,vig) ’ Opening and initializing device (6241A/6242) (time out 10 s)
Call ibconfig(vig,IbcUnAddr,1) ’ Address setting performed for each transmission or reception
Call ibwrt(vig, "C,*RST" & vbLf) ’ DCL and parameter Initialization
Call ibwrt(vig, "OH1" & vbLf) ’ Header ON
Call ibwrt(vig, "M1" & vbLf) ’ Trigger mode hold
Call ibwrt(vig, "VF" & vbLf) ’ Voltage source function
Call ibwrt(vig, "F2" & vbLf) ’ Current measurement function
Call ibwrt(vig, "SOV1,LMI0.003" & vbLf) ’ DC Source value 1 V, Limiter value 3 mA
Call ibwrt(vig, "OPR" & vbLf) ’ Output ON
Call SUBmeas(vig, dt) ’ Measurement trigger & data recall
Cells(1, 1) = Left(dt, 15) ’ Assigns data to the designated cell.
R