Creating Datalogging Applications in Microsoft Excel



Similar documents
Communicate with Test Instruments Over LAN Using Visual Basic

Agilent Evolution of Test Automation Using the Built-In VBA with the ENA Series RF Network Analyzers

Agilent N5970A Interactive Functional Test Software: Installation and Getting Started

Agilent BenchVue Software (34840B) Data capture simplified. Click, capture, done. Data Sheet

Agilent Automotive Power Window Regulator Testing. Application Note

VisionMate Flat Bed Scanner 2D Tube Barcode Reader

Agilent Automated Card Extraction Dried Blood Spot LC/MS System

Programming 34970A for high channel count and high throughput with Visual Basic

MDM Mass Configuration Tool User s Manual

Agilent U2000 Series USB Power Sensors

Keysight Technologies N1918A Power Analysis Manager and U2000 Series USB Power Sensors. Demo Guide

Software for Agilent Technologies Vector Series Network Analyzers

The Next Generation in Automated Oscilloscope Test

Word 2010: Mail Merge to with Attachments

Agilent Technologies. Connectivity Guide. USB/LAN/GPIB Interfaces. Agilent Technologies

Tips and Tricks SAGE ACCPAC INTELLIGENCE

R&S AFQ100A, R&S AFQ100B I/Q Modulation Generator Supplement

Rapid Assessment Key User Manual

81110A Pulse Pattern Generator Simulating Distorted Signals for Tolerance Testing

Agilent Technologies E8047B Analysis Probe System for the Intel Xeon Processor Family

Agilent MATLAB Data Analysis Software Packages for Agilent Oscilloscopes

Simply Accounting Intelligence Tips and Tricks Booklet Vol. 1

Transfer of Trace Data From R&S Network Analyzer ZVx To Microsoft Excel

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1

TX3 Series TELEPHONE ACCESS SYSTEMS. Configurator Quick Start. Version 2.2 Mircom Copyright 2014 LT-973

Universal Simple Control, USC-1

Microsoft Access 2010 Part 1: Introduction to Access

Appendix A How to create a data-sharing lab

EVAL-UFDC-1/UFDC-1M-16

RIT Installation Instructions

SIMATIC. WinCC V7.0. Getting started. Getting started. Welcome 2. Icons 3. Creating a project 4. Configure communication 5

Microsoft Excel 2013: Using a Data Entry Form

Agilent PNA Microwave Network Analyzers

Configuring the SST DeviceNet OPC Server

Microsoft Office Access 2007 Basics

Using MCC GPIB Products with LabVIEW

Simplify Data Acquisition with a Built-in LXI Web Server

Release Document Version: User Guide: SAP BusinessObjects Analysis, edition for Microsoft Office

Introduction. - Please be sure to read and understand Precautions and Introductions in CX-Simulator Operation Manual and

Maximizer CRM 12 Winter 2012 Feature Guide

Out n About! for Outlook Electronic In/Out Status Board. Administrators Guide. Version 3.x

LabVIEW Report Generation Toolkit for Microsoft Office

Siemens Applied Automation Page 1 11/26/03 9:57 PM. Maxum ODBC 3.11

Prisma II Software Upgrade Program (SOUP) Installation Guide

MS Excel. Handout: Level 2. elearning Department. Copyright 2016 CMS e-learning Department. All Rights Reserved. Page 1 of 11

Specific Information for installation and use of the database Report Tool used with FTSW100 software.

CRE Monitor Instructions Manual

MAGPOWR Spyder Firmware Update Instruction Manual

iridium for Weinzierl KNX IP BAOS

Excel Companion. (Profit Embedded PHD) User's Guide

Introduction to Microsoft Access 2003

Printer Driver Installation Guide

KCU-02 Monitor. Software Installation User Manual. For Windows XP and Windows 7

Agilent Mobile WiMAX R&D Test Set Solutions: Software and Technical Support Contract

MS WORD 2007 (PC) Macros and Track Changes Please note the latest Macintosh version of MS Word does not have Macros.

SharePoint Wiki Redirect Installation Instruction

SKP16C62P Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

SA-9600 Surface Area Software Manual

