Lab-1: Introduction To Labview (Part-1) : 1. Objective

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Lab-1: Introduction to LabVIEW(Part-1)

1. Objective
 Introduction to the Graphical interface of LabVIEW with its application.
 Building and simulation of block functional programs including basic mathematical
functions, loops, sequences, Boolean operators, case structures, plotting, working with
data files and troubleshooting.

2. Reference Reading
Virtual Instrumentation Using LabVIEW by Jovitha Jerome

3. Introduction
Labview is a versatile graphical programming language which, because of its relatively
simple user interface, should allow you, the programmer, to be writing functional programs
in no time.

This lab will serve as an introduction to the programming language of Labview and will
introduce you to the most important aspects of the programming language, focusing on
those parts of Labview you will need to successfully complete the labs for EE-314L. In
particular, Labview is ideally suited for controlling various hardware devices and recording
data.

Before we dive in, however, we should understand why we are using Labview and what
the advantages and limitations of the program are. Labview is extremely easy to use and,
for relatively small programs, easy to debug. All of the programming is done graphically
with icons and does not require any sort of complicated syntax. If you can use a mouse,
you can program in Labview.

Note that compared to other programming languages, the graphical representation of


Labview uses more memory: this reduces the speed of your programs. This is especially
true for earlier versions of Labview, though the program has improved in later editions. For
our purposes, speed will not be a major concern, so a program like Labview is an ideal
introduction to programming.

In this lab, and the coming labs, we will be covering following aspects of Labview:

1. Getting Started
2. Basic Mathematical Functions
3. “For” Loops, Sequences, and Plotting
4. Boolean Operators, Rings, and Case Structures
5. Working with Data Files

1|Page
6. Troubleshooting (optional)

3.1 Getting started


1. On the Windows Start Menu → All Programs, click on National Instruments
Labview 2015.

A box will open. In the future, previously created programs will appear on the right
under “Open Existing.” To start from scratch, there is “Blank VI” and “Blank Project” on
the left.

2. Select Blank VI

When you do this, you will see two windows open. The two windows are the “Front
Panel” window and the “Block Diagram” window. These two windows are collectively
called a blank VI (VI stands for “virtual instrument”). This is the canvas upon which you
will write your programs. The Front Panel window is essentially the control panel of your
program – it is where you will input the necessary parameters for your program and also
where, oftentimes, the output from your program will be displayed. The Block Diagram
window houses the actual meat and bones of your program. Here is where you will actually
‘write’ the code for your program and where you will process the inputs from the Front
Panel. An appropriate automotive metaphor might have the Front Panel as the clutch, gas,
brake, gear-shift, steering wheel, dashboard, etc. of your car. The Block Diagram would
correspond to the various mechanisms under the hood (engine, radiator, etc.) that actually
make the car run.

2|Page
3. In the View menu, select Tools Palette.

A palette with various blocks on it will appear; this window will allow you to easily
switch between the various tools you will need to write your program.

When you select the Front Panel, you will also see a window labeled Controls. (If you
do not see it, open it by going to View → Controls Palette.) This window is your Controls
palette, which will provide you with all the building blocks necessary to construct your
Front Panel.

Likewise, when you select the Block Diagram, you should see a Functions palette
(View → Functions Palette). This is the Block Diagram equivalent of the Front Panel
Controls palette and provides all the tools necessary for building your program in the Block
Diagram window.

Finally, you should also see a Help window on the screen (Help → Show Context
Help). As you move your mouse over the various objects in your Front Panel or Block
Diagram, this window will provide you with information about how it works.

3.2 Basic Mathematical Functions


The first thing you will do is write a simple program that performs basic mathematical
functions. This program will take two inputs, perform a mathematical operation, and
display the result.

Start with a basic multiplication operation. For the program to perform the operation “x
times y equals xy,” or

x * y = xy,

3|Page
You will need a program with two input variable names (“x” and “y”) and an output
variable name (“xy”).

1. Select the Front Panel, and click on the Num Ctrls icon on the Controls panel.

You will see a new window, with a variety of choices. Each of these choices (Num
Ctrl, Fill Slide, Knob, Dial, etc.) is a mechanism for inputting information into your
program. Generally, we will simply use Num Ctrl.

2. Click on the Num Ctrl icon.

Your mouse pointer will turn into an open hand.

3. Move the hand to the Front Panel and click where you wish to put the control.

The label “Numeric” will be highlighted above the control.

4. Erase the “Numeric” and type in your own label for the input.

In our case, “x” makes sense.

5. Place another Num Ctrl on the Front Panel and label it as “y”.

You have just placed the two inputs for your program into the front panel. To enter a
number into these controls, double-click on the input space (white area) and then type a
number. To increment (add) or decrement (subtract) the existing number by one, use the
arrows on the left of the input space.

You will also want display the result of your program. Because this is output of the
program, not an input, you will not use a control for this display. Instead you will use an
indicator.

Thus, in Labview:

Input → Control

Output → Indicator

Because you are now in the Numeric Controls menu of the Controls panel, hit the
“Express” label to get back to the higher level menu. Note: The express menu contains the
most commonly used Labview tools. To get access to the full selection, press the double
arrow button at the bottom of the Controls palette.

