Agilent IVI-COM driver and VISA-COM I/O programming examples in Microsoft Visual C# Application Note Abstract This paper details the installation instructions and Visual C# (C-sharp) programming examples for Agilent Technologies IVI-COM instrument drivers and VISA-COM I/O. This application note will demonstrate examples from the N4965A multi-channel BERT controller and the N4962A serial BERT 12.5 Gb/s. William Sitch Agilent Technologies, Inc.
Table of Contents Agilent Technologies IVI-COM driver and VISA-COM I/O programming examples in Microsoft Visual C#.............................................................................3 What is an instrument driver?..................................................................................3 What is an IVI driver?.................................................................................................3 What is an IVI-COM driver?...........................................................
Agilent Technologies IVI-COM driver and VISA-COM I/O programming examples in Microsoft Visual C# Agilent Technologies offers a full suite of IVI-COM instrument drivers and Visual C# programming examples for remote instrument control. The drivers and programming examples are available as free downloads from the Agilent Technologies website. IVI Shared Components are also required; these are available as a free download from the IVI Foundation website.
What is an IVI-COM driver? IVI drivers are available in two flavors: IVI-C and IVI-COM. IVI-C drivers are developed for use in ANSI C development environments. IVI-COM drivers are developed for use in development environments that support the Component Object Model (COM). IVI-COM drivers are used in the typical Windows-based PC ADEs like Visual C# and Visual Basic .NET, but also including Agilent VEE, NI LabVIEW, NI TestStand, MATLAB, and other ADEs.
From the National Instruments (NI) webpage (http://www.ni.com/visa/): “VISA provides the programming interface between the hardware and development environments such as LabVIEW, LabWindows/CVI, and Measurement Studio for Microsoft Visual Studio®. NI-VISA™ is the National Instruments implementation of the VISA I/O standard.
Installation instructions for IVI drivers IVI drivers provided by a manufacturer are the easiest way to interface with the instrument hardware also provided by that manufacturer. Agilent Technologies provides IVI drivers for all instruments that have GPIB and/or USB interface capability. Please see the individual instrument webpage linked from the Agilent Technologies website. There are three steps to installing an IVI driver.
1.2 Install the NI-488.2 software and select appropriate features Proceed with the software installation when presented with a menu. There is no need to read the documentation. You do not need an additional license. The installation will next display a feature selection window, shown below in Figure 1.
Step 2: Installing the IVI shared components IVI Shared Components allow all IVI drivers to use a common code base. This simplifies IVI driver development, and as detailed on the IVI Foundation website, at: http://www.ivifoundation.org/shared_components/Default.aspx “To improve users’ experience when they combine drivers and other software from various vendors, it is important to have some key software components common to all implementations.
Step 3: Installing the Agilent Technologies IVI drivers IVI drivers simplify communications with the instrument they are written for. Each type of instrument has its own dedicated IVI driver, and you will need to install each driver separately if you want to control multiple types of instruments. 3.1 Download the latest MSI or EXE package Download the latest Agilent Technologies IVI drivers for the instruments you want to control.
VISA-COM programming examples in Visual C# VISA-COM libraries are used to communicate with instruments on relatively low-level message-based communication sessions. For most instruments this means sending SCPI commands and reading/processing data read from the instrument. For most customers and most applications, we do not recommend using VISACOM libraries for instrument communication. Instead, we recommend using the Agilent Technologies IVI-COM drivers detailed below.
Figure 5 . Microsoft Visual Studio, add reference window, VISA-COM library Find and select the VISA-COM 3.0 Type Library from the list. When you add this reference to your project, a VisaComLib reference will be listed under the project “References” treenode, as shown in Figure 4. This reference is now available in your project. 4.
4.3 Communicating with an instrument using the VISA-COM library The next step is to assign the message-based session to a specific instrument using the resource manager. There are easy and difficult methods to do this, the hardest of which would be an automated scan of the resources available. The code example shown below details how you connect to an instrument where the GPIB address is known. 4.4 10-second BER measurement example using the N4962A serial BERT 12.5 Gb/s and N4963A clock synthesizer 13.
// setup BERT Console.Write(“N4962A SERIAL BERT 11.3 GB/S “ + BERTAddress + “ setup..”); BERT.IO.Clear(); BERT.WriteString(“*RST;*OPC?”, true); temp = BERT.ReadString(); BERT.WriteString(“:SOUR:ROSC:SOUR EXT”, true); System.Threading.Thread.Sleep(200); BERT.WriteString(“:SOUR:ROSC:FREQ “ + (srcFreq/1e6), true); BERT.WriteString(“:SOUR:PATT “ + BERTPattern, true); BERT.WriteString(“:SOUR:VOLT “ + (BERTAmplitude*1000), true); if (BERTErrInj) BERT.
4.5 Example code output If the autophase procedure is unable to find a clock phase location that yields a BER result below the threshold, the output looks like: N4963A CLOCK SYNTHESIZER13.5 GHZ GPIB::16 setup..done N4962A SERIAL BERT 12.5 GB/S GPIB::5 setup..done Autoalign and error check..14 degrees..failed 0.1, BER: 0.
The same type of code is used to reset and initialize the N4962A serial BERT 12.5 Gb/s. Once initialized, the following example performs an autophase and checks to see if the resulting BER is better than a pre-determined threshold value (if it is, it exits): BERT.WriteString(“:SENS:ROSC:PHAS AUTO”, true); BERT.WriteString(“*OPC?”, true); temp = BERT.ReadString(); BERT.WriteString(“:SENS:ROSC:PHAS?”, true); temp = BERT.ReadString().TrimEnd(‘\r’, ‘\n’); BERT.WriteString(“:SENS:SWE:TIME 0.1”, true); BERT.
IVI-COM Programming Examples in Visual C# IVI drivers use the VISA-COM library to communicate with instruments, but the driver encapsulates error-checking and optimized instrument communication methods into a format that’s much easier to use in an object-oriented programming language like Visual C#.
Figure 7. Microsoft Visual Studio, add reference window, Agilent Technologies IVI drivers list Find the IVI drivers in the list, and select the specific IVI driver you want to add a reference to. In this example, we select IVI Agilent Technologies N4962A and IVI Agilent Technologies N4963A libraries. When you add these references, another reference to IviDriverLib will be added to your project reference list.
5.2 Using IVI-COM driver references in your program code Now you’ve added the IVI driver reference to your project, you can interact with the IVI driver from any code block in your project. Select the code file you want to interact with the instrument and add a “using” statement to simplify the namespace associated with the IVI driver reference. Using Agilent Technologies.Agilent TechnologiesN4962A.Interop; Using Agilent Technologies.Agilent TechnologiesN4963A.
Agilent TechnologiesN4962AErrorInjection1E1PerSecond; Agilent TechnologiesN4962APatternEnum BERTPattern = Agilent TechnologiesN4962APatternEnum.
BERT.Data.Generator.Output = Agilent TechnologiesN4962AOutputStateEnum. Agilent TechnologiesN4962AOutputStateOn; Console.WriteLine(“done”); // autoalign and check for error-free operation Console.Write(“Autoalign and error check..”); BERT.Clock.AutoPhase(); Console.Write(BERT.Clock.Phase + “ degrees..”); BERT.Data.Detector.GateTime = 0.1; BERT.Measurement.Start(); System.Threading.Thread.Sleep(100); BERT.Measurement.
5.5 Useful code snippets for programming the N4965A-CTR multi-channel BERT controller Once you’ve referenced the IVI driver in your Visual Studio project, assigned a using command simplify the object namespace, initialized the driver object, and connected to an instrument, now what? To turn on the TG5P1A generator pod attached to Channel 1 of the N4965A-CTR multi-channel BERT controller instrument, set the amplitude of the output to 1.0V, change the pattern to PRBS15, and set 2.
Troubleshooting If you run into problems, or if you have any questions not answered in this document, please don’t hesitate to contact an Agilent Technologies application engineer.
Appendix A: End User License Agreement LEGAL NOTICE: PLEASE READ THESE TERMS BEFORE INSTALLING OR OTHERWISE USING THE LICENSED MATERIALS. ALL USE OF THESE LICENSED MATERIALS IS SUBJECT TO THE LICENSE TERMS SET FORTH BELOW. “LICENSED MATERIALS” INCLUDES THE SOFTWARE, ANY WHOLE OR PARTIAL COPIES, AND ANY ACCOMPANYING INSTRUCTIONS, DOCUMENTATION, TECHNICAL DATA, IMAGES, RECORDINGS AND OTHER RELATED MATERIALS.
No Disassembly. You may not disassemble or decompile the Licensed Materials unless you obtain Agilent Technologies’ prior written consent High Risk Activities. The Licensed Materials are not specifically designed, manufactured or intended for use in the planning, construction, maintenance or direct operation of a nuclear facility, nor for use in on-line control or fail safe operation of aircraft navigation, control or communication systems, weapon systems or direct life support systems.
www.agilent.com www.agilent.com/find/BERT For more information on Agilent Technologies’ products, applications or services, please contact your local Agilent office. The complete list is available at: Agilent Email Updates www.agilent.com/find/emailupdates Get the latest information on the products and applications you select. Agilent Channel Partners www.agilent.