Virtual Instrumentation Lab: 18EIL67
Program 1
Basic operations using LabVIEW.
Aim: To build a Programming structure in LabVIEW for the following basic operations.
a. Boolean operation.
b. Basic arithmetic operation
c. Sum of n numbers using for loop
d. Sorting even numbers using while loop in an array
a. Boolean operation
Front panel
Block Diagram
Procedure:
1. Find the LabVIEW icon on desktop, double click>> New VI.
2. Two panel will open, Front panel and block diagram.
3. In front panel right click>> control >>Modren->Boolean>> push button (push button
appears on both panel) select push button and name as A, B.
4. In Block diagram right click >>function>>programming>>Boolean (find the Boolean
icon for AND OR, XOR…..etc) place the icons and do the connection.
5. Insert while loop: In block diagram right click>>structures>>while loop (select the
area and place it)
8
Dept. of Electronics & Instrumentation Engineering., Dr. AIT, B’lore-56
Virtual Instrumentation Lab: 18EIL67
A While Loop is structure you use to execute a block of code repeatedly until a given condition
is met. When the VI runs, the code inside the While Loop executes, and then the terminal
condition is evaluated.
6. Find the loop condition inside the loop>> right click>> create control.
7. Save the program with prog1a.vi
8. In front panel>> click Run.
b. Basic airithmetic operation
Front Panel
Block Diagram
Procedure:
1. Consider the Qyadratic equation to find the roots.
2. Open the new VI, in front panel >> right click>> control>>Numeric>>Numeric
control
( select three numeric control and name as A, B, C).
3. In block diagram window,right click>>programming>>Neumeric: select the
appropriate mathamatical operation to perform the calculation.
4. Rigup the connection as required.
5. Right click on Divide to select indicator( r1,r2)
6. Save the program as prog1b.vi
7. In front panel>> click Run
9
Dept. of Electronics & Instrumentation Engineering., Dr. AIT, B’lore-56
Virtual Instrumentation Lab: 18EIL67
c. Sum of n Numbers using for loop
Front Panel
Block Diagram
Procedure
1. Open new VI. In front panel>>Right click>>Control>> Modren>>Data
container>>Array (select and place in the window)
2. Again, Right click>>Modern>>Numeric>>Numeric control (place it inside the array
block).
3. In block diagram >>program>>structure>> for loop (fix it in the screen). Then inside
the loop right click>> numeric>>Add.
A For Loop is a structure you use to execute a block of code a set number of times. When
the VI runs, the iteration count is evaluated, and then the code is executed. A For Loop can be
configured to conditionally stop code execution in addition to its iteration-based exit.
4. Connect ‘Add’ output terminal to right edge of loop and right click>>replace with shift
register (shift register symbol appears on both side of the loop). Left side on shift
register symbol right click>>create constant and connect to Add. Also Connect array
output to add.
5. To find number of elements in array, on block diagram >>program>>array>> Array
size, connect to both input array and indicator.
6. To fine average, on block diagram>>program>>numeric>>divide (connect sum and
size as input. Right click on output terminal of divide>>create indicator.
7. Save as prog1cand Run the VI.
Result:
10
Dept. of Electronics & Instrumentation Engineering., Dr. AIT, B’lore-56