Labview Lab Manual

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

RV Institute of Technology and Management, Bengaluru

Rashtreeya Sikshana Samithi Trust's


Rashtreeya Vidyalaya Institute of Technology and
Management (RVITM), Bengaluru

SEMESTER-III
LABVIEW PROGRAMMING BASICS
(21EC384)

Prepared by

1. Dr. Prashant P Patavardhan


2. Dr. Vikash Kumar
3. Dr. Venu Gopal B T

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


1|Page
RV Institute of Technology and Management, Bengaluru

List of Experiments

1. BASIC ARITHMETIC OPERATIONS: ADDITION, SUBTRACTION,


MULTIPLICATION AND DIVISION

2. BOOLEAN OPERATIONS: AND, OR, XOR, NOT and NAND

3. SUM OF ‘n’ NUMBERS USING ‘FOR’ LOOP


4. FACTORIAL OF A GIVE NUMBER USING FOR LOOP

5. DETERMINE SQUARE OF A GIVEN NUMBER

6. FACTORIAL OF A GIVE NUMBER USING WHILE LOOP


7. SORTING EVEN NUMBERS USING WHILE LOOP IN AN ARRAY

8. FINDING THE ARRAY MAXIMUM AND MINIMUM

9. BUILD A VIRTUAL INSTRUMENT THAT SIMULATES A HEATING AND COOLING


SYSTEM. THE SYSTEM MUST BE ABLE TO BE CONTROLLED MANUALLY OR
AUTOMATICALLY

10. BUILD A VIRTUAL INSTRUMENT THAT SIMULATES A BASIC CALCULATOR


(USING FORMULA NODE).

11. BUILD A VIRTUAL INSTRUMENT THAT SIMULATES A WATER LEVEL


DETECTOR.

12. DEMONSTRATE HOW TO CREATE A BASIC VI WHICH CALCULATES THE AREA


AND PERIMETER OF A CIRCLE.

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.

Figure 1: Front Panel (Left) and Back Panel (Right)


The front panel is built using controls and indicators. Controls are inputs that allow a user to supply
information to the VI. Indicators are outputs that display the results based on the inputs given to the
VI. Controls can be switches, knobs, dials, and buttons. Indicators can be meters, gauges, LEDs, and
displays. These are located on the Controls palette and are placed on the front panel (Figure 2).

3|Page
RV Institute of Technology and Management, Bengaluru

Figure 2: Controls Palette


The back panel, which is also known as the block diagram, contains the graphic-based source code.
The environment of the back panel is navigated using the Tools palette (Figure 3).

Figure 3: Tools Palette


In Figure 3, only the icons in colored boxed will be used in this experiment. The operating
tool changes the value of a control (such as a switch or LED). The positioning tool positions, resizes,
and selects objects. The labeling tool is used to create and edit all labels in the VI, such as the name of
a Boolean control. The wiring tool wires objects together on the back panel. The scrolling tool allows
scrolling the window by clicking and dragging.

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.

Figure 4: Control and Indicator Terminals


The back panel also contains structures and functions that perform operations on controls and supply
data to indicators. Structures and functions are found on the Functions palette and are placed on the
back panel (Figure 5).

5|Page
RV Institute of Technology and Management, Bengaluru

Figure 5: Functions Palette


Structures are process control elements, such as while loops and for loops. The structure to be used in
this experiment is the case structure (Figure 6), which is essentially multiple if-statements. A case
structure contains multiple subdiagrams (or cases), and a case will be executed depending on the input
to the case structure.

6|Page
RV Institute of Technology and Management, Bengaluru

Figure 6: Case Structure


In Figure 6, Item 1 is the selector label, which displays the input value for which the associated case
will execute. The black arrows on the side of the selector label toggle between the different cases. Item
2 is the area for the code that executes for the specific input in the selector label. When the selector
label is toggled, the code in this area will also change. Item 3 is the case selector, which gives the input
value to the case structure. The data type that is wired to the case selector will determine the possible
cases. For example, if a Boolean data type is wired to the case selector, the possible cases will only be
true and false.
Functions are the fundamental operating elements of LabVIEW, and have input and output terminals
to pass data in and out. They are indicated by a pale yellow background in the icon (Figure 7).

