Deleting Data Input or Output Terminals. Agilent Technologies VEE Pro


Add to my manuals
602 Pages

advertisement

Deleting Data Input or Output Terminals. Agilent Technologies VEE Pro | Manualzz

3 Easy Ways to Control Instruments Chapter

Deleting Data Input or Output Terminals

Place the mouse pointer over the terminal and press CTRL-D.

N O T E

You could also open the object menu and select Delete Terminal

Input... from the object menu and choose the appropriate input from the menu presented.

On Your Own

Set a state on the HP 3325B Function Generator, or any other function generator available. Change the Function setting to a

Square wave. Add input components for Amplitude and

Frequency. Create input dialog boxes for the amplitude and frequency and modify the titles to prompt the operator. Enter different values for the amplitude and frequency, and run the program to see if the settings have changed after operator inputs. (If an instrument is attached, then its settings will change if Live Mode is ON.)

146 VEE User’s Manual

Easy Ways to Control Instruments Chapter 3

Using Direct I/O

If there is not a driver available for a particular instrument, or you want higher throughput, use the Direct I/O object.

Lab 3-3: Using Direct I/O

In this exercise, you will configure the HP 3325B function generator using Direct I/O.

1 Select I/OInstrument Manager....

2 Highlight the fgen(@(NOT LIVE)) entry and select Instrument

Properties.

3 Click on Advanced. Select the Direct I/O folder as shown

in Figure 91. Look through the options available, then

click OK to return to Instrument Properties, then OK again to return to the Instrument Manager.

VEE User’s Guide

N O T E

Figure 91 The Direct I/O Configuration Folder

This example uses the GPIB interface (IEEE488). To configure Serial,

GPIO, or VXI instruments, refer to the VEE Pro Advanced Techniques manual.

147

3 Easy Ways to Control Instruments Chapter

4 To place the object on the screen, make sure that fgen(@(NOT

LIVE)) is still highlighted, and click Create I/O ObjectDirect

I/O. Figure 92 shows the Direct I/O object.

Figure 92 A Direct I/O Object

To use a Direct I/O object in a program, you have to configure

I/O transactions. The next section explains writing text commands, reading data, and uploading/downloading instrument states.

Sending a Single Text Command to an Instrument

To send a single text command to an instrument, type in the appropriate string. Most GPIB instruments use alphanumeric strings for commands sent to the instrument. For example, to send a command to the HP3325B Function Generator to set the amplitude to 5 volts, you would enter the command string "AM

5 VO

".

148 VEE User’s Manual

Easy Ways to Control Instruments Chapter 3

This exercise uses the HP 3325B function generator configured

in the previous section. If necessary, go back to “Using

Direct I/O" on page 147 and configure the instrument before

you continue.

1 In the fgen(@(NOT LIVE))object, double- click the transaction bar to get the I/O Transaction dialog box, as shown in

Figure 93.

VEE User’s Guide

Figure 93 The I/O Transaction Dialog Box

The down arrow next to WRITE shows a menu of transactions: READ, WRITE, EXECUTE, and WAIT. To write data to an instrument, use the default selection. Open the object menu and consult Help to find out about each action.

2 Use the default selections WRITE, TEXT, DEFAULT

FORMAT, and EOL ON. Click the input field labeled a, type

"AM 5 VO" (including the quotes), and click OK.

You should see the transaction WRITE TEXT "AM 5 VO" EOL as

shown in Figure 94. The text in quotation marks is the

command that will be sent to the HP3325B when the program runs.

149

3 Easy Ways to Control Instruments Chapter

150

Figure 94 A Direct I/O Transaction

In most cases, the process will be the same for sending text commands to instruments. However, there are instruments that specify characters sent at the end of each command or at the end of a group of commands. You need to get this information from the instrument documentation, then include it in the

Direct I/O Configuration dialog box.

Sending an Expression List to an Instrument

In some cases, you may want to send an expression list to an instrument. For example, you may want to loop through a number of frequencies in the Function Generator. To do so using a Direct I/O Transaction, you would use a variable for the frequency in an expression list, and add a data input for that variable to the Direct I/O object. The following steps describe how to send an expression list to an instrument.

1 Place a second Direct I/O object for the HP3325B in the Main window. Double- click in the transaction area to get the I/O

Transaction dialog box.

You can use all of the defaults except for the command string.

In this case, use the format "FR", <frequency>, "HZ". This is an

Expression List, each expression being separated by commas. The frequency is represented by variable A, which will be a data input to the Direct I/O object.

2 Click on the input field for command strings and type

"FR",A,"HZ" . (For example, if A were 100, VEE would send the string "FR100HZ".) Click OK. Notice that VEE automatically adds a data input pin labeled A.

VEE User’s Manual

Easy Ways to Control Instruments Chapter 3

3 Select FlowRepeatFor Range and place it to the left of the Direct I/O object.

4 Connect the For Range data output pin to the Direct I/O data input pin.

5 Edit the fields in For Range to: From 10, Thru 1.8M, and

Step 50k.

For Range will now send out numbers ranging from 10 to 1.8 million in steps of 50,000. As the numbers are received by the

Direct I/O object, the command string causes the function generator to output the frequencies. The Direct I/O setup

should look like Figure 95.

VEE User’s Guide

Figure 95 Direct I/O Setup Using an Input Variable

6 (Optional) Connect an HP3325B to your computer, if you have one, and edit the configuration of this Direct I/O object to include the address of the instrument. Run the program and you will see the instrument generating these frequencies.

Reading Data From an Instrument

Instruments send data to a computer in many different formats.

To read data from an instrument, you must know the datatype you want to read, and whether the data is returned as a single value (scalar) or an array. You must also know if the instrument returns data as text (ASCII) or binary.

You can find this information in the instrument documentation, or you can use the VEE Bus I/O Monitor in the I/O menu to examine the data being returned. This information determines how to configure the I/O transaction.

151

3 Easy Ways to Control Instruments Chapter

N O T E

In this example, an HP3478A Multimeter is connected to the

HP3325B Function Generator described in the last exercise.

When the generator sends out a certain frequency, the multimeter triggers a reading and sends the results back to VEE.

The following steps describe how to configure the transactions for the multimeter.

This example describes a READ TEXT transaction. Other choices for

READ include BINARY, BINBLOCK, and CONTAINER, which are discussed in detail in the VEE Pro Advanced Techniques manual.

1 Select I/OInstrument Manager.... Click Add.... Change the name to dvm. Click on Advanced ... and set Live Mode: to

OFF. Assuming that you do not have an HP3478A connected, click OK to return to the Instrument Manager. (If you do have an HP3478A, modify the address and the instrument will track the commands.)

2 Highlight dvm(@(NOT LIVE)) and click Direct I/O under Create

I/O Object.

3 Double- click the <Double-Click to Add Transaction> bar to display the I/O Transaction dialog box.

4 Highlight the input field and type "T5", then click OK. This will write the "T" command to the instrument. T5 is the command for a single trigger to the multimeter.

5 Open the object menu and click Add Trans ... to add another transaction bar, or use <Double-Click to Add Transaction> to add a transaction and display the I/O Transaction dialog box.

6 Click the down arrow beside WRITE to get a drop- down menu, then select READ. When you select READ, new buttons appear in the I/O Transaction box.

7 Check the ExpressionList input field to verify that it contains an x. Press Tab to move to the next field. Data returned from an instrument is sent to data output pins. In this case, data will be read from the instrument and put into a data output named x.

152 VEE User’s Manual

VEE User’s Guide

Easy Ways to Control Instruments Chapter 3

N O T E

Names are not case sensitive.

N O T E

8 Leave the REAL64 FORMAT default. The multimeter returns single readings as real numbers.

9 Leave DEFAULT NUM CHARS as is.

The default for the number of characters is 20. If you want to change the number, click on DEFAULT NUM CHARS to toggle to MAX NUM CHARS and change the number 20 to the desired number.

10 Leave SCALAR as is and click OK.

You will see the transaction displayed on the bar as READ

TEXT X REAL64. Notice that VEE automatically adds a data output named x.

If the instrument is returning an array of values, click on the SCALAR menu in the I/O Transaction dialog box to get the menu for different dimensions,

