Keysight M9260A Programming Manual

Page 1
Keysight M9260A PXIe Audio Analyzer
Programming Guide
Page 2
Notices
CAUTION
WARNING
Copyright Notice
© Keysight Technologies 2017 - 2018 No part of this manual may be repro-
duced in any form or by any means (including electronic storage and retrieval or translation into a foreign language) without prior agreement and written consent from Keysight Technol­ogies as governed by United States and international copyright laws.
Manual Part Number
M9260-90001
Edition
Edition 2, January 15, 2018
Printed in:
Printed in Malaysia
Published by:
Keysight Technologies Bayan Lepas Free Industrial Zone, 11900 Penang, Malaysia
Technology Licenses
The hard ware and/or software described in this document are fur­nished under a license and may be used or copied only in accordance with the terms of such license.
Declaration of Conformity
Declarations of Conformity for this product and for other Keysight prod­ucts may be downloaded from the Web. Go to http://www.keysight.com/
go/conformity. You can then search by
product number to find the latest Dec­laration of Conformity.
U.S. Government Rights
The Software is “commercial computer software,” as defined by Federal Acqui­sition Regulation (“FAR”) 2.101. Pursu­ant to FAR 12.212 and 27.405-3 and Department of Defense FAR Supple­ment (“DFARS”) 227.7202, the U.S. government acquires commercial com­puter software under the same terms by which the software is customarily provided to the public. Accordingly, Keysight provides the Software to U.S. government customers under its stan­dard commercial license, which is embodied in its End User License Agreement (EULA), a copy of which can be found at http://www.keysight.com/
find/sweula. The license set forth in the
EULA represents the exclusive authority by which the U.S. government may use, modify, distribute, or disclose the Soft­ware. The EULA and the license set forth therein, does not require or per­mit, among other things, that Keysight: (1) Furnish technical information related to commercial computer soft­ware or commercial computer software documentation that is not customarily provided to the public; or (2) Relinquish to, or otherwise provide, the govern­ment rights in excess of these rights customarily provided to the public to use, modify, reproduce, release, per­form, display, or disclose commercial computer software or commercial com­puter software documentation. No additional government requirements beyond those set forth in the EULA shall apply, except to the extent that those terms, rights, or licenses are explicitly required from all providers of commercial computer software pursu­ant to the FAR and the DFARS and are set forth specifically in writing else­where in the EULA. Keysight shall be under no obligation to update, revise or otherwise modify the Software. With respect to any technical data as defined by FAR 2.101, pursuant to FAR
12.211 and 27.404.2 and DFARS
227.7102, the U.S. government acquires no greater than Limited Rights as defined in FAR 27.401 or DFAR
227.7103-5 (c), as applicable in any technical data.
Warranty
THE MATERIAL CONTAINED IN THIS DOCUMENT IS PROVIDED “AS IS,” AND IS SUBJECT TO BEING CHANGED, WITHOUT NOTICE, IN FUTURE EDITIONS. FURTHER, TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, KEYSIGHT DIS­CLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, WITH REGARD TO THIS MANUAL AND ANY INFORMA­TION CONTAINED HEREIN, INCLUD­ING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MER­CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. KEYSIGHT SHALL NOT BE LIABLE FOR ERRORS OR FOR INCIDENTAL OR CONSE­QUENTIAL DAMAGES IN CONNECTION WITH THE FURNISHING, USE, OR PERFORMANCE OF THIS DOCUMENT OR OF ANY INFORMATION CON­TAINED HEREIN. SHOULD KEYSIGHT AND THE USER HAVE A SEPARATE WRITTEN AGREEMENT WITH WAR­RANTY TERMS COVERING THE MATE­RIAL IN THIS DOCUMENT THAT CONFLICT WITH THESE TERMS, THE WARRANTY TERMS IN THE SEPARATE AGREEMENT SHALL CONTROL.
Safety Information
A CAUTION notice denotes a hazard. It calls attention to an operating proce­dure, practice, or the like that, if not correctly performed or adhered to, could result in damage to the product or loss of important data. Do not pro­ceed beyond a CAUTION notice until the indicated conditions are fully understood and met.
A WARNING notice denotes a hazard. It calls attention to an operating proce­dure, practice, or the like that, if not correctly performed or adhered to, could result in personal injury or death. Do not proceed beyond a WARNING notice until the indicated conditions are fully understood and met.
2 Keysight M9260A Programming Guide
Page 3

Safety Symbols

WARNING
The following symbols on the instrument and in the documentation indicate precautions which must be taken to maintain safe operation of the instrument.
Caution, risk of danger (refer to this manual for specific Warning or Caution information)

Safety Considerations

Read the information below before using this instrument.
The following general safety precautions must be observed during all phases of operation, service, and repair of this instrument. Failure to comply with these precautions or with specific warnings elsewhere in this manual violates safety standards for design, manufacture, and intended use of the instrument. Keysight Technologies assumes no liability for the customer’s failure to comply with these requirements.
Keysight M9260A Programming Guide 3
– If this product is not used as specified, the protection provided by the
equipment could be impaired. This product must be used in a normal condition (in which all means for protection are intact) only.
– No operator serviceable inside. Refer servicing to qualified personnel. To
prevent electrical shock do not remove covers.
– To prevent electrical shock, disconnect the Keysight Technologies
instrument from mains before cleaning. Use a dry cloth or one slightly dampened with water to clean the external case parts. Do not attempt to clean internally. To clean the connectors, use alcohol in a well ventilated area. Allow all residual alcohol moisture to evaporate, and the fumes to dissipate prior to energizing the instrument.
Page 4
CAUTION
– To maintain protection from electric shock and fire, replacement
components in mains circuits - including the power transformer, test leads, and input jacks - must be purchased from Keysight. Standard fuses with applicable national safety approvals may be used if the rating and type are the same. Other components that are not safety-related may be purchased from other suppliers as long as they are equivalent to the original component (note that selected parts should be purchased only through Keysight to maintain accuracy and functionality of the product). If you are unsure about the applicability of a replacement component, call a Keysight office for information.
– The maximum working voltage for the
M9260A input port is ±46 Vp while
the output port can only source up to ±10 Vp. Do not exceed the maximum
M9260A input voltage to prevent damage to the module.
4 Keysight M9260A Programming Guide
Page 5

Environmental Conditions

