0% found this document useful (0 votes)
620 views25 pages

Virtual Instrumentation Lab Manual

Here are the steps to find the decimal equivalent of a binary number using subVIs in LabVIEW: 1. Create a main VI with inputs for the binary number as a string. 2. Create a subVI called "Bit Value" that takes a single bit (0 or 1) as input and returns its decimal value as output. 3. Create another subVI called "Calculate Decimal" that takes the binary number string as input. 4. In the "Calculate Decimal" subVI: - Use a for loop to iterate through each bit of the binary string from right to left - Call the "Bit Value" subVI on each bit to get its decimal value - Use addition to keep

Uploaded by

nitesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
620 views25 pages

Virtual Instrumentation Lab Manual

Here are the steps to find the decimal equivalent of a binary number using subVIs in LabVIEW: 1. Create a main VI with inputs for the binary number as a string. 2. Create a subVI called "Bit Value" that takes a single bit (0 or 1) as input and returns its decimal value as output. 3. Create another subVI called "Calculate Decimal" that takes the binary number string as input. 4. In the "Calculate Decimal" subVI: - Use a for loop to iterate through each bit of the binary string from right to left - Call the "Bit Value" subVI on each bit to get its decimal value - Use addition to keep

Uploaded by

nitesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

MANGALORE INSTITUTE OF TECHNOLOGY AND ENGINEERING

(An ISO 9001:2008 certified Institution)


Badaga Mijar, Moodbidri-574225,Karnataka.

Virtual Instrumentation Lab Manual


(15MT52)

DEPARTMENT OF MECHATRONICS
ENGINEERING

NAME…………………………………………
………………….
USN……………………………………………
…………………..
SEMESTER……………………………………
…………………
BATCH
NO………………………………………………
……...

1
CONTENTS

Sl. Date Page No.


Experiment Name
No.

0 Introduction to LabVIEW 3

Programming on Arithmetic and logical


1 5
operations

2 Modular programming 7

3 Loops and shift registers 10

4 Clusters, graphs & Charts 12

5 Structures 13

6 Arrays 14

7 Strings and File I/O 16

2
EXPERIMENT NO. : 0 DATE:

Introduction to LabVIEW

Aim: To understand the principles of Virtual Instrumentation (VI).


Theory: 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.
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 built 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. The front panel is the user interface of the VI.
The front panel is built 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

3
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.
Block diagram - Contains the graphical source code that defines the functionality of 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. 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 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.
The Functions palette: The Functions palette is available only on the block diagram. The
Functions palette contains the VIs and functions used to build the block diagram. To display
the Functions palette, select Window » Show Functions Palette or right-click the block
diagram workspace. The Functions palette can be placed anywhere on the screen.
Dataflow Programming: LabVIEW follows a dataflow model for running VIs. A block
diagram node executes when all its inputs are available. When a node completes execution, it
supplies data to its output terminals and passes the output data to the next node in the
dataflow path. Procedure:
1. Open NI LabVIEW and press <Ctrl_N> to open a blank VI.
2. Press <Ctrl_T> to tile front panel and block diagram windows.

4
EXPERIMENT NO. : 1 DATE:

Arithmetic and logical operations


Aim: To perform basic arithmetic and logical operations using LabVIEW.
Instructions:

Step 1: Select controls by right clicking on the front panel and choose the specific type of
control similarly choose indicators.
Step 2: Different operators such as addition, subtraction, multiplication, less than, greater
than, Boolean, etc can be performed by right clicking on block diagram.
Step 3: Using wires inputs and outputs are connected to the respective operators in the
block diagram panel.
Step 4: Enter the input values in front panel.
Step 5: Observe the output by performing single step and continuous mode execution.

Example 1. Execute a VI to perform the operation of y=3x+4.

Example 2. Execute a VI to perform the operation of checking a given number is odd or


even

5
Example 3. Execute a VI to perform the operation Y=(A*B*C)+(D*E) and y=mx+c

Example 4. Execute a VI to Convert Celsius to Fahrenheit.


Hint: F= (1.8C+32)

6
EXPERIMENT NO. : 2 DATE:

Modular programming

Aim: To perform modular programming in LabVIEW.

Instructions:
A. Creating SubVI
Step 1: Build a VI with front panel and block diagram
Step 2: Assign terminals to control and indicators using control panel.
Step 3: Create icon
Step 4: Save the file with extension .vi
Step 5: Call the file in the main program using ‘select vi’ option in block diagram pane.
Step 6: If multiple SubVI are to be used group can be saved as .llb (LabVIEW library).

B. Creating EXE from a VI


Step 1: Right click ‘build specifications’ in the ‘project explorer’ window and
select ‘New’>> ‘Application (EXE)’ from the shortcut menu
Step 2: Modify the file name of the target and destination directory for the
application in the ‘Application Information category’.
Step 3: Select the ‘Application Information category’.
Step 4: Change the target filename to your ‘filename .exe’.

Example 1. Execute a VI to perform half adder and full adder.

Half adder: A half-adder is an arithmetic circuit block that can be used to add two bits. Such
a circuit thus has two inputs that represent the two bits to be added and two outputs, with one
producing the sum output and the other producing the carry.

7
Full adder:

A full adder circuit is an arithmetic circuit block that can be used to add three bits to
produce a sum and a carry output.

8
Example 2. Create a VI to find the decimal equivalent of a binary number using subVI.

9
Example 3: Create a VI to find the grey code equivalent of a BCD number using subVIs.

10
Example 4: Create a VI to find the roots of a quadratic equation using subVIs. Find both the values of
the roots and nature of the roots.

11
Example 5: Create a VI to find the average of two numbers and convert a section of a VI into a
subVI.

12
13
EXPERIMENT NO. : 3 DATE:

Loops and shift registers

Aim: To perform the operation using loops in LabVIEW.

Instructions:
A. While loop: to be used when condition needs to be checked after an iteration.
Step 1: In block diagram panel, right click and select ‘Programming’>> ‘structures’
>> ‘while loop’.
Step 2: choose the terminating condition.
B. For loop: to be used when condition needs to be checked before every iteration.
Step 1: In block diagram panel, right click and select ‘Programming’ >> ‘Structures’
>> ‘for loop’.
Step 2: Assign the number ‘N’, which means number of times loops should be execute.

Example 1. Creating Virtual Instrumentation for simple applications- invert the state of
boolean indicator twice a second until program is stopped by user.

14
Example 2. Programming exercises for loops in virtual instrumentation-Continuous
Monitoring of Temperature (Generated using Random no 0<t<100 ). for every 250 ms.

Example 3. Programming exercises for loops in virtual instrumentation-Factorial of a given


number using for loop and shift registers.

15
Example 4: Create a VI to find the sum of first “n” natural numbers using a while loop with a
feedback node.

Example 5: Create a VI to find the sum of first “10” natural numbers using a for loop.

16
Example 6: Create a VI which converts a decimal number to binary number using for loops.

Example 4: Create a VI to find 𝑛𝐶 𝑟 and 𝑛𝑃 𝑟 of a given number using for loop.

17
EXPERIMENT NO. : 4 DATE:

Clusters and graph & chart


Aim: To perform the operation on clusters and graphs in LabVIEW.
Clusters are group of data with element of mixed type.
Instructions:
To create clusters, select cluster by right clicking in front panel and select
‘controls’>>’All controls’>>’Arrays & cluster palette’, place it on front panel. Drag and
drop objects or elements into the cluster.
Plotting Data:
1. Graph: display typical data
2. Chart : displays data at continuous rate
a. Strip chart: shows continuous data and continuously scroll from left to
the right
b. Scope chart: shows one item, and scroll partway across left to right.
c. Sweep chart: shows old data on right and new data on left.
3. XY graph: two dimension plot
4. 3D plot
5. Intensity graph:
Right click on front panel, select ‘graphs and charts’.

Example 1. Programming exercises for graphs- Display Random Number Into 3 different
CHARTS (STRIP, SLOPE,SWEEP) and understand the difference between these in the UI.

18
EXPERIMENT NO. : 5 DATE:

Structures

Aim: To perform the operation on structures in LabVIEW.

Theory:
Structures are used in block diagram to repeat blocks of code and to execute code
conditionally or in a specific order. Section of block diagram inside the structure border is
called ‘subdiagram’. The terminals that feed data into and out of structures are called
‘tunnels’. Following structures can be used in LabVIEW
1. Loop’s
2. Case structure
3. Sequence structure
4. Event structure
5. Timed structure
6. Diagram disable structure
7. Conditional disable structure
To add structures right click on block diagram, select ‘programming’>> ‘structures’.
Example 1. Programming Exercises on case and sequence structures:-Design the simple Calculator,
making use of the inherent GUI present in the virtual instrumentation software.

19
EXPERIMENT NO.: 6 DATE:
Arrays
Aim: To perform the array operations in LabVIEW
Instructions:
Creating a one-dimensional array control/indicators/constant
Step 1: In front panel right click >>’Controls’ >> ‘Modern’>>’Array, Matrix & Clusters
palette’.
Step 2: Insert an object in the array. The array data type will be assigned as that of the
object inserted.
Step 3: To create multidimensional array, Right click on array and select ‘Add
Dimension’.
Step 4: From the array particular set of elements can be made visible by varying the
values of ‘index’ provided next to array.

Example 1. Programming Exercises on Arrays– Take a 2D array input from the user and perform
various array (and matrix) manipulations on it.
1. Display array inputs to corresponding outputs

20
Example 2. Sorting even numbers using while loop in an array.

Example 3. To find the maximum and minimum variable from an array.

21
Example 4. Create a VI to find the determinant of 2*2 and 3*3 matrix which is represented in the
form of 2D array using Index array function.

22
EXPERIMENT NO. : 7 DATE:

Strings and File I/O

Aim: To perform the operations on strings and file I/O in LabVIEW.


Theory:
String is a sequence of displayable or non-displayable ASCII characters.
String control and indicator is located on the ‘Controls’>> ‘Text controls’>>’Text
indicators palettes’ in the front panel.
File I/O records or reads data in a file. Functions related to file I/O is located by right
clicking the block diagram ‘Functions’>>’All functions’>> ‘File I/O’.

Example 1. Programming Exercises on File Input output System – Read and write from ASCII and
TDMS files

23
Read and write from ASCII file:

24
Read and write from TDMS file:

25

You might also like