as shown in Figure 96. Once you have selected the array dimension, you

also need to specify a size for the array.

153

3 Easy Ways to Control Instruments Chapter

154

Figure 96 Configuring a READ Transaction

11 Add a Display

AlphaNumeric to the right and connect its input to the Direct I/O output labeled x .

The two Direct I/O transactions should look like Figure

97.

Figure 97 Direct I/O Configured to Read a Measurement

The process to configure a transaction is similar, regardless of the data format for the READ TEXT transaction. You can explore the other formats available. For a more detail ed information about each item, refer to the VEE Pro Advanced Techniques manual.

VEE User’s Manual

VEE User’s Guide

Easy Ways to Control Instruments Chapter 3

To create a complete test program, this multimeter object and a function generator object could be combined with VEE data and display objects. Fully functional test programs are easy to create in VEE. However, it is beyond the scope of this introductory chapter to show specific details for all the various instruments you might be using. For more complex examples, refer to the VEE Pro Advanced Techniques manual.

Uploading and Downloading Instrument States

Some instruments offer a “learn string” capability. The learn string embodies all the function settings that compose an instrument state. Direct I/O will upload this learn string, save it with that particular Direct I/O object, and later allow you to download it to the instrument in the program. To upload an instrument state, follow these steps:

1 Set the instrument to the desired state manually.

2 Open the Direct I/O object menu and click Upload State.

Now this state is associated with this particular instance of the Direct I/O object.

3 Open an I/O Transaction dialog box by double- clicking in the transaction area.

4 Click TEXT, select STATE (LEARN STRING), then click OK to close the I/O Transaction box. The previously captured state is sent to the instrument when this WRITE transaction is executed.

Uploading and downloading are controlled by the settings in the

Direct I/O Configuration dialog box. If Conformance is IEEE

488.2, then VEE will automatically handle learn strings using the 488.2 *LRN? definition. If Conformance is IEEE 488, then

Upload String specifies the command used to query the state, and Download String specifies the command that precedes the

state string when downloaded. Figure 98 shows an example.

155

3 Easy Ways to Control Instruments Chapter

156

Figure 98 Learn String Configuration for HP54100A

Conformance can support IEEE 488 or IEEE 488.2. This example uses the HP 54100A Digitizing Oscilloscope, which conforms to IEEE 488 and requires a "SETUP?" to query the learn string and "SETUP" to precede the learn string when downloading. When you select Configured for State (Learn

String) two more fields appear, labeled Upload String and

Download String. The proper strings have been entered in their input fields.

VEE User’s Manual

Easy Ways to Control Instruments Chapter 3

Using PC Plug-in Boards

Data Translation's Visual Programming Interface (VPI)

Data Translation's VPI works with VEE to create seamless data acquisition performance for PC plug- ins. By leveraging the flexibility of Data Translation's Open Layers standards, you have access to over 50 data acquisition boards.

The VPI works directly with plug- in ISA, PCI, and

USB- based data acquisition cards that require low channel count. The VPI adds a menu selection and specific PC plug- in data acquisition icons to VEE. These drive the Data

Translation hardware functionality.

Amplicon

VEE provides three ways to control PC plug- in boards or cards:

1 Data Translation's Visual Programming Interface. (Order the VPI application directly through Data Translation.)

2 Dynamic link libraries supplied by the PC board manufacturer, such as ComputerBoards or Meilhaus. (See

“Using Dynamic Link Libraries" on page 453 for

information on using dynamic link libraries.)

Amplicon has a wide range of analog and digital I/O PC plug- in boards within the 200 Series, all with VEE support.

The software interface is part of Amplicon’s AmpDIO driver package, a 32- bit API with a multithreaded DLL for

Windows and support for interrupt driven acquisition. The

API contains over 100 calls for efficient and flexible programming as a Compiled Function using a VEE- specific definition file and the facility to utilize up to eight boards in one program.

In addition to Amplicon’s own range of plug- in boards, which includes serial communication devices, Amplicon can supply boards from a wide range of other manufacturers for data acquisition, serial communication, and GPIB applications.

VEE User’s Guide 157

3 Easy Ways to Control Instruments Chapter

Figure 99 shows the VEE runtime software (provided free

with Amplicon analog output boards PCI224 and PCI234 and analog input boards PCI230 and PCI260) providing concurrent input and output signals on a PC.

158

Figure 99 Amplicon Data Acquisition Example

ComputerBoards PC Plug-ins

ComputerBoards offers low cost, powerful PC plug- in boards that are compatible with VEE. (For a complete list of supported PC plug- in vendors, see VEE literature or VEE

Pro Advanced Techniques.)

You simply install the board and its I/O library, and configure the board using a program supplied by the manufacturer. Follow the instructions to connect the board to the device. In VEE, import the library, and you are ready to call the measurement functions in the ComputerBoards

I/O library. See the figures below from a demonstration program supplied by the manufacturer.

VEE User’s Manual

Easy Ways to Control Instruments Chapter 3

Figure 100 VEE Using a ComputerBoards 100 KHz Board

Figure 100 shows the panel view of the demonstration program using this 100 KHz A/D board. Figure 101 shows

VEE importing the ComputerBoards I/O library that made these data acquisition function calls possible.

VEE User’s Guide

Figure 101 Importing the ComputerBoards I/O Library

159

3 Easy Ways to Control Instruments Chapter

Meilhaus Electronic ME-DriverSystem

Meilhaus Electronic is one of the leading European designers, producers and sales companies for PC- based data acquisition and interface technology. The ME- DriverSystem for Windows on CD- ROM is included with all data acquisition boards made by Meilhaus Electronic (i.e. ME series). The ME- DriverSystem is also integrated into the VEE menu structure.

After the ME- DriverSystem for VEE is installed, the driver

functions appear in a VEE pull- down menu. Figure 102

shows the ME Board menu in VEE.

160

Figure 102 ME Board Menu in VEE

The second menu level presents functional groups such as

Analog Input and Output, Digital I/O, and special functions

of certain boards. Figure 103 shows the user panel for data

acquisition board ME- 3000.

VEE User’s Manual

Easy Ways to Control Instruments Chapter 3

VEE User’s Guide

Figure 103 User Panel for Data Acquisition Board ME-3000

Finally, in the third menu, the actual functions are located, such

as me3000AISingle. Figure 104 shows the function panel.

161

3 Easy Ways to Control Instruments Chapter

Figure 104 Function Panel for ME-DriverSystem

162 VEE User’s Manual

Easy Ways to Control Instruments Chapter 3

Using a VXIplug&play Driver

VXIplug&play drivers are issued and supported by the various instrument vendors. These are C- based drivers and are designed for the maximum performance and ease of use.

Agilent VEE is fully VXIplug&play compatible. All available

VXIplug&play drivers from Agilent Technologies ship as a separate product, and are also available on the Web at http://www.agilent.com/find/inst_drivers and on the Agilent Developers Network (ADN) at http://www.agilent.com/find/adn . These same drivers are also included with VEE along with all Agilent Technologies panel drivers. To get VXIplug&play drivers for other instruments, contact the instrument vendor.

Lab 3-4: Configuring a VXIplug&play Driver

This example describes how to configure an hpe1412 driver.

1 Select I/OInstrument Manager....

2 Highlight My configuration, then click Add... under

Instrument to get the Instrument Properties dialog box.

Enter a name, such as Instrument, and click Advanced ... to display the Advanced Instrument Properties dialog box.

3 In the Advanced Instrument Properties dialog box, toggle

Live Mode: to OFF and select the Plug&play Driver folder.

Click the Plug&play Driver Name : field to display the drop- down menu which lists all the drivers installed on the computer. This example uses the hpe1412 driver, as

shown in Figure 105.

VEE User’s Guide 163

3 Easy Ways to Control Instruments Chapter

164

N O T E

Figure 105 Selecting a VXI

plug&play

Driver

Select the hpe1412 driver, click OK to return to the Instrument

Properties dialog box, and click OK to return to the Instrument

Manager. There should now be an entry for Instrument(@(NOT

LIVE)).

4 Highlight Instrument(@(NOT LIVE)), and under Create I/O

