Getting Started Guide Your Guide to Getting Started with IVI Drivers Revision 1.
Contents •••••• Chapter 1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Why Use an Instrument Driver? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Why IVI?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Why Use an IVI Driver? . . . . . . . . . . . . . . . . . . . . . . .
Create a New Project and Import the Driver Type Libraries. . . . . . . . . . 22 Declare Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Define Error Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Initialize the Instrument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Configure the Instrument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Create a Project and Access the Driver . . . . . . . . . . . . . . . . . . . . . . . . . 38 Initialize the Instrument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Configure the Instrument . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Take the Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Display the Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Further Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Chapter 6 Using IVI with MATLAB® . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 The Development Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Example Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Download and Install the Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Prepare the PAWS Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Add the WCEM Interface Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Connect to the IVI-COM Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Build the Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Prepare the Run-Time System Environment . . . . . . . . . . . . . . . . . . . . . 82 Load and Run the Project. . . . . . . . .
Set the Trigger Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Set the Reading Timeout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Close the Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Display the Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Tips. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Chapter 1 Introduction •••••• Purpose Welcome to IVI Getting Started Guide. This guide introduces key concepts about 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 is intended for individuals who write and run programs to control test-and-measurement instruments. As you develop test programs, you face decisions about how you communicate with the instruments.
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).
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.
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 – IVI drivers all follow a common model of how to control the instrument.
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.
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 IVI Getting Started Guide use a DMM driver, you will likely employ a variety of IVI drivers to develop test programs. To jumpstart that 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.
• Access an instrument property – We set the trigger delay to 0.01 seconds. • Set the reading timeout – We set the reading timeout to 1000 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.
• • 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.
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. 1 Launch 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. 2 3 4 5 From the Tools menu select Options.
“$(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. 6 7 Click OK To import the type libraries, type the following statements following the header file reference: #import “IviDriverTypeLib.dll” no_namespace #import “IviDmmTypeLib.dll” no_namespace #import “GlobMgr.dll” no_namespace #import “Agilent34401.
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 dmm->Configure(IviDmmFunctionDCVolts, 1.5, 0.001); Set the Trigger Delay To set the trigger delay to 0.
Set the Reading Timeout/Display the Reading Create a variable to represent the reading and make a reading with a timeout of 1 second (1000 milliseconds). 1 Type double reading = dmm->Measurement->Read(1000); 2 To display the reading, use printf. Type wprintf(L“Reading: %g\n”, reading); Error Checking To catch errors in the code, activate error checking. 1 Surround the preceding statements with a try block.
exit(1); { IAgilent34401Ptr dmm(__uuidof(Agilent34401)); try{ dmm->Initialize("GPIB::23",false,true,"simulate=true"); dmm->DCVoltage->Configure(1.5, 0.001); dmm->Trigger->Delay = 0.01; double reading = dmm->Measurement->Read(1000); wprintf(L“Reading: %g\n”, reading); } catch(_com_error e){ wprintf(L“Error: %s\n”, e.ErrorMessage); } dmm->Close(); } CoUninitialize(); return 0; } Build and Run the Application Build your application and run it to verify it works properly.
2 3 4 5 From the Tools menu select Options. Expand “Projects and Solutions”, then click on “VC++ Directories” Click on the “Show directories for” combo box and choose “Library files” Add 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” 6 7 Click on the “Show directories for” combo box and choose “Include files” Add the following entries to your “Include files” path.
10 Expand “Configuration Properties” 11 Expand “Linker” 12 Select Input. In the Additional Dependencies field, type “hp34401a.lib” 13 Select OK. 14 To add the hp34401a instrument driver header file to your program, type the following statement following the existing header file reference: #include “hp34401a.h” 15 From the Main Menu, select Build and click Build IVIDemo. Declare Variables 1 You will need to declare some variables that will be used in your program.
Define Error Checking 1 Next 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.
• Simulate=1 in the Options parameter sets the driver to simulation mode • &session assigns the Instrument Handle to the variable “session” defined above Configure the Instrument 1 To set the range to 1.5 volts and resolution to 0.001 millivolts, type: checkErr( hp34401a_ConfigureMeasurement (session, HP34401A_VAL_DC_VOLTS, 1.5, 0.001)); Set the Trigger and Trigger Delay 1 To set the trigger source to immediate and the trigger delay to 0.
#endif int main(int argc, _TCHAR* argv[]) { ViSession session; ViStatus error = VI_SUCCESS; ViReal64 reading; checkErr( hp34401a_InitWithOptions ("GPIB::23::INSTR", VI_FALSE, VI_TRUE, "Simulate=1", &session)); checkErr( hp34401a_ConfigureMeasurement (session, HP34401A_VAL_DC_VOLTS, 1.5, 0.0001)); checkErr( hp34401a_ConfigureTrigger (session, HP34401A_VAL_IMMEDIATE, 0.
1 2 From the Start Menu, select Build, and click Build IVI Demo. From 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 trademarks of Microsoft Corporation in the United States and/or other countries.
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. If you are looking for an example using Visual Basic 6.0, refer to Chapter 9.
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. 1 Launch 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. 2 3 Select Project and click Add Reference. The Add Reference dialog appears. Select the COM tab. All IVI drivers begin with IVI.
Create an Instance of the Driver To allow your program to access the driver without specifying the full path, type the following line immediately below the other using statements: 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.
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. 1 2 Type Agilent34401Class dmm = new Agilent34401Class(); Type dmm.Initialize (“GPIB::23”, false, true, “simulate=true”); Note: IntelliSense helps ensure you use correct syntax and values.
Configure the Instrument To set the range to 1.5 volts and the resolution to 1 millivolt, type dmm.DCVoltage.Configure(1.5, 0.001); Set the Trigger Delay To set the trigger delay to 0.01 seconds, type dmm.Trigger.Delay = 0.01; Set the Reading Timeout/Display the Reading Create a variable to represent the reading and display the reading: 1 2 Type double reading; 3 4 Type Console.
Your final program should contain the code below: using using using using System; System.Collections.Generic; System.Text; Agilent.Agilent34401.Interop; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Agilent34401Class dmm = new Agilent34401Class(); dmm.Initialize("GPIB::23", false, true, "simulate=true"); dmm.DCVoltage.Configure(1.5, 0.001); dmm.Trigger.Delay = 0.01; double reading; reading = dmm.Measurement.Read(1000); Console.
Imports Agilent.Agilent34401.Interop Module Module1 Sub Main() Dim dmm As New Agilent34401 dmm.Initialize("GPIB::23", False, True, "simulate=true") dmm.Function = Agilent34401FunctionEnum.Agilent34401FunctionDCVolts dmm.DCVoltage.Configure(1.5, 0.001) dmm.Trigger.Delay = 0.01 Dim reading As New Double reading = dmm.Measurement.Read(1000) dmm.Close() Console.WriteLine(“The reading is {0}”, reading) Console.
• • 36 •• • • Chapter 3
Chapter 4 Using IVI with LabVIEW TM •••••• 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.
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 LabVIEW 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 1 2 Launch LabVIEW. 3 4 Right-click in the Block Diagram. The Functions palette appears.
Initialize the Instrument 1 Select Initialize With Options VI from the hp34401a palette and place it on the Block Diagram. 2 Create constants and enter values for instrument resource name, ID Query, Reset, and IVI option string: • • • • GPIB0::23::INSTR in the instrument resource name field False in the ID Query field True in the Reset field Simulate=1 in the Options field Note: To create a constant, control, or indicator, right-click on the desired input terminal and select Create.
Configure the Instrument 1 From the Configuration subpalette, select Configure Measurement VI and place it on the Block Diagram. 2 Create 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 in the Resolution field • DC volts in the Measurement Function field • 1.5 in the Range field 3 Connect the instrument handle and error terminals from Initialize With Options VI to Configure Measurement VI.
3 Connect resource name and error information from Configure Trigger to Read VI. Display the Reading Create an indicator for Reading from the terminal on the Read VI. Close the Session 1 Return to the main hp 34401a palette. Select Close VI and place it on the Block Diagram. 2 Connect resource name and error information from Read VI to Close VI. Note: LabVIEW compiles while developing, which lets you check the program execution at any time. Add Error Checking 1 Return to the main functions palette.
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: 1 From the Functions palette select Application Control and drop a Property Node on the Block Diagram. 2 Connect the resource name and error information from Configure Measurement VI to the Property Node.
2 From the File menu, select New VI. The Front Panel and Block Diagram appear. 3 4 Right-click in the Block Diagram. The Functions palette appears. Select the Connectivity subpalette and then the ActiveX subpallete. From this palette, you can access ActiveX and COM objects including all IVI-COM drivers. 5 Select Automation Open from the palette and place it on the block diagram. 6 Right-click on the Automation Refnum terminal, select Select ActiveX Class... and then Browse...
7 From 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. Initialize the Instrument • • 44 •• • • Chapter 4 1 From the View menu, select Class Browser.
4 Back in the Class Browser, under Properties and Methods, scroll down and select Initialize. Click Create and drag the Invoke Node to the Block Diagram. 5 Create constants and enter values for ResourceName, IDQuery, Reset, and OptionString: • • • • 6 GPIB0::23::INSTR in the instrument ResourceName field False in the IDQuery field True in the Reset field Simulate=1 in the OptionString field Connect the automation refnum and error terminals from Automation Open to Initialize Invoke Node.
3 Connect the automation refnum and error terminals from Initialize Invoke Node to DCVoltage.Configure Invoke Node. 4 In 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. 5 6 Create a constant and enter a value of 0.01 seconds for the Delay field. Connect the automation refnum and error terminals from DCVoltage.Configure Invoke Node to Trigger.Delay Property Node.
Run the Application Your final VI Block Diagram should contain the elements shown below. To run your VI: 1 2 Switch to the VI’s Front Panel and click on the Run arrow to run the application. The 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.
• • 48 •• • • Chapter 4
Chapter 5 Using IVI with LabWindows /CVI TM TM •••••• 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.
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. 6 Add the following line to your program to include the instrument driver header file: #include “hp34401a.h” Initialize the Instrument 1 2 From the Edit menu, select Insert Construct, and click Main.
4 Select the Instrument Handle parameter. From the Code Menu, click Declare Variable to set the Instrument Handle parameter. 5 6 Enter session in the Variable Name field. Check the boxes titled Execute declaration in Interactive Window and Add declaration to top of target file “*.c”. Click OK. Note: To test the function with the specified parameter values, select Code and click Run Function Panel or click the run button in the toolbar to operate the function panel interactively.
Configure the Instrument 1 From the library tree, select Configuration and click ConfigureMeasurement. The ConfigureMeasurement function panel opens. 2 Set the function to DC Voltage, range to 1.5 volts, resolution to 1 millivolt, and instrument handle to session. Select and enter: • • • • • • 52 •• • • Chapter 5 DC Volts from the drop-down list in the Measurement Function field, 1.5 in the Range field, 0.001 in the Resolution field, and session in the Instrument Handle field.
3 Select 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. 4 From the library tree, select Configuration, select Trigger, and click ConfigureTrigger. The Configure Trigger function panel opens. 5 Set the trigger source to immediate, the trigger delay to 0.01 seconds, and the instrument handle to session.
• session in the Instrument Handle field Display the Reading 1 2 3 4 Select the Reading parameter. 5 Select Code and click Insert Function Call to insert the function and values into your program. Close the function panel. The hp34401a_Read function appears in your program. Select Code and click Declare Variable. The Declare Variable dialog appears. Enter reading in the Variable Name field. Check the boxes titled Execute declaration in Interactive Window and Add declaration to top of target file “*.c”.
printf (“%f”, reading); Note: Including error checking in your programs is good practice. Use the 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/.
• • 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. MATLAB supports IVI instrument drivers using the Instrument Control Toolbox.
Configure the IVI Driver The Instrument Control Toolbox 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. 1 At the MATLAB command line, type tmtool to launch the Test & Measurement Tool GUI.
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. 6 Select the Driver Sessions tab.
10 Select the Logical Names tab.
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 dmm.mdd appears in the current directory window. This is the instrument wrapper created by the makemid command.
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.
Further Information 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.
• • 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.
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. 1 2 3 4 Launch Measure Foundry. 5 Double-click the LXI component. The Properties dialog appears. Select File and Click New. The New Project screen opens. In the Foundry window, select All Components. Enter IVI in the Search field.
• • • • • Agilent34401 in the device type field GPIB and 23 in the VISA connect string field 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. 7 Click Next. 8 Configure the operating mode. Select Auto refresh and enter 1000 in the update rate field.
9 Click Next. 10 Configure the trigger delay. In the Properties dialog, enter 0.01 in the trigger delay field and Immediate in the trigger source field. 11 Click Next. 12 Configure the option string, reset, and reading timeout to 1 second. In the Properties dialog, enter the following: • Simulate=true in the IVI connect option string • 1000 in the timeout field • Check the Reset on Connect box 13 Click Next.
Using IVI with Measure Foundry® • • • 69 • • •
Data Sink The property pages contain all the information necessary to display the output. 1 In the Foundry window, select Display Components. Drag and drop the Single Value Label onto the form. 2 Double-click the Single Value Label. The Properties of Single Value Label dialog appears. 3 4 Scroll the list of Data sources and click Form:ivi2_IVI Dmm. Check the box by DCV in the Channels field.
DT Measure Foundry® is a registered trademark of Data Translation® in the United States and/or other countries.
• • 72 •• • • Chapter 7
Chapter 8 Using IVI with PAWS •••••• The Environment PAWS 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 (ATE) configuration.
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. 1 Launch PAWS Studio and create a new project. In the New PAWS Project dialog, enter a project name and directory for the project. Click OK. 2 To add a new file to the ATLAS Project Module, from the Main Menu select File and click New File. The New dialog appears.
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.
{ 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. 1 From the Main Menu, select File and click New Module. The New dialog appears.
9 To 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 1 From the PAWS Project window, select the DMM.h file. Insert the following code in the DMM.h file: #ifndef __DMM_h__ #define __DMM_h__ #include
#import "IviDmmTypeLib.dll" named_guids, raw_interfaces_only, raw_native_types no_namespace #import "Agilent34401.dll" named_guids, raw_interfaces_only, raw_native_types no_namespace #endif Note: This header file allows access to the COM, IVI-specific, and device environments. 2 From the PAWS Project window, select the ctrl.cpp file. Insert the following code in the ctrl.cpp file directly below #include "key.h" code: #include "DMM.
5 In the doOpen() interface function, insert the following code below the line Please insert your CEM driver code here: hr = driver.
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"); } 8 To set the trigger delay to 0.01, select the DMM.cpp file from the PAWS Project window.
hr = pDMMData->Initiate(); if (FAILED(hr)) { Display("\033[30;41m Bad return from Initiate() method\033[m\n"); } 10 To set the reading timeout to 1 second, select the DMM.cpp file from the PAWS Project window.
} driver.Release(); pDMMData.Release(); pDMMTrig.Release(); pDMMDCVolt.Release(); Note: The function doUnload gets called only once, when the Paws project is unloaded from the run-time system. Build the Project 1 From the Main Menu, select Options and click on CEM. The WCEM dialog appears. 2 Select the Files tab and enter C:\Program Files\IVI\Include in the Include Path field. Click Apply. Note: The path includes the Visacom_i.c file from the DMM.h header.
Load and Run the Project 1 From 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. 2 From the list at left, select Run.
• • 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.
2 From the Start Menu, select Project, and click References. The References dialog appears. 3 Select 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. 4 Click OK. The References dialog closes.
Create an Instance of the Driver 1 Double-click Test. The Project1 – Form1(Code) screen appears. Note that some code has already been added, including Private Sub btnTest_Click() and End Sub. 2 To enable strong type checking, at the top of the screen before the Private Sub line type Option Explicit 3 Create a variable for the driver and initialize it with the New statement.
Configure the Instrument Set the function to DC Voltage, range to 1.5 volts, and resolution to 1 millivolt. 1 2 3 Type dmm.Function = Agilent34401FunctionDCVolts Type dmm.DCVoltage.Configure 1.5, 0.001 Select 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. 4 • • 88 •• • • Chapter 9 Type 1.5, 0.
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. 1 Return to the form view and click the Label Button in the Toolbox to create a label. 2 3 4 5 Drag it to the form and drop it. Change the Name to lblResult in the Properties list at right. Remove the text under Caption. In the code after the trigger delay command, type lblResult.Caption = dmm.Measurement.
Tips 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. You will need to add a Reference to the IviDmm Class Type library for your project to compile. Here is the code: Option Explicit Dim dmm As New Agilent33401 Dim ividmm As IIviDmm Private Sub btnTest_Click() Set ividmm = dmm ividmm.Initialize "GPIB::23", False, True, "Simulate=True" ividmm.Configure IviDmmFunctionDCVolts, 1.5, 0.
Further Information Learn more about Visual Basic at http://msdn.microsoft.com/library/default.asp?url=/library/enus/dnanchor/html/vb6anchor.asp. Microsoft® and Visual Studio® are registered trademarks of Microsoft Corporation in the United States and/or other countries. Using IVI with Visual Basic 6.
• • 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. You select 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.
3 Click Add under instrument in the list at the right to add a simulated instrument. The Instrument Properties dialog box appears. 4 In the Instrument Properties dialog box, enter or select the following: • • • • 5 6 myDMM in the Name field GPIB in the Interface field 0 in the Board Number field GPIB0::23::INSTR in the VISA Address field Click Advanced. The Advanced Instrument Properties dialog box appears. Click the IVI-COM Driver tab. Select Agilent 34401 from the drop-down list.
7 Click 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. 8 9 Click OK. The dialog closes and returns to the Instrument Properties dialog. Click OK. The dialog closes and returns to the Instrument Manager. Congratulations! You can now access the IVI Driver in the Instrument Manager.
3 Double-click in the To/From myDMM object. The Select an Operation dialog box appears. 4 Select 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. 5 6 Click OK. The Edit CreateInstance dialog box appears. Click OK. Initialize the Instrument • • 96 •• • • Chapter 10 1 Double-click to add another operation.
3 In the Edit Initialize dialog box, GPIB0::23::INSTR has already been entered in the ResourceName field. Enter or select the following: • False in the IdQuery field • True in the Reset field • simulate=true in the OptionString field 4 Click OK. Configure the Instrument 1 Double-click to add another operation. The Select an Operation dialog box appears. 2 Expand the treenode DCVoltage and select Configure. Click OK. The Edit Configure dialog box appears. 3 To set a range of 1.
Close the Session Now that you have completed all of the driver operations, you should close the driver session to free resources. 1 Double-click to add another operation. The Select an Operation dialog box appears. 2 Select Close to release all resources associated with the simulated Agilent 34401. Click OK. Display the Reading 1 To display the measurement, from the Main Menu select Display, and click AlphaNumeric. Place the AlphaNumeric object on your workspace.
Further Information Learn more about VEE Pro at www.agilent.com/find/vee.
• • 100 •• • • Chapter 10
Chapter 11 Advanced Topics •••••• Now that you’ve seen how to create a short program to perform a measurement in popular programming environments, we want to introduce a few advanced IVI topics: architecture, requirements for interchangeability, Configuration Store, and future developments. These should broaden your view of the capabilities of IVI drivers. IVI Architecture Up to this point, we’ve focused on using either an IVI-COM or IVI-C driver from a specific ADE.
Driver developers also provide wrapper interfaces optimized for specific development environments. The wrapper functions as an adapter between an ADE and a driver not designed for that ADE. It enables the ADE to use technologies for which no native implementation exists. In Chapter 6, IVI with MATLAB, for example, generating an instrument wrapper is a key step in creating the program.
Now that we’ve defined the capabilities, we can look at each driver in terms of those it supports. Custom Specific Driver: This driver supports only IVI inherent capabilities and instrument-specific capabilities, but not base class or class extension capabilities. This lets instrument manufacturers 1) innovate and provide specialized features, and 2) supply IVI drivers for instruments for which no class specification exists, such as network analyzers and Bluetooth testers.
capabilities, it is called an IVI-COM custom driver. If the driver includes the class capabilities, it is called an IVI-COM Class Compliant driver. IVI-COM Class Compliant drivers may or may not include custom capabilities. Instrument I/O All IVI drivers communicate to the instrument hardware through an I/O Library. The VISA library is typically used because it provides uniform access to GPIB, RS-232, USB-TMC and LAN instrument.
• The instruments must provide the same behavior, at least with respect to the calling program. Meeting these requirements is necessary to achieve “100%” interchangeability. However, if your application does not meet all of these requirements, in some cases you may be able to add additional code to your program to handle the differences between the instruments or drivers you are using and still achieve a certain degree of interchangeability.
IVI Configuration Store The IVI Configuration Store holds information about the IVI drivers installed on your computer and configuration information for your instrument system. By providing a way to flexibly reference and configure IVI drivers and instrument I/O connections outside of your application, the IVI Configuration Store makes interchangeability possible. Consider an application in which you use a specific driver to communicate with a specific instrument model at a fixed location.
and contains the commands and functions necessary to communicate with the instrument. You can use the software module entry data to locate the component on your system and determine what instrument models and class interfaces (called Published APIs in the configuration server) are supported by the component. HardwareAsset: A HardwareAsset describes a specific physical device in your system with which you communicate such as an oscilloscope or power supply.
In the illustration below, we replace the Vendor X DMM with a Vendor Y DMM. All we need to do is change the LogicalName so that it points to a different DriverSession. In this example, change the LogicalName so that it point to the Vendor Y DriverSession. We do not need to make any modifications to the application itself. All changes are contained within the Configuration Store. Below we show examples of using interchangeability using logical names with IVICOM and IVI-C.
IVI-COM This C# example shows interchangeability using IIviDriver, which references all of IVI’s inherent capabilities. 1 IIviDriver Create a string variable for logical name. string logicalName = "AgilentDriver"; 2 Add a reference to the Session Factory. Go to Project and Add Reference. Select the IVI Session Factory Type Library under the COM tab. 3 Create an instance of the Session Factory.
a reference to the instance of the driver. This line of code then casts the reference returned to type IIviDriver, from which all of IVI’s inherent capabilities can be referenced. IIviDriver driver = (IIviDriver)factory.CreateDriver(logicalName); 6 Initialize is required, because the Session Factory does not take care of that function. driver.Initialize(logicalName, true, true); 7 Identity is a property of IIviDriver that references the IIviDriverIdentity interface.
The rest of the code follows that used for the examples, but note that it is written to the class-compliant interfaces, not the instrument-specific ones. dmm.Configure(IviDmmFunctionEnum.IviDmmFunctionDCVolts, 1.5, 0.001); dmm.Trigger.Delay = 0.01; Console.WriteLine(dmm.Measurement.Read(1000).ToString()); dmm.Close(); IVI-C This C example shows how to use an IVI-C Class Driver to achieve interchangeability.
IviDMM_ConfigureTrigger (session, IVIDMM_VAL_IMMEDIATE, 0.01); IviDMM_Read (session, 1000, &reading); printf ("%f", reading); IviDMM_close (session); Editing the Configuration Store If you installed the IVI Shared Components in the default location, you will find the Configuration Store information in a file named IviConfigurationStore.xml in C:\Program Files\IVI\Data. Recent versions of Microsoft Internet Explorer can display .xml files.
2 Several vendors include examples as part of driver installation. For the Agilent 34401A driver (from Agilent Technologies) we use in some of the examples throughout the guide a folder, located at C:\Program Files\IVI\Drivers\Agilent 34401\Examples, contains examples that show its use in a variety of different environments. Finally, contact your driver vendor for help.
• • 114 •• • • Chapter 11