Figure 7: Examples of Functions


Functions have a certain number of inputs and outputs, depending on the type of function. For
example, the addition function (leftmost icon in Figure 7) has two inputs as it will add the two inputs
together, and it will have one output, which is the sum of the inputs. The inputs are wired to the left
side of the function, and the outputs are wired to the right side of the function. The number of inputs
and outputs of a function can be observed by hovering over the icon with the wiring tool and observing
the terminals that appear (Figure 8).

Figure 8: Function Terminals

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).

Figure 9: Wiring Nodes


The toolbar at the top of the front panel is used to execute and stop the program (Figure 10). The run
tool (white arrow) runs the program once. The run continuously tool (two white arrows in a circle)
keeps the program running continuously until the program is paused or stopped. This tool should be
used when executing programs in this experiment. The abort execution tool (red stop sign) stops the VI
immediately. The pause button (two vertical black rectangles) pauses the program, and can be clicked
again to continue the program.

Figure 10: Toolbar


National Instruments' Educational Laboratory Virtual Instrumentation Suite (NI ELVIS)
board (Figure 11) is one solution LabVIEW can utilize to physically interface with external devices. It
is a modular engineering device that includes a breadboard, power supply, ground, thermocouple,
oscilloscope, function analyzer, and other common lab instruments. In this experiment, an NI ELVIS
board will be used to provide inputs and display outputs for the VIs that will be created.

Figure 11: NI ELVIS II+ Board

8|Page
RV Institute of Technology and Management, Bengaluru

Materials and Equipment


 Lab PC
 LabVIEW 2019 software
 NI ELVIS II+ prototyping board
 Wires
 Two 100 kΩ resistors (brown, black, yellow)

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.

Figure 12: LabVIEW Workspace


For help with the operation of any LabVIEW icon, select Help > Show Context Help > click the icon
for the operation that is unclear. It will be explained in the Context Help window.

9|Page
RV Institute of Technology and Management, Bengaluru

Exp No: 1

BASIC ARITHMETIC OPERATIONS: ADDITION,


SUBTRACTION, MULTIPLICATION AND DIVISION

Aim: To perform basic arithmetic operations using Labview.

Algorithm:
Step 1: Start the Lab view and select the blank VI.

Step 2: Create front and block diagram panel.

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 4: Different arithmetic operators such as addition, subtraction, multiplication


and division are generated in block diagram 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

Block Diagram Panel:

11 | P a g e
RV Institute of Technology and Management, Bengaluru

Front Panel:

Input:

Output:

Result:

Thus the arithmetic operations were performed and the result is


verified using lab view.
12 | P a g e
RV Institute of Technology and Management, Bengaluru

Exp No: 2

BOOLEAN OPERATIONS: AND, OR, XOR,


NOT and NAND

Aim: To perform Boolean operations using Labview.


Algorithm:
Step 1: Start the Labview and select the blank VI.

Step 2: Create front and block diagram panel.

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

RESULT: Thus the Boolean operation using LAB view is performed.


17 | P a g e
RV Institute of Technology and Management, Bengaluru

Exp No: 3

SUM OF ‘n’ NUMBERS USING ‘FOR’ LOOP

Aim: To find the sum of ‘n’ numbers using FOR loop.


Algorithm:
Step 1: Create blank VI.

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

FACTORIAL OF A GIVEN NUMBER USING FOR LOOP

Aim: To perform the factorial of a given number using FOR loop.


Algorithm:
Step 1: Create blank VI.

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

Block diagram panel:

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

DETERMINE SQUARE OF A GIVEN NUMBER

Aim: To determine the square of a given number.


Algorithm:
Step 1: Start the Lab view and select the blank VI.

Step 2: Create front and block diagram panel.

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 4: Square is generated in block diagram 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.