Object, select Plug&play Driver. Click to place the object.

In VEE, a VXIplug&play driver resembles a Direct I/O object.

To make measurements with the instrument, you need to configure I/O transactions that use C functions in the

VXIplug&play driver. The driver provides you with panels to pick the right functions to use.

5 Double- click on the transaction bar labeled <Double- click to

Add Function>, and Select a Function Panel is displayed as

shown in Figure 106. Figure 107 shows the hierarchy of

functions in the function panel. Notice that Help for the item selected is displayed in the dialog box.

VEE User’s Manual

Easy Ways to Control Instruments Chapter 3

N O T E

VEE automatically initializes the instrument. You do not have to use an init function, as you would in other languages.

VEE User’s Guide

Figure 106 Selecting a Function for a VXI

plug&play

Driver

6 Click Configure Present Settings

Measurement Type

Measurement Type Setup. The Edit Function Panel is displayed.

Under func, click to display the drop- down list. Select the default

DC Voltage, as shown in Figure 107.

165

3 Easy Ways to Control Instruments Chapter

166

Figure 107 The hpe1412 Edit Function Panel

7 Click OK. The To/From Instrument object now contains an entry for

hpe1412_configure(instruHandle,hpe1412_CONF_VOLT_DC), as

shown in Figure 108.

Figure 108 DC Voltage Function in VXIplug&play Object

VEE User’s Manual

Easy Ways to Control Instruments Chapter 3

8 In the To/From Instrument object, double- click to add a function and select Take Measurement under Measure. Click on the Configuration folder to display the dialog box shown

in Figure 109.

Figure 109 Configuration Folder in Edit Function Panel

9 Click OK. A second function call is listed in the To/From

Instrument object as shown in Figure 110.

VEE User’s Guide

Figure 110 HPE1412 Driver Ready for a DC Reading

167

3 Easy Ways to Control Instruments Chapter

Other I/O Features

1 Explore the full power of VEE's I/O capabilities in the I/O

Advanced I/O submenu: Interface Operations, Instrument

Event, Interface Event, and MultiInstrument Direct I/O.

2 You can display, print, or store bus activity for debugging with the Bus I/O Monitor in the I/O menu.

3 VEE includes an ActiveX Automation server to programmatically find instruments. For further information, see the VEE Pro Advanced Techniques manual.

4 You can also change I/O configurations programmatically at run time. For further information, see the VEE Pro Advanced

Techniques manual.

168 VEE User’s Manual

Easy Ways to Control Instruments Chapter 3

Chapter Checklist

You should now be able to perform the following tasks. Review the appropriate topics, if necessary, before going on to the next chapter.

Explain the benefits of using instrument drivers and Direct

I/O.

Explain the process for controlling instruments.

Configure an instrument for a state driver.

Configure an instrument for Direct I/O.

Change settings on an instrument driver.

Add and delete component inputs and outputs.

Move to different panels on an instrument driver.

Use Direct I/O to write commands to an instrument.

Use Direct I/O to read data from an instrument.

Upload and download instrument states using learn strings.

Use VXIplug&play drivers to communicate with an instrument.

Explain two methods for controlling PC plug- in boards.

VEE User’s Guide 169

3 Easy Ways to Control Instruments Chapter

170 VEE User’s Manual

VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

4

Analyzing and Displaying Test Data

Overview 173

Agilent VEE Data Shapes and Data Types 174

Agilent VEE Analysis Capabilities 177

Using Built-In Math Objects 178

Creating Expressions with the Formula Object 182

Using MATLAB Script in Agilent VEE 188

Displaying Test Data 195

Customizing Test Data Displays 197

Chapter Checklist 201

171

4 Analyzing and Displaying Test Data Chapter

Analyzing and Displaying Test Data

In this chapter you will learn about:

VEE data types

VEE analysis capabilities

Using math objects

Using the Formula object

Using the MATLAB Script object

VEE display capabilities

Customizing displays

Average Time to Complete: 1.5 hours

172 VEE User’s Guide

Overview

Analyzing and Displaying Test Data Chapter 4

In this chapter, you will learn about VEE analytical and display capabilities. You will learn how to locate the right math objects for your applications and how to display test results, so that you can turn data into useful information easily and quickly.

You can also use other familiar applications such as MS Excel to analyze the data using ActiveX Automation. (For more

information, refer to Chapter , “Creating Reports Easily

Using ActiveX,” on page 247.) You can use display

capabilities external to VEE using ActiveX controls. (For

more information, refer to “Lab 11- 4: Using an ActiveX

Control" on page 432). This chapter focuses on VEE's own

core set of tools and the MATLAB Script object included with VEE.

VEE User’s Guide 173

4 Analyzing and Displaying Test Data Chapter

Agilent VEE Data Shapes and Data Types

In a VEE program, data is transmitted across the lines between objects and is then processed by subsequent objects. In order to specify a set of data, VEE packages it into a container that has both a data shape (scalar or array) and a data type (such as

Int32, Real64, or Text).

Data Shape: A scalar is a single number including numbers expressed as two or more components such as complex numbers, and an array contains a group of data items that can be specified as one dimensional (Array 1D), two dimensional

(Array 2D), etc.

Data Types: The VEE data types are described in Table 14.

In general, you will not be concerned with data types or shapes, because most objects operate on any VEE data type and will automatically convert data to the type required for that object.

For example, if a Magnitude Spectrum display receives a

Waveform data type, VEE automatically performs a Fast Fourier

Transform to convert it from the time domain into the frequency domain.

Occasionally, however, an object requires a particular data type so it is good to be aware of them. You also want to be aware of the differences in supported data types between

VEE and MATLAB. (For more information, refer to the

section “Working with Data Types” on page 192.)

The following are brief descriptions of VEE data types that you can read through quickly. Issues involving using these data types are explained in subsequent chapters.

Table 14 Agilent VEE Data Types

Data Type

UInt8

Int16

Description

Unsigned byte 0 to 255.

A 16-bit two's complement integer (-32768 to 32767).

174 VEE User’s Guide

VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

Table 14 Agilent VEE Data Types

Data Type

Int32

Real32

Real64

PComplex

Complex

Waveform

Spectrum

Coord

Enum

Text

Record

Description

A 32-bit two's complement integer (-2147483648 to

2147483647).

A 32-bit floating point number that conforms to the IEEE 754 standard (+/-3.40282347E+/-38).

A 64-bit floating point number that conforms to the IEEE 754 standard (+/- 1.797693138623157 E308).

A magnitude and phase component in the form (mag,

@phase). Phase is set by default to degrees, but can be set to radians or gradians with the File

Default Preferences

Trig Mode setting.

A rectangular or Cartesian complex number having a real and imaginary component in the form (real, imag). Each component is Real64. For example, the complex number 1 +

2i is represented as (1,2).

A composite data type of time domain values that contains the Real64 values of evenly-spaced, linear points and the total time span of the waveform. The data shape of a

Waveform must be a one-dimensional array (Array 1D).

A composite data type of frequency domain values that contains the PComplex values of points and the minimum and maximum frequency values. The domain data can be mapped as log or linear. The data shape of a Spectrum must be a one-dimensional array (Array 1D).

A composite data type that contains at least two components in the form (x,y,...). Each component is Real64.

The data shape of a coord must be a Scalar or an Array 1D.

A text string that has an associated integer value. You can access the integer value with the ordinal(x) function.

A string of alphanumeric characters.

A composite data type with a field for each data type. Each field has a name and a container, which can be of any type and shape (including Record).

175

4 Analyzing and Displaying Test Data Chapter

Table 14 Agilent VEE Data Types

Data Type

Object

Variant

Description

Used only for ActiveX Automation and Controls, a reference to an ActiveX control or a reference returned from an

Automation call. Literally, this is a reference to an IDispatch or IUnknown interface.

Used only for ActiveX Automation and Controls, a data type that is required for some ActiveX method calls as a By Ref parameter type.

N O T E

Investigate I/O

To/From Socket for sharing data in mixed environments.

176 VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

Agilent VEE Analysis Capabilities

