
243
Chapter 6 Application Programs
Example Programs for Excel 7.0
4
6
Example Programs for Excel 7.0
This section contains two example programs written using Excel macros
(
Visual Basic® for Applications
) to control the 34970A/34972A. Using
Excel, you can send SCPI commands to configure the instrument and
then record measurement data on the Excel spreadsheet.
To write an Excel macro you must first open a module in Excel. Go to the
Insert
menu, choose
Macro
, and then
Module
. Name this module “Send
Commands” by clicking on the tab with the right mouse button. Create
another module and name it “Port Configuration”. You will use the “Port
Configuration” module to configure all of the overhead required to
communicate with the instrument over the interface. You will use the
“Send Commands” module to send the SCPI commands to the
instrument using the “Port Configuration” module.
Two Excel examples are included in this section. To enter the first
example (“takeReadings”), type the text as shown on page 244 into the
“Send Commands” module. Then type the text for configuring the
interface as shown on page 245
into the “Port Configuration” module.
After entering the information for both modules, go to a spreadsheet and
run the example program. Note that you must run the macro from a
spreadsheet. With the cursor in the spreadsheet, select
Macro
from the
Tools
menu. Then double-click on the “takeReadings” macro in the
Macro dialog box.
To run the second example (“ScanChannels”), type the text as shown on
page 247 into the “Send Commands” module and reuse the “Port
Configuration” module from the first example (page 245).
Make any changes necessary to suit your application in the “Send
Commands” module. You must enter the information in the modules
exactly as shown or an error will be generated. If several system errors
occur while attempting to run a macro, you may have to reboot your PC
to get the GPIB port to work properly.
Note
:
To use these examples with Windows
3.1, you will need to modify
the declarations at the top of the “Port Configuration” module. Change
visa32.dll
to
visa.dll
in all declarations.
34970A Refresh UG.book Page 243 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 ...