Labview Lab Manual
Labview Lab Manual
Labview Lab Manual
SEMESTER-III
LABVIEW PROGRAMMING BASICS
(21EC384)
Prepared by
List of Experiments
2|Page
RV Institute of Technology and Management, Bengaluru
Overview
The Laboratory Virtual Instrument Engineering Workbench (LabVIEW) is a development
environment designed by National Instruments that creates graphic-based programs called virtual
instruments (VIs) that simulate actual laboratory instruments. A VI consists of two parts: a front panel
and a back panel (Figure 1). The front panel allows the user to interact with the VI by displaying
outputs and allowing the user to supply the program with inputs. The back panel consists of the code
used by the VI to obtain inputs from the front panel, operate on the inputs, and display the results.
3|Page
RV Institute of Technology and Management, Bengaluru
4|Page
RV Institute of Technology and Management, Bengaluru
All of the objects placed on the front panel will appear on the back panel as terminals. Terminals are
the ports that exchange information between the front panel and back panel, and appear with small
triangles in the icons to indicate that they can be used to process information (Figure 4). A control
terminal has the triangle to the right to indicate that it sends data to be processed. An indicator terminal
has the triangle to the left to indicate that it receives data.
5|Page
RV Institute of Technology and Management, Bengaluru
6|Page
RV Institute of Technology and Management, Bengaluru
7|Page
RV Institute of Technology and Management, Bengaluru
Collectively, controls, indicators, structures, and functions are referred to as nodes. Nodes are
connected to one another using the wiring tool. For example, two controls and an indicator can be
wired to the addition function so that the indicator displays the sum of the two controls (Figure 9).
8|Page
RV Institute of Technology and Management, Bengaluru
Procedure
Note: Some tasks will be repeated and the same icons will be used. A LabVIEW digest of common
tasks at the bottom of the page contains references for faster navigation.
Setting up a Blank VI
1. Open LabVIEW and select Blank VI under Create Project.
2. Click Window > Tile Left and Right to display the front panel (left window) and back panel
(right window) side by side. This will make them visible at the same time, making it easier to
work.
3. With the back panel selected, click View > Tools Palette to open the Tools palette.
4. With the front panel selected, click View > Controls Palette. The workspace should look like
Figure 12. To open the Controls palette in the future, simply right click in the front panel.
Similarly, to open the Functions palette, simply right click in the back panel.
9|Page
RV Institute of Technology and Management, Bengaluru
Exp No: 1
Algorithm:
Step 1: Start the Lab view and select the blank VI.
Step 3: Numeric controls are given as inputs and numeric indicators are given as
output they are selected by right clicking on the front panel.
Step 5: Using wiring operation inputs and outputs are connected to the respective
operators in the block diagram panel.
Step 6: Input values are given in the front panel and the program is executed.
Hence the output is generated.
10 | P a g e
RV Institute of Technology and Management, Bengaluru
11 | P a g e
RV Institute of Technology and Management, Bengaluru
Front Panel:
Input:
Output:
Result:
Exp No: 2
Step 3: To perform Boolean operation push buttons are taken as inputs and round
LED as output.
Step 4: Different Boolean operations such as AND, OR, XOR, NOT, NAND are
selected from the block diagram panel.
Step 5: Boolean inputs and outputs are wired in the block diagram panel.
Step 6: Logic values 0 & 1 are given in the front panel and the program is
executed.
13 | P a g e
RV Institute of Technology and Management, Bengaluru
Block diagram:
14 | P a g e
RV Institute of Technology and Management, Bengaluru
Front Panel:
Input:
Output:
15 | P a g e
RV Institute of Technology and Management, Bengaluru
Truth Table:
AND:
X1 X2 Y
0 0 0
0 1 0
1 0 0
1 1 1
OR:
X1 X2 Y
0 0 0
0 1 1
1 0 1
1 1 1
16 | P a g e
RV Institute of Technology and Management, Bengaluru
XOR:
X1 X2 Y
0 0 0
0 1 1
1 0 1
1 1 0
NAND:
X1 X2 Y
0 0 1
0 1 1
1 0 1
1 1 0
NOT:
X Y
0 1
1 0
Exp No: 3
Step 2: Right click on the block diagram panel, select program, go to structures
and select a FOR loop.
Step 3: Right click on the border of the FOR loop and select add shift register,
borders are converted into shift register.
Step 4: Using wiring operations required connections are given in the block
diagram.
Step 5: Inputs are given in the front panel and the program is executed.
18 | P a g e
RV Institute of Technology and Management, Bengaluru
Block diagram:
19 | P a g e
RV Institute of Technology and Management, Bengaluru
Front Panel:
Input:
Output:
Result: Thus the sum of ‘n’ natural numbers using FOR loop is performed in
LABview.
20 | P a g e
RV Institute of Technology and Management, Bengaluru
Exp No: 4
Step 2: Right click on the block diagram panel, select program, go to structures
and select a FOR loop.
Step 3: Right click on the border of the FOR loop and select add shift register,
borders are converted into shift register.
Step 4: Using wiring operations required connections are given in the block
diagram.
Step 5: Inputs are given in the front panel and the program is executed.
21 | P a g e
RV Institute of Technology and Management, Bengaluru
22 | P a g e
RV Institute of Technology and Management, Bengaluru
Front Panel:
Input:
Output:
Result: Thus the factorial of a given number is using FOR loop is performed in
LAB view.
23 | P a g e
RV Institute of Technology and Management, Bengaluru
Exp No:5
Step 3: Numeric controls are given as inputs and numeric indicators are given as
output they are selected by right clicking on the front panel.
Step 5: Using wiring operation inputs and outputs are connected to the respective
operators in the block diagram panel.
Step 6: Input values are given in the front panel and the program is executed.
24 | P a g e
RV Institute of Technology and Management, Bengaluru
FRONT PANEL:
Input:
Output:
25 | P a g e
RV Institute of Technology and Management, Bengaluru
Exp No:6
Step 2: Right click on the block diagram panel, select program , go to structures
and select a WHILE loop.
Step 3: Right click on the border of the WHILE loop and select add shift register,
borders are converted into shift register.
Step 4: Using wiring operations required connections are given in the block
diagram.
Step 5: Inputs are given in the front panel and the program is executed.
26 | P a g e
RV Institute of Technology and Management, Bengaluru
27 | P a g e
RV Institute of Technology and Management, Bengaluru
Front Panel:
Input:
Output:
Result: Thus the factorial of the given number using WHILE loop is performed.
28 | P a g e
RV Institute of Technology and Management, Bengaluru
Exp No:7
Step 2: Right click on the block diagram panel, select program, go to structuresand
select a WHILE loop.
Step 3: Create an array in the front panel and add numeric indicator to it.
Step 5: Using wiring operations required connections are given in the block
diagram.
Step 6: Inputs are given in the front panel and the program is executed.
29 | P a g e
RV Institute of Technology and Management, Bengaluru
30 | P a g e
RV Institute of Technology and Management, Bengaluru
FRONT PANEL:
Result: Thus the even numbers from the given set of numbers is sorted using
WHILE loop in an array.
31 | P a g e
RV Institute of Technology and Management, Bengaluru
Exp No:8
Step 2: Right click on the front panel →modern →array→ array matrix→ numeric
control.
Step 3: Create four numeric indicators in the front panel for maximum variable,
index, minimum variable and index.
Step 4: Using wiring operations required connections are given in the block
diagram.
Step 5: Inputs are given in the front panel and the program is executed.
32 | P a g e
RV Institute of Technology and Management, Bengaluru
33 | P a g e
RV Institute of Technology and Management, Bengaluru
Front Panel:
Input:
Output:
Result: Hence the maximum and minimum values of array were displayed using
LabVIEW.
34 | P a g e
RV Institute of Technology and Management, Bengaluru
Exp No:9
Heating and Cooling System
Build a Virtual Instrument that simulates a heating and cooling system. The system must be able to be
controlled manually or automatically. The VI’s specifications are listed below.
1. In the front panel, drag and drop three Round LEDs and three Slide Switches by going to the
Controls palette > Modern tab > Boolean (Figure 1). Each round LED and each slide switch
will represent the AC, heater, and manual mode. The round LEDs will indicate if the item is
on, and the slide switches will toggle the items on/off.
35 | P a g e
RV Institute of Technology and Management, Bengaluru
36 | P a g e
RV Institute of Technology and Management, Bengaluru
37 | P a g e
RV Institute of Technology and Management, Bengaluru
38 | P a g e
RV Institute of Technology and Management, Bengaluru
39 | P a g e
RV Institute of Technology and Management, Bengaluru
40 | P a g e
RV Institute of Technology and Management, Bengaluru
41 | P a g e
RV Institute of Technology and Management, Bengaluru
Exp No: 11
Build a virtual instrument that simulates a basic calculator (using formula node).
Create a program that simulates a basic calculator. The calculator will be able to add, subtract, and
multiply.
42 | P a g e
RV Institute of Technology and Management, Bengaluru
ii. Select Horizontal Pointer Slide from the icons shown. Click on the left window
to place the slide on the front panel at any location.
Note: The slide may be moved by clicking on it and holding down the left mouse button to drag
the control to a preferred location. When correctly located, let go of the left mouse button. This
will work for all items in both the front and back panels.
Note: When items are placed on the front panel (left window), symbols corresponding to each
item will appear on the back panel (right window). When the front panel is complete, the items
43 | P a g e
RV Institute of Technology and Management, Bengaluru
on the back panel will be wired to make the calculator work.
iii. Click on the number 10 and change it to 2. Now the slide control will look like
Figure 3.
iv. Right click on the slide to bring up a pull down menu. Select Representation,
and choose the I8 icon. Figure 4 shows what the pull down menus look like and
the I8 icon. This completes the slide control on the front panel.
44 | P a g e
RV Institute of Technology and Management, Bengaluru
b. Three Boolean indicators to specify the operation selected. The instructions are:
i. On the controls palette, select the Boolean icon under Modern. This
will bring up the window shown in Figure 5.
ii. Select the Round LED icon from the icons shown. Click on the left window to
place the LED on the front panel at a specific location. The best place to put it is
centered under the slide. Do this two more times, putting the lights on each side
of the first light created so there are three lights in a row under the slide.
iii. Rename the three LEDs to correspond to the functions the calculator will be
performing: add, subtract, and multiply. To rename each LED, click on the Edit
45 | P a g e
RV Institute of Technology and Management, Bengaluru
Text icon on the tools palette. Then click on the labels on each LED and
replace it with the proper text: "Add" for the left light, "Subtract" for the center
light, and "Multiply" for the right light.
c. Two numeric controls will allow the user to input data from the keyboard. The
instructions are:
i. On the controls palette, click on the Numeric icon under Modern. This will
bring up the window shown in Figure 3 again.
ii. Click on the Numeric Control icon and click on the left window to the left of
the slide to place a numeric control there. This will look like a window that
allows data input. Click the Numeric Control icon again, and place another
numeric control on the right side of the slide.
d. A numeric indicator to display the output. The instructions are:
i. On the controls palette, click on the Numeric Indicator icon and click on the
left window centered below the three lights. This numeric indicator will display
the answer from the calculator.
Note: This numeric indicator, used for output, is a different type of object from the two
numeric controls (which are for input) that was constructed earlier in Item c.
46 | P a g e
RV Institute of Technology and Management, Bengaluru
ii. In the block diagram (back panel) of LabVIEW, go to the menu bar, select
View, and choose Functions Palette. This will bring up the functions palette,
shown in Figure 8.
47 | P a g e
RV Institute of Technology and Management, Bengaluru
iii. Click on the Structures icon under Programming. This will bring
up the window shown in Figure 9.
48 | P a g e
RV Institute of Technology and Management, Bengaluru
iv. Click on the Case Structure icon. Click on the right window to locate it on the
back panel. It is a very large object and will have many connections. The best
strategy is to locate it in the middle of the panel. Note that at the top of the
object there a caption box with the value True in it. On each side of the caption
box are arrows pointing to the left and right. Note also the question mark on the
49 | P a g e
RV Institute of Technology and Management, Bengaluru
left side of the case structure object; any control outside of the case structure
wired to the question mark determines which case is executed.
v. On the tools palette, chose the Connect Wire icon . Connect the slide to the
case structure by clicking on the slide object and then on the question mark on
the left side of the case structure. The back panel should now look like Figure
10.
vi. When the case statement is created, it only has two cases. Since there are three
operations for the calculator, another case is needed. To add the third case
operation, right-click the caption at the top of the case structure and select Add
Case After, as shown in Figure 11.
50 | P a g e
RV Institute of Technology and Management, Bengaluru
vii. Now add the mathematical operations that the calculator should perform for
51 | P a g e
RV Institute of Technology and Management, Bengaluru
viii. Click on the left arrow at the top of the case structure box until the caption for
the case structure changes to 0. In the Numeric Programming window, click on
52 | P a g e
RV Institute of Technology and Management, Bengaluru
the Add icon , and click on a location in the middle of the case structure box
to place it.
ix. Click on the right arrow at the top of the case structure box. This should change
the caption for the case structure to 1. In the Numeric Programming window,
click on the Subtract icon , and click on a location in the middle of the
case structure to place it.
x. Click on the right arrow at the top of the case structure box one more time,
changing the number in the caption to 2. In the Numeric Programming window,
click on the Multiply icon , and click on a location in the middle of the
case structure to place it. At this point, each case should look like the ones
shown in Figures 13 a-c. Check each case by clicking on the left and right
arrows to change the case number in the caption.
53 | P a g e
RV Institute of Technology and Management, Bengaluru
xi. Wire the inputs to the calculator. Set the case structure case to zero by clicking
on the left arrow until the caption reads 0. The triangle inside should be addition,
with a plus sign in the middle. Click on the Connect Wire icon on the tools
palette. Click on the leftmost numeric control on the back panel, and click on the
top left side of the operation triangle to wire the first numeric input to the input
of the addition operation. Click on the other numeric control on the back panel,
and on the left bottom of the addition triangle, establishing the second input.
Click on the right side of the triangle, and click on the numeric indicator on the
back panel. This will display the output of the addition calculation in the
Numeric 3 box on the front panel. The addition function is complete. The back
panel should look like Figure 14.
54 | P a g e
RV Institute of Technology and Management, Bengaluru
xii. To complete the other cases, click on the right arrow next to the case structure
caption. This will change the caption to 1, and the subtraction triangle will be in
the middle of the case structure. Connect the tunnel from the first numeric
control to the top left of the triangle, the tunnel from the second numeric control
to the bottom left of the triangle, and the right of the triangle to tunnel to the
Numeric 3 box at the bottom of the back panel. Click the right arrow next to the
case structure caption one more time. This will change the case number to 2, and
the multiplication triangle will be in the middle of the case structure. Wire the
numeric objects to the triangle as was done for the other two cases. The output
tunnel is now complete and filled with a solid color. The numeric inputs and
outputs are done.
xiii. To illuminate the LED corresponding to each operation, click the left arrow to
the left of the caption of the case structure until the caption reads 0, Default. On
55 | P a g e
RV Institute of Technology and Management, Bengaluru
56 | P a g e
RV Institute of Technology and Management, Bengaluru
xiv. Add three Boolean constants to the case structure. Since this is Case 0, which
corresponds to add, the add indicator must be true, and the other two must be
false. Click on the True Constant icon , and then click inside the
case structure on the right side to the left of the add indicator that is outside of
the case structure. Select the False Constant icon and place it
inside the case structure on the right side next to the subtract and multiply
indicators.
xv. To wire the constants to their respective indicators, click on the Connect
Wire icon on the tools palette. Click on the right side of the top constant
inside the case structure and connect it to the top indicator by clicking on the
indicator next. Do the same for the other two constants and their corresponding
indicators. Three incomplete output tunnels have been formed. The add
operation is complete.
xvi. Click on the right arrow next to the case structure icon. The caption should now
show 1. To have the subtract indicator illuminate for this case. Place a True
Constant inside the case structure on the right side to the left of the subtract
LED. Place a False Constant inside the case structure on the right side to the
left of the add LED, and again to the left of the multiply LED. Click on
the Connect Wire icon on the tools palette. Click on the right side of the top
constant inside the case structure and connect it to the top output tunnel. Do the
same for the other two constants and their corresponding output tunnels. The
subtract operation is complete.
xvii. To finish the calculator, click on the right arrow next to the case structure icon.
The caption should now show 2. The multiplication indicator should illuminate
for this case. Add a True Constant to the right side of the case structure to the
left of the multiplication LED. Place a False Constant inside the right side of
the case structure to the left of the add LED, and again to the left of the
subtraction LED. Click on the Connect Wire icon on the tools palette. Click
on the right side of the top constant inside the case structure and connect it to the
top output tunnel. Do the same for the other two constants and their
corresponding output tunnels. The multiply operation is complete and all output
tunnels have been filled.
4. The VI must be tested:
a. Enter different input numbers through the control icon on the front panel.
b. Make sure the output is correct.
c. Make sure the correct LED lights up for the operation.
d. Have the TA test the VI.
57 | P a g e
RV Institute of Technology and Management, Bengaluru
58 | P a g e
RV Institute of Technology and Management, Bengaluru
Exp No: 11
Vertical Pointer
You can download this simulation of Water Level Detector in LabView by clicking the below button: Download
LabView SimulationVertical pointer is used to control the level of the water in the tank. Upper level indicator
shows when the tank is about to completely fill. Lower level indicator shows indication by turning "ON" the
LED when the level of the water in the tank is too low and we need to fill it. Graphs shows the graphical
visualization as the vertical pointer moves up and down.
Go to the "Front Panel" and press "Right Click" from your personal computer or laptop.
By doing this, you can see the following figure in your PC's screen.
59 | P a g e
RV Institute of Technology and Management, Bengaluru
60 | P a g e
RV Institute of Technology and Management, Bengaluru
Now, put the "Cursor" on the tank and press "Click" you can see that the water level changes with each
61 | P a g e
RV Institute of Technology and Management, Bengaluru
Now go to the "Front Panel" and then go to the Controls-> Modern-> Numeric-> Vertical Pointer.
By doing this, you can see the following figure in your PC's screen:
62 | P a g e
RV Institute of Technology and Management, Bengaluru
63 | P a g e
RV Institute of Technology and Management, Bengaluru
Put the "Cursor" on the "Vertical Pointer", press click and then move up and down.
Blue color indicates the value or rate at which we want to fill the tank
64 | P a g e
RV Institute of Technology and Management, Bengaluru
So now, you have selected both the tank and the vertical pointer and you can see that it looks like the figure
below:
You can see the "Block Diagram" window is looking like the below figure
65 | P a g e
RV Institute of Technology and Management, Bengaluru
Now, since we want to control the level of the water in the tank with the help of the vertical pointer by
Take a wire from the output terminal of the vertical pointer (Slide) and connect it to the input terminal of the
tank
66 | P a g e
RV Institute of Technology and Management, Bengaluru
No we have to set the upper and lower level for the less and high amount of water indication
We need to put two LED's, one for the upper level indication and the second for the lower level indication
67 | P a g e
RV Institute of Technology and Management, Bengaluru
Connect its first input terminal with the output terminal of the "Vertical Pointer"
Go to the second input terminal of the "Greater or Equal" press "Right Click"
Go to the Create->Constant
68 | P a g e
RV Institute of Technology and Management, Bengaluru
69 | P a g e
RV Institute of Technology and Management, Bengaluru
Now we have to put an LED in the "Front Panel" for the upper level indication
70 | P a g e
RV Institute of Technology and Management, Bengaluru
Select the LED and place it onto the "Front Panel" with the top right corner of the tank
71 | P a g e
RV Institute of Technology and Management, Bengaluru
Connect the output terminal of the "Greater or Equal" to the input terminal of the "LED" as shown below
72 | P a g e
RV Institute of Technology and Management, Bengaluru
You can see, as the vertical pointer moves up from the desired upper which is "9" in this case, limit LED turns
on
73 | P a g e
RV Institute of Technology and Management, Bengaluru
select this block and connects one of its inputs to the "Vertical Pointer".
Go to Create-> Constant.
74 | P a g e
RV Institute of Technology and Management, Bengaluru
Set the constant, in this case I have set it to "2" as shown below:
In "Block Diagram" window connect the LED with the "Less or Equal" block
75 | P a g e
RV Institute of Technology and Management, Bengaluru
If you want that your program should no terminate until you did it by yourself then follow the below steps
76 | P a g e
RV Institute of Technology and Management, Bengaluru
Connect this button with the "RED" small circle at the bottom right corner of the "While Loop" as shown
Complete "Block Diagram" logic of making water level detector is shown below
77 | P a g e
RV Institute of Technology and Management, Bengaluru
78 | P a g e
RV Institute of Technology and Management, Bengaluru
Exp No: 12
Demonstrate how to create a basic VI which calculates the area and perimeter of a circle
The following exercise will demonstrate how to create a basic VI which calculates the area and
perimeter of a circle, given its radius r.
1. Open LabVIEW.
2. Open a new VI by clicking on Blank VI in the LabVIEW Getting Started window.
79 | P a g e
RV Institute of Technology and Management, Bengaluru
• Right-click on the front panel to open the Controlspalette, and put down a Numeric Control
from the Modern → Numeric subpalette, as shown in Figure 4.
• Double-click on the label for this control and rename it to r.
• Place down two numeric indicators from the Modern → Numeric subpalette and rename them
Area and Perimeter.
• You can change the font of the labels using the font drop-down menu near the menu
bar, as shown in Figure 5.
80 | P a g e
RV Institute of Technology and Management, Bengaluru
5. Open Context Help using the key combination Ctrl-H. When you hover over any block or con-
nector, the Context Help will provide a brief description of its function or its type, depending on
context. This will prove very helpful in creating VIs.
6. Create the block diagram for this VI as shown in Figure 6.
• Right-click on the block diagram to open the Functions palette and place down the
necessary mathematical functions from the Programming → Numeric subpalette, as shown
in Figure 7.
If you will be using a right-click menu frequently, as you did just now, you can ‘pin’ the menudown by
clicking on the button that resembles a pushpin ( ) on the top left corner of the menu. Also, clicking on
the Searchbutton causes the search functionality to persist.
81 | P a g e
RV Institute of Technology and Management, Bengaluru
•Place down the necessary constants from the Programming→ Numeric → Math Constants
subpalette, as shown in Figure 8.
The key combination Ctrl-E will help you toggle quickly between the front
panel and the block diagram.
8. Select the Highlight Execution button in the toolbar of the block diagram ( ),
and run the VI while viewing the block diagram. Notice how data flows from left
to right through the block diagram and gets processed by each block. Deselect the
button when done.
82 | P a g e