VEE supports common math operations and hundreds of other functions. In addition, VEE also includes the MATLAB Script feature. The MATLAB Script feature is a subset of the standard full- featured MATLAB from The MathWorks. It provides additional mathematical capabilities in VEE including Signal

Processing, advanced mathematics, data analysis, and scientific and engineering graphics. The MATLAB Script feature is fully integrated with VEE, and you can include MATLAB Script objects in any VEE program.

If neither VEE nor MATLAB have a math function you need, you still have several options available. You can create the function with the Formula object, which is discussed later in this chapter, you can write the function in a compiled language such as C and link it to VEE, or you can communicate with another software application from VEE.

VEE User’s Guide 177

4 Analyzing and Displaying Test Data Chapter

Using Built-In Math Objects

In the VEE Device

Function & Object Browser, you can access built- in (preprogrammed) mathematical expressions for both

VEE and MATLAB.

Accessing a Built-in Operator or Function

To access VEE mathematical operators and functions, select

Device

Function & Object Browser. For example, to create a formula that returns a random number in a specified range, select Type: Built- in Functions, Category: Probability &

Statistics, and Functions: random, as shown in Figure 111.

178 description of function

Help topic for current selection

Figure 111 A VEE Function in the Function & Object Browser

VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

Notice that the Function & Object Browser displays a brief

description of the current selection, as shown in Figure 111.

You can also click on the Help button for a more detailed description of the current selection and get information such as the definition, use, syntax and examples.

To access MATLAB operators and functions, select Device

Function & Object Browser, and under Type: select MATLAB

Functions. For example, to convert roots to polynomials, select

Type: MATLAB Functions, Category: Interpolation &

Polynomials, and Functions: poly as shown in Figure 112.

VEE User’s Guide

Figure 112 A MATLAB Function in the Function & Object Browser

Again, a brief description of the current selection is displayed in the Function & Object Browser, and clicking on Help will display a more detailed description about the current selection.

The MATLAB Runtime Engine and Script is discussed more in

the section “Using MATLAB Script in Agilent VEE” on page 188.

179

4 Analyzing and Displaying Test Data Chapter

Lab 4-1: Calculating Standard Deviation

Generate a cosine waveform at a frequency of 1 kHz, amplitude of 1 V, a time span of 20 ms, represented by 256 points. Calculate its standard deviation and display it.

5 Select Device

Virtual SourceFunction Generator. Set the

Frequency appropriately and iconize it.

6 Select Device

Function & Object Browser, then select

Built- in Functions, Probability & Statistics, and sdev.

Click Create Formula.

N O T E

You can go directly to the Function & Object Browser dialog box by pressing the f

x icon on the tool bar, shown in Figure 113, or by pressing

Ctrl-I .

180

Function and Object Browser Icon

N O T E

Figure 113 Opening Function and Object Browser from fx Icon

7 Open the object menu for sdev() to consult Help.

The sdev(x) object is defined as the square root of the variance of x, and x may be of the type UInt8, Int16, Int32, Real32, Real64, Coord, or Waveform.

The Function Generator outputs a Waveform data type.

8 Connect the Function Generator to sdev(x).

9 Select Display

AlphaNumeric and connect it to the sdev(x) data output pin.

10 Run the program. It should look like Figure 114.

VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

Figure 114 Calculating Standard Deviation

VEE User’s Guide 181

4 Analyzing and Displaying Test Data Chapter

Creating Expressions with the Formula Object

The Formula object can be used to write mathematical expressions in VEE. The variables in the expression are the data input pin names or global variables. The result of the evaluation of the expression will be put on the data output pin.

Figure 115 shows a Formula object. The input field for the

expression is in the center of the object. A default expression (2*A+3) indicates where to enter the formula. Just double- click the field to type in a different expression.

N O T E

You can type in a Formula expression on more than one line. If a Formula expression contains a Return, it is interpreted as a multi-line single expression. If a Formula contains statements separated by semi-colons (;), they are interpreted as multiple expressions in the Formula.

The Formula box is an Rich Text Format box and you can use standard editing commands to edit expressions in a

Formula. For example, you can drag the mouse to highlight characters, use Ctrl-C for copying the characters, Ctrl-V for pasting, and Ctrl-X for deleting as well as using End,

Insert, Delete, Backspace, etc.

Input field

Figure 115 The Formula Object

182 VEE User’s Guide

VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

N O T E

All the functions created from the Devices

Function & Object Browser

Built-in type are simply Formulas that already have their expressions set appropriately. They can be modified to combine functions and add (or delete) inputs. You can also do multiple-line entry in the Formula object, and assign values to output terminals.

Evaluating an Expression with the Formula Object

In this example, you will evaluate the expression, 2*A^6-B, where A=2 and B=1. (Notice the ^ sign for exponentiation.)

The variable names are not case-sensitive.

N O T E

N O T E

1 Select Device

Formula. Click the Formula input field and type 2*A^6-B.

2 Place the mouse pointer over the data input area (but not right over the A input) and press Ctrl-A to add an input pin.

It will be labeled B by default, but you can rename it.

3 Select Data

ConstantInt32, clone it by selecting Clone from the object menu, and connect the two Int32 objects to the Formula inputs A and B.

4 Enter 2 in the A Int32 input box and 1 in the B Int32 input box.

5 Select Display

AlphaNumeric and connect it to the output of

Formula, and run the program. It should display the result

127, as shown in Figure 116.

183

4 Analyzing and Displaying Test Data Chapter

184

Figure 116 Evaluating an Expression

Using an Agilent VEE Function in the Formula Object

This example generates a cosine wave and calculates the standard deviation and root mean square using the Formula object.

1 Select the Function Generator, Formula, and AlphaNumeric objects and connect them together using their data pins.

2 Clone the Formula object by opening the object menu and selecting Clone, and place it just below the first one. Connect the Function Generator data output pin to the second

Formula object.

3 Clone another AlphaNumeric display and connect it to the second Formula object.

4 Enter sdev(A) in the first Formula object, and rms(A) in the second Formula object.

sdev(A) and rms (A) are the two math functions from the

Device

Function & Object Browser dialog box. Notice that they can be called as functions or independent objects, and they will perform in the same way.

5 Run the program. The program displays the same answers when these functions are put into the Formula object as it did when they were used as independent objects, as

shown in Figure 117.

VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

VEE User’s Guide

N O T E

Figure 117 Formula Examples Using VEE Functions

Now calculate the standard deviation and root mean square using only one Formula object. Formulas can have multiple output terminals with values assigned to them.

6 Double- click the object menu to Cut one of the Formula objects.

7 In the remaining Formula object, change the expression to

B=sdev(A);

C=rms(A)

When a Formula object contains multiple expressions, you must put a semicolon at the end of an expression to distinguish it from the next expression. For example, in the formula B=sdev(A); the semi-colon indicates the end of the expression.

N O T E

You can put line breaks at any point in a Formula object. The formula is read as one expression as long as there are no semi-colons. For example, you could enter a single expression as

B=sdev

(A)

You can also add spaces in the formula to improve readability.

185

4 Analyzing and Displaying Test Data Chapter

8 In the Formula object, add an output terminal. Rename the output terminals B and C. Connect output terminal B to one of the Alphanumeric objects, and output terminal C to the other Alphanumeric object.

9 Run the program. It should look like Figure 118.

186

Figure 118 VEE Functions Using One Formula Object

On Your Own

Complete the following exercises and check the results as

shown in Figure 119.

1 Create an array of numbers from 1 to 2048 using the ramp object in the Generate category of Built- in Functions.

Calculate the standard deviation of this array and display it.

2 Do the same exercise described in the previous step, using the ramp() function in a Formula object instead of the ramp object.

3 Do the same exercise described in the previous step by nesting the functions. Use only two objects.

VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

VEE User’s Guide

Figure 119 On Your Own Solution: Ramp and SDEV

For the second and third exercises, you have to delete the input terminal A on the Formula object to avoid an error message, because all data input pins must be connected and have data before an object can operate.

187

4 Analyzing and Displaying Test Data Chapter

Using MATLAB Script in Agilent VEE

VEE includes the MATLAB Script object, which gives you access to the functionality of MATLAB. VEE can pass data to the

