95
────────────────────────────────────────────────────
7.7 Sample Program
────────────────────────────────────────────────────
GP-IB Communications
(Using National Instruments GP-IB Board)
■ Simple Resistance and Voltage Measurement
Imports measured values 10 times, and saves measurements in a text
file.
Private Sub MeasureSub()
Dim buffer As String * 40 ’Receiving butter
Dim recvstr As String ’Receiving char string
Dim pad As Integer ’Controller access
Dim gpibad As Integer ’Device Address
Dim timeout As Integer ’Timeout period
Dim ud As Integer ’State (unused)
Dim i As Integer
pad = 0 ’Board Address 0
gpibad = 1 ’3560 Address 1
timeout = T10s ’Timeout about 10s
Call ibfind("gpib0", 0) ’Initialize GP-IB
Call ibdev(pad, gpibad, 0, timeout, 1, 0, ud)
Call SendIFC(pad)
Open App.Path & "\data.csv" For Output As #1 ’Open a text file for saving
Call Send(pad, gpibad, ":HEAD OFF", NLend) ’If headers are OFF
Call Send(pad, gpibad, ":MODE RV", NLend) ’Resistance and Voltage
Measurement Mode
Call Send(pad, gpibad, ":HOLD OFF", NLend) ’Continuous measurement ON
For i = 1 To 10
Call Send(pad, gpibad, ":MEAS:BATT?", NLend) ’Send Command to import
the most recent measurement
Call Receive(pad, gpibad, buffer, STOPend) ’Receive
recvstr = Left(buffer, InStr(1, buffer, Chr(10)) - 1)
Print #1, Str(i) & "," & recvstr ’Write to the file
Next
Close #1
Call ibonl(pad, 0)
End Sub