The M9260A is designed for indoor use and in an area with low condensation. The table below shows the general environmental requirements for this instrument.
Environmental condition Requirement
Temperature
Humidity
Altitude Up to 3000 m
Pollution degree 2
Operating condition – 0 °C to 55 °C Storage condition – –40 °C to 71 °C
Operating condition – Up to 80% RH at 40 °C (non-condensing) Storage condition – Up to 95% RH at 40 °C (non-condensing)
Keysight M9260A Programming Guide 5
Page 6

Regulatory Information

The M9260A complies with the following safety and Electromagnetic Compatibility (EMC) compliances:

Safety compliance

IEC 61010-1/EN 61010-1

EMC compliance

– IEC 61326-1/EN 61326-1 (Immunity for industrial electromagnetic
environment)
– Canada: ICES/NMB-001: Issue 4, June 2006
– Australia/New Zealand: AS/NZS CISPR 11
Supplementary information:
– The product was tested in a typical configuration with Keysight Technologies
test systems.
– This is a sensitive measurement apparatus by design and may have some
performance loss when exposed to ambient continuous electromagnetic phenomenon.
6 Keysight M9260A Programming Guide
Page 7

Regulatory Markings

The CE mark is a registered trademark of the European Community. This CE mark shows that the product complies with all the relevant European Legal Directives.
ICES/NMB-001 indicates that this ISM device complies with the Canadian ICES-001. Cet appareil ISM est conforme a la norme NMB-001 du Canada.
ISM GRP.1 Class A indicates that this is an Industrial Scientific and Medical Group 1 Class A product.
This symbol is a South Korean Class A EMC Declaration. This is a Class A instrument suitable for professional use and in electromagnetic environment outside of the home.
This symbol indicates the time period during which no hazardous or toxic substance elements are expected to leak or deteriorate during normal use. Forty years is the expected useful life of the product.
The RCM mark is a registered trademark of the Australian Communications and Media Authority.
This instrument complies with the WEEE Directive (2002/96/EC) marking requirement. This affixed product label indicates that you must not discard this electrical or electronic product in domestic household waste.
Keysight M9260A Programming Guide 7
Page 8

Waste Electrical and Electronic Equipment (WEEE) Directive 2002/ 96/EC

This instrument complies with the WEEE Directive (2002/96/EC) marking requirement. This affixed product label indicates that you must not discard this electrical or electronic product in domestic household waste.

Product category

With reference to the equipment types in the WEEE directive Annex 1, this instrument is classified as a “Monitoring and Control Instrument” product.
The affixed product label is as shown below.
Do not dispose in domestic household waste.
To return this unwanted instrument, contact your nearest Keysight Service Center, or visit http://about.keysight.com/en/companyinfo/environment/takeback.shtml for more information.

Sales and Technical Support

To contact Keysight for sales and technical support, refer to the support links on the following Keysight websites:
www.keysight.com/find/M9260A
(product-specific information and support, software and documentation updates)
www.keysight.com/find/assist
(worldwide contact information for repair and service)
8 Keysight M9260A Programming Guide
Page 9

Table of Contents

Safety Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
Safety Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
Environmental Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
Regulatory Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
Safety compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
EMC compliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
Regulatory Markings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7
Waste Electrical and Electronic Equipment (WEEE) Directive
2002/96/EC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Product category . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8
Sales and Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8
1 Getting Started
Introduction to IVI Driver Programming for M9260A . . . . . . . . . . . . . . .16
Related documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
Related websites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
Overall process flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
Before You Begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
Theory of Operation for the M9260A Application Programming
Interfaces (API) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
IVI Compliant or IVI Class Compliant . . . . . . . . . . . . . . . . . . . . . . . .20
IVI Driver types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
IVI Driver hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
Instrument-Specific Hierarchies for the M9260A . . . . . . . . . . . . . . . 24
Naming conventions used to program IVI Drivers . . . . . . . . . . . . . .25
2 Tutorial: Create a Project with IVI-COM Using Visual C#
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
Step 1: Create a Console Application . . . . . . . . . . . . . . . . . . . . . . . . . .29
Step 2: Add references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30
Keysight M9260A Programming Guide 9
Page 10
Step 3: Add using statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
To access the IVI Drivers without having to specify or type the full
path of each interface or enum . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Step 4: Create Instances of the IVI-COM Drivers . . . . . . . . . . . . . . . . . 33
To create driver instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Step 5: Initialize the driver instances . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
To determine the ResourceName . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Set the Initialize() Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Call the Initialize() method with the set parameters . . . . . . . . . . . . 36
Understanding Initialize options . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Step 6: Write the program steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Example: Using the SFP to write program commands . . . . . . . . . . 40
Step 7: Close the driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Step 8: Building and running a complete example program using
Visual C# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3 Example Program Codes for the M9260A
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Example Program 1: Performing waveform acquisition using the
M9260A Analog Analyzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Example Program 2: Performing waveform generation using the
M9260A Analog Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
10 Keysight M9260A Programming Guide
Page 11

List of Figures

Figure 2-1 Add reference to the M9260A driver . . . . . . . . . . . . . .30
Figure 2-2 M9260A SFP software connection . . . . . . . . . . . . . . . .35
Keysight M9260A Programming Guide 11
Page 12
THIS PAGE HAS BEEN INTENTIONALLY LEFT BLANK.
12 Keysight M9260A Programming Guide
Page 13

List of Tables

Table 2-1 Commonly used Initialize() options . . . . . . . . . . . . . . .37
Table 2-2 Writing program commands . . . . . . . . . . . . . . . . . . . . 40
Keysight M9260A Programming Guide 13
Page 14
THIS PAGE HAS BEEN INTENTIONALLY LEFT BLANK.
14 Keysight M9260A Programming Guide
Page 15
Keysight M9260A PXIe Audio Analyzer Programming Guide

1 Getting Started

Introduction to IVI Driver Programming for M9260A 16 Before You Begin 18 Theory of Operation for the M9260A Application Programming Interfaces (API)
19
This chapter provides an overview about IVI driver programming for the Keysight M9260A PXIe Audio Analyzer.
15
Page 16
1 Getting Started

Introduction to IVI Driver Programming for M9260A

This programming guide provides a guide to write and compile source code to produce an Assembly .exe file and is intended for individuals who write and run programs to control test-and-measurement instruments.
Specifically, in this programming guide, you will learn how to use Visual Studio 2010 with the .NET Framework to write IVI-COM Console Applications in Visual C# to control the M9260A. Knowledge of Visual Studio 2010 with the .NET Framework and the programming syntax for Visual C# is required.
This basic user programming model uses the IVI-COM driver directly and allows customer code to:
– access the IVI-COM driver at the lowest level
– control the Keysight M9260A PXIe Audio Analyzer