MATLAB Script Engine and receive data back, enabling you to include MATLAB mathematical functions in VEE programs.

N O T E

If you already have MATLAB installed, VEE will use your installed

MATLAB to process MATLAB Script. However, if you do not have the

Signal Processing Toolbox, you will not be able to use those functions from VEE unless the MATLAB Script Engine that ships with VEE is registered. To register MATLAB, change directory (CD) to

<VEE_installation_dir> \MATLAB\bin and execute

MATLAB.exe /regserver.

188

N O T E

A few notes about troubleshooting VEE MATLAB installations. First, VEE will always append the MATLAB Script directory path (~installDir\matlab\ bin\win32) to the end of the PATH environment variable for the active VEE session. This means that any installed MATLAB will take precedence over the MATLAB Script that comes with VEE and that, when VEE tries to do a

LoadLibrary on libeng.dll and libmx.dll, it will get the first one it finds in the

PATH. A MATLAB install will normally modify the path to put in the location of where the matlab.exe, libeng.dll and libmx.dll are located.

Caution, the version of libeng.dll and libmx.dll must match the version of

MATLAB that is registered via COM.

The version of MATLAB that is loaded is the last one to register, which is typically the last version of MATLAB to run (MATLAB re-registers itself every time it runs). So where you can get into problems is if you have full

6.1 and full 6.5 installed on your system. Whichever MATLAB that you want to run VEE against needs to be registered last and more importantly the path to its [matlabroot\bin\win32] directory has to be in the path before the other MATLAB version.

Some uses of the MATLAB Script object include:

Letting MATLAB operate on VEE- generated data.

VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

Returning results from the MATLAB Script object and using the results in other parts of the VEE program.

Performing sophisticated filter design and implementation in the MATLAB Script object by using MATLAB’s Signal

Processing Toolbox functionality.

Visualizing data using 2- D or 3- D graphs.

Figure 120 shows how the MATLAB Script object appears in

a VEE program. When the MATLAB Script program executes, it generates the data shown in the Alphanumeric object.

VEE User’s Guide

Figure 120 MATLAB Script Object in a VEE Program

Figure 121 shows the graph that is produced when the

program runs.

189

4 Analyzing and Displaying Test Data Chapter

190

Figure 121 Graph Generated by the Program

When you include MATLAB Script objects in a VEE program,

VEE calls the MATLAB Script Engine to perform the operations in the MATLAB Script objects. Information is passed from VEE to MATLAB and back again. Some notes about MATLAB:

The first MATLAB Script object that executes in a program opens a single MATLAB session. All other instances of MATLAB Script objects share the session.

MATLAB Script objects can therefore share global variables in the MATLAB workspace.

VEE User’s Guide

VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

VEE does not perform any syntax checking of MATLAB commands before the MATLAB Script Engine is called.

Errors and warnings generated by MATLAB are shown in the regular VEE dialog boxes, just like any other VEE error or caution.

Unlike VEE, MATLAB is case sensitive. If you name a

MATLAB Script object input or output terminal with a capital X, be sure to use a capital X in MATLAB, not a lower- case x.

Only some VEE data types are allowed as MATLAB script

inputs. This is discussed in more detail on page 192.

Including a MATLAB Script Object in Agilent VEE

When you use a MATLAB object in a VEE program, it looks like a VEE Formula object. There are two ways to add a

MATLAB Script object to a program:

1 Select Device

MATLAB Script and click to place the object in the program. This creates a default MATLAB Script object that you can edit for your purposes.

- OR-

Select Device

Function & Object Browser, and select Type:

MATLAB Functions. Choose a predefined MATLAB function and click Create Formula. Click to place the

object in the program. Figure 122 shows some predefined

MATLAB functions that could be added to a VEE program.

191

4 Analyzing and Displaying Test Data Chapter

192

N O T E

Figure 122 Adding Predefined MATLAB Objects to a VEE Program

Notice that each object is named MATLAB Script<function name> to help you distinguish it from other VEE formula objects. Each object already includes the function it will perform, and the input and output pins that are likely to be needed, just like built- in VEE formula objects. You can also edit MATLAB Script objects exactly as you can edit any other VEE object.

For more information about MATLAB functions, from the main VEE window, select Help

MATLAB ScriptHelp Desk.

Working with Data Types

Only a subset of the VEE data types are supported as inputs and outputs of MATLAB objects.

VEE automatically converts some one- dimensional arrays to make it more convenient for programs that contain both

VEE and MATLAB functions. For example, a VEE one- dimensional text array will automatically convert to a two- dimensional character array when it is input to a

MATLAB Script object, and a character one- dimensional array from a MATLAB Script object will automatically convert to a Text Scalar when it is output from the MATLAB

Script object.

VEE User’s Guide

VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

N O T E

For a complete listing and description of the automatic conversions between VEE data types and MATLAB data types, refer to the VEE online

Help.

You can also use input terminal data type constraints to ensure that the data input from another object is converted to a supported type, as shown in the following example.

1 Select Data

ConstantInt32 and click to place the object.

Change the value to 7. Clone the object and place the second Int32 under the first. Change its value to 20.

2 Select Device

MATLAB Script and place the object to the right of the constant objects.

3 Select Display Alphanumeric and place it to the right of the MATLAB Script object.

4 Connect the output pin from the top Int32 object to the input pin A of the MATLAB Script object. Connect the output pin from the bottom Int32 object to the input pin

B of the MATLAB Script object. Connect the output pin from the MATLAB Script object to the input pin of the

Alphanumeric object.

Run the program. It generates a VEE Runtime Error stating the expected input was a Real64, Complex,

Waveform, or Text, and Int32 input was received instead.

To avoid errors like this, change the input terminal data type on the MATLAB Script object.

5 Double- click on terminal A to open the Input Terminal

Information dialog box. Click on Required Type: to display the drop- down menu, select Real64, and click OK.

Double- click on terminal B and change it to a Real64 as

well, as shown in Figure 123.

6 Run the program. Now the Int32 data is automatically converted to Real64 on the input pin before it is passed to MATLAB.

193

4 Analyzing and Displaying Test Data Chapter

Figure 123 Changing Input Terminal Data Type

194 VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

Displaying Test Data

Table 15 describes the display capabilities for the different

VEE objects.

Table 15 Displays

Display

Alphanumeric

Beep

Complex Plane

Description

Displays values as text or numbers. Requires SCALAR,

ARRAY 1D, or ARRAY 2D.

Gives an audible tone to highlight a place in your program.

Displays Complex, Polar Complex (PComplex), or Coord data values on a Real vs. Imaginary axis.

Indicator=>> Meter,

Thermometer, Fill

Bar, Tank, Color

Alarm

All of these indicators display numbers with a graphical representation suggested by their names. They all have color-coded ranges - usually three, but the meter has five. The Color Alarm can simulate an LED with a text message flashing up on the alarm in each range.

Label An object used to put a text label on the Panel View. The colors and fonts may be easily adjusted through

Properties... in the object menu while in the Panel View.

Logging

Alphanumeric

Note Pad

Picture (PC)

Polar Plot

Displays values as text or numbers when repeatedly logged. Requires SCALAR or ARRAY 1D.

Uses a text note to clarify a program.

An object used to put a graphic image on the Panel

View. The formats supported are: *.BMP (bitmaps), *.GIF

(GIF87a and GIF89), *.JPEG, *.PNG, and *.WMF

(Windows Meta File)

Graphically displays data on a polar scale when separate information is available for radius and angle data.

VEE User’s Guide 195

4 Analyzing and Displaying Test Data Chapter

Table 15 Displays

Display

Spectrum (Freq)

Strip Chart

Waveform (Time)

X vs. Y Plot

XY Trace

Description

A menu that contains frequency domain displays:

Magnitude Spectrum, Phase Spectrum, Magnitude vs.

Phase (Polar), and Magnitude vs. Phase (Smith). Inputs must be Waveform, Spectrum, or an array of Coords.

Waveform inputs are automatically changed to the frequency domain with a Fast Fourier Transform (fft).

Graphically displays the recent history of data that is continuously generated while the program runs. For each y input value, the x value is incremented by a specified Step size. When new data runs off the right side of the display, the display automatically scrolls to show you the latest data.

