Welcome to
IVI drivers and shows you how to create a short program to perform a
measurement. The guide also provides a brief introduction to several advanced
topics.
IVI Getting Started Guide
to control test-and-measurement instruments. As you develop test programs, you
face decisions about how you communicate with the instruments. Some of your
choices include Direct I/O, VXIplug&play drivers, or IVI drivers. If you are new to
using IVI drivers or just want a quick refresher on how to get started,
Started Guide
IVI Getting Started Guide
is intended for individuals who write and run programs
can help.
. This guide introduces key concepts about
IVI Getting
IVI Getting Started Guide
to-use tools. IVI drivers provide a number of advantages that can save time and
money during development, while improving performance as well. Whether you are
starting a new program or making improvements to an existing one, you should
consider the use of IVI drivers to develop your test programs.
So consider this the “hello, instrument” guide for IVI drivers. If you recall, the “hello
world” program, which originally appeared in Programming in C: A Tutorial, simply
prints out “hello, world.” The “hello, instrument” program performs a simple
measurement on a simulated instrument and returns the result. We think you’ll find
that far more useful.
Why Use an Instrument Driver?
To understand the benefits of IVI drivers, we need to start by defining instrument
drivers in general and describing why they are useful. An instrument driver is a set
of software routines that controls a programmable instrument. Each routine
corresponds to a programmatic operation, such as configuring, writing to, reading
from, and triggering the instrument. Instrument drivers simplify instrument control
and reduce test program development time by eliminating the need to learn the
programming protocol for each instrument.
shows you that IVI drivers can be straightforward, easy-
•
•
•
9
•
•
•
Starting in the 1970s, programmers used device-dependent commands for
computer control of instruments. But lack of standardization meant even two digital
multimeters from the same manufacturer might not use the same commands. In
the early 1990s a group of instrument manufacturers developed Standard
Commands for Programmable Instrumentation (SCPI). This defined set of
commands for controlling instruments uses ASCII characters, providing some
basic standardization and consistency to the commands used to control
instruments. For example, when you want to measure a DC voltage, the
standard SCPI command is “MEASURE:VOLTAGE:DC?”.
In 1993, the VXIplug&play Systems Alliance created specifications for instrument
drivers called VXIplug&play drivers. Unlike SCPI, VXIplug&play drivers do not
specify how to control specific instruments; instead, they specify some common
aspects of an instrument driver. By using a driver, you can access the instrument
by calling a subroutine in your programming language instead of having to format
and send an ASCII string as you do with SCPI. With ASCII, you have to create and
send the instrument the syntax “
MEASURE:VOLTAGE:DC?
”, then read back a
string, and build it into a variable. With a driver you can merely call a function called
MeasureDCVoltage( ) and pass it a variable to return the measured voltage.
Although you still need to be syntactically correct in your calls to the instrument
driver, making calls to a subroutine in your programming language is less error
prone. If you have been programming to instruments without a driver, then you are
probably all too familiar with hunting around the programming guide to find the right
SCPI command and exact syntax.
You also have to deal with an I/O library to
format and send the strings, and then build the response string into a variable.
•
•
•
10
Chapter 1
•
•
•
Why IVI?
The VXIplug&play drivers do not provide a common programming interface. That
means programming a Keithley DMM using VXIplug&play still differs from
programming an Agilent DMM. For example, the instrument driver interface for one
may be ke2000_read while another may be hp34401_get or something even
farther afield. Without consistency across instruments manufactured by different
vendors, many programmers still spent a lot of time learning each individual driver.
T o carry VXIplug&play drivers a step (or two) further, in 1998 a group of end users,
instrument vendors, software vendors, system suppliers, and system integrators
joined together to form a consortium called the Interchangeable Virtual Instruments
(IVI) Foundation. If you look at the membership, it’s clear that many of the
foundation members are competitors. But all agreed on the need to promote
specifications for programming test instruments that provide better performance,
reduce the cost of program development and maintenance, and simplify
interchangeability.
For example, for any IVI driver developed for a DMM, the measurement command
is IviDmmMeasurement.Read, regardless of the vendor. Once you learn how to
program the commands specified by IVI for the instrument class, you can use any
vendor’s instrument and not need to relearn the commands. Also commands that
are common to all drivers, such as Initialize and Close, are identical regardless of
the type of instrument. This commonality lets you spend less time hunting around
the help files and programming an instrument, leaving more time to get your job
done.
That was the motivation behind the development of IVI drivers.The IVI
specifications enable drivers with a consistent and high standard of quality,
usability , and completeness. The specifications define an open driver architecture,
a set of instrument classes, and shared software components. Together these
provide consistency and ease of use, as well as the crucial elements needed for
the advanced features IVI drivers support: instrument simulation, automatic range
checking,
state caching, and interchangeability
.
The IVI Foundation has created IVI class specifications that define the capabilities
for drivers for the following eight instrument classes:
ClassIVI Driver
Digital multimeter (DMM)IviDmm
OscilloscopeIviScope
Arbitrary waveform/function generatorIviFgen
DC power supplyIviDCPwr
SwitchIviSwitch
Power meterIviPwrMeter
Spectrum analyzerIviSpecAn
RF signal generatorIviRFSigGen
IVI Class Compliant drivers usually also include capability that is not part of the IVI
Class. It is common for instruments that are part of a class to have numerous
functions that are beyond the scope of the class definition. This may be because
the capability is not common to all instruments of the class or because the
instrument offers some control that is more refined than what the class defines.
IVI also defines custom drivers. Custom drivers are used for instruments that are
not members of a class. For example, there is not a class definition for network
analyzers, so a network analyzer
driver must be a custom driver. Custom drivers
provide the same consistency and benefits described below for an IVI driver,
except interchangeability.
Introduction
•
•
•
11
•
•
•
IVI drivers conform to and are documented according to the IVI specifications and
usually display the standard IVI logo.
Note
: For more information on the types of IVI drivers, refer to Chapter 11,
Advanced Topics.
Why Use an IVI Driver?
Why choose IVI drivers over other possibilities? Because IVI drivers can increase
performance and flexibility for more intricate test applications. Here are a few of the
benefits:
Consistency
instrument. That saves you time when you
Ease of use
Development Environments (ADEs). The APIs provide fast, intuitive access to
functions. IVI drivers use technology that naturally integrates in many differen t
software environments.
– IVI drivers all follow a common model of how to control the
need to use a new instrument.
– IVI drivers feature enhanced ease of use in popular Application
•
•
•
12
Chapter 1
•
•
•
Quality
–
IVI drivers focus on common commands, desirable options, and
rigorous testing to ensure driver quality.
Simulation –
IVI drivers allow code development and testing even when an
instrument is unavailable. That reduces the need for scarce hardware resources
and simplifies test of
measurement applications. The example programs in this
document use this feature.
Range checking –
IVI drivers ensure the parameters you use are within
appropriate ranges for an instrument.
State caching –
IVI drivers keep track of an instrument’s status so that I/O is only
performed when necessary, preventing redundant configuration commands from
being sent. This can significantly improve test system performance.
Interchangeability –
IVI drivers enable exchange of instruments with minimal
code changes, reducing the time and effort needed to integrate measurement
devices into new or existing systems. The IVI class specifications provide syntactic
interchangeability but may not provide behavioral interchangeability.
In other
words, the program may run on two different instruments but the results may
not be the same due to differences in the way the instrument itself functions.
Flavors of IVI Drivers
To support all popular programming languages and development environments,
IVI drivers provide either an IVI-C or an IVI-COM (Component Object Model) API.
Driver developers may provide either or both interfaces, as well as wrapper
interfaces optimized for specific development environments.
Although the functionality is the same,
C development environments; IVI-COM drivers are optimized for environment s
that support the
VXIplug&play driver specification and their usage is similar. IVI-COM drivers
provide easy access to instrument functionality through methods and properties.
All IVI drivers communicate to the instrument through an I/O Library. Our examples
use the Virtual Instrument Software Architecture (VISA), a widely used standard
library for communicating with instruments from a personal computer.
Shared Components
To make it easier for you to combine drivers and other software from various
vendors, the IVI Foundation members have cooperated to provide common
software components, called IVI Shared Components. These components provide
services to drivers and driver clients that need to be common to all drivers. For
instance, the IVI Configuration Server enables administration of system-wide
configuration.
Important! You must install the IVI Shared Components before an IVI driver
can be installed.
The IVI Shared Components can be downloaded from vendors’ web sites as well
as from the IVI Foundation Web site.
To download and install shared components from the IVI Foundation Web site:
1Go to the IVI Foundation Web site at http://www.ivifoundation.org.
2Locate Shared Components.
3Choose the IVI Shared Components msi file for the Microsoft Windows
Installer package or the IVI Shared Components exe for the executable
installer.
IVI-C drivers are optimized for use in ANSI
Component Object Model (COM). IVI-C drivers extend the
Download and Install IVI Drivers
After you’ve installed Shared Components, you’re ready to download and install an
IVI driver. For most ADEs, the steps to download and install an IVI driver are
identical. For the few that require a different process, the relevant chapter in
Getting Started Guide
IVI Drivers are available from your hardware or software vendor’s web site or by
linking to them from the IVI Foundation web site.
provides the information you need.
IVI
Introduction
•
•
•
13
•
•
•
To see the list of drivers registered with the IVI Foundation, go to
http://www.ivifoundation.org
Familiarizing Yourself with the Driver
Although the examples in
likely
employ a variety of IVI drivers
task, you’ll want to familiarize yourself quickly with drivers you haven’t used before.
Most ADEs provide a way to explore IVI drivers to learn their functionality. In each
chapter, where applicable, we add a note explaining how to view the available
functions. In addition, browsing an IVI driver’s help file often proves an excellent
way to learn its functionality.
Examples
As we noted above, each example chapter in
you how to use an IVI driver to write and run a program that performs a simple
measurement on a simulated instrument and returns the result. The examples
demonstrate common steps using IVI drivers.
includes the steps listed below:
•
Download and Install the IVI driver– covered in the Download and Install IVI
Drivers section above.
•
Determine the VISA address string – Examples in
use the simulate mode, so we chose the address string
often shown as GPIB::23. If you need to determine the VISA address string for
your instrument and the ADE does not provide it automatically, use an IO
application, such as National Instruments Measurement and Automation
Explorer (MAX) or Agilent Connection Expert.
•
Reference the driver or load driver files – For the examples in this guide, the
driver is the
March 2006 (from Agilent Technologies)
Specific driver, Version 4.1, October 2006 (from National Instruments).
•
Create an instance of the driver in ADEs that use COM – For the examples in
this guide, the driver is the
•
Write the program:
•
Agilent 34401A IVI-COM Specific Driver, Version 1.1.0.11,
Initialize the instrument – Initialize is required when using any IVI driver.
Initialize establishes a communication link with the instrument and must
be called before the program can do anything with the instrument. We set
reset to
true
, ID query to
.
IVI Getting Started Guide
to develop test programs. To jumpstart that
Agilent 34401A (IVI-COM) or HP 34401 (IVI-C)
false
, and simulate to
use a DMM driver, you will
IVI Getting Started Guide
Where practical, every example
IVI Getting Started Guide
GPIB0::23::INSTR,
or the
Agilent 34401A IVI-C
true
.
shows
.
•
•
•
14
Chapter 1
•
•
•
Setting reset to true tells the driver to initially reset the instrument.
Setting the ID query to false prevents the driver from verifying that the
connected instrument is the one the driver was written for. Finally,
setting simulate to true tells the driver that it should not attempt to
connect to a physical instrument, but use a simula tio n of the
instrument.
•
Configure the instrument – We set a range of
0.001 volts (1 millivolt)
.
1.5 volts
and a resolution of
•
Access an instrument property – We set the trigger delay to
seconds
•
Set the reading timeout – We set the reading timeout to
milliseconds (1 second).
•
Take a reading
•
Close the instrument – This step is required when using any IVI driver,
unless the ADE explicitly does not require it. We close the session to free
resources.
Important! Close may be the most commonly missed step when using an
IVI driver. Failing to do this could mean that system resources are not
freed up and your program may behave unexpectedly on subsequent
executions.
•
Check the driver for any errors.
•
Display the reading.
Note:
Examples that use a console application do not show the display.
Now that you understand the logic behind IVI drivers, let’s see how to get started.
.
0.01
1000
Introduction
•
•
•
15
•
•
•
•
•
•
16
Chapter 1
•
•
•
Chapter 2
Using IVI with Visual C++
• • • • • •
The Environment
Microsoft Visual C++ is a software development environment for the C++
programming language and is available as part of Microsoft Visual Studio.
Visual C++ allows you to create, debug, and execute conventional applications
as well as applications that target the .NET Framework.
Example Requirements
•
Visual C++
•
Microsoft Visual Studio 2005
•
IVI-COM: Agilent 34401A IVI-COM, Version 1.1.0.11, March 2006 (from Agilent
Technologies); or
•
IVI-C: Agilent 34401A IVI-C, Version 4.1, October 2006 (from National
Instruments)
•
Agilent IO Libraries Suite 14.2
Download and Install the Driver
If you have not already installed the driver, go to the vendor W eb site and follow the
instructions to download and install it.
Since Visual C++ supports both IVI-COM and IVI-C drivers, this example is written
two ways, first to show how to use an IVI-COM driver in Visual C++, and second to
show how to use an IVI-C driver in Visual C++.
Note
because the referenced files are not included in the program. If you need to
download and install a driver, you do not need to exit V isual Studio. Install the driver
and continue with your program.
Using IVI-COM in C++
The following sections show how to get started with an IVI-COM driver in Visual
C++
: If you do not install the appropriate instrument driver , the project will not build
•
•
•
17
•
•
•
Create a New Project and Import the Driver Type Libraries
To use an IVI Driver in a Visual C++ program, you must provide the path to the
driver DLL.
•
•
•
18
Chapter 2
•
•
•
1Launch Visual Studio 2005 and create a Win32 Console Application in C++
with the name IVI demo.
Note:
The program already includes some required code, including the header file
#include stdafx.h
.
2From the Tools menu select Options.
3Expand “Projects and Solutions”, then click on “VC++ Directories”
4Click on the “Show directories for” combo box and choose “Library files”
5Add the following two entries to your path.
The first entry will point to the default directory for IVI drivers. This is typically:
“C:\Program Files\Ivi\Bin”
The second entry points to the VISA DLL that many drivers require:
Initialize COM
“$(VXIPNPPATH)VisaCom”
Note:
These steps need only be done once for each computer you use. All
subsequent Visual Studio projects will continue to use these settings and will be
able to locate your IVI-COM drivers.
6Click OK
7To import the type libraries, type the following statements following the header
statements access the driver type libraries used by the Agilent
34401 DMM. The no_namespace attribute allows the code to access the interfaces
in the typelibraries from the global namespace.
1To initialize the COM library, type the following lines after the { following the int
Note: Including error handling in your programs is good practice. This code
checks for errors in your program.
2To close the COM library before exiting, type the following line at the end of
your code, right before the return line:
CoUninitialize();
Create an Instance of the Driver
To create an instance of the driver, type
IIviDmmPtr dmm(__uuidof(Agilent34401));
Note:
This creates a smart pointer that provides easy access to the COM object.
You are now ready to write the program to control the simulated instrument.
Using IVI with Visual C++
•
•
•
19
•
•
•
Initialize the Instrument
You can now write the main constructs for your program.
Below the smart pointer statement, type
dmm->Initialize("GPIB::23", false, true, "simulate=true");
Note
: As soon as you type ->, Intellisense displays options and helps ensure you
use correct syntax and values.
Configure the Instrument
To set the range to 1.5 volts and resolution to 0.001 volts, type
Build your application and run it to verify it works properly.
1From the Start Menu, select Build, and click Build IVIDemo.
2From the Start Menu, select Debug, and run the application.
Using IVI-C in Visual C++
The following sections show to get started with IVI-C in Visual C++.
Create a New Project and Import the Driver Type Libraries
To use an IVI-C Driver in a Visual C++ program, you must provide paths to the
header files and libraries it uses.
1Launch Visual Studio 2005 and create a Win32 Console Application in C++
with the name IVI demo.
Note:
The program already includes some required code, including the header file
#include stdafx.h
.
2From the Tools menu select Options.
3Expand “Projects and Solutions”, then click on “VC++ Directories”
4Click on the “Show directories for” combo box and choose “Library files”
5Add the following entry to your “Library files” path.
This entry points to the default directory for IVI drivers. This is typically:
“C:\Program Files\IVI\Lib\msc”
6Click on the “Show directories for” combo box and choose “Include files”
7Add the following entries to your “Include files” path.
The first entry will point to the default directory for IVI drivers. This is typically:
“C:\Program Files\IVI\include”
The second entry points to the VISA header files that IVI-C drivers require:
“$(VXIPNPPATH)WinNT\include”
8Click OK
Note:
These initial steps need only be done once for each computer you use. All
subsequent Visual Studio projects will continue to use these settings and will be
able to locate your IVI-COM drivers.
9Select Project and click Properties. The IVIDemo.cpp “Property pages” dialog
box appears.
Using IVI with Visual C++
•
•
•
23
•
•
•
10 Expand “Configuration Properties”
11 Expand “Linker”
12 Select Input. In the Additional Dependencies field, type
13 Select OK.
14 To add the hp34401a instrument driver header file to your program, type the
15 From the Main Menu, select Build and click Build IVIDemo.
Declare V ariables
1Y ou will need to declare some variables that will be used in your program. T ype
“hp34401a.lib”
following statement following the existing header file reference:
#include “hp34401a.h”
the following lines after the { in the int main () statement:
ViSession session;
ViStatus error = VI_SUCCESS;
ViReal64 reading;
•
•
•
24
Chapter 2
•
•
•
Define Error Checking
1Next define error checking for your program. First you will define a macro to
catch the errors. It is better to define it once at the beginning of the program
that to add the logic to each of your program statements. After the #include
statements, type the following lines:
Build your application and run it to verify it works properly.
Using IVI with Visual C++
•
•
•
27
•
•
•
1From the Start Menu, select Build, and click Build IVI Demo.
2From the Start Menu, select Debug, and run the application.
Further Information
Learn more about Visual C++ at http://msdn.microsfot.com/visualc/.
Microsoft® and Visual Studio® are registered tradem arks of Microsoft Corporation
in the United States and/or other countries.
•
•
•
28
Chapter 2
•
•
•
Chapter 3
Using IVI with Visual C# and
Visual Basic .NET
• • • • • •
The Environment
C# and Visual Basic are object-oriented programming languages developed by
Microsoft. They enable programmers to quickly build a wide range of applications
for the Microsoft .NET platform. This chapter provides detailed instructions in C#
as well as the code for Visual Basic.
Visual Basic 6.0, refer to Chapter 9.
Note:
One of the key advantages of using C# and Visual Basic in the Microsoft®
Visual Studio
InstelliSense is a form of autocompletion for variable names and functions and a
convenient way to access parameter lists and ensure correct syntax. The feature
also enhances software development by reducing the amount of keyboard input
required.
Example Requirements
•
Visual C#
•
Microsoft Visual Studio 2005
•
Agilent 34401A IVI-COM, Version 1.1.0.11, March 2006 (from Agilent
Technologies)
•
Agilent IO Libraries Suite 14.2
®
Integrated Development Environment is IntelliSense™.
If you are looking for an example using
Download and Install the Driver
If you have not already installed the driver, go to the vendor W eb site and follow the
instructions to download and install it. You can also refer to Chapter 1, Download
and Install IVI Drivers, for instructions.
This example uses an IVI-COM driver. IVI-COM is the preferred driver for C#, but
IVI-C is also supported.
•
•
•
29
•
•
•
Create a New Project and Reference the Driver
To use an IVI Driver in a Visual C# program, you must first add a reference to it.
1Launch Visual Studio and start a new Console Application in Visual C#.
Note:
The program already includes some required code, including using
statements. Keep this required code.
2Select Project and click Add Reference. The Add Reference dialog appears.
3Select the COM tab. All IVI drivers begin with IVI. Scroll to the IVI section and
select IVI Agilent 34401 (Agilent Technologies) 1.1 Type Library. Click OK.
Note
: If you have not installed the IVI driver, it will not appear in this list. You must
close the Add Reference dialog, install the driver, and select Add Reference again
for the driver to appear.
•
•
•
30
Chapter 3
•
•
•
Note:
The program looks the same as it did before you added the reference, but
the driver is now available for use. To see the reference, select View and click
Solution Explorer. Solution Explorer appears and lists the reference.
Create an Instance of the Driver
T o allow your program to access the driver without specifying the full path, type the
following line immediately below the other
using Agilent.Agilent34401.Interop;
Note:
As soon as you type the A for Agilent, IntelliSense lists the valid inputs.
Congratulations! You may now write the program to control the simulated
instrument.
using
statements:
Note
: T o view the functions and parameters available in the instrument driver , rightclick the library in the References folder in Solution Explorer and select View in
Object Browser.
Using IVI with Visual C# and Visual Basic
•
•
•
31
•
•
•
•
•
•
32
Chapter 3
•
•
•
Initialize the Instrument
You can now write the main constructs for your program. Create a variable to
represent your instrument and set the Initialization parameters.
To dimension a variable for the instrument and reading, use
reading
Learn more about Visual C# at http://msdn.microsoft.com/vsharp/.
Learn more about Visual Basic at http://msdn.microsoft.com/vbasic/.
Dim reading AsNewDouble
reading = dmm.Measurement.Read(1000)
dmm.Close()
Dim dmm
.
and
Dim
Microsoft® and Visual Studio® are registered tradem arks of Microsoft Corporation
in the United States and/or other countries.
Using IVI with Visual C# and Visual Basic
•
•
•
35
•
•
•
•
•
•
36
Chapter 3
•
•
•
Chapter 4
Using IVI with LabVIEW
• • • • • •
The Environment
National Instruments LabVIEW is a graphical development environment for signal
acquisition, measurement analysis, and data presentation. LabVIEW provides the
flexibility of a programming language with less complexity than traditional
development tools.
Example Requirements
•
LabVIEW 8.2.0
•
IVI-C: Agilent 34401A IVI-C specific driver, Version 4.1, October 2006 (from
National Instruments)
•
IVI-COM: Agilent 34401A IVI-COM driver, Version 1.1.0.11, March 2006 (from
Agilent Technologies)
Note:
These drivers may require an I/O library to be installed. Check the driver
vendor’s Web site for details.
Download and Install the Driver
If you have not already installed the driver, go to the vendor Web site and follow
the instructions to download and install it.
Since LabVIEW supports both IVI-C and IVI-COM drivers, this example is written
two ways, first to show how to use an IVI-C driver in LabVIEW, and second how to
use an IVI-COM driver in LabVIEW.
TM
Using IVI-C
Note:
The functionality shown in the example is available in a LabVIEW example
supplied with the IVI driver from National Instruments.
Alll IVI-C drivers provide a Dynamic Link LIbrary (DLL) interface. While LabVIEW
provides the Call Library Function node to call DLLs, many IVI-C drivers also come
with a LabVIEW wrapper that provides the familiar VI interface to the driver’s
•
•
•
37
•
•
•
functions, making it easier to use in LabVIEW. If your IVI-C driver does not have a
LabVIEW wrapper, you can create one using a free tool by clicking on
Instrument Driver Import Wizard at
http://www.ni.com/devzone/idnet/development.htm
Note:
The functionality shown in this section is available in a LabVIEW example
supplied with the IVI driver from National Instruments.
Create a Project and Access the Driver
1Launch LabVIEW.
2From the File menu, select New VI. The Front Panel and Block Diagram
appear.
3Right-click in the Block Diagram. The Functions palette appears.
4Select the Instrument I/O subpalette and then the Instrument Drivers
subpallete. You can access all instrument driver VIs from this palette.
5Click Instrument Drivers. Select hp34401a from the palette.
6Select the hp34401a IVI driver from the palette.
Note
: If the driver you want to use is not listed, download and install the driver, and
close and restart LabVIEW. The driver should now appear in the palette. The driver
palette allows you to browse the various VIs and functionality
driver.
LabVIEW
:
supported by the
•
•
•
38
Chapter 4
•
•
•
Initialize the Instrument
1Select Initialize With Options VI from the hp34401a palette and place it on the
Block Diagram.
2Create constants and enter values for instrument resource nam e, ID Query,
Reset, and IVI option string:
•
GPIB0::23::INSTR
•
False
in the ID Query field
•
True
in the Reset field
•
Simulate=1
Note:
To create a constant, control, or indicator, right-click on the desired input
terminal and select Create.
in the instrument resource name field
in the Options field
Using IVI with LabVIEWTM 39
•
•
•
•
•
•
Configure the Instrument
1From the Configuration subpalette, select Configure Measurement VI and
place it on the Block Diagram.
2Create constants and enter values to set the resolution to 1 millivolt, the
function to DC Voltage, and the range to 1.5 volts:
•
0.001
•
DC volts
•
1.5
in the Range field
3Connect the instrument handle and error terminals from Initialize With Options
VI to Configure Measurement VI.
4From the Trigger subpalette, select Configure Trigger VI and place it on the
Block Diagram.
5Connect resource name and error information from Con figure Measurement VI
to Configure Trigger VI.
6Create a constant and enter a value of 0.01 in the Trigger Delay field.
Note:
You can also set the T r igger Delay using a Property Node by replacing steps
4 & 5 with a property access as shown in the section “Setting a Property in an IVIC Driver” below.
in the Resolution field
in the Measurement Function field
•
•
•
40
Chapter 4
•
•
•
Take the Reading
1Return to the main hp34401a palette. From the Measurement subpalette,
select Read VI and place it on the Block Diagram.
2Set the value for Timeout to 1 second (1000 ms). Enter 1000 in the Timeout
field.
3Connect resource name and error information from Configure T ri gger to Read
VI.
Display the Reading
Create an indicator for Reading from the terminal on the Read VI.
Close the Session
1Return to the main hp 34401a palette. Select Close VI and place it on the Block
Diagram.
2Connect resource name and error information from Read VI to Close VI.
Note:
execution at any time.
Add Error Checking
1Return to the main functions palette. From the Dialog & User Interface
subpalette select Simple Error Handler VI and place it on the Block Diagram.
2Connect the error information from Close VI to Simple Error Handler VI.
Run the Application
Y our final VI Block Diagram should cont ain the elements shown below . To run your
VI:
1Switch to the VI’s Front Panel and click on the Run arrow to run the application.
2The Reading indicator should display a simulated reading from the instrument.
LabVIEW compiles while developing, which lets you check the program
•
•
Using IVI with LabVIEWTM 41
•
•
•
•
Setting a Property in an IVI-C Driver
Properties such as Trigger Delay can also be set (and read) with a property node.
This is important in cases where a configuration function is not provided by the
driver.
For example we can replace steps 4 and 5 of the “Configure the Instrument”
section with:
1From the Functions palette select Application Control and drop a Property
Node on the Block Diagram.
2Connect the resource name and error information from Configure
Measurement VI to the Property Node.
3Right-click on the Property Node and select Change All to Write.
4Click on the Property field and select Trigger >> Trigger Delay.
•
•
•
42
Chapter 4
•
•
•
Using IVI-COM
To use IVI-COM drivers in LabVIEW you will use the ActiveX functions and the
Class Browser that are built-in to LabVIEW.
Create a Project and Access the Driver
1Launch LabVIEW
2From the File menu, select New VI. The Front Panel and Block Diagram
appear.
3Right-click in the Block Diagram. The Functions palette appears.
4Select the Connectivity subpalette and then the Active X subp alle te. From this
palette, you can access ActiveX and COM objects including all IVI-COM
drivers.
5Select Automation Open from the palette and place it on the block diagram.
6Right-click on the Automation Refnum terminal, select Select ActiveX Class...
and then Browse...
Using IVI with LabVIEWTM 43
•
•
•
•
•
•
7From the Type Library drop-down, select the IVI Agilent 34401A (Agilent
Technologies) 1.1 Type Library Version 1.1, and then select the IAgilent34401
object. Click OK.
Note:
If the IVI-COM driver you want to use is not listed, download and install the
driver and close and restart LabVIEW. The driver should now appear in the type
library browser.
•
•
•
44
Chapter 4
•
•
•
Initialize the Instrument
1From the View menu, select Class Browser. The Class Browser allows you to
invoke methods and set or get properties of the ActiveX/COM object.
2From the Object library drop-down, select ActiveX and then Select Type
Libraries.
3Scroll down and select the IVI Agilent 34401A (Agilent Technologies) 1.1 T ype
Library Version 1.1, Click OK.
4Back in the Class Browser, under Properties and Methods, scroll down and
select Initialize. Click Create and drag the Invoke Node to the Block Diagram.
5Create constants and enter values for ResourceName, IDQuery, Reset, and
OptionString:
•
GPIB0::23::INSTR
•
False
in the IDQuery field
•
True
in the Reset field
•
Simulate=1
in the instrument ResourceName field
in the OptionString field
6Connect the automation refnum and error terminals from Automation Open to
Initialize Invoke Node.
Note:
Instead of using the Class Browser, you can select an Invoke Node from the
ActiveX subpalette and select the Initialize method. To access driver properties,
you can select a Property Node from the ActiveX subpalette and select the
appropriate property or you can use the Class Browser for both IVI-C and IVI-COM
drivers.
Configure the Instrument
1Go back to the Class Browser, and under Properties and Methods, double-
click the DC Voltage property and select the Configure method. Click Create
and drag the Invoke Node to the Block Diagram.
2Create constants and enter values to set the Resolution to 1 millivolt and the
Range to 1.5 volts:
•
0.001
•
1.5
in the Range field
in the Resolution field
•
•
Using IVI with LabVIEWTM 45
•
•
•
•
3Connect the automation refnum and error terminals from Initialize Invoke Node
to DCVoltage.Configure Invo ke Node.
4In the Class Browser, go back to the top-level object and double-click the
Trigger property and select the Delay property . Click Create Write and drag the
Property Node to the Block Diagram.
5Create a constant and enter a value of 0.01 seconds for the Delay field.
6Connect the automation refnum and error terminals from DCV oltage.Configure
Invoke Node to Trigger.Delay Property Node.
Take the Reading
1Return to the Class Browser , and under Properties an d Methods, doub le-click
the Measurement property and select the Read method. Click Create and drag
the Invoke Node to the Block Diagram.
2Set the value for Timeout to 1 second (1000 ms) by entering 1000 in the
MaxTimeMilliseconds field.
3Connect the automation refnum and error terminals from Trigger.Delay
Property Node to Measurement.Read Invoke Node.
Display the Reading
Create an indicator for Measurement.Read from the Invoke Node terminal.
•
•
•
46
Chapter 4
•
•
•
Close the Driver and Automation Sessions
1Return to the Class Browser , and under Properties an d Methods, doub le-click
the Close method. Click Create and drag the Invoke Node to the Block
Diagram.
2Close the Class Browser. From the ActiveX subpalette, select Close
Reference and place on the Block Diagram.
3Connect the automation refnum and error terminals from Measuremen t.Read
Invoke Node to Close Invoke Node and then to Close Reference function.
Add Error Checking
1Return to the main functions palette. From the Dialog & User Interface
subpalette select Simple Error Handler VI and place it on the Block Diagram.
2Connect the error information from Close Reference function to Simple Error
Handler VI.
Run the Application
Y our final VI Block Diagram should cont ain the elements shown below . To run your
VI:
1Switch to the VI’s Front Panel and click on the Run arrow to run the application.
2The Reading indicator should display a simulated reading from the instrument.
Further Information
Learn more about using an instrument driver in LabVIEW in this tutorial:
http://zone.ni.com/devzone/cda/tut/p/id/2804
.
•
•
Using IVI with LabVIEWTM 47
•
•
•
•
•
•
•
48
Chapter 4
•
•
•
Chapter 5
Using IVI with LabWindowsTM/CVI
• • • • • •
The Environment
National Instruments LabWindows/CVI is an ANSI-C integrated development
environment that provides a comprehensive set of programming tools for creating
test and control applications. LabWindows/CVI combines the longevity and
reusability of ANSI-C with engineering-specific functionality designed for
instrument control, data acquisition, analysis, and user interface development.
Example Requirements
•
LabWindows/CVI 8.1
•
Agilent 34401A IVI-C specific driver, Version 4.1, October 2006 (from National
Instruments)
Download and Install the Driver
If you have not already installed the driver, go to the vendor W eb site and follow the
instructions to download and install it. You can also refer to Chapter 1, Download
and Install IVI Drivers, for instructions.
This example uses an IVI-C driver. IVI-C is the preferred driver for
LabWindows/CVI.
TM
Create a New Project and Add Instrument Driver Files
1Launch LabWindows/CVI.
2Select File, select New, and click Project.
3To create a new C source file, select New and click Source (*.c). Save the file.
4Select Edit and click on Add Files to Project to add the C source file to your
project.
5Select Edit and click on Add Files To Project to add one of the following
instrument driver files to your project: hp34401a.fp, hp34401a.c, or
hp34401a.lib.
•
•
•
49
•
•
•
•
•
•
50
Chapter 5
•
•
•
Note: Any of the three files listed above will work. Adding one of the HP 34401A
instrument driver files loads that instrument driver. View the available functions
in the library tree in the workspace window.
6Add the following line to your program to include the instrument driver header
file:
#include “hp34401a.h”
Initialize the Instrument
1From the Edit menu, select Insert Construct, and click Main.
2Find the hp34401a instrument driver in the instrument driver tree. Select
Initialize with Options from the library tree. The Initialize with Options function
panel opens.
3Enter values for Resource Name, ID Query, Reset Device, and Option String:
•
GPIB0::23::INSTR
•
No
•
Yes
•
Simulate=1
Note:
automatically. The options are enabled by default.
in the Resource Name field
for ID Query control
for Reset Device control
in the Options field
The RangeCheck, QueryInstrStatus, and Cache options appear
4Select the Instrument Handle parameter. From the Code Menu, click Declare
Variable to set the Instrument Handle parameter.
5Enter session in the Variable Name field.
6Check the boxes titled Execute declaration in Interactive Window and Add
declaration to top of target file “*.c”. Click OK.
Note: T o test the function with the specified p arameter values, select Code and
click Run Function Panel or click the run button in the toolbar to operate the
function panel interactively.
7From the Code Menu, click Insert Function Call to insert the function and
values into your program. Close the function panel. The
hp34401a_InitWithOptions function appears in your program.
Using IVI w ith LabW indow sTM/CV ITM
•
•
•
51
•
•
•
Configure the Instrument
1From the library tree, select Configuration and click ConfigureMeasurement.
The ConfigureMeasurement function panel opens.
2Set the function to DC Voltage, range to 1.5 volt s, resolution to 1 millivolt, and
instrument handle to session. Select and enter:
•
DC Volts
•
1.5
in the Range field,
•
0.001
•
session
from the drop-down list in the Measurement Function field,
in the Resolution field, and
in the Instrument Handle field.
•
•
•
52
Chapter 5
•
•
•
3Select the Code menu and click Insert Function Call to insert the function and
values into your program. Close the function panel. The
hp34401a_ConfigureMeasurement function appears in your program.
4From the library tree, select Configuration, select Trigger, and click
ConfigureTrigger. The Configure Trigger function panel opens.
5Set the trigger source to immediate, the trigger delay to 0.01 seconds, and the
instrument handle to session. Select and enter:
•
Immediate
•
0.01
in the Trigger Delay field
•
session
6Select Code and click Insert Function Call to insert the function and values into
your program. Close the function panel. The hp34401a_ConfigureTrigger
function appears in your program.
Set the Reading Timeout
1From the library tree, select Measurement and click Read. The Read dialog
opens.
2Set the value for Timeout to 1 second (1000 ms), and instrument handle to
session. Enter:
•
1000
from the drop-down list in the Trigger Source field
in the Instrument Handle field
in the Read field
Using IVI w ith LabW indow sTM/CV ITM
•
•
•
53
•
•
•
•
session
Display the Reading
1Select the Reading parameter.
2Select Code and click Declare Variable. The Declare Variable dialog appears.
3Enter reading in the Variable Name field.
4Check the boxes titled Execute declaration in Interactive Window and Add
declaration to top of target file “*.c”. Click OK.
5Select Code and click Insert Function Call to insert the function and values into
your program. Close the function panel. The hp34401 a_Read function appears
in your program.
Close the Session
1From the library tree, select Close. The Close function panel opens.
2Enter session in the Instrument Handle field.
3Select Code and click Insert Function Call to insert the function and values into
your program. Close the function panel. The hp34401a_Close function
appears in your program. Your final program should contain the code below:
T o display the reading, add a printf function. Before the Close function, type:
printf (“%f”, reading);
Note:
CheckErr macro provided in the ivi.h file to handle errors. See the example
included with the hp34401 downloaded driver for error handling demonstration
code.
Further Information
Learn more about LabWindows/CVI at http://www.ni.com/lwcvi/.
The mark LabWindows is used under a license from Microsoft Corporation
Including error checking in your programs is good practice. Use the
Using IVI w ith LabW indow sTM/CV ITM
•
•
•
55
•
•
•
•
•
•
56
Chapter 5
•
•
•
Chapter 6
Using IVI with MATLAB
• • • • • •
The Development Environment
MATLAB from The MathWorks is an interactive software environment for data
acquisition and analysis, waveform generation, algorithm creation, and test system
development. MATLAB also provides a technical computing language that is
designed to help you solve technical challenges faster than with traditional
software environments.
MA TLAB supports IVI instrument drivers using the Instrument Control T oolbox. The
toolbox provides additional MATLAB functionality.
Example Requirements
•
MATLAB R2007a
•
MATLAB Instrument Control Toolbox
•
Agilent 34401A IVI-COM, Version 1.1.0.11, March 2006 (from Agilent
Technologies)
•
Agilent IO Libraries Suite 14.2
Download and Install the Driver
If you have not already installed the driver, go to the vendor W eb site and follow the
instructions to download and install it.
®
This example uses an IVI-COM driver, MATLAB also supports IVI-C drivers.
Note:
Older versions of the Instrument Control T oolbox (R2006b or earlier) support
only IVI instrument drivers that used the IDispatch interface. IVI instrument drivers
that use the IUknown interface only will not work with these versions. To determine
if the driver implements only the IUknown interface, please consult the vendor.
•
•
•
57
•
•
•
Configure the IVI Driver
The Instrument Control T oolbox provides a graphical Test & Measurement Tool that
enables you to interact with instrument drivers and instruments without writing
MATLAB code. The Test & Measurement Tool lets you configure IVI driver
properties in MATLAB and store them in the IVI configuration store.
Note:
Learn more about the IVI configuration store in Chapter 11 – Advanced
Topics.
1At the MATLAB command line, type tmtool to launch the Test &
Measurement Tool GUI. Or from the MATLAB Main Menu, select Instrument
Control Toolbox and click Test & Measurement Tool. The T e st & Measurement
Tool GUI opens.
2In the tree at left, click the IVI node under the Instrument Drivers node.
3Select the Hardware Assets tab. In the Hardware Asset s dialog, select Add and
enter the following:
•
myDMM
•
This is my Agilent 34401 Digital Multimeter
•
GPIB0::23
in the Name field
in the Description field (optional)
in the IO Resource name field
•
•
•
58
Chapter 6
•
•
•
4Select the Software Modules tab. The installed IVI drivers appear.
Note:
If you have not installed the IVI driver , it will not appear in this list. You must
close MATLAB, install the driver, and restart MATLAB for the driver to appear.
5Select Agilent34401 from the drop-down list. The Software Modules dialog lists
the module name, supported instrument models, and description.
Next, you must define your Driver Session to link the Software Module with the
Hardware Asset and indicate whether you want to use Simulation Mode or other
optional parameters when connecting.
6Select the Driver Sessions tab. In the Driver Sessions dialog, select Add and
enter the following:
•
DMM
in the Name field
•
This session matches the Agilent 34401 driver with the hardware asset of
GPIB0::23, and turns on Simulation mode of the driver
in the Description
field (optional)
7Select Agilent34401 in the Software module drop-down list.
8Select myDMM in the Hardware asset drop-down list.
9Check Simulate in the options.
Using IVI with MA TLAB®
•
•
•
59
•
•
•
10 Select the Logical Names tab. In the Logical Names dialog, select Add and
enter the following:
•
DMM
in the Name field
•
This logical name enables your program to access any DMM independent
of manufacturer or hardware asset
•
DMM
in the Driver session field
in the Description field (optional)
•
•
•
60
Chapter 6
•
•
•
11 Select File and Save IVI Configuration Store. Saving to the store may take
several moments.
12 Close the Test & Measurement Tool.
Generate an Instrument Wrapper
We will now automatically generate an instrument driver wrapper file (.mdd) so that
MATLAB can use the IVI driver.
At the MATLAB command prompt, type
makemid(‘dmm’);
The file
wrapper created by the
communicate with your instrument through an IVI driver.
Note: To help you learn the structure of a driver faster, MATLAB provides
autocompletion support. As you are typing your commands for a driver, press
the Tab key to get a selection of possible completions. You can also use the
command “get” to see a list of possible properties and “methods” to get a list
of methods on the object. “methodsview” will give you a graphical display of
the methods also.
dmm.mdd
appears in the current directory window. This is the instrument
makemid
Configure and Control the Instrument
You can interact with the instrument by using the Test & Measurement T ool or the
MATLAB command line. We use the MATLAB command line here.
Note:
All MATLAB methods and properties are available at the command line.
Create an Instance of the Instrument
To create an instance of the instrument, type
myDmm = icdevice(‘dmm’);
Connect to the Instrument
Similar to the Initialize command in most ADEs, the Connect command in MA TLAB
initializes the instrument. The instrument will be initialized with the properties you
specified using the Test & Measurement Tool. Type
command. You may now use MATLAB to
connect(myDmm);
Configure the Instrument
To set a range of 1.5 volts and resolution of 0.001 volts, type
myDmm.Range = 1.5;
myDmm.Resolution = 0.001;
Using IVI with MA TLAB®
•
•
•
61
•
•
•
Set the Trigger Delay
To set the trigger delay to 0.01 seconds, type
myDmm.Trigger.Delay = 0.01;
Set Reading Timeout
To take a reading with a timeout of 1 second, type
myDmm.Timeout = 0.01;
Display Reading
To display the reading, type
data = invoke(myDmm.Measurement,'Read',1000)
Disconnect from the Instrument
Similar to the Close() command in most ADEs, the Disconnect command in
MATLAB closes the instrument. To disconnect, type
disconnect(myDmm);
Remove the Driver from Memory
To remove any reference to the driver from memory, type
delete(myDmm);
•
•
•
62
Chapter 6
•
•
•
Your final application should contain the code below:
To learn more about using MATLAB with IVI instrument drivers, visit:
http://www.mathworks.com/ivi
MATLAB is a registered trademark of The MathWorks, Inc.
Using IVI with MA TLAB®
•
•
•
63
•
•
•
•
•
•
64
Chapter 6
•
•
•
Chapter 7
Using IVI with Measure Foundry
• • • • • •
The Environment
Measure Foundry is a visual software environment for creating test and
measurement, control, and analysis applications. The design environment consists
of forms and the foundry window. You choose components from the foundry
window and drop them onto your form. Clicking on the components accesses
property pages where you can set design, configuration, and connectivity. This
enables fast application development.
Each application consists of three primary elements:
•
a data source supplies data to the application
•
a control source determines how and when the data is used
•
a data sink receives data to process or display
Example Requirements
•
Measure Foundry 5
•
Agilent 34401A IVI-COM, Version 1.1.0.11, March 2006 (from Agilent
Technologies)
•
Agilent IO Libraries Suite 14.2
®
Download and Install the Driver
If you have not already installed the driver, go to the vendor Web site and follow
the instructions to download and install it. You can also refer to Chapter 1,
Download and Install IVI Drivers.
This example uses an IVI-COM driver. IVI-COM is the preferred driver for Measure
Foundry. IVI-C is not supported.
Note
: You cannot specify an instrument in Measure Foundry unless you have
already installed the appropriate driver. If you need to download a nd install a driver ,
you do not need to exit Measure Foundry . Install the driver and it appears in the list
of available devices.
•
•
•
65
•
•
•
Data Source
The property pages contain all the information necessary to create an instance of
the driver, initialize and configure the instrument, set the trigger delay and reading
timeout, and close the instrument.
1Launch Measure Foundry.
2Select File and Click New. The New Project screen opens.
3In the Foundry window, select All Components. Enter IVI in the Search field.
4Select the LXI IVI Dmm component, drag it to the Form, and drop it.
•
•
•
66
Chapter 7
•
•
•
5Double-click the LXI component. The Properties dialog appears.
Note
: The Properties dialog lets you access functions based on the purpose of
your test.
6Configure the IVI DMM. To initialize the DMM and set the range to 1.5 volts a nd
resolution to 1 millivolt, enter the following In the Properties dialog:
•
IVI Dmm
in the IVI DMM panel field
•
Agilent34401
•
GPIB
and
•
DCV
in the measurement mode field
•
1.5
in the range field
•
0.001
in the resolution field
Note:
Capabilities that are unavailable are grayed out.
7Click Next.
in the device type field
23
in the VISA connect string field
8Configure the operating mode. Select Auto refresh and enter 1000 in the
update rate field.
Using IVI with Measure Foundry®
•
•
•
67
•
•
•
9Click Next.
10 Configure the trigger delay. In the Properties dialog, enter 0.01 in the trigger
11 Click Next.
12 Configure the option string, reset, and reading timeout to 1 second. In the
13 Click Next.
Control Source
1In the Foundry window, select Application Control. Drag and drop the Control
2Double-click the Control Button. The Properties of Control Button dialog
3Enter Start/Stop in the text field.
4Select the switch button type and click Next.
5Scroll the list of Available items for the IVI Dmm and click Actions.
6Select Actions and click the double arrow to add to Item sequence.
7Select Start autorefresh from the drop-down list in Active value.
8Select Stop autorefresh from the drop-down list in Passive value.
delay field and Immediate in the trigger source field.
Properties dialog, enter the following:
•
Simulate=true
•
1000
in the timeout field
•
Check the Reset on Connect box
The property pages contain the information necessary to label the button and
specify how it controls the program.
Button to the form.
appears.
in the IVI connect option string
•
•
•
68
Chapter 7
•
•
•
Using IVI with Measure Foundry®
•
•
•
69
•
•
•
Data Sink
The property pages contain all the information necessary to display the output.
1In the Foundry window , select Display Compone nts. Drag an d drop the Single
Value Label onto the form.
2Double-click the Single Value Label. The Properties of Single Value Label
dialog appears.
3Scroll the list of Data sources and click Form:ivi2_IVI Dmm.
4Check the box by DCV in the Channels field.
•
•
•
70
Chapter 7
•
•
•
Compile and Run
The final program contains the IVC Dmm LXI component (data source), Start/Stop
button (control source), and Single Value Label (data sink). From the Start Menu,
click Compile and Run to check that your program runs.
Close Session
To close the session and release the driver, either exit the program or program a
Control Button to set the Disconnect property to true in the IVI DMM component.
Further Information
Learn more about the Measure Foundry at http://www.measurefoundry.com.
DT Measure Foundry® is a registered trademark of Data Tr anslation® in the United
States and/or other countries.
Using IVI with Measure Foundry®
•
•
•
71
•
•
•
•
•
•
72
Chapter 7
•
•
•
Chapter 8
Using IVI with PAWS
• • • • • •
The Environment
P A WS Developer's Studio gives you the capability to edit, compile, modify , debug,
document, execute, and simulate the test procedures developed in Abbreviated
Test Language for All Systems (ATLAS) in the Windows NT/2000/XP Platform
environment. PAWS supports a full range of the most commonly used ATLAS
Language subsets. A PAWS Toolkit can modify the ATLAS Language subset to
meet a particular Automatic Test Equipment (A TE) configuration. It s output can be
executed on the associated Debugging PAWS/RTS run-time system or can be
translated to run on your unique run-time system.
Creation of a PAWS project typically consists of three main steps:
•
Prepare the PAWS environment
•
Connect to the instrument driver
•
Prepare the run-time system environment and run the project
Example Requirements
•
TYX PAWS Studio 1.34.6
•
Microsoft Visual Studio
•
Agilent 34401A IVI-COM, Version 1.1.0.11, March 2006 (from Agilent
Technologies)
•
Agilent IO Libraries Suite 14.2
Download and Install the Driver
If you have not already installed the driver, go to the vendor Web site and follow
the instructions to download and install it. You can also refer to Chapter 1,
Download and Install IVI Drivers, for instructions.
This example uses an IVI-COM driver. PAWS supports both IVI-COM and IVI-C
drivers.
Note
: If you do not install the appropriate instrument driver , the project will not build
because the referenced files are not included in the program. If you need to
•
•
•
73
•
•
•
download and install a driver, you do not need to exit PAWS Studio. Install the
driver and continue with your program.
Prepare the PAWS Environment
To use an IVI Driver in PAWS, you must first prepare the PAWS environment.
1Launch PAWS Studio and create a new project. In the New PAWS Project
dialog, enter a project name and directory for the project. Click OK.
2T o add a new file to the A TLAS Project Module, from the Main Menu select F ile
and click New File. The New dialog appears.
3Select ATLAS file. Check the option to add the file to the project.
4Enter atlas in the File Name field. Click OK. The atlas.atl file appears.
•
•
•
74
Chapter 8
•
•
•
5Insert the following code in the atlas.atl file and save it:
001000 BEGIN, ATLAS PROGRAM 'IVI-COM DMM' $
001010 REQUIRE, 'DMM-DC-VOLTS', SENSOR(VOLTAGE), DC SIGNAL,
CONTROL, VOLTAGE RANGE -300 V TO 300 V,
MAX-TIME RANGE 1 SEC TO 5 SEC,
CNX HI LO $
C$
001110 DECLARE, VARIABLE, 'MEASURED' IS DECIMAL $
C$
E02000 OUTPUT, C'\LF\ATLAS PROGRAM STARTS HERE\LF\' $
C$
002200 VERIFY, (VOLTAGE INTO 'MEASURED'),
DC SIGNAL USING 'DMM-DC-VOLTS',
NOM 0 V UL 0.5 V LL -0.5 V,
VOLTAGE RANGE -0.5 V TO 0.5 V,
MAX-TIME 5 SEC,
CNX HI X20-2 LO X20-3 $
002300 OUTPUT, C'DC VOLT MEASUREMENT 1 = ', 'MEASURED', C'
VDC' $
C$
999000 OUTPUT, C'\LF\ATLAS PROGRAM ENDS HERE\LF\' $
C$
999999 TERMINATE, ATLAS PROGRAM 'IVI-COM DMM' $
6To add a Device Database Module, from the Main Menu select File and click
New Module.
7Select DEVICEDB and click OK.
8T o add a new file to the DEVICEDB Project Module, from the Main Menu select
File and click New File. The New dialog appears.
9Select DEVICE file. Check the option to add the file to the project.
10 Enter dmm in the File Name field. Click OK.
11 In the PAWS Project window, select the file dmm.ddb.
12 Insert the following code in the dmm.dbb file and save it:
begin dev DMM;
cnx hi DMM-Hi, lo DMM-Lo;
begin FNC = 101; ** DC Voltage Measurement
sensor(voltage)dc signal;
control
Using IVI with PA WS
•
•
•
75
•
•
•
{
voltage range -300 v to 300 v continuous;
}
end; ** DC Voltage Measurement
end; *end dmm
Note:
To understand the file contents, refer to the Paws Studio online help.
13 To build the project, from the Main Menu select Build and click Rebuild All.
Add the WCEM Interface Functions
The WCEM interface C++ functions are invoked by the ATLAS code. These C++
functions include the IVI-COM calls to control the instrument.
1From the Main Menu, select File and click New Module. The New dialog
appears.
2Select CEM and enter WCEM in the Module Name field. Click OK.
3From the Main Menu, select View and click CEM Wizard. The CEM Wizard
dialog appears.
4Click on the Advanced tab. The CEM Wizard Advanced Settings dialog
appears.
5Check Open, Unload and Disable CEM Logging. Click OK. The CEM Wizard
dialog appears.
6Right-click on DMM and click on Add Interface Function. The Add Function(s)
to Action(s) dialog appears.
7For Setup, select Setup in the Action(s) dialog and enter DMM_Setup in the
User Function Name(s) field. Click OK.
8For Fetch and Init, select the appropriate action in the Action(s) dialog and
enter DMM_Fetch and DMM_Init in the User Function Name(s) field. Click
OK.
Note:
This will add several files to your WCEM module: ctrl.cpp, DMM.cpp,
Error.cpp, Wrapper.cpp, and Key.h. ctrl.cpp includes the doOpen and doUnload
functions. Dmm.cpp includes the three DMM_ functions.
•
•
•
76
Chapter 8
•
•
•
9To add a new *.h file called DMM.h to include the code necessary to reference
the driver header files and librairies , right-click on the WCEM module.
10 Select Add New File to Module. The New dialog appears.
11 Select CEM header file and check Add to Project.
12 Enter DMM in the File Name field. Click OK.
Connect to the IVI-COM Driver
1From the PAWS Project window, select the DMM.h file. Insert the following
4To create the driver object and open an I/O session to the instrument with the
Initialize method, select the ctrl.cpp file from the PAWS Project window.
Note:
T o determine the syntax for the commands you want to use in your program,
consult the driver help file.
5In the doOpen() interface function, insert the following code below the line
Please insert your CEM driver code here:
hr = driver.CoCreateInstance(CLSID_Agilent34401);
if (FAILED(hr))
{
Display("\033[30;41m Bad return from
CoCreateInstance() method\033[m\n");
}
hr = driver->Initialize(CComBSTR("GPIB0::23::INSTR"),
VARIANT_FALSE,
VARIANT_TRUE,
CComBSTR("Simulate=TRUE"));
if (FAILED(hr))
{
Display("\033[30;41m Bad return from Initialize()
method\033[m\n");
}
Note:
doOpen is called for the first time when the run-time system loads the P AWS
project. If you intend to use non-A TLAS modules in your ATLAS code, subsequent
calls to doOpen will be made and you will need to execute the code above only
once.
6To set the function for DC Volt age, the r ange to 1.5 volt s, and the r esolution to
1 millivolt, select the DMM.cpp file from the PAWS Project window.
7In the DMM_Setup() interface function, insert the following code below the
line Please insert your CEM driver code here :
hr = driver->put_Function(Agilent34401FunctionDCVolts);
if (FAILED(hr))
{
Display("\033[30;41m Bad return from
put_Function(Agilent34401FunctionDCVolts)method\033[m\n"
);
}
hr = driver->get_DCVoltage(&pDMMDCVolt);
Using IVI with PA WS
•
•
•
79
•
•
•
if (FAILED(hr))
{
Display("\033[30;41m Bad return from
get_DCVoltage(&pDMMDCVolt) method\033[m\n");
}
hr = pDMMDCVolt->Configure(1.5, 0.001);
if (FAILED(hr))
{
Display("\033[30;41m Bad return from >Configure(1.5,
0.001) method\033[m\n");
}
8T o set the trigger delay to 0.01, select the DMM.cpp file from the P A WS Project
window.
9In the DMM_Init() interface function, insert the following code below the line
Please insert your CEM driver code here:
hr = driver->get_Trigger(&pDMMTrig);
The function doUnload gets called only once, when the Paws project is
unloaded from the run-time system.
appears.
field. Click Apply.
Note:
The path includes the Visacom_i.c file from the DMM.h header.
appears with a message that indicates the project was successfully built.
Note:
Most of the IVI-COM driver methods return HRESULT value, which is used
in this example across the entire driver implementation for error handling. Error
handling code is recommended as you develop a PAWs application. In our
example, the error handling code begins with if (FAILED(hr)) and ends with the }
after the Display line for most of the methods.
•
•
•
82
Chapter 8
•
•
•
Prepare the Run-Time System Environment
1In the Project Workspace area, double-click on the Busconfi. The DMM name
in a Busconfi file corresponds to the name defin ed in the dmm.ddb file following
the begin dev statement.
2Set the Listen Address MLA and Talk Address MTA to the device address of
23.
3The Bus number must correspond to the Channel number.
The Busconfi code should appear as below:
; IEEE-488 Bus Configuration File -
"Channel" 1
DMM BUS 1MLA 23MTA 23
Load and Run the Project
1From the Main Menu, select Build and click on Execute Wrts.
Note
: The message below may appear before invoking the Run-Time system
interface. This message usually appears when you have changed the code without
recompiling it. Click Yes to let the project be rebuilt before execution. If you make
changes to the Busconfi file only, you do not need to rebuild the project, because
it is used as a reference file at run-time.
2From the list at left, select Run. The program runs and returns a DC Voltage
measurement.
3From the Main Menu, select File and click Exit to exit from the Run-Time
system.
Further Information
Learn more about PAWS at http://www.tyx.com/pawsdeva.html.
Using IVI with PA WS
•
•
•
83
•
•
•
•
•
•
84
Chapter 8
•
•
•
Chapter 9
Using IVI with Visual Basic 6.0
• • • • • •
The Environment
Visual Basic 6.0 is a programming environment derived from Basic and developed
by Microsoft for the Windows operating system. Software vendors and developers
use VB to create applications quickly by writing code to accompany on-screen
objects such as buttons, windows, and dialog boxes.
This chapter focuses on VB 6.0, which is not the most current version. If you
are new to VB, we recommend you refer to Chapter 3, Using IVI with C# and
Visual Basic .NET.
Example Requirements
•
Visual Basic 6.0
•
Microsoft Visual Studio 6.0
•
Agilent 34401A IVI-COM, Version 1.1.0.11, March 2006 (from Agilent
Technologies)
•
Agilent IO Libraries Suite 14.2
Download and Install the Driver
If you have not already installed the driver, go to the vendor W eb site and follow the
instructions to download and install it. You can also refer to Chapter 1, Download
and Install IVI Drivers, for instructions.
This example uses an IVI-COM driver. IVI-COM is the preferred driver for Visual
Basic 6.0, but IVI-C is also supported via the inclusion of .bas files.
Create a New Project and Reference the Driver
To use an IVI Driver in a Visual Basic program, you must first create a project and
add a reference to the driver.
1Launch Visual Basic and create a new project using Standard EXE project.
Note:
This creates a Windows Application program.
•
•
•
85
•
•
•
2From the Start Menu, select Project, and click References. The References
dialog appears.
3Select the IVI Agilent34401 1.1 Type Library from the drop-down list. Place a
check in the box next to this driver.
Note
: If you have not installed the IVI driver, it will not appear in this list. You must
close the References dialog, install the driver , and select References again for the
driver to appear.
4Click OK. The References dialog closes.
•
•
•
86
Chapter 9
•
•
•
Add a Button
Note:
You must click OK for Visual Basic to accept the References; however, the
software provides no confirmation. You can verify the driver is available for use by
opening the Add References dialog and viewing the checked references. All
checked references appear near the top of the list.
1Click the Command Button in the Toolbox to create a button.
2Drag the button to the form and drop it.
3Change the (Name) property to btnTest and the Caption property on the
Command1 button to Test in the Properties list at right.
Create an Instance of the Driver
1Double-click Test. The Project1 – Form1(Code) screen appears. Note that
some code has already been added, including Private Sub
btnTest_Click() and End Sub.
2To enable strong type checking, at the top of the screen before the Private
Subline type
Option Explicit
3Create a variable for the driver and initialize it with the New statement. On the
next line type
Dim dmm As New Agilent33401
Initialize the Instrument
Now you will enter the code that will execute when you click Test.
On the line after
As soon as you type the period, Intellisense displays the possible methods
and properties and helps ensure you use correct syntax and values.
Note:
From the Start Menu, select View, and click Object Browser to view the
functions and parameters available in the instrument driver. Limit the Object
Browser to a specific library by selecting it in the top left list box.
Using IVI with Visual Basic 6.0
•
•
•
87
•
•
•
•
•
•
88
Chapter 9
•
•
•
Configure the Instrument
Set the function to DC Voltage, range to 1.5 volts, and resolution to 1 millivolt.
1Type dmm.Function = Agilent34401FunctionDCVolts
2Type dmm.DCVoltage.Configure 1.5, 0.001
3Select Configure from the drop-down list and press the space bar.
Note:
The Object Browser shows the parameters and syntax for Configure in the
box at bottom, along with a short description.
4Type 1.5, 0.001
Set the Trigger Delay
Set the trigger delay to 0.01 seconds.
Type: dmm.Trigger.Delay = 0.01
Display the Reading
Set the reading timeout to 1 second and display the reading.
1Return to the form view and click the Label Button in the Toolbox to create a
label.
2Drag it to the form and drop it.
3Change the Name to lblResult in the Properties list at right.
4Remove the text under Caption.
5In the code after the trigger delay command, type
lblResult.Caption = dmm.Measurement.Read(1000)
Close the Session
Type
Your final program should contain the code below.
The Agilent 34401 driver conforms to the IviDmm class, so you can easily write
your program to use the class-compliant interfaces instead of the instrumentspecific interfaces.
library for your project to compile.
Y ou will need to add a Reference to the IviDmm Class Type
Microsoft® and Visual Studio® are registered tradem arks of Microsoft Corporation
in the United States and/or other countries.
Using IVI with Visual Basic 6.0
•
•
•
91
•
•
•
•
•
•
92
Chapter 9
•
•
•
Chapter 10
Using IVI with Agilent VEE Pro
• • • • • •
The Development Environment
Agilent Visual Engineering Environment Pro is a graphical programming
environment designed to help you quickly create and automate measurements and
tests. VEE Pro lets you program by creating an intuitive block diagram. Y ou sele ct
and edit objects from pull-down menus and connect them to specify the program
flow. VEE Pro also includes Instrument Manager, which facilitates control and
management of your devices. Let’s see how VEE Pro works with IVI.
Example Requirements
•
Agilent VEE Pro 8.0
•
Agilent 34401A IVI-COM, Version 1.1.0.11, March 2006 (from Agilent
Technologies)
•
Agilent IO Libraries Suite 14.2
Download and Install the Driver
If you have not already installed the driver, go to the vendor Web site and follow
the instructions to download and install it. You can also refer to Chapter 1,
Download and Install IVI Drivers, for instructions.
This example uses the IVI-COM driver. VEE Pro does not support the use of IVI-C
drivers through the Instrument Manager.
Launch the Instrument Manager and Select the Driver
If you have correctly installed the IVI driver, VEE Pro’s Instrument Manager will
automatically find it for you.
1Launch VEE Pro.
2From the Main Menu, select I/O, and click Instrument Manager.
Note
: If you were connected to a live instrument, you would click the Find
Instruments button at the right in this screen and then skip to the next section.
•
•
•
93
•
•
•
3Click Add under instrument in the list at the right to add a simulated instrument.
The Instrument Properties dialog box appears.
4In the Instrument Properties dialog box, enter or select the following:
•
myDMM
•
GPIB
•
0
in the Board Number field
•
GPIB0::23::INSTR
in the Name field
in the Interface field
in the VISA Address field
•
•
•
94
Chapter 10
•
•
•
5Click Advanced. The Advanced Instrument Properties dialog box appears.
6Click the IVI-COM Driver tab. Select Agilent 34401 from the drop-down list.
Note
: The VISA address that you entered earlier appears automaticaly in the
Address field.
7Click the IVI-COM Driver tab. Select Agilent 34401 from the drop-down list.
Note:
The VISA address that you entered earlier appears automatically in the
Address field.
8Click OK. The dialog closes and returns to the Instrument Properties dialog.
9Click OK. The dialog closes and returns to the Instrument Manager.
Congratulations! You can now access the IVI Driver in the Instrument
Manager.
Note:
If the driver is correctly installed, the text darkens on the IVI-COM Driver
button under Create I/O Object in the list at the right.
Create an Instance of the Driver
1Click IVI-COM Driver under Create I/O Object at the right. An outline of the
object appears.
2Move the object onto your workspace.
Using IVI with Agilent VEE Pro
•
•
•
95
•
•
•
3Double-click <Double-Click to Add Operation> in the T o/From myDMM object.
The Select an Operation dialog box appears.
4Select CreateInstance to create an instance of the Agilent 34401 driver.
Note:
At the bottom of the dialog box, the code for the operation appears along with
an explanation of its function.
Initialize the Instrument
•
•
•
96
Chapter 10
•
•
•
5Click OK. The Edit CreateInstance dialog box appears.
6Click OK.
1Double-click to add another operation. The Select an Operation dialog box
appears.
2Select Initialize to initialize the simulated Agilent 34401. Click OK. The Edit
Initialize dialog box appears.
3In the Edit Initialize dialog box, GPIB0::23::INSTR has already been entered
in the ResourceName field. Enter or select the following:
•
False
•
True
in the Reset field
•
simulate=true
4Click OK.
Configure the Instrument
1Double-click to add another operation. The Select an Operation dialog box
appears.
2Expand the treenode DCVoltage and select Configure. Click OK. The Edit
Configure dialog box appears.
3T o set a range of 1.5 volt s and resolution of 1 millivolt, enter the following in the
Edit Configure dialog box:
•
1.5
in the Range field
•
0.001
4Click OK.
Set the Trigger Delay
1Double-click to add another operation. The Select an Operation dialog box
appears.
2Expand the treenode T rigger and select Delay . Click Set. The Edit Delay dialog
box appears.
3To set a trigger delay of 0.01 seconds, enter 0.01 in the delay field.
4Click OK.
in the IdQuery field
in the OptionString field
in the Resolution field
Set the Reading Timeout
1Double-click to add another operation. The Select an Operation dialog box
appears.
2Expand the treenode Measurement a nd select Read. Click OK. The Edit Read
dialog box appears.
3To take a reading with a timeout of 1 second, enter 1000 in the
MaxTimeMilliseconds field.
4Click OK. The To/From myDMM object includes an additional output node
labeled return. This will hold the value returned from the Read Measurement
operation.
Using IVI with Agilent VEE Pro
•
•
•
97
•
•
•
Close the Session
Now that you have completed all of the driver operations, you should close the
driver session to free resources.
1Double-click to add another operation. The Select an Operation dialog box
appears.
2Select Close to release all resources associated with the simulated Agilent
34401. Click OK.
Display the Reading
1To display the measurement, from the Main Menu select Display, and click
AlphaNumeric. Place the AlphaNumeric object on your workspace.
2Connect a wire from the return output terminal on T o/From myDmm to the input
terminal of the AlphaNumeric object.
3Click F5 or the Right Arrow button on the toolbar to run the program. The
Display returns a simulated result.
Tips
•
•
•
98
Chapter 10
•
•
•
Another Method to Display the Reading
You can display the measurement in another way as well. From the Main Menu,
select
select Data, Variable, and click Declare Variable.
variable named agilent34401Class
Select Edit and
•
Agilent.Agilent34401.Interop
•
Agilent.Agilent34401.Interop
•
Agilent34401Class
Then delete the agilent34401Class output terminal. You can now share this IVICOM object with other To/From objects or formula objects in VEE. This will let you
use multiple objects for the same driver instance without creating all of your driver
commands in one object.
in the Specify Object Type dialog, select the following:
in the Type field
with a Type Object and Sub Type .NET.
in the Assembly field
in the Namespace field
Declare a global
Further Information
Learn more about VEE Pro at www.agilent.com/find/vee.
Using IVI with Agilent VEE Pro
•
•
•
99
•
•
•
•
•
•
100
Chapter 10
•
•
•
Loading...
+ 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.