HP 34970A manual Excel 7.0 Example takeReadings Macro, VISAaddr =

Models: 34970A

1 429
Download 429 pages 47.62 Kb
Page 319
Image 319
’ Start the readings and wait for instrument to put ’ one reading in memory
’ Get the number of readings stored

Chapter 7 Application Programs

Example Programs for Excel 7.0

Excel 7.0 Example: takeReadings Macro

’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

This Excel Macro (Visual Basic) configures the HP 34970A for scanning with the HP 34901A,

HP 34902A, or HP 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

HP-IB 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 HP-IB address, modify the variable ’VISAaddr’ below.

VISAaddr = "9"

OpenPort

Open communications on HP-IB

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 (see page 201 for more information). 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" Do

SendSCPI "DATA:POINTS?" 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 HP-IB

End Sub

BAA

Page 319
Image 319
HP 34970A manual Excel 7.0 Example takeReadings Macro, VISAaddr =