24 | P a g e
RV Institute of Technology and Management, Bengaluru

Block diagram panel:

FRONT PANEL:
Input:

Output:

Result: Thus the square of given numbers calculation experiment is


performed.

25 | P a g e
RV Institute of Technology and Management, Bengaluru

Exp No:6

FACTORIAL OF A GIVEN NUMBER USING


WHILELOOP

Aim: To perform the factorial of a given number using WHILE loop.


Algorithm:
Step 1: Create blank VI.

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

Block diagram panel:

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

SORTING EVEN NUMBERS USING WHILE LOOP IN


AN ARRAY

Aim: To sort even numbers using WHILE loop in an array.


Algorithm:
Step 1: Create blank VI.

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 4: Add the numeric control in the front panel.

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

Block diagram panel:

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

ARRAY MAXIMUM AND MINIMUM

Aim: To find the maximum and minimum variable from an array.


Algorithm:
Step 1: Create blank VI.

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

Block diagram panel:

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.

 Must be able to be controlled automatically or manually


 In manual mode, the heater and air conditioning (AC) can be switched on/off by the user
 In automatic mode, the heater and AC turn on/off based on the following conditions:
o The air conditioner is turned on when the temperature is above 80°F
o The heater is turned on when the temperature is below 60°F
o The heater and the air conditioner are turned off when the temperature is between 60°F and
80°F

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.

Figure 1: Slide Switches and Round LEDs in the Controls Palette


2. Rename the LEDs and their corresponding switches "Manual," "AC," and "Heater" to make
building the system clearer (Figure 2). This can be done by using the editing text tool in the
Tools palette.

35 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 2: Named Switches and LEDs in the Front Panel


3. Drag and drop a thermometer (Figure 3) into the front panel (Controls palette > Modern tab >
Numeric > Thermometer).

Figure 3: Thermometer Control


4. In the back panel, right click the thermometer terminal and select Change to Control, and
observe how the arrow switches from the left side to the right side (Figure 4). This makes the
thermometer a control that will give an input to the program, which in this case is temperature.

36 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 4: Indicator (Left) vs Control (Right)


5. In the back panel, insert a case structure to control the manual and automatic operation of the
heating and cooling system (Functions palette > Structures > Case Structure). To place the case
structure, click once to place one corner of the case structure, and once more to place the other
corner of the case structure (Figure 5).

Figure 5: Case Structure


6. Wire the slide switch designated as Manual to the case selector on the case structure (Figure 6).
This should automatically change the selector label values to True and False, if they were not
already, because the slide switch is a Boolean data type. The true value corresponds to manual
mode being on (where the user can directly toggle the heater and AC), while the false value
corresponds to manual mode being off (where the heater and AC are automatically toggled by
the system).

37 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 6: Manual Switch as Case Selector


7. Because the temperature of the room is input into the system only when the system is not in
manual mode (the false case), the thermometer terminal should be moved into the false
subdiagram (Figure 7).

Figure 7: Thermometer in the False Subdiagram


8. In the true subdiagram, wire the AC and heater switches directly to their corresponding LEDs
(Figure 8). This allows the switches to directly toggle their corresponding LEDs.

38 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 8: Wiring the Switches to the LEDs


9. Staying in the true subdiagram, insert a True Constant (Functions palette > Programming tab >
Boolean > True Constant). Wire the true constant to the manual LED to turn the manual LED
on and indicate that the system is in manual mode (Figure 9).

Figure 9: Subdiagram for True Case


10. In the false subdiagram, insert two Numeric Constants (Functions palette > Programming >
Numeric > Numeric Constant), one Greater? function and one Less? function (Functions
palette > Programming > Comparison). These will be used to build the program for the heating
and cooling system in automatic mode (Figure 10).

39 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 10: Terminals for False Subdiagram


11. The less and greater functions compare what is wired to the upper input terminal to what is
wired to the lower input terminal. Wire the thermometer to the upper input terminals of the less
and greater functions. Set a numeric constant to 60 and the other to 80. Wire the 60 numeric
constant to the lower input terminal of the less function and the 80 numeric constant to the
lower input terminal of the greater function. Wire the output terminal of the greater function to
the AC LED and wire the output of the less function to the heater LED (Figure 11).