Graphically displays Waveforms or Spectrums in the real time domain. Spectrums are automatically converted to the time domain using an Inverse Fast Fourier Transform

(ifft). The x axis is the sampling units of the input waveform.

Graphically displays values when separate data information is available for X and Y data.

Graphically displays mapped arrays or a set of values when y data is generated with evenly-spaced x values.

The x value that is automatically generated depends on the data type of the trace data. For example, a Real trace would generate evenly-spaced Real x values; whereas, a

Waveform trace would generate x values for time.

196 VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

Customizing Test Data Displays

Displays may be customized in a variety of ways. Not only can you label, move, and size displays like all VEE objects, but you can also change the x/y scales, modify the traces, add markers, or zoom in on parts of the graphical display.

The following example illustrates some of these features. It uses the Noise Generator to generate a waveform, and then displays it with the Waveform (Time) display. The example also describes how to change the X scale, zoom in on a wave segment, and use the markers to measure the distances between points on the waveform. The same principles may be applied to all the graphical displays.

Displaying a Waveform

1 Select Device

Virtual SourceNoise Generator.

2 Select Display

Waveform (Time).

3 Connect the data output of the Noise Generator to the data input of Waveform (Time) and run the program. It

should look like Figure 124.

VEE User’s Guide 197

4 Analyzing and Displaying Test Data Chapter

Figure 124 Displaying a Waveform

Changing the X and Y Scales

1 Double- click the Waveform (Time) title bar to get the Y

Plot Properties box, select the Scales folder, select 20m for the X Maximum and enter 1m.

This alters the time span of the display from 20 milliseconds to 1 millisecond.

2 Double- click the Minimum field on the Y axis where it says -1, and enter - .5. Click OK.

Zooming in on Part of the Waveform

1 Open the Waveform (Time) object menu and click Zoom

In.

The cursor becomes a small right angle. By clicking and dragging, you can draw a square on the graph outlining the area you want to enlarge.

2 Outline an area of the waveform including several peaks, and release the mouse button.

The display zooms in to this selected area of the waveform. Notice the x and y scales change automatically.

Adding Delta Markers to the Display

1 Move to the open view on the Noise Generator.

a Change the Num Points setting to 16. Run the program again.

b Open the Waveform (Time) object menu and select

Properties (or just double- click on the title bar), then under Markers, click Delta. Then click OK.

N O T E

You can get and set the values of the markers at runtime. See the online

Help topic under Contents and Index

How Do I...Display Data for more information.

198 VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

You will see two white arrows pointing up and down at one of the data points on the waveform. Also, notice that the display records the x and y coordinates of these markers at the bottom of the display. To measure the x or y distance between two peaks, click- and- drag the arrows to the peaks you want to measure. You will see one of the markers move to those new peaks with the new coordinates recorded at

the bottom of the display, as shown in Figure 125.

VEE User’s Guide

Figure 125 Delta Markers on a Waveform Display

VEE will automatically interpolate between waveform data points. Open the object menu, select Properties, then under

Markers, click MarkerInterpolate.

199

4 Analyzing and Displaying Test Data Chapter

Changing the Color of the Trace

1 Double- click the title bar to get to Properties, then double click the Trace property.

You can select the Color, LineStyle, Name, and PointStyle properties for the Trace selected in this folder.

N O T E

You can also change these values at run time by using the Traces or

Scales control inputs. For more information, see the VEE Pro Advanced

Techniques manual.

N O T E

2 The trace will now be displayed in the new color. Other display characteristics such as GridType may be customized in a similar fashion as the features in the exercise above.

VEE also includes Plot in the display object menus, which allows you to plot test results on the display without printing out the rest of the program.

For Additional Practice

To learn about other VEE objects and gain more practice, do

the exercises in Appendix , “Test Sequencing 541,” on page 497. Solutions are provided with a discussion of key

points.

200 VEE User’s Guide

Analyzing and Displaying Test Data Chapter 4

Chapter Checklist

You should now be able to do the following tasks. Review topics as needed, before going on to the next chapter.

Describe the main data types in VEE.

Describe some of the main areas of analytical capabilities in VEE.

Find an online Help explanation for any object in the

Function & Browser dialog box.

Describe the relationship between input pins and variables in a VEE math object.

Evaluate a mathematical expression using the Formula object, and then evaluate two expressions using the

Formula object. (Remember to use a semicolon after the first line.)

Use a VEE function in a mathematical expression in the

Formula object.

Use the MATLAB Script object.

Describe major display capabilities in VEE.

Customize a graphical display in terms of the scales used, the part of the waveform seen, the markers used, and the color of the trace.

VEE User’s Guide 201

4 Analyzing and Displaying Test Data Chapter

202 VEE User’s Guide

Storing and Retrieving Test Results Chapter 5

5

Storing and Retrieving Test Results

Overview 205

Using Arrays to Store Test Results 206

Using the To/From File Objects 210

Using Records to Store Mixed Data Types 222

Using DataSets to Store and Retrieve Records 232

Customizing a Simple Test Database 237

Chapter Checklist 246

VEE User’s Guide 203

5 Storing and Retrieving Test Results Chapter

Storing and Retrieving Test Results

In this chapter you will learn about:

Putting test data into arrays

Using the Collector object

Using the To/From File objects

Creating mixed data types using Records

Performing search and sort operations using DataSets

Creating simple test databases using the Dataset objects

Average Time to Complete: 2 hours

204 VEE User’s Guide

Storing and Retrieving Test Results Chapter 5

Overview

N O T E

In this chapter, you will learn the fundamentals of storing and retrieving test data. You will create arrays of the right data type and size to hold your test results, and then access the data or part of the data for analysis or display.

This chapter also describes the To/From File objects, the Record data type, and Dataset files. The To File and From File objects read data to and from files based on I/O transactions. The

Record data type can be used to store several types of data in a single structure. You can use the Dataset to store one or more records in a file, and perform search and sort operations on datasets.

The To File object is also described in “Lab 2-3: Using Data Files” on

page 85 of Chapter , “Agilent VEE Programming Techniques.”

VEE User’s Guide 205

5 Storing and Retrieving Test Results Chapter

Using Arrays to Store Test Results

Data types can be stored in two ways:

Scalar values (that is, a single number such as 9 or (32, @10))

- OR-

Arrays from 1 to 10 dimensions.

N O T E

The overview of VEE data types is described in the Chapter , “Analyzing and Displaying Test Data.”

Indexing for arrays is zero- based in VEE, and brackets are used to indicate the position of the array element. For example, if the array A holds the elements [4, 5, 6], then

A[0] = 4, A[1] = 5, and A[2] = 6

The syntax for arrays is as follows:

Table 16 Syntax for Arrays

Syntax Element Description colon Used to indicate a range of elements. For instance,

A[0:1] = [4, 5] in the array above.

asterisk (*) a wildcard to specify all elements from a particular array dimension. A[*] returns all elements of array A .

commas In the subarray syntax, commas are used to separate array dimensions. If B is a two-dimensional array with three elements in each dimension, B[1,0] returns the first element in the second row of B .

The syntax to access elements of an array can be used in the

Formula object or any expression field, such as those in the

To/From File object.

206 VEE User’s Guide

VEE User’s Guide

Storing and Retrieving Test Results Chapter 5

Lab 5-1: Creating an Array for Test Results

The easiest way to create an array is to use the Collector object.

This exercise uses the For Count object to simulate four readings from an instrument. The readings are put into an array and the results are printed. The principles will be the same regardless of the data type or the size of the array, since the

Collector will take any data type and create the array size automatically depending on the number of elements sent.

1 Select FlowRepeatFor Count, DataCollector, and

Display ⇒ AlphaNumeric.

Table 17

Object Name about the

For Count object about the

Collector object

Description

For Count outputs increasing integer values starting at 0 depending on the number of iterations you specify in the input field. Highlight the default number 10 by double-clicking, then type 4. For Count will output 0 , 1 , 2 , and 3 .

The Collector receives data values through its Data input terminal. When you finish collecting data, you “ping” the

