0% found this document useful (0 votes)
9 views34 pages

Lab Report1

This document outlines a laboratory exercise for EE 383: Instrumentation and Measurements, focusing on the introduction to LabVIEW. It provides objectives, detailed instructions on creating basic Virtual Instruments (VIs), and various programming structures such as While Loops and For Loops. The lab aims to familiarize students with LabVIEW's interface and functionalities through hands-on tasks involving data manipulation and control structures.

Uploaded by

ahmadmanahil80
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)
9 views34 pages

Lab Report1

This document outlines a laboratory exercise for EE 383: Instrumentation and Measurements, focusing on the introduction to LabVIEW. It provides objectives, detailed instructions on creating basic Virtual Instruments (VIs), and various programming structures such as While Loops and For Loops. The lab aims to familiarize students with LabVIEW's interface and functionalities through hands-on tasks involving data manipulation and control structures.

Uploaded by

ahmadmanahil80
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/ 34

NUST School of Electrical Engineering and Computer Science

Faculty Member: Muhammad Mustafa Tehseen Date:18/09/24

Lab Engineer: Fahad Khalid

Section: A
Semester:5th

Department of Electrical Engineering

EE 383: Instrumentation and Measurements


Lab 01: Introduction to LabView

PLO4/ PLO5/ PLO8/ PLO9/ CLO7


CLO4 CLO5 CLO6

Name Reg. Viva / Analysis Modern Ethics Individual and


No Quiz / of data in Tool and Team Work
Lab Lab Usage Safety
Perfor Report
mance
5 Marks 5 Marks 5 Marks 5 Marks 5 Marks
Manahil Ahmad 407744

Hafiza Adeela Arif 420111

Aleesha Waqar 417349

1. Objectives

i. Introduction to LabVIEW
ii. Designing a simple VI
iii. Introducing Control and Simulation Module in LabVIEW
2. Introduction to LabVIEW

Laboratory Virtual Instrumentation Engineering Workbench (LabVIEW) is a platform and


development environment for a visual programming language from National Instruments.
It is a very popular software tool among electrical engineers. LabVIEW is a graphical
programming language that uses icons instead of lines of text to create applications.

There is also another important difference between text-based programming languages


and LabVIEW. In most text-based programming languages instructions determine program
execution. LabVIEW uses dataflow programming, where the flow of data determines
execution. This point will become clearer as you will work in LabVIEW.

3. Virtual Instruments (VIs)

LabVIEW programs are called virtual instruments (Vis) because their appearance and
operation imitate physical instruments, such as oscilloscopes and millimeters. LabVIEW
contains a comprehensive set of tools for acquiring, analyzing, displaying, and storing data.
There are also many tools in LabVIEW that help you troubleshoot your program.

There are two parts of a VI, the front panel window and the block diagram.

3.1. Front Panel

The front panel is the user interface of the VI. You build the front panel 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 the data
generated by the block diagram.

Figure: Front panel


3.2. Block Diagram
After you build the front panel, you need to add graphical code to describe what needs
to be done when the controls/input devices are manipulated in the front panel. You also
need to add graphical code for describing what information is displayed on the output
terminals in the front panel. This graphical coding is done in the block diagram part of the
VI.

The block diagram contains functions and structures from built-in LabVIEW VI libraries.
Wires are used to connect nodes in the block diagram, including control and indicator
terminals, functions, and structures.

Figure: Block diagram

3.3. Controls and Indicators

You create the front panel with controls and indicators, which are the interactive input
and output terminals of the VI, respectively. Controls are knobs, push buttons, 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 that the block diagram acquires or generates.
The figures below show some of the controls and indicators
Figure: Controls and Indicator as seen in the block diagram

Figure: Controls and Indicator as seen in the front panel

4. Palettes

Palettes in LabVIEW are menus that contain commands to create or edit the front panel
and the block diagram.

4.1. Tools Palette

The Tools palette is available on both the front panel and the block diagram. A tool is a
special operating mode of the mouse cursor. Use the tools to operate and modify front
panel and block diagram objects.

Go to View->Tools Palette to display the Tools palette.

If automatic tool selection is enabled and you move the cursor over objects on the front
panel or block diagram, LabVIEW automatically selects the corresponding tool from the
Tools palette. (It is recommended that automatic tool selection must always be enabled)
Figure: Tool Palette

4.2. Controls Palette

