
247
Chapter 6 Application Programs
Example Programs for Excel 7.0
4
6
’"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’ 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
’ scan 5 channels and display the readings on a spreadsheet. You can easily modify the
’ channels in the scan list, number of scans, channel delay, and scan delay. 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 ScanChannels()
Dim columnIndex As Integer
’ The column number of the data
’ "1" indicates the first data column
Dim numberScans As Integer
’ Total number of scans
Dim numberChannels As Integer
’ Total number of scanned channels
Dim ScanInterval As Single
’ Time interval in seconds between scans
Dim points As Integer
’ Reading count in instrument memory
Dim replyString As String
’ Store the string returned from instrument
Dim scanList As String
’ List of channels included in scan
Dim channelDelay As Single
’ Delay between relay closure and measurement
Dim Channel As Integer
Range("a1:ba40").ClearContents
’ Clear the spreadsheet
’
’"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’ 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 scan interval, the scan count,
’ and channel delay.
’
’ These are variables that are used to set the scan parameters
ScanInterval = 10
’ Delay (in secs) between scans
numberScans = 3
’ Number of scan sweeps to measure
channelDelay = 0.1
’ Delay (in secs) between relay closure and measurement
’ To delete channels from the scan list, modify the scan list string variable
’ ’scanList’ below. To add channels to the scan list, modify ’scanList’ and then
’ configure the channel using the CONFigure command.
’
’ ’scanList’ is the list of channels in the scan list; note that this does not have
’ to include all configured channels in the instrument.
scanList
= "(@101,102,110:112)"
SendSCPI
"CONF:TEMP TC,T,(@101)"
’ Configure channel 101 for temperature
SendSCPI
"CONF:TEMP TC,K,(@102)"
’ Configure channel 102 for temperature
SendSCPI
"CONF:TEMP THER,5000,(@103)"
’ Configure channel 103 for temperature
SendSCPI
"CONF:VOLT:DC (@110,111,112)"
’ Configure three channels for DC volts
’"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
SendSCPI
"ROUTE:SCAN " & scanList
’ Select the list of channels to scan
SendSCPI
"ROUTE:SCAN:SIZE?"
’ Query the number of channels in scan list and
numberChannels = Val(GetSCPI())
’ set variable equal to number of channels
SendSCPI
"FORMAT:READING:CHAN ON"
’ Return channel number with each reading
SendSCPI
"FORMAT:READING:TIME ON"
’ Return time stamp with each reading
’ Set the delay (in seconds) between relay closure and measurement
SendSCPI
"ROUT:CHAN:DELAY " & Str$(channelDelay) & "," & scanList
Continued on next page
Excel 7.0 Example:
ScanChannels Macro
34970A Refresh UG.book Page 247 Wednesday, February 17, 2010 12:34 PM
Summary of Contents for 34970A
Page 16: ...16 34970A Refresh UG book Page 16 Wednesday February 17 2010 12 34 PM ...
Page 20: ...34970A Refresh UG book Page 20 Wednesday February 17 2010 12 34 PM ...
Page 21: ...1 1 Quick Start 34970A Refresh UG book Page 21 Wednesday February 17 2010 12 34 PM ...
Page 39: ...2 2 Front Panel Overview 34970A Refresh UG book Page 39 Wednesday February 17 2010 12 34 PM ...
Page 59: ...3 3 System Overview 34970A Refresh UG book Page 59 Wednesday February 17 2010 12 34 PM ...
Page 87: ...4 4 Features and Functions 34970A Refresh UG book Page 87 Wednesday February 17 2010 12 34 PM ...
Page 217: ...5 5 Error Messages 34970A Refresh UG book Page 217 Wednesday February 17 2010 12 34 PM ...
Page 241: ...6 6 Application Programs 34970A Refresh UG book Page 241 Wednesday February 17 2010 12 34 PM ...
Page 254: ...254 34970A Refresh UG book Page 254 Wednesday February 17 2010 12 34 PM ...
Page 255: ...7 7 Tutorial 34970A Refresh UG book Page 255 Wednesday February 17 2010 12 34 PM ...
Page 324: ...324 34970A Refresh UG book Page 324 Wednesday February 17 2010 12 34 PM ...