Professional Documents
Culture Documents
LabVIEW Programming
USN:___________________________________________________________
Branch:______________________________Section:____________________
ACHARYA INSTITUTE OF TECHNOLOGY
LabVIEW Programming
Approved By:
Dr. Rajeswari
Head of Department of Electronics & Communication Engineering,
AIT, Acharya, Bangalore -107
ACHARYA INSTITUTE OF TECHNOLOGY
MOTTO
"Nurturing Aspirations Supporting Growth"
VISION
“Acharya Institute of Technology, committed to the cause of sustainable value-based
education in all disciplines, envisions itself as a global fountainhead of innovative
human enterprise, with inspirational initiatives for Academic Excellence”.
MISSION
“Acharya Institute of Technology strives to provide excellent academic ambiance to the
students for achieving global standards of technical education, foster intellectual and
personal development, meaningful research and ethical service to sustainable societal
needs.”
LIST OF EXPERIMENTS
Demonstration experiments
9 Build a Virtual instrument that simulates a heating and cooling system .The system
mustbe able to be controlled manually or automatically.
12 Demonstrate how to create basic VI which calculates area and perimeter of a circle.
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
COURSE OBJECTIVES:
• Aware of various front panel controls and indicators.
• Connect and manipulate nodes and wires in the block diagram.
• Locate various toolbars and pull down menus for the purpose of implementing specific
functions.
• Locate and utilize the context help window.
• Familiar with LabVIEW and different applications using it.
• Run a virtual instrument(VI).
R A G H U N A T H
COURSE OUTCOMES:
At the end of the course the student will be able to :
1. Use LabVIEW to create data acquisition , analysis and display oerations.
2. Create user interfaces with charts ,graphs and buttons.
3. Use the programming structures and data types that exist in Lab VIEW.
4.Use various editing and debugging techniques.
Dept Of ECE 2
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
LIST OF EXPERIMENTS
Demonstration experiments
9 Build a Virtual instrument that simulates a heating and cooling system .The system must
be able to be controlled manually or automatically.
12 Demonstrate how to create basic VI which calculates area and perimeter of a circle.
Dept Of ECE 3
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
Introduction to LabVIEW
Virtual Instrumentation:
Virtual instrumentation is the use of customizable software and modular measurement
hardware to create user-defined measurement systems, called virtual instruments. Traditional
hardware instrumentation systems are made up of pre-defined hardware components, such as
digital multimeters and oscilloscopes that are completely specific to their stimulus, analysis, or
measurement function. Because of their hard-coded function, these systems are more limited
in their versatility than virtual instrumentation systems. The primary difference between
hardware instrumentation and virtual instrumentation is that software is used to replace a large
amount of hardware. The software enables complex and expensive hardware to be replaced by
already purchased computer hardware; e. g. analog-to-digital converter can act as a hardware
complement of a virtual oscilloscope, a potentiostat enables frequency response acquisition
and analysis in electrochemical impedance spectroscopy with virtual instrumentation.
R A G H U N A T H
LabVIEW
Laboratory Virtual Instrumentation Engineering Workbench (LabVIEW) is a graphical
programming language that uses icons instead of lines of text to create applications. In contrast
to text-based programming languages, where instructions determine program execution,
LabVIEW uses dataflow programming, where the flow of data determines execution. In
LabVIEW, a user interface can be build by using a set of tools and objects. The user interface
is known as the front panel. Then code can be added using graphical representations of
functions to control the front panel objects. The block diagram contains this code. In some
ways, the block diagram resembles a flowchart.
LabVIEW programs are one of the suitable for virtual instruments, or VIs, because their
appearance and operation imitate physical instruments, such as oscilloscopes and multimeters.
Every VI uses functions that manipulate input from the user interface or other sources and
display that information or move it to other files or other computers.
A VI contains the following three components:
Front panel - Serves as the user interface. Fig 1 shows front panel example.
Block diagram - Contains the graphical source code that defines the functionality of the VI.
Icon and connector panel - Identifies the VI so that the VI can be used in another VI. A VI
within another VI is called a subVI. A subVI corresponds to a subroutine in text-based
programming languages. Fig 2 shows Block diagram of VI programming.
Dept Of ECE 4
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
The front panel is the user interface of the VI. The front panel is build with controls and
indicators, which are the interactive input and output terminals of the VI, respectively. Controls
are knobs, pushbuttons, dials, and other input devices. Indicators are graphs, LEDs, and other
displays. Controls simulate instrument input devices and supply data to the block diagram of
the VI. Indicators simulate instrument output devices and display data the block diagram
acquires or generates. After the front panel is build, add code using graphical representations
of functions to control the front panel objects. The block diagram contains this graphical source
code. Front panel objects appear as terminals on the block diagram.
Additionally, the block diagram contains functions and structures from built-in LabVIEW VI
libraries. Wires connect each of the nodes on the block diagram, including control and indicator
terminals, functions, and structures.
LabVIEW Palettes
LabVIEW palettes give provide the options needed to create and edit the front panel and block
diagram. The Tools palette is available on the front panel and the block diagram. A tool is a
Dept Of ECE 5
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
special operating mode of the mouse cursor. By selecting a tool, the cursor icon changes to the
tool icon. Use the tools to operate and modify front panel and block diagram objects.
Select Window » Show Tools Palette to display the Tools palette.
The Tools palette can be placed anywhere on the screen. If automatic tool selection is enabled
and as the cursor is moved over objects on the front panel or block diagram, LabVIEW
automatically selects the corresponding tool from the Tools palette.
The Controls palette
The Controls palette is available only on the front panel. The Controls palette contains the
controls and indicators used to create the front panel. to display the Controls palette, Select
Window » Show Controls Palette or right-click the front panel workspace. The Controls palette
can be placed anywhere on the screen. Fig 3 shows control pallete.
R A G H U N A T H
Dept Of ECE 6
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
R A G H U N A T H
Advantages of LabVIEW
– Graphical User Interface
– Drag-and-Drop built-in functions
– Modular design and hierarchical design
– Multiple high level development tools
– Professional Development Tools
– Multi platforms
– Reduces cost and preserves investment
– Flexibility and scalability
– Connectivity and instrument control
Creating a VI
Launch Labview: Fig 5 shows front and block diagram panel of LabVIEW files.
Dept Of ECE 7
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
R A G H U N A T H
Block Diagram
Terminals
– Front panel object appear as terminals on the block diagram.
– Terminals are entry and exit ports that exchange information between the front panel
and block diagram.
– Terminals are analogous to parameters and constants in text-based programming
languages. Types of terminals include control or indicator terminals and node terminals.
– Control and indicator terminals belong to front panel controls and indicators.
– Data you enter into the front panel controls enter the block diagram through the control
terminals.
– The terminals represent the data type of the control or indicator.
– You can configure front panel controls or indicators to appear as icon or data type
terminals on the block diagram.
– By default, front panel objects appear as icon terminals.
Dept Of ECE 8
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
– To display a terminal as a data type on the block diagram, right-click the terminal and
select View As Icon from the shortcut menu
Wires
– You can transfer data among block diagram objects through wires.
– Each wire has a single data source, but you can wire it to many VIs and functions that
read the data.
– Wires are different colors, styles and thicknesses, depending on their data types.
– A broken wire appears as a dashed black line with a red X in the middle.
– Broken wires occur for a variety of reasons, such as when you try to wire two objects
with incompatible data types.
– You must connect the wires to inputs and outputs that are compatible with the data that
is transferred with the wire.
– You cannot wire an array output to a numeric input.
– In addition, the direction of the wires must be correct. You must connect the wires to
only one input and at least one output.
– You cannot wire two indicators together
R A G H U N A T H
– <Ctrl+B> to delete all broken wires or right click and select Clean Up Wire to reroute
the wire.
Review Questions.
What is virtual instrumentation?
What are the different palettes in VI?
What is sub VI?
What are the advantages of VI?
Compare hardware instrumentation and VI
Dept Of ECE 9
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
EXPERIMENT 1
ARITHMETIC OPERATIONS
AIM:
To perform basic arithmetic operations using LabVIEW.
Addition, Subtraction, Multiplication and division.
THEORY:
To give the 2 inputs numeric controls are selected in Front panel .And all arithmetic operators
can be selected from Functions palette. Addition, subtraction, multiplication and division are
the basic arithmetic operations.
R A G H U N A T H
PROCEDURE:
Step 1: Start the LabVIEW 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.
Dept Of ECE 10
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
BLOCK DIAGRAM:
The block diagram for basic arithmetic operations using LabVIEW is shown below in Fig.1.1.
R A G H U N A T H
OUTPUT/FRONT PANEL:
Output of basic arithmetic operations is shown in below fig 1.2.
Dept Of ECE 11
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
RESULT:
The arithmetic operations were performed and the result is verified using LabVIEW.
Viva questions:
1. What are the advantages of LabVIEW?
3. What is the difference between local variable and global variable in LabVIEW?
R A G H U N A T H
Dept Of ECE 12
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
EXPERIMENT 2
BOOLEAN OPERATIONS
AIM:
To perform Boolean operations using LabVIEW.
AND,OR,NOT,XOR , NAND
THEORY:
The truth table of Boolean operations like AND, OR,NOT,XOR ,and NAND is shown below
in Fig 2.1.The Boolean inputs are given by push buttons in the control palette .All the Boolean
operators can be taken from the functions palette.
R A G H U N A T H
PROCEDURE:
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.
Dept Of ECE 13
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
Step 6: Logic values 0 & 1 are given in the front panel and the program is executed.
BLOCK DIAGRAM:
The block diagram of Boolean operations is shown below in Fig.2.2.
R A G H U N A T H
OUTPUT/FRONT PANEL:
The output of Boolean operations is shown below in Fig.2.3.
Dept Of ECE 14
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
R A G H U N A T H
RESULT:
The Boolean operation using LabVIEW is performed.
VIVA QUESTIONS:
1. Is LabVIEW a compiled programming language?
3.What is LabVIEW?
Dept Of ECE 15
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
EXPERIMENT 3
SUM OF N NUMBERS USING FOR LOOP
AIM:
To find the sum of ‘n’ numbers using FOR loop.
THEORY:
Usually sum of n numbers, we take for natural numbers.The equation to calculate sum of n
numbers is n(n+1)/2.So we want to take sum of first 3 numbers, n=3.Then as per the equation
it becomes 3(4)/2=6.i.e 3+2+1=6.
FOR loop in LabVIEW is shown below in Fig 3.1.
R A G H U N A T H
PROEDURE:
Step 1: Create blank VI.
Step 2: First of all move to the front panel and press right then control palette and choose
numeric option place in the front panel and its correspondent will shown block diagram.
Step 3:Right click on the block diagram panel, select program , go to structures and select a
FOR loop.
Step 4: Right click on the border of the FOR loop and select add shift register, borders are
converted into shift register.
Step 5: In block diagrams select the numeric button and choose constant and connect it to
register.
Step 6: Select the add button from the numeric tab. Then select the increment option from the
numeric tab .Connect the output of this increment block to the remaining input of the add block.
Step 7: At the right shift register click right and from the drop down select create and then
select indicator .
Step 8:Inputs are given in the front panel and the program is executed.
Dept Of ECE 16
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
BLOCK DIAGRAM:
The block diagram of sum of n numbers using FOR loop is shown in Fig 3.2 below.
R A G H U N A T H
OUTPUT/FRONT PANEL:
The output or the front panel view of sum of n numbers using FOR loop is shown below in Fig
3.3.
Dept Of ECE 17
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
RESULT:
R A G H U N A T H
Thus the sum of ‘n’ natural numbers using FOR loop is performed in LabVIEW.
VIVA QUESTIONS:
1.What is shift register?How is it implemented in Lab VIEW?
2.Can LabVIEW Vis be merged?
3. What is LabVIEW signal express?
Dept Of ECE 18
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
EXPERIMENT 4
FACTORIAL OF A NUMBER
AIM:
To perform the factorial of a given number using FOR loop.
THEORY:
Factorial is an important function, which is used to find how many ways things can be arranged
or the ordered set of numbers. The factorial concept is used in many mathematical concepts
such as probability, permutations and combinations, sequences and series, etc. In short, a
factorial is a function that multiplies a number by every number below it till 1. For example,
the factorial of 3 represents the multiplication of numbers 3, 2, 1, i.e. 3! = 3 × 2 × 1 and is equal
to 6.
R A G H U N A T H
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. In these
cases, the code will execute until the count terminal setting is reached or the condition is met
– whichever happens first.The structure of FOR loop in LabVIEW is shown below in Fig.4.1.
In FOR loop structure , N is the count and I is the iteration value. Initial value of I is zero.
PROCEDURE
Step 1: Create blank VI.
Step 2: Click right on the front panel from the control palette selects numeric and then
selects control .
Step 3: Right click on the block diagram panel , select program , go to structures and select a
FOR loop.
Dept Of ECE 19
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
Step 4: Connect the numeric control in which the user input will be stored to the N. Right click
on the border of the FOR loop and select add shift register, borders are converted into shift
register.
Step 5: To initialize the shift register, from the function palette select numeric and then select
constant. Place this numeric with the shift register and set its value to 1.
Step 6: For the multiplication task place a multiply block, from the function
palette select numeric and then select multiply. At one of the two inputs of the multiply block
connect the right shift register, and the output of this block connect the right shift register.
Step 7: On the other input of the multiply block we have to connect the incremented iteration
because the number of iterations start from 0 but we want the factorial from 1 onwards, because
the factorial will turn out to be zero otherwise. From the function palette select numeric and
then select increment.
Step 8: At the input of this increment block connect the iterative index of the for loop, and
R A G H U N A T H
connect the output of this increment block to the remaining input of the multiply block.
Step 9: At the right shift register click right and from the drop down select create and then
select indicator.
Step 10:Inputs are given in the front panel and the program is executed.
BLOCK DIAGRAM:
Block diagram of factorial of a number using FOR loop is given below in Fig.4.2.
Dept Of ECE 20
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
OUTPUT/FRONT PANEL:
The output of factorial of a number using FOR loop is shown below in Fig.4.3.
R A G H U N A T H
RESULT:
The factorial of a given number is using FOR loop is performed in LabVIEW.
VIVA QUESTIONS:
1. How mixed data types are combined and passed from one file or place to the other in
LabVIEW?
2. What is the initial value of iteration count?
3. What is subVI?
4. What is block diagram panel?
5. What is front panel?
Dept Of ECE 21
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
EXPERIMENT 5
DETERMINE SQUARE OF A GIVEN NUMBER
AIM:
To determine Square of a given number using LabVIEW.
THEORY:
The Square root VI computes the square root of the input value. If x is negative, the square root is NaN
unless x is complex. If x is a matrix, this function takes the matrix square root of x. The connector pane
displays the default data types for this polymorphic function. x can be a scalar number, array or cluster
of numbers and array of clusters of numbers. sqrt(x) is a double-precision, floating-point number if x
is an integer. If x is less than 0, sqrt(x) is not a number (NaN).
PROCEDURE:
R A G H U N A T H
BLOCK DIAGRAM:
Block diagram to calculate square and square root of a number is shown below in fig 5.1.
Fig.5.1: To find square root of a number (additionally factorial and square of number is also
shown)
Dept Of ECE 22
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
OUTPUT/FRONT PANEL:
R A G H U N A T H
RESULT:
Square of a given number is determined using LabVIEW.
VIVA QUESTIONS:
1. What is the output of square root block if input is negative number?
2. What is the default data type for input for square root block?
3. Can square root block help in finding roots of a complex number?
4. What is the datatype for integer or floating-point number?
Dept Of ECE 23
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
EXPERIMENT 6
FACTORIAL OF A NUMBER USING WHILE LOOP
AIM :
To find factorial of a number using while Loop in LabVIEW.
THEORY:
Use shift registers when you want to pass values from previous iterations through a loop to the
next iteration. A shift register appears as a pair of terminals, shown as follows, directly opposite
each other on the vertical sides of the loop border. The terminal on the right side of the loop
contains an up arrow and stores data on the completion of an iteration. LabVIEW transfers the
data stored in the right terminal of the shift register to the left terminal. The loop then uses the
R A G H U N A T H
data from the left terminal as the initial values for the next iteration. This process continues
until all iterations of the loop execute. After the loop executes, the terminal on the right side of
the loop returns the last value stored in the shift register. A shift register transfers any data type
and automatically changes to the data type of the first object wired to the shift register. The
data you wire to the terminals of each shift register must be the same type. If you have multiple
operations that use previous iteration values within a loop, use multiple shift registers to store
the data values from those different processes in the structure, as shown in the following block
diagram in Fig 6.1 and 6.2.
PROCEDURE:
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.
Dept Of ECE 24
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
BLOCK DIAGRAM :
R A G H U N A T H
Dept Of ECE 25
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
OUTPUT/FRONT PANEL:
The output or the front panel window view is shown below in fig 6.2.
Fig.6.2 output
RESULT:
Factorial of a number is determined using while loop in LabVIEW.
R A G H U N A T H
VIVA QUESTIONS:
1. What is the role of shift register in the while loop?
2. What is the default data type for factorial block?
3. How to find factorial of integer numbers?
4. Differentiate for loop and while loop.
Dept Of ECE 26
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
EXPERIMENT 7
SORTING EVEN NUMBERS USING WHILE LOOP IN AN
ARRAY
AIM:
To sort even numbers using WHILE loop in an array.
THEORY:
Loops are used for controlling the iteration and execution flow of programs. Charts display
the recent data and update periodically by maintaining a history of the past data.
While Loop
While Loop executes a subdiagram until a condition is met. The While Loop executes the
R A G H U N A T H
subdiagram until the conditional terminal, an input terminal, receives a specific Boolean value.
The default behavior and appearance of the conditional terminal is Continue If True. When a
conditional terminal is Continue If True, the While Loop executes its subdiagram until the
conditional terminal receives a FALSE value. To change the behavior and appearance of the
conditional terminal, right-click on the terminal and select Stop If True. When a conditional
terminal is Stop If True, the While Loop executes its subdiagram until the conditional terminal
receives a TRUE value. Because the VI checks the conditional terminal at the end of each
iteration, the While Loop always executes at least one time. The VI is broken if the conditional
terminal is not wired. Fig 7.1 shows example of while loop structure
Basic error handling can be performed using the conditional terminal of a While Loop. When
an error cluster s wired to the conditional terminal, only the TRUE or FALSE value of the
status parameter of the error cluster passes to the terminal. Also, the Stop If True and
Continue If True shortcut menu items change to Stop If Error and Continue while Error. The
iteration terminal (an output terminal) contains the number of completed iterations. The
iteration count always starts at zero. During the first iteration, the iteration terminal returns 0.
Dept Of ECE 27
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
programming languages.
• The While Loop always executes at least once.
• The For Loop differs from the While Loop in that the For Loop executes a set
number of times.
• A While Loop stops executing the subdiagram, only if the expected value at the
conditional terminal exists.
• In LabVIEW, the WHILE Loop is located on the Functions » Programming »
Structures palette.
• You also can place a For Loop on the block diagram, right-click the border of the
For Loop, and select Replace with While Loop from the shortcut menu to change a
For Loop to a While Loop.
• The While Loop contains two terminals, namely Conditional Terminal and Iteration
Terminal.
• The Conditional Terminal is used to control the execution of the loop, whereas the
Iteration Terminal is used to know the number of completed iterations.
R A G H U N A T H
PROCEDURE:
Step 1: Create blank VI.
Step 2: Right click on the Block diagram panel →structures→ while loop
Step 3: Right click on the Block diagram panel (inside while loop) → array→ index array
Step 4: Right click on the index array (input side) →create →control
Step 5: Right click on the Block diagram panel →array →array size
Step 6: Right click on the Block diagram panel →numeric→ Quotient & Remainder
Step 7: Right click on the Block diagram panel → Comparison→ Equal to 0?
Step 8: Right click on the Block diagram panel →numeric→ numeric constant
Step 9: Right click on the Block diagram panel →numeric→ decrement
Step 10: Right click on the Block diagram panel →numeric→ numeric constant
Step 11: Right click on the Block diagram panel → Comparison→ Equal ?
Step 12: Using wiring operations required connections are made as given in the block diagram
inside loop.
Step 13: Make a connection to while loop from index array
Step 14: Right click step 13 connection (on loop) →Tunnel mode→ Indexing
Step 15: Right click step 14 connection (on loop) →Tunnel mode→Conditional
Step 16: Right click on the Block diagram panel →array→ sort 1D array
Step 17: Right click on the sort 1D array (input side) →create→ control [Even array]
Step 18: Right click on the sort 1D array (output side) →create→ control [Sorted array]
Dept Of ECE 28
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
Step 19: Using wiring operations required connections are made as given in the block diagram
outside loop.
BLOCK DIAGRAM:
Fig 7.2 shows the block diagram of sorting even numbers using while loop. The array takes the
input values. Using indexing values are accessed, and checked for even or not. To check for
even number the element value is divided by two and resulting remainder if zero considered as
even. This data is stored in output array. Using sort function, array is sorted.
R A G H U N A T H
RESULT:
Fig 7.3 shows the input array and sorted array. Even numbers are sorted using while loop in an
array.
Dept Of ECE 29
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
VIVA QUESTIONS:
1. What are the different loops available in LabVIEW?
2. Distinguish between for and while loop.
3. What is loop iteration control?
4. What is Multitracing?
R A G H U N A T H
Dept Of ECE 30
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
EXPERIMENT 8
FINDING ARRAY MAXIMUM AND ARRAY MINIMUM
AIM:
To find the maximum and minimum variable from an array.
THEORY:
Arrays
• A group of homogeneous elements of a specific data type is known as an array.
• Arrays hold a sequence of data elements,usually of the same size and same data
type placed in contiguous memory locations.
• Individual elements are accessed by their position in the array.
• The position is given by an index, which is also called as subscript
R A G H U N A T H
• Some arrays are multi-dimensional, generally one -and two- dimensional arrays are
the most common.
• You can build arrays of numeric, boolean, path, string and cluster data types.
• You cannot create arrays of arrays
Initializing Arrays
• When an array is initialized, define the number of elements in each dimension and
contents of each element.
• An uninitialized array has a dimension but no elements.
• An uninitialized array control with all the elements are dimmed indicating that the
array is uninitialized.
Dept Of ECE 31
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
• To add an element 1D, right click the array on the front panel and select Data Operation
» Insert Element Before.
• To add a row or column to a 2D array, right click the array on the front panel and select
Data Operations » Insert Row Before or Insert Column Before.
• One can insert elements, rows, column into arrays using the Insert Into Array function.
• Place an Insert Into Array function on the block diagram.
• The index input specifies the element, row, column where to insert the element or array
with 0 being the first.
• Elements are added before the value wire to index.
2D Arrays
• A 2D arrays stores elements in a grid.
• It requires a column index and a row index to locate an element both of which are zero-
based.
• To create a 2D array on the front panel, right click the index display of the array and
select Add Dimension from the shortcut menu.
R A G H U N A T H
Dept Of ECE 32
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
PROCEDURE:
Step 1: Create blank VI.
Step 2: Right click on the Block diagram panel →array→ max & min.
Step 3: Right click on the max & min (input side) →create →control.
Step 4: Create four numeric indicators in the front panel for maximum variable, index,
minimum variable, and index by right clicking on output side of max & min.
Step 5: Using wiring operations required connections are made as given in the block diagram.
Step 6: Inputs are given in the front panel and the program is executed.
BLOCK DIAGRAM:
Fig 8.1 shows the block diagram of array maximum and minimum in LabVIEW. Array input
R A G H U N A T H
is taken and using the array max and min function values are indicated using the indicators.
Dept Of ECE 33
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
RESULT:
Fig 8.2 shows the maximum and minimum of given input array. The array maximum and
minimum is determined using LabVIEW and also its index.
VIVA QUESTIONS:
1. What is array? How it can be assigned?
2. Distinguish Array and Clusters.
3. How do graphs are made in VI?
4. Mention the difference between graph and charts.
Dept Of ECE 34
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
DEMONSTRATION EXPERIMENTS
EXPERIMENT 9
BUILD A VI THAT SIMULATES A HEATING AND COOLING
SYSTEM.THE SYSTEM MUST BE ABLE TO BE
CONTROLLED MANUALLY OR AUTOMATICALLY.
AIM:
To build a vi 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.
• 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.
THEORY:
Structures are process control elements, such as while loops and for loops. The structure to be
used in this experiment is the case structure 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
PROCEDURE:
1. In the front panel, drag and drop three Round LEDs and three Slide Switches by going to
the Controls palette > Modern tab > Boolean. 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.
2. Rename the LEDs and their corresponding switches "Manual," "AC," and "Heater" to make
building the system clearer. This can be done by using the editing text tool in the Tools
palette.
3. Drag and drop a thermometer into the front panel (Controls palette > Modern tab > Numeric
> Thermometer).
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. This makes the
Dept Of ECE 35
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
thermometer a control that will give an input to the program, which in this case is
temperature.
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.
6. Wire the slide switch designated as Manual to the case selector on the case structure. 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).
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 sub-
R A G H U N A T H
diagram.
8. In the true sub-diagram, wire the AC and heater switches directly to their corresponding
LEDs. This allows the switches to directly toggle their corresponding LEDs.
9. Staying in the true sub diagram, 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.
10. In the false sub diagram, 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.
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.
12. In the false sub diagram, Insert a False Constant (Functions palette > Programming >
Boolean > False Constant) and wire it to the manual LED. This is to turn off the manual
LED and indicate that the system is in automatic mode.
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. Click the switches and thermometer on the front panel to test the system.
Dept Of ECE 36
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
BLOCK DIAGRAM:
Fig 9.1 and 9.2 shows the block diagram for true case and false case respectively.
R A G H U N A T H
Dept Of ECE 37
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
R A G H U N A T H
OUTPUT/FRONT PANEL:
The output for VI simulating a heating and cooling system is shown in Fig 9.3.
Fig 9.3.output
RESULT:
A virtual instrument that simulates a heating and cooling system is built.
Dept Of ECE 38
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
VIVA QUESTIONS:
1. Design a temperature-controlled kettle for heating water and freezing water.
2. What are the temperature indicators in LabView?
3. What are True and False constant in LabView?
4. What is a if Block in LabView ?
R A G H U N A T H
Dept Of ECE 39
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
EXPERIMENT 10
BUILD A VIRTUAL INSTRUMENT THAT SIMULATES
BASIC CALCULATOR USING FORMULA MODE
AIM :
To build a Virtual Instrument that simulates basic Calculator Using Formula Mode.
THEORY:
The Formula Node in LabVIEW software is a convenient, text-based node you can use to
perform complicated mathematical operations on a block diagram using the C- syntax structure.
It is most useful for equations that have many variables or are otherwise complicated. The text-
based code simplifies the block diagram and increases its readability. Furthermore, you can
R A G H U N A T H
copy and paste existing code directly into the Formula Node rather than recreating it
graphically. The Formula Node is available in all development versions of LabVIEW and does
not require an additional toolkit or add-on.
PROCEDURE:
The Formula Node in LabVIEW software is a convenient, text-based node you can use to
perform complicated mathematical operations on a block diagram using the C- syntax structure.
It is most useful for equations that have many variables or are otherwise complicated.
The text-based code simplifies the block diagram and increases its readability. Furthermore,
you can copy and paste existing code directly into the Formula Node rather than recreating it
graphically. The Formula Node is available in all development versions of LabVIEW and does
not require an additional toolkit or add-on.
This tutorial is useful for familiarizing yourself with the Formula Node. Follow the steps to
create a simple structure to compute different formulas depending on input values. Then,
compare the simplicity of your block diagram using a formula node to its counterpart using
graphical programming. The Formula Node is a tool that allows the benefits of text-based code
within the easy-to-use graphical LabVIEW architecture.
Dept Of ECE 40
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
5. Right-click the border of the Formula Node and select Add Output from the shortcut
menu as in fig 10.2.
R A G H U N A T H
Dept Of ECE 41
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
1. Right-click on each input and select Create»Control from the shortcut menu.
2. Right-click on each output and select Create»Indicator from the shortcut
menu.
R A G H U N A T H
Dept Of ECE 42
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
R A G H U N A T H
BLOCK DIAGRAM :
The block diagram with formula node is shown in Fig 10.7.
Dept Of ECE 43
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
OUTPUT/FRONT PANEL:
The front panel view is shown in following fig 10.7.
RESULT:
A virtual instrument that simulates a basic calculator is built.
VIVA QUESTIONS:
1. What is the formula node?
2. Use formula node for finding area of circle, circumference of circle and arc of a circle
3. What is the advantage of using formula node?
4. Is formula node text based or block (graphical) based?
Dept Of ECE 44
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
EXPERIMENT 11
WATER LEVEL INDICATOR
AIM:
To create and demonstrate water level indicator.
Description:
If No water is in tank then motor must be ON.
If water level crosses 8 then Motor must be OFF.
THEORY:
The water level indicator circuits are used in factories, chemical plants, and electrical substations and
R A G H U N A T H
in other liquid storage systems. There are many possible uses for this simple system, examples include
monitoring a sump pit (to control pump activation), rainfall detection, and leakage detection. Electronic
water level circuits have the capability of alerting if there is a water leak somewhere in the factory.
When the water level is too high or too low or exceeds the higher limit, it can detect the water level
easily by hearing an alarm sound or from different colors of a light bulb. We can also measure the fuel
level in motor vehicles and the liquid level containers which are huge in the companies.
The circuit is designed to indicate three levels of water stored in the tank: empty, half and full but not
overflowing. When there is no water in the tank, all the LEDs are off as an indication that the tank is
completely empty. Then, manually control the knob to turn ON LED. When water level increases and
touches the maximum limit, the OFF LED will glow indicating that there is water within the tank. As
the water level continues to rise and reaches half the tank, ON LED will still glow indicating tank is
filling.
The important LabVIEW components or tools, required to design a water level detector, list of
these components below:
• Tank
• Round Knob
• Numerical Indicator
Vertical 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 ow down.
Dept Of ECE 45
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
PROCEDURE:
Step 1: Create blank VI.
Step 2: Right click on the front panel →numeric→ knob.
Step 3: Right click on the knob →Properties→ scale→ Set maximum 10 and minimum 0
Step 4: Right click on the front panel →Boolean→ Round LED (Name it ON).
Step 5: Right click on the front panel →Boolean→ Round LED (Name it OFF).
Step 6: Right click on the front panel →numeric→ Numeric control
Step 7: Right click on the front panel →numeric→ Tank
Step 8: Right click on the Block diagram panel →comparison→ greater or equal?
Step 9: Right click on the Block diagram panel →comparison→ less?
R A G H U N A T H
Step 10: Right click on the Block diagram panel → numeric→ Numeric constant (set 8) [twice]
Step 11: Using wiring operations required connections are made as given in the block diagram.
Step 5: Execute- give inputs in the front panel by rotating knob and observe tank filling and
switches ON & OFF.
BLOCK DIAGRAM:
Fig 11.1 shows the block diagram water level indicator in LabVIEW. A round control knob is
used to switch on the motor and off. Numeric indicator display water level in tank.
Dept Of ECE 46
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
RESULT:
Fig 11.2 (a), (b) and (c) shows Motor on with no water and filling and reached upper limit and
off. A VI that indicates water level is built.
VIVA QUESTIONS:
1. How to create vertical indicators?
2. Is it possible to change the settings of LED?
3. Is it possible to implement this using While loop?
4. Comparator functions are present in which palette?
Dept Of ECE 47
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
EXPERIMENT 12
CALCULATION OF AREA AND PERIMETER OF CIRCLE
AIM:
To calculate area and perimeter of a circle.
Description: Area of circle = 𝜋𝑟2
Perimeter/circumference of circle = 2𝜋𝑟
r- radius of circle
if r>10 then indicate to reduce radius.
THEORY:
R A G H U N A T H
The area shows the space inside an object having two dimensions. Where as, circumference is
the parameter which shows the boundary of the object. Area is usually measured in m² and
circumference is measured in m according to their System International (SI) units. In this area
and area and circumference calculation of circle is achieved. In this LabVIEW program, which
will take radius as an input and calculates the area and circumference of circle, You can also
select the maximum limit of the radius. When the radius approaches its maximum limit an LED
will glow showing the notification reduce the radius.
PROCEDURE:
Step 1: Create blank VI.
Step 2: Right click on the front panel → numeric→ Numeric control
Step 3: Right click on the front panel → numeric→ Numeric indicator [Name Area]
Step 4: Right click on the front panel → numeric→ Numeric indicator [Name Circumference]
Step 5: Right click on the front panel → Boolean→ Square LED
Step 6: Right click on the Block diagram panel →Numeric→ multiply (thrice)
Step 7: Right click on the Block diagram panel →structures→ while loop
Step 8: Right click on the Block diagram panel →numeric→ numeric constant [set value 10]
Step 9: Right click on the Block diagram panel →numeric→ numeric constant [set value 2]
Step 10: Right click on the Block diagram panel →numeric→ math constants→pi
Step 11: Using wiring operations required connections are made as given in the block diagram
Dept Of ECE 48
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
BLOCK DIAGRAM:
Fig 12.1 shows the block diagram of area and circumference of circle in LabVIEW. Area and
circumference is calculated using formulas. An upper limit to radius is also kept here.
R A G H U N A T H
RESULT:
VIVA QUESTIONS:
1. What are the units of area and perimeter?
2. Where to select pi function?
3. What is the difference between continuous run and run?
4.How to indicate broken wire in LabVIEW?
Dept Of ECE 49
LabVIEW programming Basics Lab manual 18EC384 Ability Enhancement Lab
R A G H U N A T H
Dept Of ECE 50