
244
Chapter 6 Application Programs
Example Programs for Excel 7.0
’"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’This Excel Macro (Visual Basic) configures the 34970A for scanning with the 34901A,
’34902A, or 34908A multiplexer modules. When this subroutine is executed, it will
’take the specified number of readings on the selected channel. You can easily modify the
’number of readings, channel delay, and channel number. To make these changes, modify the
’code in the section titled ’SET UP’. Note that you must have one of the above
’modules installed in slot 100 for this program to run properly. You must also have an
’GPIB interface card installed in your PC with the VISA or VTL library.
’"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’
Option Explicit
Sub takeReadings()
Columns(1).ClearContents
Columns(2).ClearContents
Dim I As Integer
’Used for counter in For-Next loop
Dim numberMeasurements As Integer
’ Number of readings
Dim measurementDelay As Single
’ Delay between relay closure and measurement
Dim points As Integer
’
’"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’ To change the GPIB address, modify the variable ’VISAaddr’ below.
VISAaddr = "9"
OpenPort
’ Open communications on GPIB
SendSCPI
"*RST"
’ Issue a Factory Reset to the instrument
’"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’
SET UP:
Modify this section to select the number of readings, channel delay,
’ and channel number to be measured.
numberMeasurements = 10
’ Number of readings
measurementDelay = 0.1
’ Delay (in secs) between relay closure and measurement
’ Configure the function, range, and channel
SendSCPI
"CONF:VOLT:DC (@103)"
’ Configure channel 103 for DC voltage
’"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’ Select channel delay and number of readings
SendSCPI
"ROUT:CHAN:DELAY " & Str$(measurementDelay)
SendSCPI
"TRIG:COUNT " & Str$(numberMeasurements)
’ Set up the spreadsheet headings
Cells(2, 1) = "Chan Delay:"
Cells(2, 2) = measurementDelay
Cells(2, 3) = "sec"
Cells(3, 1) = "Reading #"
Cells(3, 2) = "Value"
SendSCPI
"INIT"
’ Start the readings and wait for instrument to put
Do
’ one reading in memory
SendSCPI
"DATA:POINTS?"
’ Get the number of readings stored
points = Val(getScpi())
Loop Until points >= 1
’ Remove one reading at a time from memory
For I = 1 To numberMeasurements
SendSCPI
"DATA:REMOVE? 1"
’ Request 1 reading from memory
Cells(I + 3, 1) = I
’ The reading number
Cells(I + 3, 2) = Val(getScpi()) ’ The reading value
Do
’ Wait for instrument to put another reading in memory
SendSCPI
"DATA:POINTS?"
’ Get the number of readings stored
points = Val(getScpi())
Loop Until points >= 1 Or I >= numberMeasurements
Next I
ClosePort
’ Close communications on GPIB
End Sub
Excel 7.0 Example:
takeReadings Macro
34970A Refresh UG.book Page 244 Wednesday, February 17, 2010 12:34 PM
Содержание 34970A
Страница 16: ...16 34970A Refresh UG book Page 16 Wednesday February 17 2010 12 34 PM ...
Страница 20: ...34970A Refresh UG book Page 20 Wednesday February 17 2010 12 34 PM ...
Страница 21: ...1 1 Quick Start 34970A Refresh UG book Page 21 Wednesday February 17 2010 12 34 PM ...
Страница 39: ...2 2 Front Panel Overview 34970A Refresh UG book Page 39 Wednesday February 17 2010 12 34 PM ...
Страница 59: ...3 3 System Overview 34970A Refresh UG book Page 59 Wednesday February 17 2010 12 34 PM ...
Страница 87: ...4 4 Features and Functions 34970A Refresh UG book Page 87 Wednesday February 17 2010 12 34 PM ...
Страница 217: ...5 5 Error Messages 34970A Refresh UG book Page 217 Wednesday February 17 2010 12 34 PM ...
Страница 240: ...240 Chapter 5 Error Messages Plug In Module Errors 34970A Refresh UG book Page 240 Wednesday February 17 2010 12 34 PM ...
Страница 241: ...6 6 Application Programs 34970A Refresh UG book Page 241 Wednesday February 17 2010 12 34 PM ...
Страница 254: ...254 34970A Refresh UG book Page 254 Wednesday February 17 2010 12 34 PM ...
Страница 255: ...7 7 Tutorial 34970A Refresh UG book Page 255 Wednesday February 17 2010 12 34 PM ...
Страница 324: ...324 34970A Refresh UG book Page 324 Wednesday February 17 2010 12 34 PM ...