The Controls palette is available only on the front panel. The Controls palette contains
the controls and indicators you use to create the front panel.

Go to View->Controls Palette or right-click the front panel workspace to display the


Controls palette.

Figure: Control Palette


4.3. Functions Palette

The Functions palette is available only on the block diagram. The Functions palette
contains the VIs and functions you use to build the block diagram.

Go to View->Functions Palette or right-click the block diagram workspace to display the


Functions palette.

Figure: Function Palette

5. Wires

Data is transferred between block diagram objects through wires. Wires connect the
controls and indicators. Each wire has a single data source, but you can wire it to many VIs
and functions that read the data. Wires are of different colors, styles, and thicknesses,
depending on their data type. The table below shows the most common types of wires.
Table: Common Wire Types

There is also another type of wire called the broken wire. It appears as a dashed black
line with a red X in the middle, as shown in the figure below. Broken wires occur for a variety
of reasons, such as when you try to wire two objects with incompatible data types.

Figure: Broken wire

6. Shortcuts Keys

The table below lists some of the useful shortcut keys available in LabVIEW

Key Function
Ctrl+N New VI
Ctrl+Q Quit LabView
Ctrl+B Remove Broken wires
Ctrl+R Run VI
Ctrl+. Abort VI
Ctrl+E Display Block/Front Diagram
Ctrl+T See Block/Front diagram at same time
Ctrl+H Display Context Help
Ctrl+Shift+L Lock Context Help

Table: Common Shortcuts keys


Task 1
Numeric Control

7. Creating a basic VI

The use of LabVIEW is best understood by creating a basic VI. We will proceed step by
step to create a VI that performs some very simple functions. We will do the following tasks

• We will start by adding two numbers entered by use.


• Then we will add two randomly generated numbers.
• How to continuously run the program in LabVIEW.
• Use of While Loop in LabVIEW
• Adding delay in While Loop
• Conversion from While Loop to For Loop.
• Using For Loop as conditional Loop
• Displaying the message as per the condition.
• Using Case Structure to glow the LED as per condition.

Follow the steps given below to create a basic VI:

1. Go to Start >> Programs >> LabVIEW 2009. The window shown below will be
displayed. Click on Blank VI to start programming.

2. In the front panel Right click >> Control Palette>> Express >> Numeric Controls. Drag
two Numeric Controls to front panel and name them “A” and “B” respectively.
3. Go to Express >> Numeric Indicators. Drag a numerical indicator in front panel and
name it “C”.

4. Switch to the block diagram. (Switch between front panel and block diagram by
pressing Ctrl+E). The block diagram will look like the figure given below
5. Now to perform the numeric operation Right click in block diagram, function palette
will be displayed, go to Programming >> Numeric. Drag Add in your block diagram

6. Now connect the wires in your Block diagram as shown in the figure below
7. Switch to the front panel and Run the program by clicking the white arrow

8. Enter the values of A and B and resultant C will be shown.


Task 1 Results:

Screenshot:

Explanation:
In this task, we have developed a simple process/machine which performs addition
function. The process inputs values of the two numbers to be added via Numeric Control
from the user, adds them on the backend and then outputs the sum to the user via Numeric
Indicator.
Task 2:
Random Number

9. Delete A and B.

10. Drag two Random Numbers in your block diagram by going to Programming >>
Numeric >> Random Number

11. Connect the wires and block diagram will look like
12. Run the program a few times and see what happens.
Task 2 Results:

Screenshot:

Explanation:
In this task, we performed the same operation as in task 1, but this time, instead of
taking the summation inputs from the user, our machine produces random numbers and
adds them. On each run, the Random Number blocks produce two random numbers and
their sum is presented to the user.
Task 3:
While Loop
13. Now we will insert a loop in the program. To add the loop go to Programming >>
Structures >> drag While Loop in your block diagram.

14. While Loop will only be terminated if the required condition is met, in our case we
simply add a stop button by switching to the front panel and going to Express >>
Buttons >> Drag Stop button in your front panel.
15. Connect the stop button with terminate point to complete the while loop.

16. Now when we execute the program, we will notice that the program is running at
very high speed and we cannot see the output. We can add delay to program by
going to Programming >> Timing >> drag wait to your block diagram. (you can also
use other blocks within Timing for adding delay)

17. Right click the Wait and go to create >> constant and enter 500. (Delay of 500 ms
will be added)
Task 3 Results:
Screenshot:

Explanation:
This task is an extension of task 2. Here, we have placed the entire functionality of
the adder system inside a While loop. This loop continuously generates random numbers
and their sum till its termination condition is met. To fulfill this, we have placed a Stop
Buton to enable us to manually terminate its execution. The loop was working on a high
frequency, making it difficult to read the output value. Therefore, we used a Wait block to
delay the subsequent iteration by a period of 500ms.
Task 4:
For Loop

18. To replace while loop with For loop, right click the loop and select “Replace with For
Loop”

19. Now remove the conditional terminal as it may not be required in for loop.

20. Add the no of times you want the loop to run by right clicking on “N” >> create >>
constant and enter 10.
Task 4 Results:

Screenshot:

Explanation:
This required us to make a slight modification to our previous design. This time,
instead of a while loop, we used the For Loop to control the number of cycles of our
process. The number of iterations done was 10.
Task 5:
Conditional For
21. To run the for loop conditionally, right click the loop and select “Conditional
Terminal” and connect the stop button with it. Now the loop will run 10 times but
can be terminated by pressing the stop button.

Task 5 Results:

Screenshot:

Explanation:
A replica of the previous process. However, in this case, we added the option for the
user to manually terminate the machine by providing the Stop Buton.
Task 6:
Conditional While

22. Replace the for loop with the while loop.

23. Now we want that if the sum of two random numbers is greater than 1 than a string
message should be displayed on the front panel quoting “Greater than 1” or “Less
than 1” for the other condition. We can do this by using the “Select” block in
Comparison. Go to Programing >> Comparison >> drag select into your block
diagram.

24. To check that whether the sum is greater than 1 or not select “Greater” from
comparison under programming and connect one terminal of that with the output
of the add terminal and other with a constant 1.
25. “Select” has three input terminal, select, true and false. Select terminal is the
conditional terminal which checks which condition has been invoked, if true has
been invoked the block attached with true terminal will be executed and false will
be executed for the other condition.

26. We will add the input string saying “Greater than 1” with true terminal and ‘Less
than 1” with false terminal. To do this right click in block diagram and go to
Programming >>Strings >>String constant. Drag two string constants in the block
diagram and enter the respective messages.
27. From the front panel select a “String Control” within Express. Now to change the
string control to indicator, right click on that block and select “Change to Indicator”

28. Wire the respective terminals to complete the program.


29. Now when you run the program, you will see the respective message as per
condition.
Task 6 Results:

Screenshot:

Explanation:
This is an extension to the previous task. Here, we added a function to the machine
that enabled it to tell if the sum of the two randomly generated numbers is greater than 1 or
not. For this purpose, we added a Greater than block to compare the output of the sum
with constant 1. The result of this operator produces either true or false which is sent to the
Select Bock. This block is connected to two String Constants “Greater than one” and “Less
than one” and a String Controller Block which depending on the condition, prints the
appropriate string.
Task 7:
True and False

30. Now we will do the same by using the “Case Structure”, the only difference will be
that instead of string message, a LED will show whether the sum is greater or less
than 1. To do this go to Programming >> Structures >> drag Case Structure into
the block diagram.

31. Wire the output terminal of “Greater” with the conditional terminal of Case
Structure.

Page 1
32. Select a LED from front panel by going to Express >> Buttons >>Round LED.

33. When the condition is true LED will glow to indicate it. To do that drag a true
constant into the “TRUE” case of the structure by going to Programming >>
Boolean >> True constant.

34. Connect the true constant with LED. (Right click the case structure at the terminal
which is connected to LED and select “Use default if unwired”.

Page 2
35. Now go to False structure.

36. Connect the false constant with LED.

Page 3
Run the program, output will be displayed as per condition.

Page 4
Task 7 Results:

Screenshot:
True:

False:

Explanation:
For this task, we performed a similar function as above. In this case, we used a Case
Block which provides a True or False state as an output. This is provided to an LED which
indicates if the number is greater or less.

Page 5
Additional Task:

Solution:

Output:

Conclusion:
In this lab, we got familiar with the interface of LabView, how its different aspects work and
how to make simple operation machines with this tool. We performed different tasks to
get a hands on experience of the software like using for loos, while loops, random number
generators different arithmetic operation. We used conditional loops and at last performed
additional task of using operations on a signal.

Page 6

You might also like