XEQ terminal to tell the Collector to construct the array and output it. You can use the For Count sequence output pin to ping the Collector XEQ pin. The Collector displays a button that toggles between a 1 Dim Array and n+1 Dim Array .

Double-click the Collector to get the open view, and read through Help in the object menu to understand the object.

2 Click n+1 Dim in the Collector to change the selection to 1 Dim

Array.

3 Connect the For Count data output pin to the Data input pin on the Collector.

4 Connect the For Count sequence output pin to the XEQ input pin on the Collector.

207

5 Storing and Retrieving Test Results Chapter

The XEQ pin, a special trigger pin that exists on several different objects, determines when the object executes. In this case, you want the object to fire after all of the data for the array has been collected.

5 Connect the Collector data output pin to the AlphaNumeric data input pin.

6 Enlarge AlphaNumeric to accommodate the array by clicking and dragging on any corner of the object. (You could also have enlarged AlphaNumeric when you first selected it by using “click and drag” on the object outline.)

7 Run the program. It should look like Figure 126.

208

Figure 126 The Collector Creating an Array

Lab 5-2: Extracting Values from an Array

To extract values from an array, you can either use the bracket notation in an expression, or use the Access Array

Get Values object. The following example uses expressions in the Formula object. You will add several objects to the program in this exercise.

1 Delete the data line between the Collector and AlphaNumeric by placing the mouse pointer over the line, pressing

VEE User’s Guide

Storing and Retrieving Test Results Chapter 5

Shift-Ctrl , and then clicking the left mouse button. Then iconize the Collector.

2 Select DeviceFormula and clone it. Move AlphaNumeric to the right, and put both Formula objects to the right of the

Collector.

3 Connect the Collector data output to the data inputs of the

Formula objects. Enter A[2] in the upper Formula input field, and A[1:3] in the lower Formula input field.

4 A[2] will extract the third element of the array as a Scalar;

A[1:3] will return a sub- array of three elements holding the second, third, and fourth elements of A (meaning the array on the A input terminal).

5 Clone AlphaNumeric and connect a display to each Formula object.

6 Run the program. It should look like Figure 127.

VEE User’s Guide

Figure 127 Extracting Array Elements with Expressions

209

5 Storing and Retrieving Test Results Chapter

Using the To/From File Objects

The To File and From File objects read data to and from files based on I/O transactions. They have the following characteristics:

A data file is opened on the first READ or WRITE transaction. When the program ends, VEE closes any open files automatically.

VEE maintains one read pointer and one write pointer per file regardless of how many objects are accessing the file. The read pointer identifies the next data item to be read, and the write pointer indicates where the next data item should be written.

The To/From File objects can append data to existing files or overwrite them. If the Clear File at PreRun & Open setting is checked in the open view of the To File object, then the write pointer starts at the beginning of the file. If not, the pointer is positioned at the end of the existing file. Each WRITE transaction appends information to the file at the location of the write pointer. If an EXECUTE CLEAR transaction is performed, the write pointer moves to the beginning of the file and erases its contents.

A read pointer starts at the beginning of a file, and advances through the data depending on the READ transactions. You may perform an EXECUTE REWIND in the From File object to move the pointer back to the beginning of the file without affecting any data.

N O T E

The To File object is also described in “Lab 2-3: Using Data Files” on

page 85 of Chapter , “Agilent VEE Programming Techniques.”

210

Understanding I/O Transactions

I/O transactions are used by VEE to communicate with instruments, files, strings, the operating system, interfaces, other programs, and printers. For example, look at the To File

object in Figure 128.

VEE User’s Guide

Storing and Retrieving Test Results Chapter 5

Figure 128 The To File Object

The To File object shown in Figure 128 sends data to the

specified file myFile. It can include inputs, called transactions, to accept data from a program. For example, this To File object includes the transaction WRITE TEXT a

EOL. When you double- click the transaction, an I/O

Transaction dialog box appears as shown in Figure 129,

which configures the specific transaction statement.

VEE User’s Guide

Figure 129 An I/O Transaction Dialog Box

There are different forms of this dialog box depending on the object, but all contain certain common elements, including the

“actions”, the “encoding”, the “expression list”, the “format”, and the “end- of- line” (EOL) sequence.

211

5 Storing and Retrieving Test Results Chapter

I/O Transaction Format

An I/O transaction to write data is usually in the following format:

<action> <encoding> <expression list> <format> <EOL>

Table 18 describes the most common actions: READ, WRITE,

EXECUTE, and WAIT.

Table 18 Types of I/O Transactions

Action

READ

WRITE

EXECUTE

WAIT

Description

Reads data from the specified source using the specified encoding and format.

Writes data to the specified target using the specified encoding format.

Executes a specific command. For example, EXECUTE

REWIND repositions a file read or write pointer to the beginning of the file without erasing the contents. EXECUTE

CLOSE closes an open file.

Waits the specified number of seconds before the next transaction.

212

N O T E

There are also a number of actions for I/O

Advanced I/O Operations that you can examine by exploring the objects in the menu.

Encodings and formats refer to the way data is packaged and sent. For instance, a TEXT encoding sends data as ASCII characters. The TEXT encoding could be formatted in a number of ways. For example, to send a string of letters and numbers to a file, a WRITE TEXT STRING transaction would send the entire string represented by ASCII characters. A WRITE TEXT REAL transaction would only extract the Real numbers from the same string and send them using ASCII characters for the individual digits. Table 19 provides brief explanations of encodings.

VEE User’s Guide

VEE User’s Guide

Storing and Retrieving Test Results Chapter 5

Table 19 I/O Transaction Encoding

Encoding

TEXT

BYTE

CASE

BINARY

BINBLOCK

CONTAINER

Explanations

Reads or writes all data types in a human-readable form

(ASCII) that can easily be edited or ported to other software applications. VEE numeric data is automatically converted to text.

Converts numeric data to binary integer and sends or receives the least significant byte.

Maps an enumerated value or an integer to a string and reads/writes that string. For example, you could use CASE to accept error numbers and write error messages.

Handles all data types in a machine-specific binary format.

Uses IEEE488.2 definite length block headers with all VEE data types in binary files.

Uses VEE specific text format with all data types.

In a write transaction, an “expression list” is simply a comma- separated list of expressions that need to be evaluated to yield the data sent. The expression may be composed of a mathematical expression, a data input terminal name, a string constant, a VEE function, a UserFunction, or a global variable.

In a read transaction, the expression list should consist of a comma- separated list of output terminal names that indicate where to store the data when it is read.

In conjunction with reading data from instruments, data

formats are described in the Chapter , “Easy Ways to

Control Instruments,” on page 127. Most of these formats

apply to all I/O transactions.

EOL (end- of- line sequence of characters) may be turned on or off, and you can specify the EOL sequence by opening the object menu of most of the I/O ⇒ To objects and selecting

Properties..., then select Data Format, and make the changes under Separator Sequence.

213

5 Storing and Retrieving Test Results Chapter

Lab 5-3: Using the To/From File Objects

This lab exercise describes the process of getting test data to and from files. In this exercise, you will store and retrieve three common test result items: a test name, a time stamp, and a one- dimensional array of Real values. The same process will apply to all VEE data types.

Sending a Text String to a File

1 Select I/OToFile. Set the entries as follows

Table 20 Sending a Text String to a File

Operation filename

Clear File At

PreRun & Open

Description

Use the default file myFile. The default file can be changed by clicking the To File input field to get a list box of files in the home directory.

Check this box. By default, VEE appends new data to the end of an existing file. Checking the box clears the file before new data is written.

2 Double- click in the transaction area to display the I/O

Transaction dialog box. (Refer to Figure 128 and Figure

129, if necessary.)

WRITE TEXT an EOL is the default transaction. It writes the data on pin a using TEXT encoding and a specified end- of- line sequence. VEE is not case- sensitive. You can use lower- case or upper- case strings for data input and data output terminal names.

Set the entries as follows:

214 VEE User’s Guide

VEE User’s Guide

Storing and Retrieving Test Results Chapter 5

Table 21 Writing the Default Transaction

Entry a (expression field)

WRITE

TEXT

DEFAULT

FORMAT

EOL ON

Description