How to Obtain an OPC License--5. Creating a System Code 5 Entering an Authorization Code 6. Getting Started with SNMP Editor--7

XMailer Reference Guide

Testing WiMAX receiver performance in a multipath propagation environment using Agilent s E6651A with an EB Propsim C8 radio channel emulator

USB GSM 3G modem RMS-U-GSM-3G. Manual (PDF) Version 1.0,

How to use MS Excel to regenerate a report from the Report Editor

Chapter 16. Using Dynamic Data Exchange (DDE)

iridium for KNX/EIB Fast Start: Connection Setting Manual for KNX/EIB equipment

28 What s New in IGSS V9. Speaker Notes INSIGHT AND OVERVIEW

CAPIX Job Scheduler User Guide

Agilent N8973A, N8974A, N8975A NFA Series Noise Figure Analyzers. Data Sheet

Case study: how to use cutoff conditions in a FRA frequency scan?

Application Unit, MDRC AB/S 1.1, GH Q R0111

SOFTWARE MANUAL UNIOPC

Business Insight Report Authoring Getting Started Guide

«Intellect» software system

Software User's Guide

User Manual. Thermo Scientific Orion

Tutorial. for. HG2F/3F/4F Series Operator Interfaces

Agilent Electronic Calibration (ECal) Modules for Vector Network Analyzers

Building a Simulink model for real-time analysis V Copyright g.tec medical engineering GmbH

User s Manual. Management Software for Inverter

Excel & Visual Basic for Applications (VBA)

