Vous êtes sur la page 1sur 9

EXPERIMENT NO: 02

INTRODUCTION TO LABVIEW
Aim: To study various functions, tools and Libraries of LabVIEW (LV) software.

INTRODUCTION
Laboratory for Virtual Instrumentation Engineering Workbench (LabVIEW)is program
development environment and uses Graphical( G ) Programming Language as a programming
tool.LV has extensive libraries for Data Acquisition and Control, Data Analysis, Data Storage,
GPIB, Serial Instrument Control and Networking.

With LV, we build programs called Virtual Instruments ( VI ) to acquire and analyzed data. A VI
consists of the following parts:
1. Front Panel: This is the user interface of the instrument. It contains knobs, switches,
graphs and other controls and indicators that can be used to view results on the
screen.
2. Block Diagram: VI receives instructions from a block diagram (Figure 2.1)that acts a
source code. The block diagram is a pictorial representation of the program
constructed using G Programming Language.
3. Sub- VI: This represents a sub program which can be used by any VI in its block
diagram. So this is a VI within another VI. The icon and connector of a sub VI work
like a graphical parameter list so that other VIs can pass data to a sub VI.

Figure 2.1: Block Diagram & Front Panel

In this experiment we will do exercises to get familiar with some of the function, tools and
libraries of LV. LV software includes functions, tools and libraries for interfacing a variety of
DAQ (Data Acquisition) cards. Real time process data can be acquired processed and analyzed
using these cards. A DAQ card provides connectors to interface Analog (AC/DC) Input/output
and Digital Input/output. Data can also be acquired using RS232C port or GPIB. Input/Output
range of the signal depends on the design of the card.
In this experiment, we will use PCI 6024E DAQ card with CB 68LP terminal block. Figure 2.2
Shows the interconnection of different functional blocks.

Figure 2.2: the interconnection of different building blocks

The boards have three different input modes --- (no referenced single-ended NRSE) input,
reference single-ended (RSE) input, and differential (DIFF) input. The single-ended input
configurations provides up to 16 channels. The DIFF input configuration provides up to 8
channels. Input modes are programmed on a per channel basis for multimode scanning. For
example, you can configure the circuitry to scan 12 channels---four differentially configured
channels and eight single-ended channels.
Virtual Bench is a group of VIs that can be used for Data Acquisition, Processing, Storage and

Display. There are following three VIs available in virtual bench.

1. Data Logger: It can display upto 16 channels.


2. Digital I/O Controller: It can be used to control and monitor Digital I/O lines. Each line can be
configured as an input or output in the DAQ Channel Wizard.
3. Digital Multimeter: It is capable of measuring voltage, current, resistance and Temperature.

EXPERIMENT:

(a) To study various functions, tools and libraries of LabVIEW (LV) software.
Run 1: Creating a Simple VI: (covered in class)

1. Select first LabVIEW and then New VI option from LabVIEW dialog box. From the
menu bar pop up Windows and choose. Tiles left and right to view Both front panel and
block diagram simultaneously.
2. Front Panel and Block Diagram have identical menu bar and tools icons except that for
front panel there is a controls menu while for block diagram there is a functions menu.
Controls menu contributes to controls and Indicators; they represent the input parameter
and output values respectively. Functions menu contributes to functions. We can also get
the controls or Functions menu by clicking the right button of the mouse anywhere inside
the windows.
3. Using Numeric section of the Controls in the front panel, place a Digital Control on the
screen and label it as Input. Add a Thermometer from the same palette and label it as
Temperature-F. Add a Digital Indicator and label it as Temperature-C.
4. Go to the diagram and wire the digital control to the thermometer and digital indicator.
Note the colour of the connection. It should correspond to Real.
5. Use continuous Run button on the tool bar and see the changes in thermometer and
digital indicator with change in the value of input. Use Stop button to stop.
6. Change the range of the thermometer to 32 - 212.Vary the input and see that thermometer
shows the same value. What are the values shown by digital indicator in each case?
7. Create your own folder and save this VI in a file tempr.vi in your folder.

Run 2: Editing VI: (covered in class)