The expression list field is highlighted and contains the default a. Type "Test1" , then click OK. (You need the quotation marks to indicate a Text string. If you typed

Test1 without the quotation marks, VEE would interpret this as a terminal name or global variable name.)

Use the default WRITE .

Use the default TEXT . The encoding TEXT will send the data using ASCII characters.

Use DEFAULT FORMAT . The DEFAULT FORMAT will choose an appropriate VEE format such as STRING .

Use the default. The default

EOL

sequence is the escape character for a new line

\n

.

3 Click OK to return to the To File object. The transaction bar should now contain the statement WRITE TEXT "Test1"

EOL. This transaction sends the string Test1 to the specified file.

Sending a Time Stamp to a File

The function now() in the Device ⇒ Function & Object Browser

Time & Date category gives the current time expressed as a

Real64 Scalar. The value of the Real is the number of seconds since 00:00 hours on Jan. 1, 0001 AD.

215

5 Storing and Retrieving Test Results Chapter

Therefore, now() returns a value about 63G. VEE provides this format because it is easier to manipulate mathematically and conserves storage space. If you want to store the time stamp in a more readable format, use the TIME STAMP FORMAT in the

To File object. Follow these steps to send a time stamp to a file.

1 In the same To File object, double- click in the transaction area to display the I/O Transaction box.

2 Double- click the expression list input field to highlight the a and type now(). The now() function sends the current time from the computer clock in a Real format.

3 Change the Real format to the Time Stamp Format. Click the arrow next to DEFAULT FORMAT to display the drop- down menu and select TIME STAMP FORMAT. The I/O Transaction dialog box now displays additional entries. Set the entries as follows:

Table 22 Time Stamp Formats

Time Stamps

Date & Time

HH:MM:SS

24 HOUR

Description

Select Time in the drop-down menu.

Click and toggle to

HH:MM

(from the hour, minute, and second format to the hour, minute format).

Click and toggle to 12 HOUR (from 24-hour format to a.m. and p.m. format).

The I/O Transaction dialog box should now look like

Figure 130.

216 VEE User’s Guide

Storing and Retrieving Test Results Chapter 5

VEE User’s Guide

Figure 130 The TIME STAMP I/O Transaction Box

4 Click OK to return to the To File box. The second transaction bar should now contain the statement WRITE TEXT now()

TIME:HM:H12 EOL.

Sending a Real Array to a File

Create a one- dimensional array of four elements using the For

Count and Collector objects, and append it to myFile.

1 Select FlowRepeatFor Count. Change the default value in For Count to 4.

2 Select DataCollector. Double- click the Collector to switch to Open view. Connect the data output of For Count to the data input of the Collector (the top input pin). Connect the

For Count sequence output pin to the XEQ pin (the bottom input pin) on the Collector. Iconize the Collector.

3 The Collector will now create the array [0, 1, 2, 3], which you can send to the data file.

4 Using the same To File object, double- click in the transaction area. In the I/O Transaction dialog box, open the DEFAULT

FORMAT menu, and select REAL64 FORMAT.

5 The I/O Transaction dialog box displays additional buttons for the REAL64 FORMAT selection. You can leave all of the default choices, but you might want to investigate the options for future reference.

217

5 Storing and Retrieving Test Results Chapter

6 Click OK to close the I/O Transaction box. The transaction bar in the To File object should now contain the statement

WRITE TEXT a REAL64 STD EOL. Notice that VEE also automatically adds an input terminal a.

7 Connect the output from the Collector to the input a of To

File. The program should now look like Figure 131. (The

configured I/O Transaction box is also displayed.)

218

Figure 131 Storing Data Using the To File Object

Retrieving Data with the From File Object

To retrieve data using a From File object, you must know how the data was stored.

N O T E

You can also store and retrieve data using To DataSet or From DataSet, which does not require you to know the type of data in the file. Datasets

are described in the section “Using DataSets to Store and Retrieve

Records" on page 232

VEE User’s Guide

Storing and Retrieving Test Results Chapter 5

In this example, the name of a test is stored in a String Format, followed by a time stamp in Time Stamp Format and an array of

Real64 numbers. You will create three transactions in From File to read the data back into VEE.

1 Select I/OFromFile and place it below the To File object.

2 Connect the sequence output pin of the To File object to the sequence input pin of the From File object.

This sequence connection ensures the To File object has completed sending data to myFile before From File begins to extract data.

3 In the From File object, leave the default data file myFile.

Double- click the transaction bar to get the I/O Transaction dialog box. Click REAL64 FORMAT and change it to STRING

FORMAT, as shown in Figure 132.

VEE User’s Guide

Figure 132 Selecting String Format

4 All of the other defaults are correct, so click OK to close the

I/O Transaction box. The transaction bar in the From File object should now contain the statement READ TEXT x STR.

219

5 Storing and Retrieving Test Results Chapter

N O T E

Now add two more transactions to read back the time stamp and the real array.

5 In the same From File object, double- click below the first transaction bar. The I/O Transaction dialog box appears.

Double- click on the expression list input field to highlight x and type y, for the second transaction to read data back to pin y. (If this pin were left as “x” then the second transaction would overwrite the data that the first transaction put into

x,” instead of appending it.) Change REAL64 FORMAT to

STRING FORMAT, then click OK.

To read the time stamp back as a text string, use the STRING FORMAT.

The TIME STAMP FORMAT converts the time stamp data back to a Real number.

6 In the same From File object, double- click below the second transaction bar to display to the I/O Transaction dialog box.

Set entries as follows:

Table 23 I/O Transaction Entries

Entry Description

(expression field) Edit x to z , so that the Real array is read back to the Z output terminal.

SCALAR

SIZE:

Change SCALAR to ARRAY 1D .

Now the I/O Transaction box adds a SIZE button. In this case, the array has four elements. Replace 10 with 4 and click OK .

N O T E

If you do not know the size of an array, you may toggle SIZE to TO END.

This will read data to the end of the file without VEE knowing its exact size. For example, you could use this feature to read the entire contents of a file as a string array to examine the file contents.

220 VEE User’s Guide

Storing and Retrieving Test Results Chapter 5

The transaction bar in the From File object should now contain the statements READ TEXT y STR and READ TEXT z

REAL64 ARRAY:4. Notice that VEE automatically adds the data output terminals for x, y, and z. You can also manually add or delete input and output terminals under object menu

Add Terminal, Delete Terminal, or using the shortcuts Ctrl-A and Ctrl-D.

7 Select DisplayAlphaNumeric and clone it twice to get three displays. Connect the AlphaNumeric objects to the three data output pins on From File. Enlarge the array display by clicking and dragging the object by any corner.

You can also size the AlphaNumeric displays by clicking and dragging the object outlines when you first select them from the menu.

8 Run the program. It should look like Figure 133.

VEE User’s Guide

Figure 133 Retrieving Data Using the From File Object

Notice that the first Alphanumeric displays the title, the second displays the time of the test, and the third lists the numbers in the array.

221

5 Storing and Retrieving Test Results Chapter

Using Records to Store Mixed Data Types

The Record data type can store different data types in a single data container. Record can include any VEE data type. The data can be in the shape of a Scalar or an Array. You can store a test name, a time stamp, and a real array in a single data structure.

The individual elements in a Record are stored as fields and are accessed using a dot notation. For example, Rec.Name accesses the field called Name within a Record called Rec. In an array of records, Rec[2].Name signifies the Name field in the third record in the array. All arrays start indexing at zero.

There are several benefits to structuring test data using the

Record data type:

You can create logical groupings of mixed data types in a single container, which makes a program easier to develop and maintain. For example, you might use the following fields for a record storing test data: test name, value returned, pass or fail indicator, time stamp, nominal value expected, upper pass limit, lower pass limit, and a description of the test.

You can manipulate a single data container rather than eight separate data containers. This makes the program simpler and more readable.

You can store and retrieve Records from DataSets in VEE. A

DataSet is a special file created to store records. When you retrieve records from a DataSet, you do not have to know the data types. VEE provides objects to retrieve, sort, and search the information stored in DataSets.

222 VEE User’s Guide

advertisement

Was this manual useful for you? Yes No
Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Related manuals

advertisement

Table of contents