Adding Live Oscilloscope Data to Popular Analysis Software
Includes Excel
CONNECTIVITY
, Visual Basic, MATLAB
MADE EASY
and LabVIEW
Examples
Copyright Tektronix Inc. All rights reserved. Licensed software products
are owned by Tektronix or its suppliers and are protected by United States
copyright laws and international treaty provisions. LabVIEW and
LabWindows™/CVI are trademarks of National Instruments Corporation.
Mathcad is a registered trademark of MathSoft, Inc. MATLAB is a registered
trademark of The MathWorks, Inc. Microsoft and Excel are trademarks and
Windows is a registered trademark of Microsoft Corporation.
Tektronix, Inc., P.O. Box 500, Beaverton, OR 97077
Tektronix and Tek are registered trademarks of Tektronix, Inc.
Software on the CD is provided AS IS with no warranties of any
Note:
kind, specifically excluding WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. Tektronix, Inc.
assumes no liability of any kind for your use of this software.
This book shows you how to use a variety of popular tools to build graphical
user interfaces to Tektronix Windows-based oscilloscopes. By using these
“soft front panels,” you can quickly and easily connect your oscilloscope,
whether locally or remotely, to the latest PC tools for analyzing waveform
and measurement data. In addition, this book explores the functionality of the
TekExcel Toolbar Add-In for Excel, which requires no additional
programming.
Who Should Read This Book
Whether you are a novice who has never built a graphical user interface
before or an experienced programmer, you will find this book helpful if you
are interested in increasing your productivity with Tektronix Windows-based
oscilloscopes. The examples cover programming environments ranging from
Excel Visual Basic for Applications (VBA) and Visual Basic 6.0 to
MATLAB, LabWindows/CVI, and LABVIEW. Familiarity with any or all of
these environments is helpful but not necessary in order to work most of the
examples.
How This Book is Organized
This book is divided into two parts. Each part includes multiple chapters and
is designed to impart new information in progressive steps.
• Part 1 covers the use of Excel with the TekExcel Toolbar
and the TekVISA ActiveX control, and also includes Visual
Basic 6.0 examples with the TekVISA ActiveX control.
• Part 2 describes the use of MATLAB with the Instrument
Control Toolbox, and the use of LabWindows/CVI and
LabView with Tektronix Plug-n-Play drivers.
• The appendices summarize the syntax of commands and
controls used in the book, discuss LAN connectivity, present
more complex examples, and describe the use of an optional
Waveform Generator program to generate live waveforms
for examples.
Oscilloscope Analysis and Connectivity Made Easy xi
Document Conventions
A CD-ROM accompanies this book. The CD-ROM includes the text of the
book saved in PDF format, so you can use Adobe Acrobat Reader to access
the book on-line. Also on the CD are the programming examples discussed in
the book.
Document Conventions
This book makes use of certain notational conventions and typefaces in
distinctive ways, as summarized in Table 1.
Table 1: Table of typographic conventions
Typeface Meaning Example
boldface
italics
SampleName
Note:
Code
Menu >
Submenu
Used to emphasize important
points and to denote exact
characters to type or buttons to
click in step-by-step
procedures.
Used to introduce terms and to
specify variables in syntax
descriptions.
Used to designate the name of
a function, statement, filename,
or similar construct in regular
body text.
Used to call attention to notes
or tips in text.
Used to designate blocks of
code.
Used to designate a series of
cascading menus.
The example here means: from
the Tools menu, choose
Macro.
Connect your monitor to the
video port.
1. Click OK.
An industry-standard
communications protocol
called VXI-11
Attribute (type) = newvalue
You will employ a userdefined function called
Acquire_Instrument.
Note: Start here.
sCHCommands =
"DESE 1;*ESE 1;*SRE 32"
1. Choose Tools > Macro.
xii Oscilloscope Analysis and Connectivity Made Easy
Connectivity Made Easier
Chapter 1:
Connectivity Building
Blocks
Connectivity Made Easier
The first connectivity book to accompany a Windows-based Tektronix
oscilloscope was entitled Oscilloscope Connectivity Made Easy. Since that
book was published, Tektronix has added a number of new building blocks to
make connectivity even more seamless and broad-based. These connectivity
building blocks provide a new layer of middleware for connecting your
Windows-based analysis programs to Tektronix embedded oscilloscope
software.
The previous book showed you how to copy and paste or export and import
data into three popular analysis programs: Excel, Mathcad, and MATLAB.
That book also showed you how to use a stand-alone application to feed
waveform data repeatedly into Excel or Mathcad.
This Oscilloscope Analysis and Connectivity Made Easy book gives you
even more routes to jump-start connectivity to your favorite analysis
program. You will:
• explore new levels of connectivity to Excel and MATLAB
• learn how to use Visual Basic to interact with your
oscilloscope in the Windows environment
• acquire the tools and expertise to interconnect with the
LabVIEW graphical programming environment
Built-in Connectivity Features
Because Excel and MATLAB are of special interest to our customers,
Tektronix has built simple point-and-click interfaces from its oscilloscopes to
these three programs. For example, Figure 1 shows the dialog box for
copying TDS5000/7000 Series Oscilloscope waveform data to be pasted into
Excel. The oscilloscope software also includes similar setup boxes for
exporting data in a format suitable for MATLAB.
Oscilloscope Analysis and Connectivity Made Easy 1
Built-in Connectivity Features
Figure 1: A Copy Setup box prepares waveform data for Excel
Table 2 quickly reviews how to pass oscilloscope data to Excel and
MATLAB. As shown in the table, you can use copy-and-paste or export-andimport techniques to move information from your oscilloscope to these
programs.
Table 2: Quick review of exporting and importing oscilloscope data
To Copy / Export
Data from
Microsoft
Excel with
Clipboard
Edit > Copy
Setup
Menu Selections / Commands
Using
Using
Microsoft
Excel .txt File
File > Export
Setup
Using
MATLAB
.dat File
File > Export
Setup
TDS5000 and
TDS7000 Series
Oscilloscopes
To Copy / Export
Data from
Edit > Copy
Waveform
File > Export
Waveform
TDS/CSA8000 Series
Oscilloscopes
To Paste / Import
Data into
Excel / MATLAB
Edit > Paste Data > Get
External Data >
Import Text File
or
Right-click and
Reference data
filename as
argument of
M-file function
call in Command
Window
select
Refresh Data
2 Oscilloscope Analysis and Connectivity Made Easy
New Connectivity Building Blocks
New Connectivity Building Blocks
Now a number of new connectivity components have come on the scene.
These new connectivity tools support faster and more seamless transfer of
continuous live data into Excel and MATLAB. New connectivity building
blocks also support other popular programming environments: Visual Basic
as well as LabVIEW and LabWindows/CVI, a Measurement Studio
component.
• TekExcel Toolbar, an add-in that supports easy data capture
into Microsoft Excel without any programming
• TekVISA ActiveX Control, a Visual Basic OCX control that
“wraps” and encapsulates the TekVISA library, enabling
rapid application development in Visual Basic 6.0 or Visual
Basic for Applications (VBA)Excel’s behind-the-scenes
development environment
• TekVISA API, a standard application programming interface
(API) and common I/O library for connecting to and
controlling measurement devices such as oscilloscopes
• Internal “virtual”GPIB, a software resource built into
TekVISA, that links the Windows processor to the
embedded processor in Tektronix Windows-based
oscilloscopes, permitting faster acquisitions than
conventional GPIB hardware links
• VXI Plug-n-Play Drivers, for Tektronix Windows-based
oscilloscopes, capable of connecting with LabWindows/CVI
and LabVIEW test automation software and other
programming environments
• Seamless connectivity with MATLAB via the Instrument
Control Toolbox, available from The MathWorks, Inc.
• VXI-11.2 Client/Server, technology for LAN connectivity
Oscilloscope Analysis and Connectivity Made Easy
3
New Connectivity Building Blocks
TekVISAA Standard Way to Connect
TekVISA is the new Tektronix implementation of the industry-standard
library of common I/O operations known as VISA. VISA (Virtual Instrument Software Architecture) was the brainchild of the VXIplug&play Systems
Alliance (http://www.vxipnp.org
), a group formed to standardize the building
of instrumentation drivers. TekVISA’s set of operations, attributes, and
events supports connectivity between application development
environmentssuch as C++, Visual Basic, MATLAB, and LabVIEWand
multiple kinds of resources including devices connected:
• via a local GPIB connection
• via a local Serial (RS-232) connection
• via the Tektronix internal software connection known as
virtual GPIB
• via a remote GPIB-LAN connection
• remotely via virtual GPIB, Tektronix VXI-11 client/server
technology, and an Ethernet LAN connection
Figure 2 shows the broad range of connectivity brought together through
TekVISA technology.
4 Oscilloscope Analysis and Connectivity Made Easy
New Connectivity Building Blocks
Figure 2: TekVISA supports connectivity to programming environments
TekExcel Toolbar
The easiest way to get up and running with your Windows-based
oscilloscope is by making connections using the TekExcel Toolbar. This addin to Microsoft Excel works just like any other toolbar in that application.
When you click an icon, a dialog box pops up that allows you to pass
information back and forth between the Microsoft Excel application and your
Windows-based oscilloscope, without any programming modifications. If
you need no special customization beyond the built-in toolbar functions, the
TekExcel Toolbar will serve you well and get you going quickly, whether
you are transferring oscilloscope measurements or captured waveforms into
Excel. Chapter 2 introduces you to the use of this multi-purpose toolbar.
Oscilloscope Analysis and Connectivity Made Easy
5
New Connectivity Building Blocks
TekVISA ActiveX Control
The TekVISA ActiveX Control will make your job a lot easier if you are
familiar with Visual Basic or Excel’s Visual Basic for Applications. This
book explores some ways to use this powerful control to build fast
connections from VB or VBA to the acquisitions side of your oscilloscope.
With this tool, you can spend time using the programs that help you do your
job, instead of losing time building complicated specialized instrument
drivers out of sheer necessity, as was often required in the past. You can
simply drop this control onto a form and then quickly design an interface
with buttons and boxes to suit your needs.
If you just know a little bit about VB, the TekVISA ActiveX Control and the
sample programs that come with this book will arm you with enough
hands-on information to customize the examples given. Or, you can write
your own pop-up dialogs between your oscilloscope and Excel or Visual
Basic 6.0. Chapters 3 through 7, along with Table 36 in Appendix A, cover
programming at this level using the TekVISA Control. Chapters 3 through 6
focus on using VBA with Excel spreadsheets, while Chapter 7 and Appendix
C concentrate on using Visual Basic 6.0.
TekVISA API
If you are an accomplished VB or C++ programmer, you can write programs
that call TekVISA operations directly, especially if you need more
fine-grained control. The TekVISA API software now comes standard on
Tektronix Windows-based oscilloscopes. The online TekVISA Programming Manual includes a lookup reference section and a tutorial section with
programming examples. This subject matter is beyond the scope of this book.
Internal “Virtual” GPIB
TekVISA support for an internal resource called virtual GPIB means fast
connectivity between Windows and the embedded software side of your
oscilloscope. Virtual GPIB provides a software bridge to and from embedded
oscilloscope software, permitting direct internal access to the oscilloscope for
much faster and larger acquisitions than conventional GPIB ports. What is
more, this feature facilitates remote connections with other PCs over a
standard Ethernet LAN without the need for special GPIB-to-LAN hardware
adapters.
TekVISA also includes Asynchronous Serial (ASRL) and GPIB resources
that support more traditional connections to non-Windows-based
instruments.
VXI-11.2 Client /Server Connected by Local Area Network (LAN)
Tektronix VXI-11.2 Client/Server technology adds another important piece
to the connectivity picture. The VXI-11 Server-side component, combined
with TekVISA’s virtual GPIB, provides a software passageway for
connecting your Windows-based oscilloscope over an Ethernet LAN to
remote PCs. On each remote PC, you would install another copy of TekVISA
to make use of its built-in VXI-11 Client-side component.
6 Oscilloscope Analysis and Connectivity Made Easy
New Connectivity Building Blocks
You will need your own VXI-11 Client-side software if you want to connect
UNIX-based systems to your Windows-based oscilloscope.
Appendix B discusses the details of accessing the oscilloscope across a local
area network (LAN) from the programming environments discussed in this
book. Figure 3 shows the range of connections made possible by the various
TekVISA building block components. Figure 4 focuses on the components
that make LAN connectivity possible.
Figure 3: Range of connections made possible by TekVISA components
Oscilloscope Analysis and Connectivity Made Easy
7
New Connectivity Building Blocks
Figure 4: The path to LAN connectivity
Tektronix Plug-n-Play Drivers with LabWindows/CVI and LabVIEW
Tektronix VXI Plug-n-Play drivers add another feature to the connectivity
landscape, enabling easy linkage with popular test automation software such
as LabVIEW (Figure 5) and LabWindows/CVI. VXI Plug-n-Play drivers for
Tektronix Windows-based oscilloscopes add a layer of middleware so you
can work in these graphical programming environments without spending a
lot of time getting data in or out of your test equipment. Chapter 9 and Table
38 in Appendix A focus on connectivity scenarios using these graphical
tools.
8 Oscilloscope Analysis and Connectivity Made Easy
New Connectivity Building Blocks
Figure 5: Tektronix VXI Plug-n-Play Drivers integrate with popular test automation
software such as LabVIEW
MATLAB’s Instrument Control Toolbox
Anothr connectivity tool has emerged from The MathWorks, which now
offers an Instrument Control Toolbox with MATLAB
. This toolbox makes
connectivity with Windows-based oscilloscopes such as the Tektronix TDS
Family possible without complicated programming. Chapter 8 shows you
how to import live waveforms into MATLAB using this new toolbox.
Oscilloscope Analysis and Connectivity Made Easy
9
New Connectivity Building Blocks
10 Oscilloscope Analysis and Connectivity Made Easy
PART 1: EXCEL AND VISUAL BASIC
CHAPTER 2: THE TEKEXCEL TOOLBAR 13
CHAPTER 3: UNDERSTANDING THE TEKVISA ACTIVEX CONTROL 37
CHAPTER 4: A SIMPLE PROGRAM TO GET WAVEFORMS 41
CHAPTER 5: A MORE COMPLEX FOUR-PART PROGRAM 77
CHAPTER 6: A MEASUREMENT CHARTING EXAMPLE 99
CHAPTER 7: A TRIGGERED DATA CAPTURE EXAMPLE 127
11
PART 1: EXCEL AND VISUAL BASIC
12 Oscilloscope Analysis and Connectivity Made Easy
Introduction
Chapter 2:
The TekExcel Toolbar
Using the TekExcel Toolbar with
Microsoft
Excel
Introduction
This chapter introduces you to the TekExcel Toolbara multi-purpose
toolbar that allows you to place data from your Windows-based oscilloscope
directly into an Excel document simply by clicking a few buttons. Easy
acquisition is the heart of the toolbar. You can make single or repeated
captures of data on a triggered, periodic, or timed basis, with the option of
also graphing the data. Figure 6 shows the TekExcel Toolbar, which includes
six button icons.
Figure 6: The TekExcel Toolbar in Excel
No programming is required in order to use the TekExcel Toolbar; however,
the Visual Basic source code for the toolbar is available on the companion
CD for experienced VB programmers who wish to modify toolbar features
for their own use. In later chapters of this book, you will learn how to build
less complicated VBA programs that implement some of the functions built
into this toolbar.
Toolbar Prerequisites
You can use the TekExcel Toolbar with Microsoft Excel
your Tektronix Windows-based oscilloscope or on a separate PC connected
by a network to your oscilloscope. The oscilloscope and connected PC (if
any) must each have TekVISA installed on it in order to establish a
connection between Excel and your oscilloscope. See Appendix B for
information about configuring access to networked oscilloscopes.
1
The toolbar runs as an Add-In to Microsoft Excel 2000 and XP.
1
running either on
Oscilloscope Analysis and Connectivity Made Easy 13
Adding the TekExcel Toolbar to Excel
Toolbar Features
The TekExcel Toolbar enables rapid capture of oscilloscope data from within
Microsoft Excel worksheets. Table 3 describes the six buttons on the toolbar
that work with the TDS5000, 6000, and 7000. Some other instruments do not
offer all six buttons.
Table 3: Summary of TekExcel Toolbar buttons
Icon Button Name Meaning
Connect
Settings
Chooses the TekVISA-enabled oscilloscope with which
to connect.
Saves oscilloscope settings to a file or Excel workbook,
and restores oscilloscope settings from a file or Excel
workbook. Settings saved into a workbook are
automatically loaded into the oscilloscope when the
workbook is opened.
Waveform
Measurement
Trigger Capture
Captures waveform data into a worksheet and graphs
it.
Captures and graphs single or periodic waveform
measurements.
Captures waveform data from an oscilloscope-defined
trigger, places it into a worksheet, and graphs it.
Note: The TDS5000, 6000, and 7000 support this
toolbar button. Other instruments do not.
Help
Launches the online help file for the TekExcel Toolbar.
The toolbar is easy to use. Click a button and a dialog box appears. Within
dialog boxes, you can select the type of data you want to capture and
automatically paste into Excel, along with an optional line chart.
If you let your mouse linger over a button, a tool tip will appear indicating
the button’s function. Clicking the
Help button launches an online help file
for the TekExcel Toolbar (see page 34).
Adding the TekExcel Toolbar to Excel
The TekExcel Toolbar is an Excel Add-In. During toolbar installation, the
toolbar file (
main TekVISA files.
14 Oscilloscope Analysis and Connectivity Made Easy
2
Assuming you are installing on the C: drive on a Windows 98 system, the toolbar is placed in
C:\VXIpnp\Win95\TEKvisa\ExcelToolbar\TekExcelToolbar.xla. On a Windows NT system, the toolbar is
placed in C:\VXIpnp\WinNT\TEKvisa\ExcelToolbar\TekExcelToolbar.xla.
TekExcelToolbar.xla) is normally placed in a subdirectory of the
2
Connecting to Oscilloscopes
When you first install the TekExcel Toolbar, follow these steps to add it to
Excel:
Start up Excel and select
Tools > Add-Ins… from the Excel menu bar.
The Add-Ins dialog box appears.
Select the check box next to
TekExcel Toolbar in the list of choices. If the
TekExcel Toolbar does not appear in the list, click the
to the appropriate directory, and select the
TekExcelToolbar.xla file.
Browse… button, navigate
Click
OK.
The TekExcel Toolbar appears undocked in the Excel program.
Leave the toolbar undocked, or drag it up to the Excel Formatting Toolbar if you
want it to remain docked in a fixed position.
Connecting to Oscilloscopes
The Connect button on the TekExcel Toolbar allows you to select a
TekVISA-enabled oscilloscope with which to establish a connection.
To connect to a Tektronix Windows-based oscilloscope from within Excel:
1. Click the Connect button on the TekExcel Toolbar.
Oscilloscope Analysis and Connectivity Made Easy
15
Saving and Restoring Scope Settings
A dialog box similar to the following appears:
2. By default, the first GPIB device encountered in the
instrument list is selected.
3. Leave the selection as is, or select another instrument with
which to connect and click
OK.
The connection with the selected instrument is made. You may only
connect to one instrument at a time using the TekExcel Toolbar.
Note: Click the Refresh button to display any changes to the list
of connected devices since the last time you clicked the Connect
button.
Click the Identify button to display the instrument model number at
the bottom of the dialog box.
Saving and Restoring Scope Settings
The Settings button on the TekExcel Toolbar allows you to save
oscilloscope settings to a file or to an active Excel workbook, and restore
them later to the oscilloscope.
If you save settings to an active worksheet and then save and reopen the
associated Excel .
oscilloscope.
xls file, the settings are automatically assigned to the
If you save settings to a file, you have the option of placing a descriptor in
the settings file. The file can take one of two forms:
16 Oscilloscope Analysis and Connectivity Made Easy
Loading...
+ 316 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.