Basics Lab View Lab
Basics Lab View Lab
!"#$
% " ! & ' &
(
)*! & " " *)+,-!
.#&
. /,/, % " ! &
' & (
To my parents and to our family who made
this accomplished possible
7$%/(2)&217(176
Contents
Chapter One...................................................................................................................... 1
Introduction ..................................................................................................................... 2
Dataflow Programming ................................................................................................... 3
Graphical Programming .................................................................................................. 3
What Basic Functions can LabVIEW Perform? ............................................................. 4
LabVIEW Benefit............................................................................................................ 5
LabVIEW Criticism ........................................................................................................ 7
What LabVIEW Used for? .............................................................................................. 8
MyDAQ......................................................................................................................... 10
List of Abbreviation
Abbreviation Meaning
LabVIEW Laboratory Virtual Instrument
Engineering Workbench
VI Virtual Instrument
MAX Measurement and Automation eXplorer
VISA Virtual Instrument Software Architecture
IDNet Instrument Driver Network
ANSI American National Standards Institute
IEEE Institute of Electrical and Electronics
Engineers
ISO International Organization for
Standardization.
DMM Digital Multimeter
UI User Interface
CHAPTER ONE
LABVIEW INTRODUCTION
Introduction to Book
LabVIEW programs are called virtual instruments, or VIs, because their appearance
and operation imitate physical instruments, such as oscilloscopes and multimeters.
LabVIEW contains a comprehensive set of tools for acquiring, analyzing, displaying,
and storing data, as well as tools to help you troubleshoot code you write. In LabVIEW,
you build a user interface, or front panel, with controls and indicators. Controls are knobs,
push buttons, dials, and other input mechanisms. Indicators are graphs, LEDs, and other
output displays. After you build the front panel, you add code using VIs and structures
to control the front panel objects. The block diagram contains this code.
You can use LabVIEW to communicate with hardware such as data acquisition, vision,
and motion control devices, as well as GPIB, PXI, VXI, RS232, and RS485 instruments.
This book rather leads its readers to mastery of this powerful laboratory tool through the
process of carrying out interesting and relevant projects. Readers--who are assumed to
have no prior computer programming or LabVIEW background--will begin writing
meaningful programs within the first few pages. Hands-On Introduction to LabVIEW is
designed for flexible use so that readers can easily choose the desired depth of coverage.
Use this book as a tutorial to familiarize yourself with the LabVIEW graphical
programming environment and the basic LabVIEW feature you use to build data
acquisition and instrument control applications. This book contains exercises that you can
use to learn how to develop basic applications in LabVIEW. These exercises take a short
amount of time to complete and help you get started with LabVIEW.
CHAPTER ONE
LABVIEW INTRODUCTION
Introduction
Laboratory Virtual Instrument Engineering Workbench (LabVIEW) is a system-
design platform and development environment for a visual programming
language from National Instruments.
LabVIEW is a very large virtual laboratory program and an integrated development
environment based on graphical programming, through the use of forms familiar to all
engineers and technicians. Where LabVIEW program relies on graphical symbols instead
of using a specific programming language, where in scripting the idea is based on the
scribes of a text program either in graphical programming, it is replaced by a set of tools
and components, which is known dataflow programming. Of course, it supports
programming languages such as C and HTML in advanced tasks. What distinguishes it
is the ease of use through simple procedures for configuring the graphical user interface
and linking these tools by specifying properties and functions to perform the required
tasks. LabVIEW also includes a wizard that creates various applications by following a
series of instructions and options that lead to the creation of the application. It also has a
very important feature, which is creating executables for the applications you have
created. It is mainly integrated to communicate with devices such as GPIP, VXI, RS-485,
RS-232 and others. Ports can be used in all its forms to connect to the surrounding, be it
parallel, USB or other ports. It contains very large internal public libraries, for use in
software standards such as transmission control systems, the connection of TCP / IP
networks, ACTIVE X and others. Supports data acquisition by providing very powerful
tools, image processing and also IMAQ. The program comes within a package of
programs that are used for a variety of purposes in the same work environment of the
LabVIEW program, which creates amazing integration, and the tasks of these programs
vary from processors that link devices that we want to communicate with applications to
~1~
CHAPTER ONE
LABVIEW INTRODUCTION
monitor these devices and record and record their errors. In figure 1.1 that shown the
LabVIEW symbols.
Dataflow programming
The programming paradigm used in LabVIEW, sometimes called G, is based on data
availability. If there is enough data available to a subVI or function, that subVI or function
will execute. Execution flow is determined by the structure of a graphical block diagram
(the LabVIEW-source code) on which the programmer connects different function-nodes
by drawing wires. These wires propagate variables and any node can execute as soon as
all its input data become available. Since this might be the case for multiple nodes
simultaneously, LabVIEW can execute inherently in parallel. Multi-
processing and multi-threading hardware is exploited automatically by the built-in
scheduler, which multiplexes multiple OS threads over the nodes ready for execution.
Graphical programming
LabVIEW integrates the creation of user interfaces (termed front panels) into the
development cycle. LabVIEW programs-subroutines are termed virtual instruments
(VIs). Each VI has three components: a block diagram, a front panel, and a connector
~2~
CHAPTER ONE
LABVIEW INTRODUCTION
pane. The last is used to represent the VI in the block diagrams of other, calling VIs. The
front panel is built using controls and indicators. Controls are inputs: they allow a user to
supply information to the VI. Indicators are outputs: they indicate, or display, the results
based on the inputs given to the VI. The back panel, which is a block diagram, contains
the graphical source code. All of the objects placed on the front panel will appear on the
back panel as terminals. The back panel also contains structures and functions which
perform operations on controls and supply data to indicators. The structures and functions
are found on the Functions palette and can be placed on the back panel. Collectively
controls, indicators, structures, and functions are referred to as nodes. Nodes are
connected to one another using wires, e.g., two controls and an indicator can be wired to
the addition function so that the indicator displays the sum of the two controls. Thus, a
virtual instrument can be run as either a program, with the front panel serving as a user
interface, or, when dropped as a node onto the block diagram, the front panel defines the
inputs and outputs for the node through the connector pane. This implies each VI can be
easily tested before being embedded as a subroutine into a larger program.
The graphical approach also allows nonprogrammers to build programs by dragging
and dropping virtual representations of lab equipment with which they are already
familiar. The LabVIEW programming environment, with the included examples and
documentation, makes it simple to create small applications. This is a benefit on one side,
but there is also a certain danger of underestimating the expertise needed for high-quality
G programming. For complex algorithms or large-scale code, it is important that a
programmer possess an extensive knowledge of the special LabVIEW syntax and the
topology of its memory management. The most advanced LabVIEW development
systems offer the ability to build stand-alone applications. Furthermore, it is possible to
create distributed applications, which communicate by a client–server model, and are
~3~
CHAPTER ONE
LABVIEW INTRODUCTION
thus easier to implement due to the inherently parallel nature of G. In figure 1.2 that shown
the LabVIEW Front Panel and Block Diagram.
~4~
CHAPTER ONE
LABVIEW INTRODUCTION
LabVIEW Benefits
Interfacing to devices
LabVIEW includes extensive support for interfacing to devices, instruments, camera, and
other devices. Users interface to hardware by either writing direct bus commands (USB,
GPIB, Serial) or using high-level, device-specific, drivers that provide native LabVIEW
function nodes for controlling the device.
LabVIEW includes built-in support for NI hardware platforms such
as CompactDAQ and CompactRIO, with a large number of device-specific blocks for
such hardware, the Measurement and Automation eXplorer (MAX) and Virtual
Instrument Software Architecture (VISA) toolsets.
National Instruments makes thousands of device drivers available for download on the
NI Instrument Driver Network (IDNet).
Code compiling
LabVIEW includes a compiler that produces native code for the CPU platform. The
graphical code is converted into Dataflow Intermediate Representation, and then
translated into chunks of executable machine code by a compiler based on LLVM. Run-
time engine calls these chunks, allowing better performance. The LabVIEW syntax is
strictly enforced during the editing process and compiled into the executable machine
code when requested to run or upon saving. In the latter case, the executable and the source
code are merged into a single binary file. The execution is controlled by LabVIEW run-
time engine, which contains some pre-compiled code to perform common tasks that are
defined by the G language. The run-time engine governs execution flow, and provides a
consistent interface to various operating systems, graphic systems and hardware
components. The use of run-time environment makes the source code files portable across
supported platforms. LabVIEW programs are slower than equivalent compiled C code,
~5~
CHAPTER ONE
LABVIEW INTRODUCTION
though like in other languages, program optimization often allows to mitigate issues with
execution speed.
Large libraries
Many libraries with a large number of functions for data acquisition, signal generation,
mathematics, statistics, signal conditioning, analysis, etc., along with numerous for
functions such as integration, filters, and other specialized abilities usually associated with
data capture from hardware sensors is enormous. In addition, LabVIEW includes a text-
based programming component named MathScript with added functions for signal
processing, analysis, and mathematics. MathScript can be integrated with graphical
programming using script nodes and uses a syntax that is compatible generally
with MATLAB.
Parallel programming
LabVIEW is an inherently concurrent language, so it is very easy to program multiple
tasks that are performed in parallel via multithreading. For example, this is done easily
by drawing two or more parallel while loops and connecting them to two separate nodes.
This is a great benefit for test system automation, where it is common practice to run
processes like test sequencing, data recording, and hardware interfacing in parallel.
Ecosystem
Due to the longevity and popularity of the LabVIEW language, and the ability for users
to extend its functions, a large ecosystem of third-party add-ons has developed via
contributions from the community. This ecosystem is available on the LabVIEW Tools
Network, which is a marketplace for both free and paid LabVIEW add-ons.
User community
There is a low-cost LabVIEW Student Edition aimed at educational institutions for
learning purposes. There is also an active community of LabVIEW users who
~6~
CHAPTER ONE
LABVIEW INTRODUCTION
communicate through several electronic mailing lists (email groups) and Internet
forums.
Home Bundle Edition
National Instruments provides a low-cost LabVIEW Home Bundle Edition.
LabVIEW Criticism
LabVIEW is a proprietary product of National Instruments. Unlike common
programming languages such as C or Fortran, LabVIEW is not managed or specified by
a third party standards committee such as American National Standards
Institute (ANSI), Institute of Electrical and Electronics
Engineers (IEEE), International Organization for Standardization (ISO), etc. Many
users have criticized it for its tendency to freeze or crash during simple tasks, often
requiring the software to be shut down and restarted.
Slow
Very small applications still have to start the run-time environment which is a large and
slow task. This tends to restrict LabVIEW to monolithic applications. Examples of this
might be tiny programs to grab a single value from some hardware that can be used in a
scripting language - the overhead of the run-time environment render this approach
impractical with LabVIEW.
Non-textual
G language being non-textual, software tools such as versioning, side-by-side (or diff)
comparison, and version code change tracking cannot be applied in the same manner as
for textual programming languages. There are some additional tools to make comparison
and merging of code with source code control (versioning) tools such as subversion, CVS
and Perforce.
No zoom functions
~7~
CHAPTER ONE
LABVIEW INTRODUCTION
There was no ability to zoom in to (or enlarge) a VI which will be hard to see on a large,
high-resolution monitor.
~8~
CHAPTER ONE
LABVIEW INTRODUCTION
~9~
CHAPTER ONE
LABVIEW INTRODUCTION
MyDAQ
Designed for hands-on experimentation, that is shown in figure 1.7. NI MyDAQ
combines portability with a comprehensive set of features. NI MyDAQ allows for real
engineering and, when combined with NI LabView and Multisim, gives students the
power to prototype systems and analyze circuits in or outside of the classroom. NI
MyDAQ hardware integrates with NI LabVIEW graphical development software, giving
the students hands-on interaction with real analogue circuits, sensor measurements, and
signal processing. It bridges the gap between theory and real-world practice by providing
students with eight LabVIEW software-based instruments including a digital multimeter
(DMM), oscilloscope, function generator, bode analyzer, dynamic signal analyzer,
arbitrary waveform generator, digital reader and digital writer, as shown in figure 1.8. NI
MyDAQ is compact enough to fit in a student's pocket, and is powered by a USB
connection.
~ 10 ~
CHAPTER ONE
LABVIEW INTRODUCTION
~ 11 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Introduction
In this chapter, we will take a set of lessons from which to get to know the LabVIEW
program. Through these lessons, you will be able to use the LabVIEW and create
projects. We will learn about the toolbar in Block Diagram and Front panel. You will
learn how to work with the program and make simple examples. All this will be done with
the use of program illustrations.
LabVIEW program
Aim of the lesson
~ 12 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
defines VIs, and each contains two main parts are the front panel or what can be called
the control panel, and the second part is the block diagram the third part is icon and
connectors.
1- Front Panel: The User Interface
This interface is used to interact with the user as all the different application requirements
are set on it, as they are control and control elements (icon control), Graphic and
illustration items (Waveform), Contact item, and Other. In figure 2.1 that shown the front
panel.
The front panel is built by controls and indicators, as shown in figure 2.2.
~ 13 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Controls:
These are the input modules in VI such as knobs, push buttons, dials, etc. It is the same
as the input units in the real electronic devices. In figure 2.3 that shown the controls types.
Indicators:
These are VI output or display units such as graphs, leds, etc. It is the same as the output
and display units in real electronic devices. In figure 2.4 that shown the indicators types.
And what happens in the program is that the data moves from Controls to Block Diagram
so that the program code is executed on it and then the results appear from Block Diagram
to Indicators, as shown in figure 2.5.
~ 16 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Figure 2.7: Control and indicator in Front Panel and Opposite Terminal Block Diagram
The Block Diagram in addition to terminals contains SubVIs, Functions, Constants,
Structures, and Wires that make up the data path.
3- The Icon and Connector Pane
These connections are used if the project that we are preparing is connected to an
external terminal to receive or send data from outside the PC and are on the upper
left of the Diagram or panel user interface. It represents the basis for the part that
is the nature of the work of the project, which we are preparing. Also have the
advantage of excellent too, is the ability to use a virtual front subset are called
when it is needed in the event that the project contains many of the fabrication
~ 17 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
parts that we link Some are completely the same is the idea of subprograms in
programming languages. This Icon can contain drawing, writing, or both, as
shown in figure 2.8.
~ 18 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Basically, the idea that gives the program LabVIEW great strength is the ability to
configure complex applications in tasks and a high degree of efficiency is very easy
steps and flexible. In order to access this configuration sub-applications or interfaces
subset partial tasks required in order to create an integrated application based on assembly
These are partial applications together, this is the concept of SubVIs.
Connectors Pane
It is a set of links that indicate and specifies the way SubVI is connected in Block
Diagram. These connections are the inputs and outputs of the SubVI, as shown in figure
2.10.
~ 19 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
To run the program. And be like this . If there is an error in the program it appears
like this .
For continuous implementation of the program until the program is stopped or pressed
again and appears during the continuous implementation of the program like this .
To stop the program completely and immediately, it is only available during the
implementation of the program.
To stop the implementation of the program temporarily and complete the
implementation of the program by clicking on it again.
Note: In the event of a pause, LabVIEW shows where the program stopped in Block
Diagram.
~ 20 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Dropdown menu for changing text properties: color, size, font type.
Step Into: One step: To implement the program. With it you can enter subVI or loops
to implement it step by step.
Step Over: To implement the program, one step with each pressure, considering that
SubVI or Loop is implemented in one step without entering it.
Step Out: Exit loop or SubVI in one step.
Tools Palette
They are opened from:
Window Î Show Tools Palette
As shown in figure 2.12.
~ 21 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Operating Tool: Change the values of Controls or typed text. Usually used during
program implementation.
~ 22 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Scrolling Tool: To make a sliding window without using the sliding bar.
Probe Tool: It is used to create a data display point (Probe) to display the values
while the program is executed for testing or handling errors.
Color Copy Tool: To take color values from any position in the window for use By
Coloring Tool
~ 24 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
It can also be opened by right-clicking on the Front Panel window, as shown in figure
2.17.
Functions Palette
It opens from the block diagram window.
Window Î Functions palette Show
In figure 2.17 that shown the functions palette.
~ 25 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 26 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 27 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 28 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 29 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Figure 2.23: Change the value of control using the operating tool
~ 30 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Numeric Indicators
In figure 2.25 that shown the numeric Indicator list.
~ 31 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Note:
Indicators and Controls properties can be changed by pressing the right click on the unit,
whether Indicator or Control, a drop-down menu appears showing us what can be
changed, as shown in figure 2.29.
~ 32 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Nodes
It is any object in Block Diagram that has entries or exits, or both, and it performs an
operation while executing the program.
The types of Nodes are: Functions, SubVI, and Structures.
Functions:
These are ready-made basic functions built into the LabVIEW environment.
It can be obtained from Functions Palette, as shown in figure 2.31.
~ 34 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Terminals
They are of two types: Indicator or Control Terminal and Node Terminals.
Indicator or Control Terminal
As we explained before for each Control or Indicator present in the Front Panel there is
corresponding Terminal in the Block Diagram. This Terminal has Data Type for Control
or Indicator.
Data Type determines the data type as well as each of the storage capacity of the value
and thus the extent of this value. Each Data Type has a specific color, as shown in figure
2.33.
~ 35 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Node Terminals
Each Node has a Connector Pane that is a set of connections that shows and specifies how
it connects to any Node's input and output locations. These connections are Node
Terminals. To display the Connector pane of Node
Right-click on the Node Î select Visible Items ÎTerminals
This is shown in figure 2.34.
~ 36 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Wires
It is the data path between the Block Diagram (Object) units.
Wire connects to a single data source, but this data can be accessed by more
than one entry for a function or SubVI, as shown in figure 2.35.
~ 37 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 38 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Dataflow Programming
The implementation of LabVIEW software is dependent on Dataflow.
Node executes immediately when data is ready on its inputs. Upon completion of Node
implementation, the outputs immediately exit their outputs to be ready for the next Node
in the data flow path. This is in contrast to other programming languages that rely on
Control Flow, where instructions are executed successively according to the order in
which they are written in the program
Create LabVIEW Program File
Steps:
1- Download LabVIEW Program.
2- Download a new file.
3- Press. New VI.
4-Select Blank VI for new VI.
Save LabVIEW Program File
You can save the program as a separate file in the extension vi, or as part of a library that
contains several programs and that is in an .llb extension.
1- Save the file in a separate file:
Choose File Î Save
This is shown in figure 2.36.
~ 39 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 41 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Select Objects
The Positioning tool is used to select and move units in the Front Panel or Block
Diagram, as shown in figure 2.40.
To select more than one unit, press the Shift key while pressing the tool on the units
to be selected.
You can also click the tool anywhere and pull the cursor while holding down to select
all the units that we want.
In figure 2.41 that shown the selection of objects.
~ 43 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Moving Objects
The tool is used to select and move units.
After selecting the unit, you can drag it anywhere, or use the arrows to move the selected
units.
When using the arrow in the move, you can press the Shift key with the arrow to speed
up the move.
Delete Objects
Objects are deleted first by selecting the tool and then pressing Delete or Edit >> Clear.
(Undo / Redo) Steps:
If you took some steps and want to cancel them, use Undo from the Edit menu and to
return those steps after canceling them, select Redo from the same list.
~ 44 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Copy Objects
If you want to obtain more than one copy of any unit.
Choose the object with the tool then choose Edit >> Copy and then choose Edit >>
Paste.
Or choose the object with the tool then press the Ctrl key and then drag the unit to any
other place while holding the key down, as shown in figure 2.42.
Insert Label
The label is used to identify objects, as shown in figure 2.43.
~ 45 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Each object has a label. This label can be changed individually, but if you move the unit
it will move with its label. The label of the object can be shown or hidden, as shown in
figure 2.44.
~ 46 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
To select Wire Segment, we press the one-click on the link by using the tool , as
shown in figure 2.50.
~ 48 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Dashed Line
Connection Error
~ 49 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Align Objects
If you want to align an array of units, first select them and then choose the alignment type
from the Align list, as shown in figure 2.57.
~ 51 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 52 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 53 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
LabVIEW Help
Consider the importance of using LabVIEW Help in creating and testing VI and
identifying errors in the program. We will know how to use LabVIEW Help before
knowing how to test VI.
Context Help window
This window shows the basic information about the objects on the Front Panel or the
Block Diagram.
By moving the cursor over any object, basic information about that object appears in the
Context window, as shown in figure 2.60.
~ 54 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 55 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
You must connect to it and if you do not connect to it, the program will not be executable
and the Run key will look like this .
The titles of these Terminals appear in the Context Help window in Bold line, as shown
in figure 2.63.
~ 56 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 58 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 59 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
LabVIEW Help
With LabVIEW, you can find complete Help files for anything you want to program
with LabVIEW.
We have seen that LabVIEW can be opened through the Context Help window.
LabVIEW Help can also be opened from the menu Help >> Search the LabVIEW Help,
as shown in figure 2.69.
NI Example Finder
~ 60 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
With LabVIEW there are many examples that you can modify to suit the application you
want and some parts of it can be copied for use in your application and it helps in
understanding many of the topics in the LabVIEW program.
The NI Example Finder is used to search and find the example you want, whether it is
located with a copy of LabVIEW or on the NI company website.
The NI Example Finder is called by pressing Find Examples on the Getting Started
LabVIEW screen, as shown in figure 2.71.
~ 61 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 62 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 63 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
All errors must be fixed and all links must be verified so that the implementation switch
becomes this way that is, VI is enforceable.
VI Test
If all errors are corrected and the VI becomes executable but the VI is not implemented as
expected or it gives an error in the results then the VI implementation must be tested.
LabVIEW provides us with several tools to track program implementation and testing,
including:
1- Executing the program using. Highlight Execution
By clicking on the key in the Toolbar in Block Diagram (turns to ) and then by
pressing the Execute key , the program execution movement will be displayed slowly
with the flow of data flow during the program execution, as shown in figure 2.76.
~ 64 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Sometimes you need to implement Block Diagram as a step that is executed in every single
Node step and this is known as Single-Stepping or a step-by-step system
implementation.
The Step Into , Step Over , and Step Out keys in the Toolbar in Block
Diagram are used step by step.
To start the program implementation in the step system, press one of the previous keys.
By clicking the Step Into and Step Over keys, the current Node is executed and
the next Node is ready to be executed in the next step.
When you press the Step Over key, Node is executed in one step and is not entered.
For example, if Node is a SubVI, it will execute completely in one step and move to the
next Node in the next step without entering into the internal details in executing that
SubVI.
Either by pressing the Step Into key, you will be entered into SubVI, step by step.
Step Out is used to end Block Diagram, Structure, or VI that is currently executing
Press the key to execute at the next step or complete the execution completely.
By moving the mouse pointer over those keys at any point, we will see text indicating
what will happen if we press these keys.
During the step-by-step system implementation, the Pause key can be pressed to
complete program execution in the normal way.
In figure 2.77 that shown the Step Over Execution.
~ 65 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
3- Use Probe
Probe is used to know the data on the tracks at the time of program implementation.
~ 66 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Right-click on
the path
~ 69 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
3- Supplied Probe
It is an VI that gives more comprehensive information about the data on the path. For
example, VI Refnum Probe gives information about the VI name, its storage path, and
its Hex value.
This Probe can interact with the software. For example, a condition can be set when the
data on the path is met and the program execution is stopped, as shown in figure 2.85(a,b).
Supplied Probe appears at the top of the Customer Probe list, as shown in figure 2.84.
It varies depending on the type of data on the path.
~ 70 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
(a)
~ 71 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
(b)
Figure 2.85: The Condition in the Supplied Probe
4- Custom Probe
You can make your own Custom Probe by modifying an existing Probe or creating a
new Probe. To create a Probe, right-click on the track and then choose Custom Probe
>> New, as shown in figure 2.86. It shows us a set of windows that define the Probe
specifications that we want.
~ 73 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
this .
In this case, one of these steps can be taken:
1- Completing the program implementation with the step-by-step system using the keys
in the Toolbar.
2- Use Probe to check path values.
3- Changing the values of the Controls in the Front Panel
4- Press the Pause key to complete the program execution until the program reaches
another stopping point or until the program has finished executing.
~ 75 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
The initial form of the icon is and the number on the icon indicates the number of
the new VI that has been opened since the operation of the program.
LabVIEW in the sense that if you do another new VI, the icon will be like this . Note
that the number has increased by one.
This icon can be modified to the shape you want:
• Right-click the icon and choose Edit Icon.
• or by double click on the icon.
In figure 2.93 that shown the icon modifies.
~ 77 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 78 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Line tool to draw lines. If you want the line to be horizontal or vertical, press the Shift
key while drawing the line.
The Color Copy tool to copy a color in Icon to be the writing color.
Fill tool to fill a specific area of writing color.
Rectangle tool to draw a blank writing rectangle. By pressing this tool two consecutive
presses, an outer window is drawn for the entire icon writing color.
~ 79 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Filled Rectangle tool for drawing rectangular writing color and background color
shading.
Select tool to choose a specific area to erase, copy, or move to another location.
By pressing this tool two consecutive presses and then pressing the Delete key, the entire
icon content is erased.
Text tool to write on the icon. By pressing two consecutive presses a window opens
with the properties of the line and these properties can be modified.
To show and choose the writing color and the background color (the writing color
is the front rectangle and the background color the rectangular back) and by pressing
which two rectangles the color is chosen.
3- Connector Pane
In order to use VI as a SubVI the Connector Pane must be set up for it. Connector Pane
is a set of Terminals. These Terminals represent Controls and Indicators found in VI. The
Connector Pane determines the inputs and outputs of the VI to be used as SubVI. To
display the Connector Pane for VI, press the right click on the icon and choose Show
Connector, as shown in figure 2.96.
~ 80 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 81 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 83 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Show the Front Panel window then
1- Using the Wiring tool, press "Terminal". You will notice that after pressing, it
becomes highlighted, as shown in figure 2.100 (a).
(a)
2- Press the same tool on the Control or Indicator you want to link to. You will notice that
the Control or Indicator is surrounded by a dotted line, thus Terminal is linked, as shown
in figure 2.100 (b).
(b)
3- Repeat the same steps with the rest of the Terminals, as shown in figure 2.100 (c).
4- To end the fastening process, press anywhere empty.
~ 84 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
(c)
Figure 2.100: Connection Terminals to Controls and Indicators
Notes:
• Although the Wiring tool is used in the linking, there is no line that connects Terminals
with Controls or Indicators
• In the linking process you can choose Control or Indicator first and then Terminal
• If an error occurs in the linking process, you can remove all links between Terminals
and Controls or Indicators by pressing the right button and choosing Disconnect all
Terminals.
• Or, you can remove the link for one Terminal by pressing the right button and selecting
“Disconnect This Terminal.”
In figure 2.101 that shown the remove all terminal or single terminal.
~ 85 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 86 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 87 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 88 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 89 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
In figures 2.108 (a, b, c) that shown the Description and Tip design.
(a)
(b)
~ 90 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
(c)
Figure 2.108: Description and Tip Design
~ 91 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Loops
Loops are used to duplicate part of the code. LabVIEW has two main types of Loops: For
Loop and While Loop.
For Loop It is to repeat the execution of a specific part of the code a specified number of
times. Example: Repeating two numbers five times
~ 92 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
While Loop It is to repeat a specific part of the code until a certain condition is met, that
is, until this condition is True or False, depending on the type of condition used as we
will see.
While Loop and For Loop are listed from Function Palette >> Programming >>
Structures, as shown in figure 2.109.
For Loop
For Loop is used to repeat the code inside of it a specified number of times. The code
inside of For Loop is called Subdiagram.
With for loop there are two terminals:
Count Terminal : It determines the number of executions inside a For loop, and the
number is connected to it from outside. If the number is connected to zero, it will not
execute inside.
~ 93 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Iteration Terminal : It contains the number of times it has been executed. The first
time that the code is executed, the value is zero, and the second time it is one value, and
so on until it reaches the number N-1.
This takes the values from 0 to N-1 where N equals the number connected to Count
Terminal (the number of times the code will execute). In figure 2.110 that shown the
for loop.
~ 94 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
(a)
(b)
Figure 2.111: How Include For-Loop
• For Loop dimensions can be changed by using the Positioning tool by moving them
on the Loop frame to make the pointer an arrow shape so we press the pointer and drag
the frame in the direction we want, as shown in figure 2.112.
~ 95 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 96 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 97 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Remove For-Loop
• If you want to delete For Loop inside it, choose For Loop and press Delete.
• To delete For Loop only and keep it inside, press the right click on the For-Loop window
and choose Remove For-Loop, as shown in figure 2.116.
Numeric Conversion
We mentioned before that the Data Type for Count Terminal is Long Integer, i.e. a
valid number between 0 and 232-1. There are other types of Data Type for Control or
Digital Indicator, such as Double-Precision and Single-Precision. If you connect two
different Terminals in a Data Type, LabVIEW converts the numeric values between the
two different types. Then LabVIEW places a point on the converted Terminal and this
point is called Coercion dot, as shown in figure 2.117.
~ 99 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 100 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
2- You can create Constant or Control that is automatically connected to the Count
Terminal and has the same Data type by pressing the right click on the Count
Terminal and choosing Create >> Constant or Create >> Control, as shown in
figure 2.120.
While Loop
It is a Structure that repeats the implementation of the code inside it until a condition is
met. In figure 2.121 that shown the while loop block.
~ 101 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
While Loop has two terminals which are Iteration Terminal and Conditional
Terminal.
1- Iteration Terminal
It is like the Iteration Terminal found in For Loop and it contains the number of times
the code was executed inside While Loop. The first time that the code is executed, the
value is zero, and every time the code is re-executed, it increases one.
2- Conditional Terminal
This takes the Boolean or False values. The execution is done inside While Loop until
the entry to this terminal is either True or False, depending on the type of Conditional
Terminal.
There are two types to this terminal:
a- Stop If True
The execution of an execution will stop inside While Loop if the internal value of
this Terminal is True.
Each time what is inside is executed while Loop, then the value inside of this
Terminal is checked, if True exiting while loop and if false repeat the execution of
what inside while loop, as shown in figure 2.122.
~ 104 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 105 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 106 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Often, we need to transfer data from one implementation to the next, such as transferring
data from implementation 1 to implementation 2 and so on.
There are two ways to obtain data from previous implementations: Shift Register and
Feedback Node.
Shift Registers
Shift Register moves data from one implementation for For-Loop or While Loop to the
next one. The Shift Register consists of these two formats and , as shown in
figure 2.129.
~ 107 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 108 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 109 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 110 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Figure 2.135: Error to Connect the Output to Same Input in Same Function
In this case, we use the Feedback Node to make the value that was output to one of the
outputs of a function or SubVI the value entered into one of the inputs to that function or
SubVI the next time that this function is executed or SubVI, as shown in figure 2.136.
~ 111 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
time that you implement it. This Terminal is set automatically by just listing the Feedback
Node, as shown in figure 2.137.
What happens if the initial values for the Feedback Node are not
specified?
If you set the initial value for the Feedback Node, this value will be the value. Feedback
Node Before entering the first implementation in Loop, this is whether the program is
executed for the first time, the second time, or any time. However, if the initial value of
the Feedback Node is not specified, Feedback Node will take the initial value of the type
of data that it transmits before the first time it is executed. Where Loop and so on. This
is similar to what happens in Shift Registers.
Case Structure
It is one way of doing conditional sentences and is equivalent to If… then… else in
other programming languages.
Case Structure is listed from Function Palette >> Programming >> Structures or
from Function Palette >> Express >> Execution Control, as shown in figure 2.139.
~ 114 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
the Case window, choose Show Case, and choose the case you want, as shown in figure
2.142.
~ 115 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
• If the input type is Boolean then there are two states, True or False, as shown in figure
2.143.
~ 116 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Figure 2.145: The Case Can Have More Than One Value
It can also be the case for a range of values. To do this, we use the two points .. for
expressing the extent, for example 2..20 means that this case for all the correct numbers
from 2 to 20 and 3.. means that the case for all the correct numbers equal to or greater than
3, as shown in figure 2.146.
~ 117 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Default Case
The condition to be executed if the value connected to the input is not assigned a case.
For example, if the existing conditions are for values 1, 2 and 3 only, what would be the
case if the income value is 100 for example. The default case will be executed. The
default state appears next to its assigned value as Default, as shown in figure 2.147.
~ 118 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
• If the input is String type, write the case values between two quotes and if you do not
put the labels, LabVIEW will set them automatically, as shown in figure 2.149.
~ 119 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 120 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 122 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 123 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 124 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 125 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
To add a new frame, right-click the Structure frame and press Add Frame After or Add
Frame Before, as shown in figure 2.160 and 2.161.
~ 126 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 127 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 128 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Timing
Timers are of great importance in LabVIEW. They are used to measure time, synchronize
between different tasks, and delay work in Loops so that Loops operate at an appropriate
rate so that they do not capture the overall processor speed.
There are two types of timers: basic functions and Express Timing VIs. All timers can
be listed from Function Palette >> Programming >> Timing, as shown in figure 2.166.
~ 129 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Basic functions
1- Wait Function (ms)
It makes this VI function wait for a certain number of milliseconds, and then the VI
implementation continues. That is, it delays in milliseconds. If you want the delay to be
in seconds, multiply the number of seconds by 1000, as shown in figure 2.167.
~ 130 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
2- Wait Until Next Function
This makes the VI function wait until the internal clock of the operating system (for
example Windows) is equal to the multiple of the function's internal value (millisecond
multiple), after which the VI continues. The inner value of the function is in milliseconds.
In figure 2.168 that shown the wait until next function.
If the internal value of Wait until Next ms Multiple is 10. The value of an hour or
timer for the system is, for example, 112. The function will wait 8 milliseconds until the
system's internal clock is 120, which means multiples of 10 (the inner value of the
function). The next time, you will wait until the time 130 is also a multiple of 10. So, note
that synchronization occurred with the system clock.
As for the function Wait (ms), if the value entered is 10. The value of an hour or timer
for the system is, for example, 112.
The function will wait 10 milliseconds for the system's internal clock to be 122. That is,
it has waited 10 milliseconds, regardless of the system clock value. Thus, you will wait
every time you implement 10 milliseconds, regardless of the system clock value.
~ 131 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Therefore, the function is used to make Loops inside activities implemented in specific
times. It is also used to make synchronization between events.
Note that when this function is used in Loop, it is the first time that it is executed that you
may wait for less than the value entered in it, as in the previous example.
The above two functions are frequently used in Loops so that Loop does not gain processor
speed. These functions make the delays necessary to do other tasks, such as the interaction
of Front Panel elements with the user.
3- Tick Count (ms) Function
This function is used to obtain the internal timer (hour) of the operating system, in
milliseconds, as shown in figure 2.168.
~ 132 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 133 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
The Time Has Elapsed value determines whether the time has elapsed or not. If True then
the specified time has passed. If False, the time has not passed yet, as shown in figure
2.172.
Formula Node
Formula Node is used to write mathematical equations.
For example, to apply this equation Y = X2 + X + 1 with the basic functions in LabVIEW,
it will look like this shown in figure 2.173.
~ 135 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 136 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 137 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Note:
There is no specific number of variables or the number of equations used in Formula
Node. Formula Node can be enlarged to accommodate any number of equations by using
the Positioning Tool, as shown in figure 2.180.
~ 138 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Expression Node
It is a simplified form of Formula Node. It contains one mathematical phrase, one entry,
and one output, as shown in figure 2.182.
~ 139 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 140 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 141 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 142 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 143 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Dimensioning the element inside the array can be done by moving the Positioning tool
on the edge of the element inside the array until the indicator appears as two indexes
or , or we press and drag to the dimensions that we want, as shown in figure 2.188.
until the index is in the form of an index with two arrows or we squeeze and
withdraw the arrow, as shown in figure 2.189.
~ 146 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 147 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
You can add an element or delete an element from an array by right-clicking on the
element inside the array and choosing
Data Operation >> Insert Element Before ÎTo add an item
or
Data Operation >> Delete ElementÎTo delete an item
How a two-dimensional Array (matrix)
We do a one-dimensional matrix and then press Index on the right click and choose Add
Dimension, as shown in figure 2.195.
tool on the array window. To turn into a two-way arrow or , press and move the
~ 148 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
frame in one of the vertical or horizontal directions. And re-do this in the other direction,
as shown in figure 2.196.
~ 149 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 150 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 151 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 152 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
This can be done using the Bundle function. In this case, we make a bundle of three entries
First: the value of X0 (the value at which the values of X begin).
Second: the value of dX (the amount of the increase in the value of X for each value of
Y).
Third: The one-dimensional matrix we want to draw (Y values).
The Bundle function is listed from Function Palette >> Programming >> Cluster &
Variant.
This is the previous example, but using the Bundle function, as shown in figure 2.101.
~ 153 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 154 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
To change the value of X0 (the value by which the values of X) and dX (the value of the
increase in the values of X) begin each graphic.
We use the Bundle function with every one-dimensional array and then compile the
Build Array function, as shown in figure 2.104.
~ 155 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 156 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
String Control or String Indicator are insert on the Front Panel of Controls Palette >>
Modern >> Strings & Path, as shown in figure 2.106.
~ 157 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 158 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
~ 159 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
Notes:
1- Changing the display pattern does not affect the content of String.
2- This pattern is used to test the texts that are sent or received from measuring devices
via Serial Port, for example, where non-printable characters such as \ n New line or \ r
Carriage Return are used to end the orders and the data sent when addressing the
measuring devices.
Password Display
In this pattern, letters do not appear, but instead the symbol *. When you enter letters in
String Control in this mode, the letters that you type do not appear, but instead the symbol
* appears, but the value that is read through the String Control Terminal in the Block
Diagram is the set of characters that you entered. This pattern is used when String Control
is used for entering passwords, as shown in figure 2.110.
~ 160 ~
CHAPTER TWO
LABVIEW LEARNING LESSONS
the mouse anywhere outside of Control or by pressing the button on the toolbar. This
is so that the text is not read completely incomplete before it is written. But if you want
the Terminal value to be updated while writing, we enable the Update Value while Type
feature.
The Update Value while typing feature is activated by right-clicking on String Control and
choose Update Value while Typing.
~ 162 ~
CHAPTER THREE
LABVIEW PROJECTS
For Loop
Executes its subdiagram n times, where n is the value wired to the count (N) terminal. The
iteration (i) terminal provides the current loop iteration count, which ranges from 0 to n-
1.
Block DiagramÎR.CÎStructureÎFor loop
Random Number
Produces a double-precision, floating-point number between 0 and 1. The number
generated is greater than or equal to 0, but less than 1. The distribution is uniform.
Block DiagramÎR.CÎNumericÎRandom Number (0-1)
Multiply
~ 163 ~
CHAPTER THREE
LABVIEW PROJECTS
Returns the product of the inputs.
Block DiagramÎR.CÎNumericÎMultiply
Array Subset
Returns a portion of array starting at index and containing length elements.
Block DiagramÎR.CÎArrayÎArray Subset
~ 164 ~
CHAPTER THREE
LABVIEW PROJECTS
2- Block Diagram
Discussion
~ 165 ~
CHAPTER THREE
LABVIEW PROJECTS
While Loop
Repeats the code within its subdiagram until a specific condition occurs. A While Loop
always executes at least one time.
Components of a While Loop
Subdiagram—Contains code that the While Loop executes once per iteration.
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
~ 166 ~
CHAPTER THREE
LABVIEW PROJECTS
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range.
Conditional Terminal—Evaluates a Boolean input value to determine whether to
continue executing the While Loop.
Contains one or more subdiagrams, or cases, exactly one of which executes when the
structure executes. The value wired to the case selector determines which case to execute.
Components of a Case Structure
Front PanelÎNumericÎThermometer
Procedure
Front Panel& Block Diagram
~ 169 ~
CHAPTER THREE
LABVIEW PROJECTS
(Play Waveform Express VI): Plays data from the sound output device using finite
sampling.
Block DiagramÎR.c Î Graphic&Sound Î Sound Î Output
(Tone Measurements Express VI): Finds the single tone with the highest amplitude or
~ 170 ~
CHAPTER THREE
LABVIEW PROJECTS
searches a specified frequency range to find the single tone with the highest amplitude.
You also can find the frequency and phase for a single tone.
Block DiagramÎR.c Î Express ÎSignal Analysis Î Tone
While Loop: Repeats the code within its subdiagram until a specific condition occurs. A While Loop
always executes at least one time.
Components of a While Loop
Subdiagram—Contains code that the While Loop executes once per iteration.
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
~ 171 ~
CHAPTER THREE
LABVIEW PROJECTS
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range. Conditional Terminal—Evaluates a Boolean input value to determine
whether to continue executing the While Loop. To specify whether the loop stops for a
TRUE or FALSE Boolean value, configure the continuation behavior of the loop. You
also can determine when the loop stops by wiring an error cluster to the conditional
terminal.
Block Diagram Î R.C Î Strucher Î While Loop
(Simulate Signal): Simulates a sine wave, square wave, triangle wave, sawtooth wave,
or noise signal.
Block Diagram Î R.C Î Express Î Signal Analysis Î Simulate Signal
~ 172 ~
CHAPTER THREE
LABVIEW PROJECTS
(Merge Signals Function): Merges two or more supported signals, such as scalar
numerics, 1D or 2D arrays of numerics, scalar Booleans, 1D or 2D arrays of Booleans,
waveforms, or 1D arrays of waveforms, into a single output.
Block Diagram Î R.C ÎExpress ÎSig ManipÎMerge Signals
Specifies how many seconds to delay running the calling VI. The default is 1.000.
Formula Node
Evaluates mathematical formulas and expressions similar to C on the block diagram. The
following built-in functions are allowed in formulas: abs, acos, acosh, asin, asinh, atan,
atan2, atanh, ceil, cos, cosh, cot, csc, exp, expm1, floor, getexp, getman, int, intrz, ln, lnp1,
log, log2, max, min, mod, pow, rand, rem, sec, sign, sin, sinc, sinh, sizeOfDim, sqrt, tan,
tanh.
Block Diagram >> R.C >> Structure >> Formula Node
Procedure
Part1
Front Panel
~ 173 ~
CHAPTER THREE
LABVIEW PROJECTS
Block Diagram
formula configures
~ 175 ~
CHAPTER THREE
LABVIEW PROJECTS
Block Diagram
Part3
Generate two signals in waveform graph
Front Panel
Block Diagram
~ 176 ~
CHAPTER THREE
LABVIEW PROJECTS
Discussion
1- Redesign signal generated in steps over to display Sawtooth?
2- Redesign program using singe wave and also enlarge signal one hundred times and
also write steps and graph front panel and block diagram?
3- what main difference when using waveform chats and waveform graph?
~ 177 ~
CHAPTER THREE
LABVIEW PROJECTS
Formula Node
Evaluates mathematical formulas and expressions similar to C on the block diagram. The
following built-in functions are allowed in formulas: abs, acos, acosh, asin, asinh, atan,
atan2, atanh, ceil, cos, cosh, cot, csc, exp, expm1, floor, getexp, getman, int, intrz, ln, lnp1,
log, log2, max, min, mod, pow, rand, rem, sec, sign, sin, sinc, sinh, sizeOfDim, sqrt, tan,
tanh.
Block Diagram >> R.C >> Structure >> Formula Node
For Loop
~ 178 ~
CHAPTER THREE
LABVIEW PROJECTS
Executes its subdiagram n times, where n is the value wired to the count (N) terminal. The
iteration (i) terminal provides the current loop iteration count, which ranges from 0 to n-
1.
Block DiagramÎR.CÎStructureÎFor loop
While Loop
Repeats the code within its subdiagram until a specific condition occurs. A While Loop
always executes at least one time.
Components of a While Loop
Subdiagram—Contains code that the While Loop executes once per iteration.
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range.
Conditional Terminal—Evaluates a Boolean input value to determine whether to
continue executing the While Loop.
~ 179 ~
CHAPTER THREE
LABVIEW PROJECTS
Divide Function
Computes the quotient of the inputs.
Front PanelÎNumericÎDivide
Finds the roots of polynomial P(x). This VI removes leading coefficients of the
polynomial that are equal to zero.
P(x): contains the real polynomial coefficients in ascending order of power. P(x) cannot
equal 0.
option: specifies the option for root finding. The default is Simple
Classification.
Block Diagram Î R.C Î Mathmatics Î Polynomial Î Polynomial Roots
Front PanelÎNumericÎKnob
~ 180 ~
CHAPTER THREE
LABVIEW PROJECTS
Expression Node
Use the Expression Node to calculate expressions that contain a single variable. The
following built-in functions are allowed in formulas: abs, acos, acosh, asin, asinh, atan,
atanh, ceil, cos, cosh, cot, csc, exp, expm1, floor, getexp, getman, int, intrz, ln, lnp1, log,
log2, max, min, mod, rand, rem, sec, sign, sin, sinc, sinh, sizeOfDim, sqrt, tan, tanh.
input is the value that the Expression Node uses as the variable.
output returns the value of the calculation.
Procedure
Formula node in mathematic operations:
Part1
Type the following equations in the Formula Node :
a=Tanh(x) + Cos(x)
y= a3 + a
Front Panel
~ 181 ~
CHAPTER THREE
LABVIEW PROJECTS
Block Diagram
Part2
Front Panel & Block Diagram
Write the following equations by using formula node:
y1=x3 + x2 + 5
y2= m*x + b
~ 182 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 183 ~
CHAPTER THREE
LABVIEW PROJECTS
Block Diagram
~ 184 ~
CHAPTER THREE
LABVIEW PROJECTS
Part2
Front Panel
Block Diagram
~ 185 ~
CHAPTER THREE
LABVIEW PROJECTS
Discussion
1- excuite the following Equation using formula node:
2- y= q+p*x
. (
w=
a=a+wy
b=b+w
3- excuite the following Equation using formula node:
The inputs are random numbers and and the each output is array of size 1000.
5- write the program by using formula node to check the multiply two numbers if the
result is equal or less than 20 the LED is on else the led OFF.
~ 186 ~
CHAPTER THREE
LABVIEW PROJECTS
Apparatus
LabVIEW software.
~ 187 ~
CHAPTER THREE
LABVIEW PROJECTS
Indicates that the voltage across any resistor Ri (Ri, i= 1, 2... n) in a series circuits equal to
the applied voltage (E) across the circuit multiplied by a factor ∑
!"
#'*, =I%
&
#'*, = % ………………… (2)
"
It should be noted that this expression is only valid if the same current I flow through all
the resistors.
Procedure
1. Design DC circuit in LabVIEW as shown in figure (2) and figure (3), connect the circuit
shown in Fig. (1), take E =10V, R1=82Ω, R2 = 100Ω
2. Measured the voltage Vout and current of "R1, R2 ".
3. Exchange the value of resistors as following: R1= 10Ω, R2= 1000 Ω in figure (2).
4. Measured the voltage Vout and current of "R1, R2 ".
5. Repeat step (2), change the value of resistors as following: R1=300Ω, R2= 500 Ω.
6. Measured the voltage Vout and current of "R1, R2 ".
Front Panel
~ 188 ~
CHAPTER THREE
LABVIEW PROJECTS
Block Diagram
~ 189 ~
CHAPTER THREE
LABVIEW PROJECTS
Discussion
1. Determine I1, I2, Iout when apply: R1= 90 KΩ, R2= 95 KΩ and Ein=40 V.
2. Compare between the practical and theoretical results by applying formula in (1) and
(2).
3. Determine Vout when apply: variable R1= (0-90) KΩ, R2= 95 KΩ and variable Ein=
(0-60) V.
4. Repeat the step in (3) and plot the result for each period as shown in table bellow
NO. -01 volt 35 KΩ 36 KΩ -789 volt
1 0 0 95
2 10 10 95
3 20 20 95
4 30 30 95
5 40 40 95
6 50 50 95
7 60 60 95
8 60 70 95
9 60 80 95
10 60 90 95
~ 190 ~
CHAPTER THREE
LABVIEW PROJECTS
Apparatus
LabVIEW software.
~ 191 ~
CHAPTER THREE
LABVIEW PROJECTS
A general formula for the current IX in a resistor RX that is in parallel with a combination
of other resistors of total resistance RT as shown in Figure (1):
3:
IX = × IT …………………. (i)
3; 3:
where IT is the total current entering the combined network of RX in parallel with RT.
Notice when RT is composed of a parallel combination of resistors, say R1, R2, ... etc.,
then the reciprocal of each resistor must be added to find the total resistance RT:
= + + ……………………. (1)
< "
1
%?
Ix = 1 1 1 IT ……......…………. (2)
+ +
%1 %2 %3
It should be noted that this expression is only valid if the same Voltage V flows through
all the resistors.
Procedure
1. Design DC circuit in LabVIEW as shown in figure (3) and figure (4), connect the
circuit shown in Fig. (2), take VS =10V, Rs= 10 Ω, R1=82Ω, R2 = 100Ω.
Block Diagram
~ 193 ~
CHAPTER THREE
LABVIEW PROJECTS
Discussion
1. Redesign DC circuit in LabVIEW as shown in figure (3) and figure (4) and determine
V1, V2, I1, I2 when apply: R s=40 Ω R1= 90 KΩ, R2= 95 KΩ, VS=40 V.
2. Compare between the practical design in LabVIEW and theoretical results by applying
formula in (i).
3. Determine I1, I2 when apply: variable R1= (0-90) KΩ, R2= 95 KΩ, R s=60 Ω and
variable Vs.= (0-60) V.
4. Repeat the step in (3) and plot the result for each period as shown in table bellow
5. The accuracy of five digital ammeter are checked by using each of them to measure a
standard 1.0000 Ampere from a calibration instrument. The ammeter readings are as
follows: I1 =1.001 Ampere, I2 =1.002 Ampere, I3 = 0.999 Ampere, I4 = 0.998 Ampere,
~ 194 ~
CHAPTER THREE
LABVIEW PROJECTS
and I5 =1.000 Ampere. Calculate the average measured ampere and the average
deviation and also determine the standard deviation of the measurement
6. Plot I1, I2 in step (4) using Waveform Chart and register all variable in front panel.
~ 195 ~
CHAPTER THREE
LABVIEW PROJECTS
Apparatus
LabVIEW software.
Theory
Local variables transfer data within a single VI and allow data to be passed between
parallel loops as shown in Figure 4.22. They also break the dataflow programming
paradigm.
Two ways to create a local variable are right-click on an object’s terminal and select
Create “Local Variable. A local variable icon for the object appears on the block
diagram as shown below.
~ 196 ~
CHAPTER THREE
LABVIEW PROJECTS
Another way is to select the Local Variable from the Structures palette. Create the front
panel and select a local variable from the Functions palette and place it on the block
diagram. The local variable node, shown as follows, is not yet associated with a control
or indicator. To associate a local variable with a control or indicator, right-click the local
variable node and select Item from the shortcut menu.
Global variables are built-in LabVIEW objects. You can use variables to access and pass
data among several VIs that run simultaneously. A local variable shares data within a VI;
a global variable also shares data, but it shares data with multiple VIs. For example,
~ 197 ~
CHAPTER THREE
LABVIEW PROJECTS
suppose you have two VIs running simultaneously. Each VI contains a While Loop and
writes data points to a waveform chart. The first VI contains a Boolean control to terminate
both VIs. You can use a global variable to terminate both loops with a single Boolean
control as shown in Figure 4.25. If both loops were on a single block diagram within the
same VI, you could use a local variable to terminate the loops.
While Loop
~ 198 ~
CHAPTER THREE
LABVIEW PROJECTS
Repeats the code within its sub diagram until a specific condition occurs. A While Loop
always executes at least one time.
Components of a While Loop
Subdiagram—Contains code that the While Loop executes once per iteration.
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range.
Conditional Terminal—Evaluates a Boolean input value to determine whether to
continue executing the While Loop.
Block DiagramÎR.CÎStructureÎCase Structure
Local Variable
Use local variables to read or write to one of the controls or indicators on the front panel
of a VI.
Block DiagramÎR.CÎStructureÎCase StructureÎLocal Variable
~ 199 ~
CHAPTER THREE
LABVIEW PROJECTS
Global Variable
Use global variables to access and pass data among several VIs.
Block DiagramÎR.CÎStructureÎCase StructureÎGlobal Variable
Procedure
Local Variable
Front Panel& Block Diagram
~ 200 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 201 ~
CHAPTER THREE
LABVIEW PROJECTS
e. Click on the global variable and select the variable.
~ 202 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 203 ~
CHAPTER THREE
LABVIEW PROJECTS
Discussion
1- Make a design that contain local and global variable.
~ 204 ~
CHAPTER THREE
LABVIEW PROJECTS
Traffic light
Aim of Experiment
The objective of this exercise to learn how to use LabVIEW for execute many cases and
design traffic light system.
Apparatus
LabVIEW software.
Procedure
(Traffic light):
Create a Sub VI that to design the traffic light system.
1. Create the Sub VI.
2. Create the Front Panel and the Block Diagram.
3. Create necessary Connectors as shown below.
4. Run the program to see if it works.
Front Panel
~ 205 ~
CHAPTER THREE
LABVIEW PROJECTS
Block Diagram
Solution:
1. On the Block diagram R.C Î TimingÎ Wait(ms).
2. On the Block diagram R.C Î structureÎ local variable.
~ 206 ~
CHAPTER THREE
LABVIEW PROJECTS
3. On the Block diagram R.CÎstructureÎflat sequence.
4. On the Block diagram R.C on the frame of flat sequence and select add frame
after.
5. On the Block diagram R.CÎ BooleanÎ F
6. On the Block diagram R.C ÎBooleanÎ T
7. On the front panel R.C ÎBooleanÎ Round Led.
Discussion
1- Using LabVIEW to Design the blinking led system every 1000 seconds.
2- Using LabVIEW to Design the traffic light system in another way.
3- Using LabVIEW to Design the Two traffic light system.
~ 207 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 208 ~
CHAPTER THREE
LABVIEW PROJECTS
Solution:
1. On the Block diagram R.CÎTimingÎ Wait(ms).
2. On the Block diagram R.C ÎNumericÎ Subtract.
3. On the Block diagram R.C ÎNumericÎ Add.
4. the Block diagram R.C ÎstructureÎ while loop.
5. On the Block diagram R.C on the red button of while ÎloopÎGreat control.
6. On the front panel R.C ÎNumerical ÎVertical pointer slide.
7. On the front panel R.C ÎNumerical ÎHorizontal pointer slide.
Part2
Front Panel & Block Diagram
~ 209 ~
CHAPTER THREE
LABVIEW PROJECTS
Solution:
~ 210 ~
CHAPTER THREE
LABVIEW PROJECTS
2. Design the program by using LabVIEW to control the water level of the tank. Select
the highest level and lowest level of water. If the water reaches the highest level,
(max alarm) ON and if it reaches the lowest level (min alarm) ON.
~ 211 ~
CHAPTER THREE
LABVIEW PROJECTS
Apparatus
LabVIEW software.
Blocks of this Experiment:
1.
~ 212 ~
CHAPTER THREE
LABVIEW PROJECTS
x When you wire an array to this function, the function resizes automatically to
display index inputs for each dimension in the array you wire to n-dimension
array.
3.
Equal? Function
Case Structure
x Contains one or more subdiagrams, or cases, exactly one of which executes when
the structure executes. The value wired to the case selector determines which case
to execute.
5.
For loop
~ 213 ~
CHAPTER THREE
LABVIEW PROJECTS
x Executes its subdiagram n times, where n is the value wired to the count (N)
terminal. The iteration (i) terminal provides the current loop iteration count, which
ranges from 0 to n-1.
Procedure
Create a Sub VI that to design the traffic light system.
1. Create the Sub VI.
2. Create the Front Panel and the Block Diagram.
3. Create necessary Connectors as shown below.
4. Run the program to see if it works.
True State
~ 214 ~
CHAPTER THREE
LABVIEW PROJECTS
False State
~ 215 ~
CHAPTER THREE
LABVIEW PROJECTS
Solution:
Discussion
1. Use LABVIEW program to Design the program to find the length of the specific
string. The string is (University).
2. Use LABVIEW program to Design the program to enter the two strings. The first
string is(system) and the second string is (Department). Put these two strings in the
same string and the output shall be(systemDeparment).
3. Use LABVIEW program to Design the program to find the subset from the string.
The input string is your name (first&last name) and the output string is your last
name.
4. Use LABVIEW program to Design the program to enter the string (Al-Nahrain
University) and Replace the (University) word with a (system).
5. Use LABVIEW program to Design the program to convert the lower-case word to
high case word and vice versa.
network NETWORK
~ 216 ~
CHAPTER THREE
LABVIEW PROJECTS
6. Use LABVIEW program to Design the program to convert the hexa (ABCD) to
number and vice versa.
~ 217 ~
CHAPTER THREE
LABVIEW PROJECTS
Marks Average
Aim of Experiment
The objective of this exercise to learn how to use LabVIEW calculate the marks average.
Apparatus
LabVIEW software.
While Loop
Repeats the code within its sub diagram until a specific condition occurs. A While Loop
always executes at least one time.
Components of a While Loop
Subdiagram—Contains code that the While Loop executes once per iteration.
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
~ 218 ~
CHAPTER THREE
LABVIEW PROJECTS
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range.
Conditional Terminal—Evaluates a Boolean input value to determine whether to
continue executing the While Loop.
Contains one or more subdiagrams, or cases, exactly one of which executes when the
structure executes. The value wired to the case selector determines which case to execute.
Components of a Case Structure
Divide Function
Computes the quotient of the inputs
Block DiagramÎR.CÎNumericÎDivide
~ 219 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 220 ~
CHAPTER THREE
LABVIEW PROJECTS
message is the text to display in the dialog box.
T button name is the name displayed on one of the dialog box buttons. The default is
OK.
F button name is the name displayed on one of the dialog box buttons. The default is
Cancel.
T button? returns a value of TRUE if you click the dialog box button named T button
name. If you click the dialog box button named F button name or click the close window
button, T button? returns a value of FALSE.
Block DiagramÎR.CÎ Dialog & User InterfaceÎTwo Btn Dialog
~ 221 ~
CHAPTER THREE
LABVIEW PROJECTS
Discussion
1- By using LabVIEW program make a simple calculator.
~ 222 ~
CHAPTER THREE
LABVIEW PROJECTS
Shift Register
Aim of Experiment
The objective of this exercise to learn how to use Shift Register to shift data in LabVIEW.
Apparatus
LabVIEW software.
Theory
Iterative Data Transfer
When programming with loops, sometimes you need to call data from previous iterations
of the loop. In LabVIEW, you can use shift registers, which are similar to static variables
in text-based programming languages, to pass values from one loop iteration to the next.
Data enters the right shift register and is passed to the left shift register on the next iteration
of the loop.
~ 223 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 224 ~
CHAPTER THREE
LABVIEW PROJECTS
7. Right-click on the input of the count terminal of the for loop and select Create
Constant. Change the value of this constant to 2.
8. Wire the output of the Initial control to the right edge of the for loop to create a
tunnel.
9. Right-click on the tunnel that you just created and select Replace with Shift
Register.
~ 225 ~
CHAPTER THREE
LABVIEW PROJECTS
10. Wire the output of the right shift register to the Result indicator.
11. Place a multiply function in the for loop.
12. Place a numeric constant in the for loop, assign it a value of 3, and connect it to one
of the input terminals of the multiply function.
13. Wire the left shift register to the remaining input of the multiply function, and wire
the output of the function to the right shift register.
14. View the block diagram by selecting Window»Show Front Panel or pressing <ctr-
E>.
15. Run the VI. The VI changes the value of the Result indicator to 18.
Explanation
~ 226 ~
CHAPTER THREE
LABVIEW PROJECTS
Shift registers are integral to this VI. To understand how the VI works, you can step
through the code.
Because the for-loop’s counter terminal is wired to a constant of 2, it runs twice. On the
first iteration of the for loop, the value of Initial, 2, is multiplied by 3. The result is 6, and
this value is passed to the right shift register. On the second iteration of the for loop, the
left shift register receives the value that was sent to the right shift register on the previous
iteration, 6. The value of 6 is multiplied by 3, for a result of 18. Because the for loop
completed all of its iterations, it stops running and the value of 18 is sent to the Result
indicator on the front panel.
The mathematical formula for this simple VI looks like this:
Result = ((Initial * 3) * 3)
If you changed the value of the for-loop’s count terminal to 4, the mathematical formula
looks like this:
Result = ((((Initial * 3 ) * 3 ) * 3 ) * 3 )
The Experiment Blocks
While Loop
Repeats the code within its subdiagram until a specific condition occurs. A While Loop
always executes at least one time.
~ 227 ~
CHAPTER THREE
LABVIEW PROJECTS
Components of a While Loop
Subdiagram—Contains code that the While Loop executes once per iteration.
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range.
~ 228 ~
CHAPTER THREE
LABVIEW PROJECTS
Block DiagramÎR.CÎNumericÎIncrement
~ 229 ~
CHAPTER THREE
LABVIEW PROJECTS
Part2
Discussion
1- Design the simple project that used the shift register in it by using LABVIEW.
~ 230 ~
CHAPTER THREE
LABVIEW PROJECTS
Home Automation
Aim of Experiment
The objective of this exercise to learn how to use LabVIEW to design home automation.
Apparatus
LabVIEW software.
While Loop
Repeats the code within its subdiagram until a specific condition occurs. A While Loop
always executes at least one time.
Components of a While Loop
Subdiagram—Contains code that the While Loop executes once per iteration.
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
~ 231 ~
CHAPTER THREE
LABVIEW PROJECTS
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range.
Conditional Terminal—Evaluates a Boolean input value to determine whether to
continue executing the While Loop.
Front PanelÎNumericÎThermometer
Procedure
Front Panel& Block Diagram
~ 232 ~
CHAPTER THREE
LABVIEW PROJECTS
Discussion
1- Design another home automation by using LABVIEW.
~ 233 ~
CHAPTER THREE
LABVIEW PROJECTS
Apparatus
LabVIEW software.
The Experiment Blocks
While Loop
Repeats the code within its subdiagram until a specific condition occurs. A While Loop
always executes at least one time.
Components of a While Loop
Subdiagram—Contains code that the While Loop executes once per iteration.
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
~ 234 ~
CHAPTER THREE
LABVIEW PROJECTS
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range.
Conditional Terminal—Evaluates a Boolean input value to determine whether to
continue executing the While Loop.
Greater? Function
Or Function
Computes the logical OR of the inputs. Both inputs must be Boolean values, numeric
values, or error clusters. If both inputs are FALSE, the function returns FALSE.
Otherwise, it returns TRUE.
Block DiagramÎR.CÎBooleanÎOr
Equal? Function
Returns TRUE if x is equal to y. Otherwise, this function returns FALSE.
Block DiagramÎR.CÎComparisonÎEqual?
Increment Function
Adds 1 to the input value.
Block DiagramÎR.CÎNumericÎIncrement
And Function
Computes the logical AND of the inputs. Both inputs must be Boolean values, numeric
values, or error clusters. If both inputs are TRUE, the function returns TRUE. Otherwise,
it returns FALSE.
Block DiagramÎR.CÎBooleanÎAnd
Select Function
Returns the value wired to the t input or f input, depending on the value of s. If s is TRUE,
this function returns the value wired to t. If s is FALSE, this function returns the value
wired to f.
Block DiagramÎR.CÎComparisonÎSelect
~ 236 ~
CHAPTER THREE
LABVIEW PROJECTS
Front Panel ÎR.CÎNumericÎVertical Pointer Slide
~ 237 ~
CHAPTER THREE
LABVIEW PROJECTS
Binary Converter
Aim of Experiment
The objective of this exercise to learn how to use LabVIEW to measure the distance by
using distance sensors.
Apparatus
LabVIEW software.
The Experiment Blocks
While Loop
Repeats the code within its subdiagram until a specific condition occurs. A While Loop
always executes at least one time.
Components of a While Loop
Subdiagram—Contains code that the While Loop executes once per iteration.
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
~ 238 ~
CHAPTER THREE
LABVIEW PROJECTS
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range.
Conditional Terminal—Evaluates a Boolean input value to determine whether to
continue executing the While Loop.
Equal? Function
Returns TRUE if x is equal to y. Otherwise, this function returns FALSE.
Block DiagramÎR.CÎComparisonÎEqual?
~ 239 ~
CHAPTER THREE
LABVIEW PROJECTS
Procedure
Front Panel& Block Diagram
~ 240 ~
CHAPTER THREE
LABVIEW PROJECTS
Counter Up/Down
Aim of Experiment
The objective of this exercise to learn how to use LabVIEW Timers and make the
simple example to make a timer.
Apparatus
LabVIEW software.
The Experiment Blocks
While Loop
Repeats the code within its subdiagram until a specific condition occurs. A While Loop
always executes at least one time.
Components of a While Loop
Subdiagram—Contains code that the While Loop executes once per iteration.
~ 241 ~
CHAPTER THREE
LABVIEW PROJECTS
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range.
Conditional Terminal—Evaluates a Boolean input value to determine whether to
continue executing the While Loop.
Contains one or more subdiagrams, or cases, exactly one of which executes when the
structure executes. The value wired to the case selector determines which case to
execute.
Components of a Case Structure
Decrement Function
~ 242 ~
CHAPTER THREE
LABVIEW PROJECTS
Subtracts 1 from the input value.
Block DiagramÎR.CÎNumericÎDecrement
Increment Function
Adds 1 to the input value.
Block DiagramÎR.CÎNumericÎIncrement
~ 243 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 244 ~
CHAPTER THREE
LABVIEW PROJECTS
Discussion
1- Design the even counter by using LABVIEW grogram.
~ 245 ~
CHAPTER THREE
LABVIEW PROJECTS
Timer
Aim of Experiment
The objective of this exercise to learn how to use LabVIEW Timers and make the simple
example to make a timer.
Apparatus
LabVIEW software.
The Experiment Blocks
While Loop
Repeats the code within its sub diagram until a specific condition occurs. A While Loop
always executes at least one time.
Components of a While Loop
Sub diagram—Contains code that the While Loop executes once per iteration.
~ 246 ~
CHAPTER THREE
LABVIEW PROJECTS
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range.
Conditional Terminal—Evaluates a Boolean input value to determine whether to
continue executing the While Loop.
Subtract Function
Computes the difference of the inputs.
Greater? Function
Returns TRUE if x is greater than y. Otherwise, this function returns FALSE. You can
change the comparison mode of this function.
~ 247 ~
CHAPTER THREE
LABVIEW PROJECTS
Front Panel ÎR.CÎBooleanÎPush Button
Or Function
The connector pane displays the default data types for this polymorphic function.
~ 248 ~
CHAPTER THREE
LABVIEW PROJECTS
Time Delay
Inserts a time delay into the calling VI.
~ 249 ~
CHAPTER THREE
LABVIEW PROJECTS
Dialog Box Options
Elapsed Time
Indicates the amount of time that has elapsed since the specified start time.
Dialog Box Options
~ 250 ~
CHAPTER THREE
LABVIEW PROJECTS
Block Diagram Outputs
Procedure
Wait (ms) Function
Front Panel& Block Diagram
~ 251 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 252 ~
CHAPTER THREE
LABVIEW PROJECTS
Elapsed Time
Timer Design
Design the timer that count from the start input number until down to zero.
Discussion
1- Design the timer by using LABVIEW program to count from zero to infinity.
~ 253 ~
CHAPTER THREE
LABVIEW PROJECTS
Animate Application
Aim of Experiment
The objective of this exercise to learn how to use LabVIEW to design animate application.
Apparatus
LabVIEW software.
While Loop
Repeats the code within its subdiagram until a specific condition occurs. A While Loop
always executes at least one time.
Components of a While Loop
Subdiagram—Contains code that the While Loop executes once per iteration.
Iteration Terminal (i)—Provides the current loop iteration count. The loop count always
starts at zero for the first iteration. If the iteration count exceeds 2,147,483,647, or 231-1,
the iteration terminal remains at 2,147,483,647 for all further iterations. If you need to
~ 254 ~
CHAPTER THREE
LABVIEW PROJECTS
keep count of more than 2,147,483,647 iterations, you can use shift registers with a greater
integer range.
Conditional Terminal—Evaluates a Boolean input value to determine whether to
continue executing the While Loop.
Waits until an event occurs, then executes the appropriate case to handle that event. The
Event structure has one or more sub diagrams, or event cases, exactly one of which
executes when the structure executes to handle an event. This structure can time out while
waiting for notification of an event. Wire a value to the Timeout terminal at the top left of
the Event structure to specify the number of milliseconds the Event structure waits for an
event. The default is -1, which indicates never to time out.
Event Structure Components
The following example shows an Event structure with the Key Down? event case.
~ 255 ~
CHAPTER THREE
LABVIEW PROJECTS
1- The event selector label specifies which events cause the currently displayed case to
execute. To view other event cases, click the down arrow next to the case name.
2- The Timeout terminal specifies the number of milliseconds to wait for an event before
timing out. If you wire a value to the Timeout terminal, you must provide a Timeout
event case to avoid an error.
3- The dynamic event terminals accept an event registration refnum or a cluster of event
registration refnums for dynamic event registration. If you wire the inside right
terminal, that terminal no longer carries the same data as the left terminal. You can
wire the event registration refnum or cluster of event registration refnums to the inside
right terminal through a Register For Events function and modify the event
dynamically. Depending on the palette from which you select the Event structure, the
dynamic event terminals might not appear by default. To display these terminals, right-
click the Event structure and select Show Dynamic Event Terminals from the
shortcut menu.
~ 256 ~
CHAPTER THREE
LABVIEW PROJECTS
4- The Event Data Node identifies the data LabVIEW returns when an event occurs. Like
the Unbundle By Name function, you can resize the node vertically and select the items
you need. Use the Event Data Node to access event data elements, such as Type and
Time, which are common to all events. Other event data elements, like Char and
VKey for example, vary based on the event you configure.
5- The Event Filter Node identifies the event data you can modify before the user
interface can process that data. This node appears in Event structure cases that handle
filter events. If you want to change event data, you can wire and modify data items
from the Event Data Node to the Event Filter Node. You also can change the event
data by wiring new values to the node terminals. To completely discard an event, wire
a TRUE value to the Discard? terminal. If you do not wire a value to a data item of
the Event Filter Node, that data item remains unchanged.
6- Like a Case structure, the Event structure supports tunnels. However, by default you
do not have to wire Event structure output tunnels in every case. All unwired tunnels
use the default value for the tunnel data type. Right-click a tunnel and deselect Use
Default If Unwired from the shortcut menu to revert to the default Case structure
behavior where tunnels must be wired in all cases. You also can configure the tunnels
to wire the input and output tunnels automatically in unwired cases.
Block DiagramÎR.CÎStructureÎEvent Structure
For Loop
~ 257 ~
CHAPTER THREE
LABVIEW PROJECTS
Executes its subdiagram n times, where n is the value wired to the count (N) terminal. The
iteration (i) terminal provides the current loop iteration count, which ranges from 0 to n-
1. Block DiagramÎR.CÎStructureÎFor loop
Random Number
Produces a double-precision, floating-point number between 0 and 1. The number
generated is greater than or equal to 0, but less than 1. The distribution is uniform.
Block DiagramÎR.CÎNumericÎRandom Number (0-1)
~ 259 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 260 ~
CHAPTER THREE
LABVIEW PROJECTS
Discussion
1- Design the program by using LABVIEW to make the animate fan speed
control.
~ 261 ~
CHAPTER THREE
LABVIEW PROJECTS
Seven Segments
Aim of Experiment
The objective of this exercise to learn how to use LabVIEW design 7segments.
Apparatus
LabVIEW software.
Local Variable
Use local variables to read or write to one of the controls or indicators on the front panel
of a VI.
Block DiagramÎR.CÎStructureÎCase StructureÎLocal Variable
~ 262 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 263 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 264 ~
CHAPTER THREE
LABVIEW PROJECTS
Discussion
1- Design the 7segments that display the random numbers.
2- Design the counter and display the numbers by two 7segments.
~ 265 ~
CHAPTER THREE
LABVIEW PROJECTS
Apparatus
LabVIEW software.
~ 266 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 267 ~
CHAPTER THREE
LABVIEW PROJECTS
~ 268 ~
CHAPTER THREE
LABVIEW PROJECTS
Reference
1- Ertugrul, Nesimi. LabVIEW for electric circuits, machines, drives, and laboratories.
Prentice Hall PTR, 2002.
2- Conway, Jon, and Steve Watts. Software Engineering with LabVIEW. Pearson
Education, 2003.
3- Jerome, Jovitha. Virtual instrumentation using LabVIEW. PHI Learning Pvt. Ltd.,
2010.
4- Travis, Jeffrey. LabVIEW for everyone. Pearson Education India, 2002.
5- Kehtarnavaz, Nasser, and Namjin Kim. Digital signal processing system-level design
using LabVIEW. Elsevier, 2011.
6- Clark, Cory L. LabVIEW digital signal processing. Tata McGraw-Hill Education,
2005.
7- Collamati, L., et al. "Induction machine stator fault on-line diagnosis based on
LabVIEW environment." Proceedings of 8th Mediterranean Electrotechnical
Conference on Industrial Applications in Power Systems, Computer Science and
Telecommunications (MELECON 96). Vol. 1. IEEE, 1996.
8- Bell, Ian, et al. "Integration of hardware into the LabVIEW environment for rapid
prototyping and the development of control design applications." Proc. of the UKACC
Control 2004 Mini Symposia. 2004.
9- Spanik, Pavol, et al. "Application of virtual instrumentation LabVIEW for power
electronic system analysis." 2006 12th International Power Electronics and Motion
Control Conference. IEEE, 2006.
10- Odon, A., P. Otomański, and M. Płaczek. "LabView application to simulation of
digital to analog converter based on binary weighted resistors ladder." Poznan
University of Technology Academic Journals. Electrical Engineering 61 (2010): 139-
145.
~ 269 ~
Buy your books fast and straightforward online - at one of world’s
fastest growing online book stores! Environmentally sound due to
Print-on-Demand technologies.
Buy your books online at
[Link]
Kaufen Sie Ihre Bücher schnell und unkompliziert online – auf einer
der am schnellsten wachsenden Buchhandelsplattformen weltweit!
Dank Print-On-Demand umwelt- und ressourcenschonend produzi
ert.
Bücher schneller online kaufen
[Link]
KS OmniScriptum Publishing
Brivibas gatve 197
LV-1039 Riga, Latvia info@[Link]
Telefax: +371 686 204 55 [Link]