Related documentation

The documentation listed below can be downloaded for free through our website at http://www.keysight.com/find/M9260A. You can check the manual revision on the second page of each manual.
Keysight M9260A PXIe Audio Analyzer Programming Guide. This manual. For
IVI-COM console applications.
Keysight M9260A PXIe Audio Analyzer Startup Guide. Procedures to help you
to unpack, inspect, install (software and hardware), perform instrument
connections, and verify operability of the M9260A.
Keysight M9260A PXIe Aud io Analyzer Soft Front Panel Software and Help.
Embedded in the Soft Front Panel software.
Keysight M9260A PXIe Aud io Analyzer LabVIEW Driver Reference (Online
Help System). Provides detailed documentation of the LabVIEW G Driver API
functions
Keysight M9260A PXIe Aud io Analyzer Data Sheet. The data sheet provides
full product specifications.
16 Keysight M9260A Programming Guide
Page 17

Related websites

– Keysight Technologies PXI and AXIe Modular Products (http://
www.keysight.com/find/modular)
– Keysight M9260A PXIe Audio Analyzer (http://www.keysight.com/find/
M9260A)
– Keysight Technologies (http://www.keysight.com)
– IVI Drivers and components downloads (http://www.keysight.com/find/ivi)
– Keysight I/O Libraries Suite (http://www.keysight.com/find/iosuite)
– GPIB, USB, and Instrument Control Products (http://www.keysight.com/find/
io)
– Keysighy VEE Pro (http://www.keysight.com/find/vee)
– Technical Support, Manuals, and Downloads (http://www.keysight.com/find/
support)
– Contact Keysight Test and Measurement (http://www.keysight.com/find/
contactus)
–IVI Foundation (http://www.ivifoundation.org) - Usage Guides, Specifications,
Shared Components Downloads
–MSDN Online (http://msdn.microsoft.com)
Getting Started 1

Overall process flow

1 Create a source code using Microsoft Visual Studio 2010 with .NET Visual C#
running on Windows 7 or above.
2 Compile the source code using the .NET Framework Library.
3 Produce an Assembly.exe file - this file can run directly from Microsoft
Windows without the need for any other programs. When using the Visual Studio Integrated Development Environment (IDE), the Console Applications created are stored in conceptual containers called Solutions and Projects. You can view and access Solutions and Projects using the Solution Explorer window (View > Solution Explorer).
Keysight M9260A Programming Guide 17
Page 18
1 Getting Started
NOTE

Before You Begin

1 Install Microsoft Visual Studio 2010 with .NET Visual C# on a PC running on
Windows 7 or higher.
The steps below are detailed in the Keysight M9260A PXIe Audio Analyzer Startup Guide (M9260-90000). However, these steps are repeated here and must be completed before you can programmatically control the M9260A PXIe Audio Analyzer hardware using the IVI Drivers.
2 Unpack and inspect all hardware.
3 Verify the shipment contents.
4 Install the following software downloaded from http://www.keysight.com/find/
M9260A in the following order.
– Install Keysight IO Libraries Suite (IOLS), Version 17.1.19313.5 or newer;
– Install the M9260A PXIe Audio Analyzer driver software, Version 1.0.0.0 or
5 Alternatively, the software can also be downloaded from the Keysight product
websites:
this installation includes Keysight Connections Expert.
newer. Driver software includes all IVI-COM, IVI-C, and LabVIEW G Drivers along with Soft Front Panel (SFP) programs and documentation.
– http://www.keysight.com/find/iosuite
http://www.keysight.com/find/ivi (Installers for Keysight IVI-COM drivers)
– http://www.keysight.com/find/M9260A
6 Install the hardware modules and connect the cables.
7 Verify the operation of the modules (or the system that the modules create).
8 Once the software and hardware are installed and verification of the operation
has been performed, the M9260A is ready to be programmatically controlled.
18 Keysight M9260A Programming Guide
Page 19
Getting Started 1

Theory of Operation for the M9260A Application Programming Interfaces (API)

The following IVI Driver terminology is used throughout this programming guide.
IVI [Interchangeable Virtual Instruments] - a standard instrument driver model defined by the IVI Foundation that enables engineers to exchange instruments made by different manufacturers without rewriting their code.
www.ivifoundation.org
There are currently 13 IVI Instrument Classes defined by the IVI Foundation and are listed as follows:
– DC Power Supply
– AC Power Supply
–DMM
– Function Generator
–Oscilloscope
– Power Meter
– RF Signal Generator
– Spectrum Analyzer
–Switch
– Upconverter
–Downconverter
– Digitizer
– Counter/Timer
The M9260A PXIe Audio Analyzer IVI driver is an IVI custom specific driver and does not belong to any of these 13 IVI Instrument Classes. It is therefore described as a "NoClass" module.
Keysight M9260A Programming Guide 19
Page 20
1 Getting Started

IVI Compliant or IVI Class Compliant

The M9260A PXIe Audio Analyzer is IVI Compliant, but not IVI Class Compliant; it does not belong to one of the 13 IVI Instrument Classes defined by the IVI Foundation.
IVI Compliant – The IVI Driver follows architectural specifications for these categories:
–Installation
– Inherent Capabilities
– Cross Class Capabilities
–Style
– Custom Instrument API
IVI Class Compliant - The IVI Driver implements one of the 13 IVI Instrument Classes.
– If an instrument is IVI Class Compliant, it is also IVI Compliant
– Provides one of the 13 IVI Instrument Class APIs in addition to a Custom API
– Custom API may be omitted (unusual)
– Simplifies exchanging instruments
20 Keysight M9260A Programming Guide
Page 21

IVI Driver types

Getting Started 1
IVI Driver
– Implements the Inherent Capabilities Specification
– Complies with all of the architecture specifications
– May or may not comply with one of the 13 IVI Instrument Classes
– Is either an IVI Specific Driver or an IVI Class Driver
Keysight M9260A Programming Guide 21
Page 22
1 Getting Started
IVI Class Driver
– Is an IVI Driver needed only for interchangeability in IVI-C environments
– The IVI Class may be IVI-defined or customer-defined
IVI Specific Driver
Is an IVI Driver that is written for a particular instrument such as the M9260A PXIe Audio Analyzer
IVI Class-Compliant Specific Driver
IVI Custom Specific Driver
– IVI Specific Driver that complies with one (or more) of the IVI defined class
specifications
– Used when hardware independence is desired
– IVI Specific Driver that is not compliant with any one of the IVI defined class
specifications. The M9260A PXIe Audio Analyzer belongs to this driver group.
–Not interchangeable

IVI Driver hierarchy

When writing programs, you will be using the interfaces (APIs) available to the IVI-COM driver.
The core of every IVI-COM driver is a single object with many interfaces.
These interfaces are organized into two hierarchies: Class-Compliant Hierarchy and Instrument-Specific Hierarchy — and both include the IIviDriver interfaces.
Class-Compl iant Hierarchy
– Since the M9260A PXIe Audio Analyzer does not belong to one of the 13 IVI
Classes, there is no Class-Compliant Hierarchy in its IVI Driver.
Instrument-Specific Hierarchy
– The M9260A PXIe Audio Analyzer Instrument-Specific Hierarchy has IKtM9260
at the root (where KtM9260 is the driver name).
– IKtM9260 is the root interface and contains references to child interfaces,
which in turn contain references to other child interfaces. Collectively, these
interfaces define the Instrument-Specific Hierarchy.
22 Keysight M9260A Programming Guide
Page 23
Getting Started 1
IIviDriver Interfaces
– The IIviDriver interfaces are incorporated into both hierarchies:
Class-Compliant Hierarchy and Instrument-Specific Hierarchy.
– The IIviDriver is the root interface for IVI Inherent Capabilities which are what
the IVI Foundation has established as a set of functions and attributes that all IVI Drivers must include — irrespective of which IVI instrument class the driver supports. These common functions and attributes are called IVI inherent capabilities, and they are documented in IVI-3.2 — Inherent Capabilities Specification. Drivers that do not support any IVI instrument class such as the M9260A PXIe Audio Analyzer must still include these IVI inherent capabilities.
Keysight M9260A Programming Guide 23
Page 24
1 Getting Started

Instrument-Specific Hierarchies for the M9260A

The following table lists the Instrument-Specific Hierarchy interfaces for the M9260A PXIe Audio Analyzer.
Keysight M9260A PXIe Audio Analyzer
Instrument-Specific Hierarchy
KtM9260 is the driver name
IKtM9260 is the root interface
Perform the following steps to view the interfaces available in the M9260A PXIe Audio Analyzer using Visual Studio:
1 Right-click the KtM9260Lib library file in the References folder from the
Solution Explorer window.
24 Keysight M9260A Programming Guide
Page 25
2 Select View in the Object Browser.
Getting Started 1

Naming conventions used to program IVI Drivers

General IVI naming conventions
– All instrument class names start with “Ivi”
– Example: IviScope, IviDmm
– Function names
– One or more words use PascalCasing
– First word should be a verb
IVI-COM naming conventions
– Interface naming
– Class compliant: Starts with “IIvi”
– I<ClassName>
Keysight M9260A Programming Guide 25
Page 26
1 Getting Started
– Sub-interfaces add words to the base name that match the C hierarchy as
– Defined values
– Enum values do not end in “Enum” but use the last word to differentiate
– Examples: IIviScope, IIviDmm
close as possible
– Examples: IIviFgenArbitrary, IIviFgenArbitraryWaveform
– Enumerations and enum values are used to represent discrete values in
IVI-COM
– <ClassName><descriptive words>Enum
– Example: IviScopeTriggerCouplingEnum
– Examples: IviScopeTriggerCouplingAC, IviScopeTriggerCouplingDC
26 Keysight M9260A Programming Guide
Page 27
Keysight M9260A PXIe Audio Analyzer Programming Guide
2 Tutorial: Create a Project
with IVI-COM Using Visual C#
Introduction 28 Step 1: Create a Console Application 29 Step 2: Add references 30 Step 3: Add using statements 32 Step 4: Create Instances of the IVI-COM Drivers 33 Step 5: Initialize the driver instances 34 Step 6: Write the program steps 40 Step 7: Close the driver 42 Step 8: Building and running a complete example program using Visual C#
43
This chapter describes the steps to programmatically control the M9260A IVI-COM drivers using Visual C#.
27
Page 28
2 Tutorial: Create a Project with IVI-COM Using Visual C#

Introduction

This tutorial walks you through the various steps required to create a console application using Visual Studio and C#. It demonstrates how to instantiate two driver instances, set the resource names and various initialization values, initialize the two driver instances, print various driver properties to a console for each driver instance, check drivers for errors and report the errors if any occur, and close both drivers.
Step 1. Create a Console Application
Step 2. Add References
Step 3. Add using Statements
Step 4. Create an Instance
Step 5. Initialize the Instance
Step 6. Write the Program Steps
Step 7. Close the Instance
Step 8. Building and running a complete example program using Visual C#
For example codes used to programmatically control the M9260A IVI-COM drivers, refer to Chapter 3, "Example Program Codes for the M9260A".
28 Keysight M9260A Programming Guide
Page 29
Tutorial: Create a Project with IVI-COM Using Visual C# 2
NOTE
NOTE

Step 1: Create a Console Application

Projects that use a Console Application do not show a Graphical User Interface (GUI) display.
1 Launch Visual Studio and create a new Console Application in Visual C# by
selecting File > New > Project and select a Visual C# Console Application.
Enter "M9260Properties" as the Name of the project and click OK.
When you select New, Visual Studio will create an empty Program.cs file that includes some necessary code, including using statements. This code is required, so do not delete it.
2 Select Project and click Add Reference. The Add Reference dialog appears.
For this step, Solution Explorer must be visible (View > Solution Explorer) and the "Program.cs" editor window must be visible - select the Program.cs tab to bring it to the front view.
Keysight M9260A Programming Guide 29
Page 30
2 Tutorial: Create a Project with IVI-COM Using Visual C#

Step 2: Add references

In order to access the M9260A PXIe Audio Analyzer driver interfaces, a reference to its driver (DLL) must be created.
1 In Solution Explorer, right-click References and select Add Reference.
2 From the Add Reference dialog box, select the COM tab.
3 Click any of the type libraries under the "Component Name" heading and enter
the letter "I". (All IVI Drivers begin with IVI so this will move down the list of
type libraries that begin with "I".)
Figure 2-1 Add reference to the M9260A driver
30 Keysight M9260A Programming Guide
Page 31
Tutorial: Create a Project with IVI-COM Using Visual C# 2
NOTE
NOTE
NOTE
– If you have not installed the IVI Driver for the M9260A PXIe Audio Analyzer
(as listed in the previous section titled "Before You Begin"), its IVI Driver will not appear in this list.
– Also, the TypeLib Version that appears will depend on the version of the IVI
Driver that is installed. The version numbers change over time and typically increase as new drivers are released.
– To get the IVI Drivers to appear in this list, you must close the Add Reference
dialog box, install the IVI Drivers, and come back to this section and repeat "Step 2 - Add references".
4 Scroll to the IVI section and, using Shift-Ctrl, select the following type libraries
then select OK.
IVI KtM9260 1.0 Type Library
When any of the references for the M9260A PXIe Audio Analyzer are added, the IVIDriver 1.0 Type Library is also automatically added. This is visible as IviDriverLib under the project Reference; this reference houses the interface definitions for IVI inherent capabilities which are located in the file IviDriverTypeLib.dll (dynamically linked library).
5 These selected type libraries appear under the References node, in Solution
Explorer, as:
Your program looks the same as it did before you added the References, but the difference is that the IVI Drivers that you added References to are now available for use. To allow your program to access the IVI Drivers without specifying full path names of each interface or enum, you need to add using statements to your program.
Keysight M9260A Programming Guide 31
Page 32
2 Tutorial: Create a Project with IVI-COM Using Visual C#
NOTE
Expanded
Collapsed

Step 3: Add using statements

All data types (interfaces and enums) are contained within namespaces. (A namespace is a hierarchical naming scheme for grouping types into logical categories of related functionality. Design tools, such as Visual Studio, can use namespaces which makes it easier to browse and reference types in your code.)
The C# using statement allows the type name to be used directly. Without the using statement, the complete namespace-qualified name must be used. To allow your program to access the IVI Driver without having to type the full path of each interface or enum, type the following using statements immediately below the other using statements; the following example illustrates how to add using statements.

To access the IVI Drivers without having to specify or type the full path of each interface or enum

These using statements should be added to your program:
using Ivi.Driver.Interop; using Keysight.KtM9260.Interop;
You can create sections of code in your program that can be expanded and collapsed by surrounding the code with #region and #endregion keywords. Selecting the – and + symbols allows the region to be collapsed and expanded.
32 Keysight M9260A Programming Guide
Page 33
Tutorial: Create a Project with IVI-COM Using Visual C# 2

Step 4: Create Instances of the IVI-COM Drivers

There are two ways to instantiate (create an instance of) the IVI-COM drivers:
– Direct Instantiation
– COM Session Factory
Since the M9260A PXIe Audio Analyzer is considered a “NoClass” module (because it does not belong to one of the 13 IVI Classes), the COM Session Factory is not used to create instances of its IVI-COM drivers. So, the M9260A PXIe Audio Analyzer IVI-COM driver uses direct instantiation.

To create driver instances

The new operator is used in C# to create an instance of the driver.
IKtM9260 driver = new KtM9260();
Keysight M9260A Programming Guide 33
Page 34
2 Tutorial: Create a Project with IVI-COM Using Visual C#

Step 5: Initialize the driver instances

Initialize() is required when using any IVI Driver; it establishes a communication link (an “I/O session”) with an instrument and it must be called before the program can do anything with an instrument or work in simulation mode.
The Initialize() method has a number of options that can be defined (see Initialize Options below). In this example, we prepare the Initialize() method by defining only a few of the parameters, then we call the Initialize() method with those parameters:

To determine the ResourceName

– In Simulate Mode, you can set the ResourceName address string to:
string resourceDesc = "%";
– If you are actually establishing a communication link (an “I/O session”) with an
instrument, you need to determine the Resource Name address string (VISA
address string) that is needed. You can use an IO application such as Keysight
Connection Expert, National Instruments Measurement, and Automation
Explorer (MAX), or you can use the Keysight product’s SFP to get the physical
Resource Name string. An example Resource Name address string using the
M9260A SFP is shown in Figure 2-2.
34 Keysight M9260A Programming Guide
Page 35
Tutorial: Create a Project with IVI-COM Using Visual C# 2
NOTE
Figure 2-2 M9260A SFP software connection
Module name M9260A PXIe Audio Analyzer
Slot number 3
VISA address PXI41::0::0::INSTR
string resourceDesc = "PXI41::0::0::INSTR";

Set the Initialize() Parameters

Although the Initialize() method has a number of options that can be defined (see Initialize Options below), this example is shown with a minimum set of options to help minimize complexity.
Keysight M9260A Programming Guide 35
Page 36
2 Tutorial: Create a Project with IVI-COM Using Visual C#
NOTE
string resourceDesc = "PXI41::0::0::INSTR";
string initOptions = "QueryInstrStatus=true, Simulate=false, DriverSetup= Model=, Trace=false";
bool idquery = true;
bool reset = true;

Call the Initialize() method with the set parameters

// Initialize the driver
driver.Initialize(resourceDesc, idquery, reset, initOptions);
Console.WriteLine("Driver Initialized\n");
The example below shows how IntelliSense is invoked by simply rolling the cursor over the word “Initialize”.
One of the key advantages of using C# in the Microsoft Visual Studio Integrated Development Environment (IDE) is IntelliSense. IntelliSense is a form of auto-completion for variable names and functions and is a convenient way to access parameter lists and ensure correct syntax. This feature also enhances software development by reducing the amount of keyboard input required.
36 Keysight M9260A Programming Guide
Page 37
Tutorial: Create a Project with IVI-COM Using Visual C# 2

Understanding Initialize options

The following table describes options that are most commonly used with the Initialize() method.
Table 2-1 Commonly used Initialize() options
Property type and example value Description of property
string ResourceName = PXI[bus]::device[::function][::INSTR]
string ResourceName = "PXI28::0::0::INSTR";
bool IdQuery = true;
bool Reset = true;
ResourceName
The driver is typically initialized using a physical resource name descriptor, often a VISA resource descriptor.
Refer to the above procedure “To determine the ResourceName” on page 34.
IdQuery
Setting the ID query to false prevents the driver from verifying that the connected instrument is the one the driver was written for because if IdQuery is set to true, this will query the instrument model and fail initialization if the model is not supported by the driver.
Reset
Setting Reset to true tells the driver to initially reset the instrument.
Keysight M9260A Programming Guide 37
Page 38
2 Tutorial: Create a Project with IVI-COM Using Visual C#
Tab le 2-1 Commonly used Initialize() options (continued)
Property type and example value Description of property
OptionString
Sets up the following initialization options: – QueryInstrStatus=true
Specifies whether the IVI specific driver queries the instrument status at the end of each user operation.
Simulate=true
Setting Simulate to true tells the driver that it should not attempt to connect to a physical instrument, but use a simulation of the
string OptionString = "QueryInstrStatus=true,
Simulate=true,
DriverSetup= Trace=false";
instrument instead.
Cache=false
Specifies whether or not to cache the value of properties.
InterchangeCheck=false
Specifies whether the IVI specific driver performs interchangeability checking.
RangeCheck=false
Specifies whether the IVI specific driver validates attribute values and function parameters.
RecordCoercions=false
Specifies whether the IVI specific driver keeps a list of the value coercions it makes for ViInt32 and ViReal64 attributes.
DriverSetup=
This is used to specify settings that are supported by the driver, but not defined by IVI. If the Options String parameter (OptionString in this example) contains an assignment for the Driver Setup attribute, the Initialize function assumes that everything following 'DriverSetup=' is part of the assignment.
Model=M9260A
Instrument model to use during simulation.
Trace=false
If false, an output trace log of all driver calls is not saved in an XML file.
38 Keysight M9260A Programming Guide
Page 39
Tutorial: Create a Project with IVI-COM Using Visual C# 2
NOTE
Additional information can be found under “Initializing the IVI-COM Driver” from the following:
– M9260 IVI Documentation
Start > All Programs > Keysight M9260 PCIe Module > M9260 IVI
Documentation
Keysight M9260A Programming Guide 39
Page 40
2 Tutorial: Create a Project with IVI-COM Using Visual C#

Step 6: Write the program steps

At this point, you can add program steps that use the driver instances to perform tasks.

Example: Using the SFP to write program commands

You may find it useful when developing a program to use the instrument's SFP "Driver Call Log"; this driver call log is used to view a list of driver calls that have been performed when changes are made to the controls on the SFP.
In this example, open the SFP for the M9260A PXIe Audio Analyzer and perform the following steps:
1 Configure acquisition settings
2 Configure channel settings
3 Apply initiate
4 Wait for acquisition to complete
5 Fetch acquired data
Tab le 2-2 Writing program commands
Property type and example value Description of property
Driver
Driver is the instance of the driver that is used in this example. This
KtM9260 is the driver name used by the SFP.
40 Keysight M9260A Programming Guide
instance would have been created in “Step 4: Create Instances of
the IVI-COM Drivers” on page 33.
IKtM9260 driver = new KtM9260();
Page 41
Tutorial: Create a Project with IVI-COM Using Visual C# 2
Table 2-2 Writing program commands (continued)
Property type and example value Description of property
// Configure acquisition settings. KtM9260.AnalogAnalyzer.SampleSize = 32768; KtM9260.System.SamplingFrequency = 192000;
// Configure channel settings. KtM9260.AnalogAnalyzer.Channels.get_Item("Ana
logAnalyzerChannel1").Configuration.Range = 1;
KtM9260.AnalogAnalyzer.Channels.get_Item("Ana logAnalyzerChannel1").Configuration.LoopbackE nabled = False;
KtM9260.AnalogAnalyzer.Channels.get_Item("Ana logAnalyzerChannel1").Configuration.Type = KtM9260AnalogAnalyzerTypeDifferential;
KtM9260.AnalogAnalyzer.Channels.get_Item("Ana logAnalyzerChannel1").Configuration.Impedance = KtM9260AnalogAnalyzerImpedanceHighZ;
KtM9260.AnalogAnalyzer.Channels.get_Item("Ana logAnalyzerChannel1").Configuration.Coupling = KtM9260AnalogAnalyzerCouplingDC;
KtM9260.AnalogAnalyzer.Channels.get_Item("Ana logAnalyzerChannel1").Measurement.InitiateCon t = False;
KtM9260.Apply();
// Apply initiate. KtM9260.AnalogAnalyzer.Channels.get_Item("Ana
logAnalyzerChannel1").Measurement.Initiate();
// Wait for acquisition to complete. KtM9260.AnalogAnalyzer.Channels.get_Item("Ana
logAnalyzerChannel1").Measurement.WaitForData (500);
// Fetch acquired data. KtM9260.AnalogAnalyzer.Channels.get_Item("Ana
logAnalyzerChannel1").Measurement.FetchArrayR eal64(0,32768,System.Double[],False);
Keysight M9260A Programming Guide 41
Page 42
2 Tutorial: Create a Project with IVI-COM Using Visual C#
NOTE

Step 7: Close the driver

Calling Close() at the end of the program is required by the IVI specification when using any IVI Driver.
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.
{
if (driver != null && driver.Initialized)
{
#region Close Driver Instances
driver.Close();
Console.WriteLine("Driver Closed");
#endregion
}
}
42 Keysight M9260A Programming Guide
Page 43
Tutorial: Create a Project with IVI-COM Using Visual C# 2

Step 8: Building and running a complete example program using Visual C#

Build your console application and run it to verify it works properly.
1 Open the solution file SolutionNameThatYouUsed.sln in Visual Studio 2010.
2 Set the appropriate platform target for your project.
In many cases, the default platform target (Any CPU) is appropriate. But, if you are using a 64-bit PC (such as Windows 7) to build a .NET application that uses a 32-bit IVI-COM driver, you may need to specify your project's platform target as x86.
3 Choose Project > ProjectNameThatYouUsed Properties and select Build |
Rebuild Solution.
Alternately, from the Debug menu, click Start Debugging or press the F5 key.
Example programs may be found by selecting either one of the following:
– C:\Program Files\IVI Foundation\IVI\Drivers\KtM9260\Examples
– C:\Program Files (x86)\IVI Foundation\IVI\Drivers\KtM9260\Examples
Keysight M9260A Programming Guide 43
Page 44
2 Tutorial: Create a Project with IVI-COM Using Visual C#
THIS PAGE HAS BEEN INTENTIONALLY LEFT BLANK.
44 Keysight M9260A Programming Guide
Page 45
Keysight M9260A PXIe Audio Analyzer Programming Guide
3 Example Program Codes
for the M9260A
Introduction 46 Example Program 1: Performing waveform acquisition using the M9260A
Analog Analyzer 47
Example Program 2: Performing waveform generation using the M9260A
Analog Generator 54
This chapter provides M9260A example codes for commonly used functions.
45
Page 46
3 Example Program Codes for the M9260A
NOTE

Introduction

The following example codes build on the previously presented Chapter 2,
"Tutorial: Create a Project with IVI-COM Using Visual C#" and demonstrate how to
perform the most commonly used functions: Performing waveform acquisition and performing waveform generation.
The example codes can also be accessed by going to the following folder:
Start > All Programs > Keysight Instrument Drivers > IVI-COM KtM9260
(version number) > Examples > CSharp
DISCLAIMER
© 2016 Keysight Technologies. All rights reserved.
You have a royalty-free right to use, modify, reproduce and distribute this Sample Application (and/or any modified version) in any way you find useful, provided that you agree that Keysight Technologies has no warranty, obligations, or liability for any Sample Application Files.
Keysight Technologies provides programming examples for illustration only. This sample program assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures.
Keysight Technologies support engineers can help explain the functionality of Keysight Technologies software components and associated commands, but they will not modify these samples to provide added functionality or construct procedures to meet your specific needs.
46 Keysight M9260A Programming Guide
Page 47
Example Program Codes for the M9260A 3

Example Program 1: Performing waveform acquisition using the M9260A Analog Analyzer

The following example code demonstrates how to instantiate a driver instance, read a few identity interface properties, set the resource name and various initialization values, as well as initiate the instrument specific functionality.
1 Create the driver instances.
2 Initialize the driver.
3 Configure acquisition and channel settings.
4 Apply changes to hardware.
5 Apply initiate acquisition.
6 Wait for acquisition to complete.
7 Fetch waveform data.
8 Report errors if any occur, and close the drivers.
Keysight M9260A Programming Guide 47
Page 48
3 Example Program Codes for the M9260A
using System;
using Keysight.KtM9260.Interop;
namespace CS_Acquisition
{
/// <summary>
///
/// Keysight IVI-COM Driver Example Program
///
/// Initializes the driver, reads a few Identity interface
/// properties, and initiates instrument specific
  /// functionality.
///
/// Runs in simulation mode without an instrument.
///
/// Requires a COM reference to the driver's type library.
///
/// </summary>
public class CS_Acquisition
{
[STAThread]
public static void Main( string[] args )
{
Console.WriteLine("CS_Acquisition");
Console.WriteLine();
KtM9260 driver = null;
48 Keysight M9260A Programming Guide
Page 49
Example Program Codes for the M9260A 3
/*
* You can change the code below to hard-code your resource descriptor and simulation mode, or you can pass the
resource descriptor in the command line when you run the example program to use that hardware in non-simulation mode.
*
* The resource descriptor is the same value as the “Selected Instrument” field of the SFP’s (Soft Front Panel)
connection dialog. This can be a comma or semicolon separated list of module addresses such as
PXI10::15::0::INSTR;PXI10::16::0::INSTR;PXI10::17::0::INSTR;PXI 10::18::0::INSTR or the name of a saved “Instrument Connection” created by the SFP such as PreselectedVSA. Refer to the SFP Help
topic “Connect to Instruments and Modules” for more details.
*/
// Pass in a command line argument as the resource descriptor, if none, will default
string resource = "MyVisaAlias";
// Use the hardware associated with the connection named "MyVisaAlias"
string options = "QueryInstrStatus=true, Simulate=true, DriverSetup= Model=M9260A, Trace=false";
if (args.Length > 0)
{
resource = args[ 0 ];
options = "QueryInstrStatus=true, Simulate=false, DriverSetup= Model=, Trace=false";
}
try
{
Keysight M9260A Programming Guide 49
Page 50
3 Example Program Codes for the M9260A
// Create driver instances
driver = new KtM9260();
const bool idquery = true;
const bool reset = true;
// Initialize the driver. See driver help topic "Initializing the IVI-COM Driver" for additional information.
driver.Initialize( resource, idquery, reset, options );
int errorcode = 0;
string message = string.Empty;
// Clear startup messages & warnings if any.
do
{
driver.Utility.ErrorQuery( ref errorcode, ref message );
if( errorcode != 0 )
{
Console.WriteLine( message );
}
} while( errorcode != 0 );
Console.WriteLine( "Driver Initialized" );
// Print IIviDriverIdentity properties
50 Keysight M9260A Programming Guide
Page 51
Example Program Codes for the M9260A 3
Console.WriteLine( "Identifier: {0}", driver.Identity.Identifier );
Console.WriteLine( "Revision: {0}", driver.Identity.Revision );
Console.WriteLine( "Vendor: {0}", driver.Identity.Vendor );
Console.WriteLine( "Description: {0}", driver.Identity.Description );
Console.WriteLine( "Model: {0}", driver.Identity.InstrumentModel );
Console.WriteLine( "FirmwareRev: {0}", driver.Identity.InstrumentFirmwareRevision );
Console.WriteLine( "Serial #: {0}", driver.System.SerialNumber );
Console.WriteLine( "Simulate: {0}", driver.DriverOperation.Simulate );
Console.WriteLine();
// Get the channel's repeated capability name.
string channel1RepCapName = driver.AnalogAnalyzer.Channels.Name[1];
// Configure acquisition.
driver.AnalogAnalyzer.SampleSize = 32768;
driver.SamplingFrequency = 192000;
// Configure channel settings.
IKtM9260AnalogAnalyzerChannel Channel1 = driver.AnalogAnalyzer.Channels.Item[channel1RepCapName];
Keysight M9260A Programming Guide 51
Page 52
3 Example Program Codes for the M9260A
Channel1.Configuration.Coupling = KtM9260AnalogAnalyzerCouplingEnum.KtM9260AnalogAnalyzerCoupling DC;
Channel1.Configuration.Impedance = KtM9260AnalogAnalyzerImpedanceEnum.KtM9260AnalogAnalyzerImpedan ce600Ohm;
Channel1.Configuration.LoopbackEnabled = false;
Channel1.Configuration.Range = 1;
Channel1.Configuration.Type = KtM9260AnalogAnalyzerTypeEnum.KtM9260AnalogAnalyzerTypeDifferen tial;
// Set trigger source to Immediate.
driver.Trigger.Source = KtM9260TriggerSourceEnum.KtM9260TriggerSourceImmediate;
// Single shot acquisition.
driver.AnalogAnalyzer.Measurement.InitiateCont = false;
// Apply settings to hardware.
driver.Apply();
// Initiate trigger and start acquisition.
driver.AnalogAnalyzer.Measurement.Initiate();
// Wait for acquisition to complete.
        driver.AnalogAnalyzer.Measurement. WaitForData(-1);
// Fetch data.
52 Keysight M9260A Programming Guide
Page 53
Example Program Codes for the M9260A 3
float[] data = new float[32768];
bool overload = false;
Channel1.Measurement.FetchArrayReal32(0, 32768, ref data, ref overload);
}
catch( Exception ex )
{
Console.WriteLine( ex.Message );
}
finally
{
if( driver != null && driver.Initialized )
{
// Close the driver
driver.Close();
Console.WriteLine( "" );
Console.WriteLine( "Driver Closed" );
}
}
Console.WriteLine( "" );
Console.WriteLine( "\nDone - Press Enter to Exit" );
Console.ReadLine();
}
}
}
Keysight M9260A Programming Guide 53
Page 54
3 Example Program Codes for the M9260A

Example Program 2: Performing waveform generation using the M9260A Analog Generator

The following example code demonstrates how to instantiate a driver instance, read a few identity interface properties, set the resource name and various initialization values, as well as initiate the instrument specific functionality.
1 Create the driver instances.
2 Initialize the driver.
3 Configure the channel and waveform settings.
4 Output waveform immediately without waiting for trigger.
5 Apply changes to hardware.
6 Start waveform generation.
7 Report errors if any occur, and close the drivers.
54 Keysight M9260A Programming Guide
Page 55
Example Program Codes for the M9260A 3
using System;
using Keysight.KtM9260.Interop;
namespace CS_Generator
{
/// <summary>
///
/// Keysight IVI-COM Driver Example Program
///
/// Initializes the driver, reads a few Identity interface
/// properties, and initiates instrument specific
  /// functionality.
///
/// Runs in simulation mode without an instrument.
///
/// Requires a COM reference to the driver's type library.
///
/// </summary>
public class CS_Generator
{
[STAThread]
public static void Main( string[] args )
{
Console.WriteLine("CS_Generator");
Console.WriteLine();
KtM9260 driver = null;
Keysight M9260A Programming Guide 55
Page 56
3 Example Program Codes for the M9260A
/*
* You can change the code below to hard-code your resource descriptor and simulation mode, or you can pass the resource descriptor in the command line when you run the example program to use that hardware in non-simulation mode.
*
* The resource descriptor is the same value as the “Selected Instrument” field of the SFP’s (Soft Front Panel) connection dialog. This can be a comma or semicolon separated list of module addresses such as PXI10::15::0::INSTR;PXI10::16::0::INSTR;PXI10::17::0::INSTR;PXI 10::18::0::INSTR or the name of a saved “Instrument Connection” created by the SFP such as PreselectedVSA Refer to the SFP Help topic “Connect to Instruments and Modules” for more details.
*/
// Pass in a command line argument as the resource descriptor, if none, will default
string resource = "MyVisaAlias";
// Use the hardware associated with the connection named "MyVisaAlias"
string options = "QueryInstrStatus=true, Simulate=true, DriverSetup= Model=M9260A, Trace=false";
if( args.Length > 0 )
{
resource = args[ 0 ];
options = "QueryInstrStatus=true, Simulate=false, DriverSetup= Model=, Trace=false";
}
try
{
56 Keysight M9260A Programming Guide
Page 57
Example Program Codes for the M9260A 3
// Create driver instances
driver = new KtM9260();
const bool idquery = true;
const bool reset = true;
// Initialize the driver. See driver help topic "Initializing the IVI-COM Driver" for additional information.
driver.Initialize( resource, idquery, reset, options );
int errorcode = 0;
string message = string.Empty;
// Clear startup messages & warnings if any.
do
{
driver.Utility.ErrorQuery( ref errorcode, ref message );
if( errorcode != 0 )
{
Console.WriteLine( message );
}
} while( errorcode != 0 );
Console.WriteLine( "Driver Initialized" );
// Print IIviDriverIdentity properties
Keysight M9260A Programming Guide 57
Page 58
3 Example Program Codes for the M9260A
Console.WriteLine( "Identifier: {0}", driver.Identity.Identifier );
Console.WriteLine( "Revision: {0}", driver.Identity.Revision );
Console.WriteLine( "Vendor: {0}", driver.Identity.Vendor );
Console.WriteLine( "Description: {0}", driver.Identity.Description );
Console.WriteLine( "Model: {0}", driver.Identity.InstrumentModel );
Console.WriteLine( "FirmwareRev: {0}", driver.Identity.InstrumentFirmwareRevision );
Console.WriteLine( "Serial #: {0}", driver.System.SerialNumber );
Console.WriteLine( "Simulate: {0}", driver.DriverOperation.Simulate );
Console.WriteLine();
// Get channel's repeated capability name.
string channel1RepCapName = driver.AnalogGenerator.Channels.Name[1];
// Configure channel settings.
IKtM9260AnalogGeneratorChannel Channel1 = driver.AnalogGenerator.Channels.Item[channel1RepCapName];
Channel1.Configuration.HighCurrentEnabled = false;
Channel1.Configuration.Impedance = KtM9260AnalogGeneratorImpedanceEnum.KtM9260AnalogGeneratorImped ance600Ohm;
Channel1.Configuration.MaxVoltage = 10;
58 Keysight M9260A Programming Guide
Page 59
Example Program Codes for the M9260A 3
Channel1.Configuration.Type = KtM9260AnalogGeneratorTypeEnum.KtM9260AnalogGeneratorTypeDiffer ential;
// Configure waveform settings.
Channel1.WaveformConfig.Amplitude = 1;
Channel1.WaveformConfig.DCOffset = 0;
Channel1.WaveformConfig.Frequency1 = 1000;
Channel1.WaveformConfig.WaveformType = KtM9260AnalogGeneratorWaveformTypeEnum.KtM9260AnalogGeneratorWa veformTypeSine;
// Output waveform immediately without waiting for trigger.
Channel1.TriggerSourceEnabled = false;
// Apply settings to hardware and start waveform generation.
Channel1.Configuration.OutputEnabled = true;
driver.Apply();
}
catch( Exception ex )
{
Console.WriteLine( ex.Message );
}
finally
{
if( driver != null && driver.Initialized )
{
// Close the driver
Keysight M9260A Programming Guide 59
Page 60
3 Example Program Codes for the M9260A
driver.Close();
Console.WriteLine( "" );
Console.WriteLine( "Driver Closed" );
}
}
Console.WriteLine( "" );
Console.WriteLine( "\nDone - Press Enter to Exit" );
Console.ReadLine();
}
}
}
60 Keysight M9260A Programming Guide
Page 61
This information is subject to change without notice. Always refer to the Keysight website for the latest revision.
© Keysight Technologies 2017 - 2018 Edition 2, January 15, 2018
Printed in Malaysia
*M9260-90001*
M9260-90001
www.keysight.com
Loading...