Figure 11: Wiring to Heater and AC LEDs


12. In the false subdiagram, Insert a False Constant (Functions palette > Programming > Boolean >
False Constant) and wire it to the manual LED (Figure 12). This is to turn off the manual LED
and indicate that the system is in automatic mode.

40 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 12: Subdiagram for False Case


13. The system is now complete. Click the continuously run button to control and test the VI. If the
continuously run button is faded out, that means the system is wired completely. When
successfully running the system, the gridlines in the background of the front panel should
disappear (Figure 13). Click the switches and thermometer on the front panel to test the
system.

Figure 13: Running Heating and Cooling System


Have a TA check the VI. Once testing is complete, take a screenshot of the VI. Save the heating and
cooling system as a VI file (saving the file will save both the front panel and back panel in one file).

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.

1. The front panel must contain:


a. One slide to control the arithmetic operation to be performed. The instructions are:
i. Select the Numeric icon under Modern on the controls palette (see Figure 1).
This will bring up the window shown in Figure 2.

Figure 1: Controls palette.

42 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 2: Modern numeric controls.

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.

Figure 3: Slide control with range changed from 10 to 2.

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.

Figure 4: Data type representation pull down menu.

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.

Figure 5: Modern boolean controls.

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.

ii. The finished front panel should look like Figure 6:

Figure 6: Finished front panel.


2. As stated earlier, on the back panel there are icons corresponding to everything that was placed
on the front panel. They will be arranged, additional objects will be added, and they will be
wired to make the calculator work.
3. The back panel must contain:
a. At least one case statement to control the arithmetic operations. This case statement will
be the heart of the calculator. The instructions are:
i. Drag all the Boolean nodes to the right edge of the window and all numeric
controls and indicator to the bottom of the window. Place the slide node on the
left edge of the window. This will leave a large area in the middle that will be
filled in at the next few steps. The back panel should look like Figure 7.

46 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 7: Rearranged back panel.

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

Figure 8: Functions palette.

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

Figure 9: Programming structure functions.

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.

Figure 10: Back panel slide to case structure connection.

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

Figure 11: Adding another case.

vii. Now add the mathematical operations that the calculator should perform for

each case. On the functions palette, click on the Numeric icon


under Programming from the main functions palette. This will bring up the
window shown in Figure 12.

51 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 12: Numeric programming functions.

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.

Figure 13a: Case structure: addition case.

Figure 13b: Case structure: subtraction case.

53 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 13c: Case structure: multiplication case.

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

Figure 14: Completed back panel for addition.


Note: Tunnels are created where the input and output wires cross into and out of the case
structure; they are signified by squares along the border of the case structure where the wires
cross the border. Input wires create complete tunnels, but output wires create tunnels that are
incomplete. To complete output tunnels, there must be an output wired to the tunnel for each
case of the case structure.

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

the functions palette, under Programming, click on the Boolean icon ,


which will bring up the Boolean Programming window shown in Figure 15.

Figure 15: Boolean programming functions.

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

Figure 16: Completed and working VI.

5. Once testing is completed, take a screenshot the VI.


6. Save the VI.

58 | P a g e
RV Institute of Technology and Management, Bengaluru

Exp No: 11

Build a Virtual Instrument that simulates a Water Level Detector


You can see the list of these components below
 Tank

 Vertical Pointer

 Upper Level Indicator

 Lower Level Indicator

 Graph to observe the results

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.

 Now, go to the Controls-> Modern-> Numeric-> Tank.

 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

 You can see different blocks in the above figure

 Select the encircled "Tank" and place it on the "Front Panel"

 It looks like the below figure

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

different click on the tank

 You can see the above step in the figure below:

61 | P a g e
RV Institute of Technology and Management, Bengaluru

 Blue color show the level of the water in the tank.

 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

 You can see different blocks in the above figure.

 Select the encircled block i.e. "Vertical Pointer".

 Place this block on the "Front Panel".

 It is looking like the figure below:

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.

 It looks like the figure below:

 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:

 Now press "Ctril+T"

 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

adjusting it at different positions

 So, we have to build a connection between them

 Take a wire from the output terminal of the vertical pointer (Slide) and connect it to the input terminal of the

tank

 The figure below exhibits the above steps

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

Upper Level Indicator

 Press "Click" on the "Block Diagram" window

 Go to the Functions-> Programming-> Comparison-> Greater or Equal?

 Figure displays the above steps

67 | P a g e
RV Institute of Technology and Management, Bengaluru

 Select and place this block on the "Block Diagram" window

 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

 The figures below displays the above steps

68 | P a g e
RV Institute of Technology and Management, Bengaluru

 Set the value of the constant as "9"

 The figure shows the adjusted value of the "Constant"

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

 Press "Right Click" on the "Front Panel"

 Go to the Controls-> Modern-> Boolean-> Square LED

 The figure below shows all of the above steps

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

 Figure elaborates a bit more

71 | P a g e
RV Institute of Technology and Management, Bengaluru

 Now, Go to the "Block Diagram" window again

 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

 Now go back to the "Front Panel"

 You can see, as the vertical pointer moves up from the desired upper which is "9" in this case, limit LED turns

on

 Here is the screenshot of the "ON" LED

73 | P a g e
RV Institute of Technology and Management, Bengaluru

Lower Level Indicator

 As the upper limit is adjusted above.

 Similarly set the lower limit.

 Go to the "Block Diagram" window and press "Right Click".

 Go to Functions-> Programming-> Comparison-> Less or Equal.

 select this block and connects one of its inputs to the "Vertical Pointer".

 Go to the second input and press "Right Click".

 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:

 Place and LED in " Front Panel"

 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

 Now, Go to the "Front Panel" and press "Right Click"

 Go to Functions-> Programming-> Structures-> While Loop

 Select and place it on the "Block Diagram" window

 Place the whole program inside the "While Loop"

76 | P a g e
RV Institute of Technology and Management, Bengaluru

 Now, go to the "Front Panel" and press "Right Click"

 Go to Controls-> Modern-> Boolean-> Stop Button

 Select and place it on the "Front Panel"

 Now, go to the "Block Diagram" window

 Connect this button with the "RED" small circle at the bottom right corner of the "While Loop" as shown

below in the figure

 Complete "Block Diagram" logic of making water level detector is shown below

77 | P a g e
RV Institute of Technology and Management, Bengaluru

 Complete output of the water level detector is shown below

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.

3. Save the VI as Circle Area Perimeter.vi:

• Select File → Save.

Figure 1 : Controls Palette

79 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 2 : Functions Palette

• Navigate to the location where you wish to save the VI.


• Name the VI Circle Area Perimeter.vi.
• Click OK.

Figure 3: Circle Area Perimeter.viFront Panel

4. Create the front panel in Figure 3.

• 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.

Note the distinction between an indicator and a control. A control


receives input, while an indicator displays output.

80 | P a g e
RV Institute of Technology and Management, Bengaluru

Figure 4 : Numeric Subpalette from the Controls Palette

Figure 5: Font Drop-Down Menu

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.

Figure 6: Circle Area Perimeter. viBlock Diagram

• 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

Figure 7: Numeric Subpalette from the Functions Palette

•Place down the necessary constants from the Programming→ Numeric → Math Constants
subpalette, as shown in Figure 8.

Figure 8: Math Constants Subpalette from the Functions Palette

• Wire the functions as shown in Figure 6.

The key combination Ctrl-E will help you toggle quickly between the front
panel and the block diagram.

7. Run the VI and verify its operation.


• Click on the numeric control rand set its value to 1.5.
• Run the application by clicking on the Run button. ( )
• Verify that the area and perimeter indicators return the correct result.
• Run the VI for different values of r and verify its operation.

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

You might also like