EasyManua.ls Logo

Keysight 34972A - Excel 7.0 Example: Takereadings Macro

Keysight 34972A
353 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
6 Application Programs
256 Keysight 34970A/34972A User’s Guide
Excel 7.0 Example: takeReadings Macro
Continued on next page
’"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’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

Table of Contents

Related product manuals