1. Use Open VI to open your file tempr.vi. Replace Digital Control with a Knob by
selecting the object and choosing Replace from the pop-up.
2. Add three LEDs and colour them as Red, Green and Yellow. Do not connect them to
anything.
3. Save the file.
4. Try other command like modifying, deleting, duplicating, moving etc. Also try to use
other tools, functions and control palettes to understand their operation. DO not save
these trials.

Run 3: Modifying VI: (covered in class)

1. Open VI tempr.vi.
2. We want to modify VI so that when input is given in oC, Thermometer shows readings in
o

F and Digital Indicator shows readings in oC.Use standard formulas

F=(oC x 9/5) + 32

3. Break connections at appropriate places and using Multiply and Add functions, modify
the diagram. Run the VI and verify the operation.
4. Now it is desired to show alarms using LEDs. Since you have already created three
LEDs, we shall use them for this purpose. Modify VI to light LEDs as follows.
Temperature range in oC
>85

LED to light
Red

<20

Orange

between 20 and 85

Green

5. Save the file.

Run 4: Implementing a Sub VI (covered in class)

1. Open Vi tempr.vi.
2. In the block diagram, use Positioning tool ( ) to select the portion using multiply and Add
functions. Choose Create SubVi from the Edit menu. This automatically creates a subVI
from the section of the code selected earlier. The subVi appears on the block diagram as a
default picture. Double click on this subVI to see the new VI that created, with front
panel and block diagram.
3. Save this new untitled VI as Sub_CtoF.vi in your folder. If you need to use this SubVi in
future as part of another program, use Select a VI.. From the functions palette and place it
on your block diagram.

We can create our own ICON for any subVI as follows:

At the top-right corner of the front panel, click the right mouse button

Choose Edit Icon

Icon Editor will pop up

Edit the icon to the desired design by using tools of the editor.

Next step is to assign the connector to the indicator and controls as follows:

At the top-right corner of the front panel, click the right mouse button.

Choose Show Connector.

The current connector map will appear.

Click the right mouse button again and choose pattern.

After a pattern is chosen, new connector map will appear.

Click the left mouse button on one of the connector, the color of that connector should
turn black.

Select one of the indicator or control from the VI to assign that particular connector for
the indicator/control.

After a connector is assigned, you should see the color of the connector change to grey.

Repeat to complete all the connections.

4. Save subVI.
5. Open tempr.vi and see that ICON designed above appears in the block diagram at

appropriate
Place. VI has used SubVi as a module.

Run 5: Using Loop Structures: (covered while loop in class)

There are two types of loop structures. One is For Loop and the other one is While Loop. The
loop structures allow continues data acquisition to be performed until certain conditions are
satisfied.For instance, we may want to measure continuous voltage change at a channel until it
reaches the limit. Codes that you want to be executed must be inside the border of the loop and
they are subdiagram.
Lets first look at For loop.

It has a count terminal that sets the number of times subdiagram is to be executed.

It also has an iteration terminal that keeps the counts of total execution so far.

The For loop starts from 0. Hence if N=10, it will eventually count to i =09.
for i=0 to N-1, execute subdiagram

The While loop structure is very similar to the For loop. It has he following characteristics.

Just like For loop. It also has an iteration terminal that keeps the count.
But rather than setting total count for the loop, it has a conditional terminal that the Boolean
is to be decided during each subdiagram execution.

Another difference is that even if the initial condition is false the loop will still execute once
before it knows the condition is true or false.

The While loop behaves differently depends on whether the terminal is place inside or
outside the loop. When the terminal is placed inside the loop the terminal will be checked and
updated on each loop iteration. If the terminal is placed outside the loop the subdiagram will
run once if initial condition is false otherwise it will run for infinite

We will create a Random number generator and control it using loop structures.
a. Create a New VI from File menu.
b. Select a Vertical Toggle Switch (Boolean) from the control palette and place it on the

front panel. Label it as power.


