University of Pennsylvania
Department of Electrical Engineering
Undergraduate Laboratory

Simple Data Acquisition  and Output in Labview

 Please do not print this tutorial. A photocopy of this write-up will be given during the lab

It is important to read  " Introduction to Data Acquisition Systems and Labview " before you proceed to read the following.

Purpose

    To design a virtual instrument (vi) in Labview software which will allow you to measure DC characteristics of 741 op amp

Introduction

    To measure output characteristics of a device/circuit one needs to measure the output voltage from a device/circuit as the input to it is varied. The vi that you are going to design, controls the installed data acquisition (daq) board which outputs  DC voltages and simultaneously measures the input DC voltage and then plots the measured voltages on a XY graph. This is achieved by using the data acquisition (daq) board installed in a PC and by using the Labview software that controls and interacts with the board. The daq board is capable of measuring voltages at any one of its 8 input channels and it can output to any one of 2 output channels. The connections to this board are made available through the breakout box . Labview needs no text programming and all functionality and control is achieved through various functional blocks. The execution and the logical flow is achieved through wires that interconnect the blocks. These blocks are called functions and subvis.
    As you may already know  a vi consists of a front panel and a diagram. Following is  the example that you are going to design. The front panel is shown in Fig 1 and the diagram is shown in Fig 2 .



Figure 1. Front Panel



Figure 2. Diagram

VI Design
This section will explain the basics of editing and designing a vi. Tools, Controls and Function palettes are explained. Launch Labview application from the desktop and choose "New VI".

Figure 3. Launching Labview


Figure 4. A new vi

    The screen will show a blank front panel and diagram. You will also notice two floating palettes, the Tools and the Controls palette. Tools palette has different tools that are used in the editing of different components of vis.


Figure 5. Tools palette.
Front Panel Design

    It is always a good practice to design the vi just as you would design an instrument. Observe the front panel in Figure 1. The front panel consists of controls and indicators. In the example shown in Fig 1, we need to have inputs for the vi to get correct information on the daq board (device), input and output channels to measure input and output data ("Analog Channel in" and "Analog Channel out" respectively), a control to set the start output voltage (Start voltage) and the delay of each increment (delay) of output and input measurement. In addition to this, we need to have Numeric Display of "Input : voltage into op-amp " and "Output : voltage from the output from the op-amp ".


Figure 6. Controls.

Explore the Controls palette and choose Numeric subpalette.  Remember to label each of the controls or indicators as soon as you place it on the front panel. This will help you to identify the terminal in the diagram. Also goto Help menu and check Show Help. This will enable a help window when you select a function or a subvi.



Figure 7. Graphs.

    Use  tool to label the axes as shown in Fig 1. Also type the title and your names. If the front panel looks like as shown in Fig 1 then you are ready to move to the design of the diagram.

Diagram Design

Click on the diagram part of the vi. You will notice another floating palette titled Functions. This palette has a variety of functions and subvis that control all aspects of  the daq board and signal  measurement and processing. If you have labeled all the numeric controls and indicators, then you will find their terminals on the diagram labeled appropriately. In case you forgot to label the numerics and strings just as you brought them into front panel it can be confusing. Use the right click mouse while selecting the terminal and choose "Find Terminal" from the menu. Alternatively, you can double-click on the terminal in the diagram and it will point to the control in the front panel.


Figure 8. Functions palette with daq subpalette open

While designing a diagram remember the following rules :  
For any Function or subvi  the  inputs to it  are always to the left and the outputs  are always to the right .
To look at all the connections, go to Help  menu and choose "Show Help". With Help turned on, as you move your editing tool  on a function/subvi the  help screen will pop up. All the screen captures in this document are  from  the "Help" screen.
When the  tool is placed over a function or a subvi, the terminals on the functions light up with the connections highlighted. This makes it easy to connect the wire to appropriate terminals.
If the connections between two functions/subvis are incompatible,  then a ----- line will appear between the connections rather then a solid line. This means that the wire connection is carrying incompatible data (e.g. as array to a number or a cluster to a array). Check the connections again with the "Help" screen  or by looking  at Fig 2.

    Let us first understand  the diagram in Fig 2. The subvi AI One PT and AO One PT  are analog input and analog output subvis. In Labview,  it is easier to use subvis within vis. A subvi may consists of one or more subvis or functions.  The daq  subvis are located in Analog Input and Output subpalette of Data Acquisition subpalette in Functions palette (Fig 8).  In addition to measurement of voltage, these sub vis enable the daq board control, configuration and initialization. These are "Easy VIs", which means they can be used with minimal connections. You will need to connect the "device"  connection to your "device" numeric control  and "analog channel in " and "analog channel out " string controls to AI One PT and AO One PT  "channel" inputs respectively.


Figure 9. Analog Input, waveform function and Analog Output subvis.

    The daq subvi as shown above acquires or outputs the voltage data only once when executed. By using a "For Loop", the AI One Pt subvi  and  AO One Pt subvi  generate the data until the loop is executed.  The For Loop has two terminals, the i terminal counts the iterations and N terminal sets the limit of number of times the loop can run (this is the "maximum number of points control").