14.1. bs^ir^qfkd=obcib`qflk= Ñçê=emI=rkfuI=~åÇ=léÉåsjp=eçëíë

The FTS Interactive Trader lets you create program trading strategies, as follows:

AccXES Account Management Tool Administrator s Guide Version 10.0

MT-350 SMS. Operation Manual. PORTech Communications Inc.

IMPORTANT PRODUCT INFORMATION

Using Microsoft SQL Server A Brief Help Sheet for CMPT 354

Accurate Measurement of the Mains Electricity Frequency

Hummingbird Enterprise

Additional Requirements for ARES-G2 / RSA-G2. One Ethernet 10 Base T/100 Base TX network card required for communication with the instrument.

Hands-On Lab. Client Workflow. Lab version: Last updated: 2/23/2011

ScanWin Installation and Windows 7-64 bit operating system

Getting Started with Access 2007

Load Manager Administrator s Guide For other guides in this document set, go to the Document Center

BSDI Advanced Fitness & Wellness Software

ACCESS Importing and Exporting Data Files. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

ios 9 Accessibility Switch Control - The Missing User Guide Updated 09/15/15

Migrating to Excel 2010 from Excel Excel - Microsoft Office 1 of 1

Agilent E6832A W-CDMA Calibration Application

Quick Start Using DASYLab with your Measurement Computing USB device

Handheld LPC Utility Software for Windows. Operation Manual

Transcription:

Creating Datalogging Applications in Microsoft Excel Application Note 1557 Table of contents Introduction 2 Steps for creating a scanning program 2 Using Excel for datalogging 4 Running the application 4 Code structure for logging data 5 Conclusion 6

Introduction Microsoft Excel and the Agilent 34980A multifunction switch/measure unit are an ideal combination to use for collecting data and analyzing it. This paper discusses how to structure and create a program in Excel for scanning multiple Agilent 34980A channels. Each channel can be configured independently to measure: temperature, voltage, frequency, resistance, or other physical property. Channels can be scanned sequentially or in an order defined by the user. In addition, this paper covers how to pace the scans, retrieve data and automatically update an Excel worksheet. You can download a working template to control the 34980A switch/measure unit and 34970A data acquisition unit from www.agilent.com/find/create_datalogger. Included is a tool that creates the channel configuration commands for the instrument. This paper and the code template make an excellent starting point for creating a custom Excel application with the 34980A and 34970A. The discussion and code snippets are centered around the Agilent 34980A, but they also apply to the Agilent 34970A. Steps for creating a scanning program Datalogging code for the 34980A in Excel requires six steps: 1. Establish a connection to the instrument 2. Configure the channels 3. Configure the scan 4. Initialize a scan and scan the data 5. Read the data 6. Insert the data into a worksheet 1. Establish a connection to the instrument Several different methods are available to establish a connection, send commands, and read data. The Excel development environment Visual Basic for Applications lends itself well to VISA COM. Developing the instrument specific connections with VISA COM assures the code will work for both Agilent and National Instruments GPIB cards. Both the Agilent and the National instruments I/O libraries will enable USB and LAN when you use the current software version. To use VISA COM, first reference the VISA COM Type library. Within the Excel Visual Basic menu select Tools > References and select VISA COM 3.0 Type Library. With the reference established make a connection to the 34980A at GPIB address 9, like this: Dim IO_mgr As VisaComLib.ResourceManager Dim deviceio As VisaComLib.IMessage Set IO_mgr = New VisaComLib.ResourceManager Set deviceio = IO_mgr.Open("GPIB0::9") This will create the object deviceio with methods to send and read strings from and to the instrument. For example, this code will retrieve the instrument identification: Dim strtemp As String deviceio.writestring "*IDN?" strtemp = deviceio.readstring(256) 2. Configure the channels First, we configure the channels to the function, range, and resolution. You can configure one or more channels at the same time. An example of configuring channels 16 through 20 for a resistance measurement: Conf:Res 1E4,(@1016:1020) The first parameter of the command, 1E4 specifies the 10-kohm range and is followed by the channels. We can follow the Configure command with another command to give 5-1/2 digit resolution: Res:NPLC 1,(@1016:1020) Each channel that is part of the scan list requires a configure statement. Typically there is a configure statement for each function. Channels with the same function and range are collected together in the channel list parameter of one configure statement. NPLC is the integration time expressed as the number of power line cycles (NPLC). The following table shows the integration time in power line cycles versus the resolution in digits or bits. 1 PLC is 16.7 ms when the power line is 60 Hz (and 20 ms for 50 Hz). NPLC Integration time 60 (50) Hz Digits Bits 0.02 PLC 0.333 (0.4) ms 4 1 2 15 1 PLC 16.7 (20) ms 5 1 2 20 10 PLC 167 (200) ms 6 1 2 24 100 PLC 1.67 (2) sec 6 1 2 prec. 26 2

3. Configure the scan Once we have all the channels set up, we can configure the scan. We must give the instrument a list of all the channels to include in the scan using the Route:Scan command. These are all or a portion of the channels used in the configurations for the different functions and channels. Route:Scan (@1016:1020,1021,1023) For a single sweep no further configuration is required. The default values are set for a single sweep. For multiple sweeps by the instrument, you need to set up the interval and number of scans to configure the scan: ' Configure the trigger source Trigger:Source Timer ' Set the time between scans Trigger:Timer 3 ' Set the number of sweeps Trigger:Count 5 In this example there are five sweeps of the scan list for a complete scan. We use the internal timer to set the interval between sweeps to 3 sec. 4. Initialize the scan To start the scan we simply send the Initialize command. Once initialized, the instrument will start the first sweep of the scan and put the data into memory. Data is put into memory at the end of each reading. The internal Timer will automatically start subsequent sweeps every 3 seconds in the above example. 5. Read the data Fetch? will read the data after the scan is complete (after all sweeps are complete). The data is returned as a comma delimited list. The data string is parsed into an array of doubles using the VB Split command: Dim rdgs() As Double Dim strrdgs() As String Dim numberchannels As Integer Dim reply As String deviceio.writestring "Fetch?" reply = deviceio.readstring(10000) strrdgs = Split(reply, ",") ReDim rdgs(ubound(strrdgs)) For i = 0 To UBound(strRdgs) rdgs(i) = Val(strRdgs(i)) Next i Regardless of the order of the channel list, the channels are scanned in sequential order by default and the data is returned in the same order. The command Route:Scan:Ordered OFF will force the instrument to measure the channels in the same order as specified with the Route:Scan command, including duplicate channels. To return a list of channels that correspond to the data, send this command and read as a string. This will return the scan list. "Route:Scan?" For a list of functions that correspond to the data, send this command and read as a string. Scan list is the list returned with the above command. "Function? " & ScanList We can also return the channel and units with each reading by sending a format statement when we set up the scan. These format statements cause the instrument to return the channel, units, and/or time stamp with each measurement. Format:Reading:Unit On Format:Reading:Channel On Format:Reading:Time On 6. Insert the data into a worksheet Inserting the data in Excel is done after each sweep. Inserting data into a worksheet is best done with a twodimensional array. The two-dimensional array is created from the array of doubles and then inserted into the array using a worksheet range to insert as a column. The range is moved one column to the right for each sweep of data with the Column variable. Dim wksheetarray() As Variant Dim rng As Range ReDim wksheetarray(numberchannels, 0) For i = 1 To numberchannels wksheetarray(i, 0) = rdgs(i - 1) Next i Set rng = ActiveSheet.Range("C3") Range(rng.Offset(0, Column - 1), _ rng.offset(numberchannels,column-1)).value= _ wksheetarray 3

Using Excel for datalogging This section addresses how to use the provided example code to configure, log and insert data into Excel. For this discussion, we have assumed you have some experience with Visual Basic for Applications. Making a connection To log data in Excel, we have provided a template that will make the connection to the instrument and log data at set intervals You can download it from www.agilent.com/ find/create_datalogger. All of the instrument-specific code is contained in one module. To run or edit any of the code, first bring up the Visual Basic editor toolbar. In Excel go to menu View > Toolbars and select Visual Basic. The Visual Basic toolbar will appear. On the toolbar, click Run Macro to show the available routines for setting the I/O and logging data. Click Visual Basic Editor to view the code. You can also quickly open Visual Basic with ALT-F11. Creating and configuring a channel list Before you can log data, you must configure the channels to the desired measurement functions and create a list of channels for the scan list. You do this in the Configure subroutine, shown in Figure 2, in the instrument-specific module mod34980a. The Excel file contains a worksheet called ScanList to assist you in creating the channel configuration. In the ScanList worksheet, enter the channel or channels, and then select the functions, ranges and other parameters for those channels. The 34980A command string is created to the right on the same row, see Figure 1. Copy that command, and insert it as a string in the Configure subroutine in Visual Basic. The string is sent to the instrument with the.writestring command. Once you have all the channels configured, create a scan list that contains all the channels from the channel configuration. When you are done, it should look like Figure 2. Running the application The application has only three commands for you to use: SetIO StartMultipleScan CancelMultiScan You can access the commands from the Macro dialog box (Excel menu Tools > Macro > Macros or select Run Macro on the Visual Basic toolbar). Before starting a scan, call the SetIO Macro and establish a connection. Figure 1. Tool to create channel configuration commands for the 34980A Figure 2. Public Sub Configure(Instrument As VisaComLib.IMessage) With Instrument ' Configure all channels in channel list.writestring "Conf:volt:DC 10,(@1014);:Volt:DC:NPLC 1,(@1014)".WriteString "Conf:Fres 100,(@1015);:FRes:NPLC 1,(@1015)".WriteString "Conf:Res 1E4,(@1016:1020);" & _ ":Res:NPLC 10,(@1016:1020)" ' Set up the scan List.WriteString "Route:Scan (@1016:1020,1015,1014)" End With End Sub 4

Connecting to the instrument Figure 3. Tool to create channel configuration commands for the 34980A Connections to the instrument are done with the form frmfindinstrument. The I/O connection uses VISA COM. Either Agilent IO Libraries Suite 14 or National Instruments VISA COM 3.1 or later must be installed in the PC. To show the connection form, run the Macro SetIO from the Macro dialog. The task of the connection dialog is to find available instruments and establish a connection. Specify the type of connection you wish to use; GPIB, USB, or TCPIP then press Find Instrument button. Starting a scan Once the 34980A is connected and the channels are configured, we are ready to perform a scan. Click the Run Macro button on the Visual Basic toolbar. Select StartMultipleScan in the Macro dialog and click Edit. This will bring up the code for starting the scan. In the StartMultipleScan routine, edit the variable m_ NumberSweeps and m_interval to set the number of sweeps and time interval. Go back to Excel, again open the Macro dialog, select the routine StartMultipleScan and click Run. The instrument will be configured and then called repeatedly to start a sweep, read the data and then insert the data into the active worksheet. The location of the data is determined by the constant refrange in the module mod34980a. headings for the worksheet. Once the instrument is configured, we rely on a callback to repeatedly call the instrument to perform a scan, read the data and insert that data into the active worksheet. This is shown in Figure 5. To pace the logging and perform multiple sweeps, Excel provides a callback called Application.OnTime. It calls a routine at a predetermined time. We set the callback to call the subroutine UpdateInstrumentScan. At the end of this subroutine the callback is again initialized for the next sweep. Stopping a scan To stop a scan, open the Macro dialog and run CancelMultiScan. This will set the counter variable m_sweepcount to 99999 and end the scan. Alternately, if it does not stop, press CTR-BREAK to stop the code and open the code window at the point of execution. Figure 4. This configures the 34980A and then gives control to UpdateInstrumentScan Start Figure 5. UpdateInstrumentScan is called repeatedly using a timed callback Callback Code structure for logging data You can pace multiple sweeps from Excel, or with the 34980A internal timer. The simpler method is to pace the logging from Excel. This implies that the timer in the 34980A is not required, and the trigger source is set to immediate, which is the default. Configure the 34980A for a single sweep of the channel list per trigger. The Excel code will initiate a scan, collect the data and then wait a predetermined length of time before starting the next scan. Initialize interval and number of sweeps Configure channel Configure scan Write headings to worksheet Done? Start scan Read data Insert data Increment counter End Creating the two code structures shown in Figures 4 and 5 allows the code to be stopped at anytime. Figure 4 shows the routine started by the user. Here we configure the channels, configure the scan list, and then create the Call UpdateInstrumentScan End Set time for next call back Wait 5

www.agilent.com The callback routine UpdateInstrumentScan is first initialized by the call from the one time configuration. The UpdateInstrumentScan routine will start a single sweep, read the data, and then insert the data into the worksheet. Before the routine exits, it calls itself at a future time using the callback routine Application.OnTime. To end this cycle, a check is made to the counter to see if it is done. Related Agilent literature Conclusion Agilent s 34980A multifunction switch/measure unit offers a flexible architecture ideal for logging both electrical and physical data. You can configure each channel independently for a variety of measurements. A Visual Basic program can combine the powerful 34980A data capture features with the analysis and graphic display capabilities in Excel. Publication title Publication type Publication number Web address 34980A Multifunction Switch/ Data sheet 5989-1437EN http://cp.literature.agilent.com/litweb/pdf/5989-1437en.pdf Measure Unit 34970A Data Acquisition Unit Data sheet 5965-5290EN http://cp.literature.agilent.com/litweb/pdf/5965-5290en.pdf Visual Basic Tutorial Online Tutorial http://www.agilent.com/find/vb_tutorial www.agilent.com/find/emailupdates Get the latest information on the products and applications you select. About Agilent Open Agilent Open simplifies the process of connecting and programming test systems to help engineers design, validate and manufacture electronic products. Agilent combines a broad range of system-ready instruments, open industry software, PC-standard I/O and global support to accelerate test system development. For more information, see: www.agilent.com/find/open. By internet, phone, or fax, get assistance with all your test & measurement needs Online assistance: www.agilent.com/find/assist Phone or Fax United States: (tel) 800 829 4444 (fax) 800 829 4433 Canada: (tel) 877 894 4414 (fax) 800 746 4866 China: (tel) 800 810 0189 (fax) 800 820 2816 Europe: (tel) (31 20) 547 2111 (fax) (31 20) 547 2390 Japan: (tel) (81) 426 56 7832 (fax) (81) 426 56 7840 Korea: (tel) (82 2) 2004 5004 (fax) (82 2) 2004 5115 Latin America: (tel) (650) 752 5000 Taiwan: (tel) 0800 047 866 (fax) 0800 286 331 Other Asia Pacific Countries: (tel) (65) 6375 8100 (fax) (65) 6836 0252 (e-mail) tm_asia@agilent.com Product specifications and descriptions in this document subject to change without notice. Microsoft is a U.S. registered trademark of Microsoft Corporation. Agilent Technologies, Inc. 2005 Printed in the USA March 31, 2005 5989-2722EN