c. Select and place a Waveform chart (Graphs) from the control palette on the front panel
and label it as Random Plot. Change its vertical scale from 10.0 to 1.0.
d. Open the block diagram. Select and place the Random Number function ( Numeric>>
Random Number (0-1) on the block diagram
e. On the block diagram, select a White Loop ( Structure ). Move the mouse, now
appearing as a square icon, to the point where you want to anchor the top left corner of
the While loop. Click and drag to enclose the Random number function as well as
Random Plot and Power terminals.
f. Wire Random Number function with Random Number Plot and Power terminal with
conditional terminal of while loop.
g. Stop the VI by clicking on the power switch to turn it off.
h. Save VI as random_number.vi in your folder.
Repeat the above using FOR loop wiring a constant of 20 to the counter of FOR loop.

Run 6: Using timing, Analysis and File I/O: (covered in class)


We shall build upon random_number.vi. During the acquisition, the VI displays the
measurements in real time on a waveform chart. We will control the acquisition rate with a knob.
After the acquisition is complete, the VI will calculate the average and write the acquired data to
a spreadsheet file.
a) Open random_number.vi file.
b) Add a Knob ( Numeric ) to the front panel and label it Delay ( msec ). Change the scale
to show a maximum value of 500.0.
c) Open the pop-up menu on the knob and select Show>>Digital Display to hide the
numeric indicator that displays the knob value.
d) Adding Timing: Open the block diagram. Select a Wait Until Next ms Multiple
function (Timing & Dialog). And place it within the while loop. Wire it with Delay
terminal. Return to front panel, turn on the power switch and Run the VI. vary the delay
to see the effect of the knob and how it controls execution timing within the while loop.
e) Adding Analysis and File I/O : Select a Mean function from the Functions >>
Mathematics >> Statistic subpalette and place it outside While loop on the block

diagram. Now select a Write To Spreadsheet File VI from the Function>>File I/O
subpalett and place it outside While loop. Place mouse over the top right corner of the
Mean function and open the pop-up menu. Select Create Indicator from the pop-up
menu. This automatically creates a numeric indicator labeled mean on the front panel and
will display the mean of the input data.
f) Wire Random Number Function with Mean and 1D array input of write to Spreadsheet
File

function.

g) Since these two functions are outside the While loop, the wire initially will be broken
outside the loop. Open the pop-up menu on the black tunnel that connects the outside of
the Random Number Function to the VIs outside the loop and select Enable Indexing.
This causes the data within the While loop to be released as a set at the termination of the
loop, and the wire will change from being broken to a thick orange line. Otherwise only
the final data point generated would be released at the termination of the loop.
h) Return to front panel, turn on the Power and Run the VI.
i) Turn off the power to stop collecting data. The average of the Random data displays in
the mean indicator and a file dialog box appears. Save the file as data.txt. You can see file
in Excel or Text Editor.
j) Save the VI as random_number_plus.vi.

Run 7: Using Different Waveform Charts: (Try it yourself )


a. Open random_number.vi.
b. Modify VI to display the data simultaneously on three waveform charts viz. Strip, Scope
and Sweep
c. Run VI and see the difference between the three charts for various values of delay. Try
various features of waveform charts: legend, palette, digital display, scroll bar and buffer.
Use Help to get more details.
d. Save it as random_number_charts.vi.

Run 8: Using Debugging Features: (Try it yourself )


When VI is not executable, a broken line arrow appears in the run button. To list error, click on
the broken Run button. Click on one of the errors listed and the click on Find to highlight the

object or terminal that reported the error. We shall use some debugging features of LabVIEW.
Open random_numberplus.vi.
a) In the block diagram, click on the Execution Highlights ( a bulb) button in the tool bar.
Run the Vi. Notice that dots flowing on along the wires show you the dataflow and
execution order in this VI. Execution highlights also shows abbreviation data within the
block diagram at each node.
b) Deselect Execution Highlights button and stop the VI by turning off the Power switch.
Save data to data.txt file.
c) In the block diagram, open the pop-up menu on the wire between the Random Number
Function and Random Plot Terminal and select Probe.
d) Set a breakpoint on the random Number Function by clicking it with the Breakpoint tool
on the tool bar. The Random Number Function will now have red outline.
e) Run the VI. The block diagram should flash on the Random Number function, indicating
that it is ready to execute. Click on the Step Over button on the tool bar to execute
random number function. The generated number will be displayed in the probe window.
f) Click on the Step Into and Step over button a few more times to see how single stepping
works.
g) To run normally, deselect the Pause button.
h) Close the VI and do not save changes.

Vous aimerez peut-être aussi