The For  Loop is equivalent to a pseudo code :  for i = 0 to N-1,   execute the subdiagram.
The i  (iteration) terminal contains the current number of completed iterations starting with 0 in the first iteration. Within the For Loop,  the "Start voltage" value  gets incremented  with a value from "i" for every iteration of  the loop.
The voltage output  from the daq board =  [( (Start voltage) *  10 ) + i]  /  10. This is achieved by various numeric functions.
Therefore,

This continues until i=N-1. The voltage output from the daq board  is displayed on "Output : voltage into the op amp"  indicator. During the same increment the input voltage that is measured by AI One Pt is measured and displayed on the  "Output : voltage from the op-amp " indicator.  When "For loop" finishes the N counts  ( "maximum number of points " numeric control ) the voltage values are passed outside the loop to the XY plot and the spreadsheet file sub vis. A dialog box will  appear at the end of the execution of the vi  which enables you to save a file on your PC. The "delay " function allows the user to see the data being output and acquired on the front panel. The delay  functions has a input in milliseconds. Enter a value of  1000 and later on you can reduce the delay number to speed up the readings.
Begin your diagram design by selecting AO One PT and AI One PT  subvis as shown in Fig 8. The Functions menu can also be popped up anywhere on the screen by right clicking on the mouse in the diagram. Next select the Build Array function from the Array subpalette in Function palette shown in Fig 10.


Figure  10. Array subpalette

    You need to build an  array for saving the data in a spreadsheet file format. As explained before,  the data available from daq subvis are samples in a series of numbers. These numbers are generated every time the loop is is executed.  The Build Array function combines  the input values so that the output array now contains both input and output voltage information. This output is a 2D (two dimensional) array where the data will be the form of two columns. This function is necessary to be used for graphing indicators (with the exception of  XY plot graph) and for writing in a file. The Build array function is a single input function by default.  Use the  tool to resize for two inputs. Leave the output unconnected for now. Make connections with the wire tool as shown in Fig 2.

    We also need to plot the  voltage output from the op-amp against the voltage input to the op-amp. The Bundle Cluster function in the Cluster subpalette of the Functions palette assembles all the components at the input and the outputs an array of clusters. In this vi the output of the Bundle function is connected to the XY plot.  The XY plot  function then  generates a  XY axis coordinate. A cluster  is a storage element that can store variety of data types. A cluster element is used in Labview environment liberally because of it advanced memory management advantages. Clusters are used to pass data from one function to another and it can contain a combination of numbers and arrays.


Figure  11. Cluster subpalette

Use the  tool to resize the cluster for two inputs. Leave the output unconnected for now. Make connections with the wire tool as shown in Fig 2.

    Bring into the diagram the addition, division and multiplication functions and make connection so that the diagram looks like as shown in Fig 2. The Write to Spreadsheet vi is in the File I/O subpalette. You only need to connect the 2D data input to the vi. Leave the rest disconnected. 2D (two dimensional) data is generated from the Build Array function and each dimension is a column of data points. In this case the first column is the voltage into the circuit (Vin) and the second column is the voltage measured from the circuit.


Figure 12. Write to Spreadsheet File.vi

    Use the For Loop function in Loop and Structures subpalette and drag it over all the terminals except "maximum number of points", "XY plot" and "Write to spreadsheet vi" numeric controls. If one of the terminals happens to be inside the loop, you can drag the terminal out by  using the  tool. Make connections to N and i terminals of the For Loop. Wire the outputs of the Build Array and the Bundle function to the "Write to Spreadsheet " and "XY plot"  functions respectively.  It is a good practice to label various function with the  tool. This will make it  easier to follow the logical structure of the vi. You will be using this vi for other circuits in coming labs. Take your time to explore various subpalettes. If you get stuck,  try using "Help" from the Help menu before calling on instructors.

    On completion and if the wiring is appropriate, the diagram should look like the one shown in Fig. 2. The front panel will be gray scale by default. Choose the paint tool to make the graph and front panel white.

On the front panel and right-click on the XY plot. A  menu will pop up with various formatting options. Choose  > X Scale > deselect AutoScale. Do the same for Y axis.

In the front panel, the tool bar can be used to set the font size and Start/Stop the vi. 


Figure 13. Front Panel  toolbar

In the diagram, the tool bar is used for debugging the execution or single stepping the  program.


Figure 14. Diagram toolbar

Connections to the circuit and Execution of VI

Created by Siddharth Deliwala, Jan 26, 1998
Updated by Siddharth Deliwala, Jan. 23, 2004



The screen captures are © National Instruments and Labview  is registered trademark of National Instruments.
The tutorial and the write-up is  © University of Pennsylvania

Back to the EE Undergraduate Lab Home page .
Back to the EE206 Home Page
Back to the EE Home Page