6. Select Num Inds.

Again, you will have the option of choosing a variety of indicators.

7. Choose the Num Ind icon, place it on the front panel, and label it “xy”.

4|Page
When you go back to the Block Diagram, you should see three rectangles
labeled “x”, “y”, and “xy”. These are the graphical representations of the controls and
indicators you have just created.

You will notice that the controls have a filled orange border which shows that
they are controls and meant to be read by your program. The indicator has an unfilled
orange border, labeling it as an indicator and demonstrating that it is meant to be written
to instead of read from.

8. In the Functions palette, click on the Arith & Compare icon, and then the Numeric
icon.

The Numeric window should show you a number of arithmetic operators.

9. Choose the Multiply operator, and place it on your Block Diagram window.
You now have everything in place to write your program. All that is left is to
wire it up.
You will notice that when you put the mouse over the multiply operator, three
leads appear, looking like dots with wires protruding slightly from them. These leads
are identified in the Context Help window. For more complicated icons, the Context
Help window not only labels the leads, but describes their purpose and the required
input.
As you can see from the Context Help window, the two leads on the left are for
your inputs while the lead on the right is for your output. When you place the mouse
cursor over the leads, it will turn into a spool of wire. Clicking on the lead while the
pointer is in this form will attach a wire to that lead.
10. Attach a wire to the ‘x” lead on the multiply operator, then move your mouse to the
“x” rectangle and click.

When a wire can be correctly attached to a control or an indicator, a blinking


output lead will appear on the right/left side of that control/indicator.

You have now connected the “x” input to the multiply operator.

11. Now do the same for the “y” lead and “y” rectangle, but click the mouse a couple of
times on the Block Diagram “canvas” between the “y” lead and the y rectangle.
You can pin the wire to locations on your block diagram by doing this. This can
be helpful for maneuvering wires through more complicated block diagrams.
12. Attach a wire between the “xy” rectangle and the output of the Multiply operator.
Once you have connected the output lead of the multiply operator to the xy
rectangle, you have finished “writing” your program.
13. Go back to the Front Panel and enter numbers into the “x” and “y” inputs.
On the upper left hand corner of the front Panel there is a white arrow. This is
the run arrow. Clicking the arrow will run your program.

5|Page
If the arrow icon appears broken, there is something wrong with your program.
Look for loose wires or misconnected icons.
When the arrow is white, your program will run. Note: a program that is capable of
running is in no way a guarantee that it will correctly do what you want it to do!
14. Click run.
Congratulations! You have just run your first Labview program!
15. Go to File → Save and save your program as “yournamemath”.

4. Tasks
4.1 Task # 01

Implement the following equation:

𝑺 = 𝑽𝒊 𝒕 + 𝟎. 𝟓𝒂𝒕𝟐

You have time value that is coming from data acquisition card (consider a variable value
coming from a knob) with 𝑉𝑖 = 10.5𝑚𝑠 −1 and 𝑎 = 9.8𝑚𝑠 −2 . Calculate S, show it on proper
scale and do a decision if the S is divisible by 10 which lights an LED.

4.2 Task # 02

You have liquid tank with an ultrasonic sensor mounted on it. It provides you with the liquid
level, ‘X’ inside it in the form of voltage ranging from 0-5V, depending on the height of liquid.
You have to develop GUI showing tank filled height, flow rate and temperature on proper
respective indicators (indicators provided in Express).

Consider the following equations:

𝒉 = 𝟒𝑿 + 𝟑. 𝟓

𝑿𝟑
𝑻= +𝟒
𝟑

𝟏𝟎
𝑭𝒍𝒐𝒘 𝒓𝒂𝒕𝒆 (𝑸) = 𝝅𝑿𝟐 +
𝑿

6|Page
EE-314L Instrumentation Lab

Lab#01 Rubric Mark Sheet


Student Name: ______________________ Reg. #: _________________

Marks 3.0 2.0 1.0 0

Cannot setup
Punctuality Student arrives or handle the
PLO-8 NA NA
in lab in time. apparatus.
Can independently Can setup and Can setup and
Apparatus Cannot setup
PLO-5 setup, operate and handle the handle the
or handle the
Usage handle the apparatus with apparatus with
apparatus.
apparatus. minimal help. some help.

Student arranges Student carelessly Student does


the workstation arranges not arrange
Work Station PLO-8 NA
properly after lab workstation after the work
completion. lab completion. station.

Analyzes and Analyzes data Unable to


Analyzes and
interprets data correctly however analyze and
interprets data
Data correctly for few unable to interpret data
PLO-4 correctly for all
Interpretation tasks/ interpret it for for any tasks/
tasks/ experiments
experiments in the tasks/ experiments experiments in
in the lab.
lab. in the lab. the lab.
All required data is Data recorded and Data recorded
Data recorded
recorded and presented is and presented is
only with
presented complete but partially
Data PLO-5 considerable
accurately and accuracy is not as complete. The
Acquisition assistance
completely in the per requirement. required format is
from
required format The required followed but with
instructor .
format is followed. few deficiencies.
Total Score in Lab /12

Instructor Signature: _________________

Date: _________________

7|Page

You might also like