1. Course Name :Virtual Instrumentation
Course Code: AEI-802
6 May 2015 1
Subject Incharge:
Ms. Princy Randhawa
Assistant Professor
2. Introduction
What is an Instrument?
Collect the data
Analysis Data
Display Information
e.g. Transducer, Oscilloscopes, Digital
Multi-meter
6 May 2015 2
3. Virtual Instrumentation- Definition
To Test, Control and Design
applications making accurate analog
and digital measurements.
Using VI, can also control external
hardware devices from desktop
computer and for displaying unit.
6 May 2015 3
5. Virtual Instrumentation-Architecture
6 May 2015 5
Sensor Module
Sensing (or Transducer)
Signal conditioning
A/D conversion
Processing Module
Sensor Interface
Data Base
Interface
Medical
Information
System
Interface
User Interface-Display and Control
6. Historical Perspective
Analog Measurement Devices
Data Acquisition and Processing
Devices
Digital processing based on general
purpose computing platform
Distributed virtual instrumentation
6 May 2015 6
7. Distributed Virtual Instrumentation
6 May 2015 7
Internet
Information
System Interface
Private
Networks
Mobile
Telephony
WAP
Gateway
Extranet
SMS Gateway
8. Contd…
Medical Information System Networks
and Private Networks
Medical information systems, such as hospital
information systems, are usually integrated as Intranets
using Local Area Network (LAN).
Advanced virtual instrumentation solutions could be
implemented using existing local and private networks.
6 May 2015 8
9. Contd…
Internet
Various remote devices, such as tele-robots or remote
experimental apparatus, can be directly controlled from
the Internet.
Many of virtual instrumentation development tools, such
as Lab VIEW, directly support integration of virtual
instruments in the Internet environment.
6 May 2015 9
10. Contd…
Cellular Networks
Wireless Access Protocol (WAP) is platform-independent
wireless technology, which enables mobile devices to effectively
access Internet content and services, as well as to communicate
with each other.
Emergency WAP push, which sends WML messages to
physicians or medical call enter in case of medical emergency.
6 May 2015 10
11. Traditional Vs Virtual Instruments
Traditional Instruments Virtual Instruments
Vendor-defined User-defined
Function-specific, stand-alone with
limited connectivity
Application-oriented system with
connectivity to networks, peripherals,
and applications
Hardware is the key Software is the key
Expensive Low-cost, reusable
Closed, fixed functionality Open, flexible functionality leveraging
off familiar computer technology
Slow turn on technology (5–10 year life
cycle)
Fast turn on technology (1–2 year life
cycle)
Minimal economics of scale Maximum economics of scale
High development and maintenance
costs
Software minimizes development and
maintenance costs
6 May 2015 11
12. Advantages of VI
Performance
Platform-Independent Nature
Flexibility
Lower Cost
Plug-In and Networked Hardware
The Costs of a Measurement Application
Reducing System Specification Time Cost
Lowering the Cost of Hardware and Software
Minimizing Set-Up and Configuration Time Costs
Decreasing Application Software development
Time Costs
6 May 2015 12
13. LABVIEW-Introduction
Laboratory Virtual Instrument Engineering
Workbench (Lab VIEW)
Lab VIEW 1.0 was launched in 1986.
Lab VIEW is a graphical programming language (G)
that uses icons instead of lines of text to create
applications.
Lab VIEW Programs Are Called Virtual Instruments
(VIs) because their appearance and operation imitate
physical instruments like Oscilloscopes, Digital
Multi-meter.
Lab VIEW contains a set of VIs and functions for
acquiring , analyzing , displaying and storing data.
6 May 2015 13
14. Contd…
It includes analysis functions for differential
equations, optimization, curve fitting, calculus,
linear algebra, statistics and so on.
It also includes the tools to present the data on the
computers: Charts, Graphs, Tables, Gauges,
Meters,Tanks,3D controls, 3D Graphs, Picture
Control etc.
6 May 2015 14
15. Using Lab VIEW in the Real World
Lab VIEW can command plug-in data acquisition, or DAQ,
devices to acquire or generate analog and digital signals
Using DAQ devices and Lab VIEW to monitor a
temperature, send signals to an external system, or determine
the frequency of an unknown signal.
Lab VIEW also facilitates data transfer over the General
Purpose Interface Bus (GPIB), or through your computer's
built-in USB, Ethernet, Firm wire (also known as IEEE 1394),
or serial port.
GPIB is frequently used to communicate with oscilloscopes,
scanners, and multi meters, and to drive instruments from
remote locations.
6 May 2015 15
16. Contd….
6 May 2015 16
Figure 1.1 The Space Industries Sheet Float Zone Furnace is used for high-
temperature superconductor materials processing research in a microgravity
environment aboard the NASA KC-135 parabolic aircraft. Lab VIEW controls the
industrialized Mac OS-based system.
17. Advantages of LAB VIEW
Graphical User Interface
Easy to use and Learn
Drag and Drop built-in functions
Modular Design and hierarchical design
Multiple high level development tools
Professional Development tools
Multi platforms
Reduces Cost and preserves investment
Flexibility and scalability
Connectivity and Instrument control
Open Environment
Distributed Development
Visualization capabilities
Rapid development with express technology
Compiled language for fast execution
Simple application distribution
Target management
Object Oriented Design
Algorithm Design
6 May 2015 17
18. Virtual Instrumentation in the
Engineering process
6 May 2015 18
Development
Test and
Validation
Research and
Design
Manufacturing
Test
Manufacturing
19. Comparison of Text Based and
Graphical Programming
Text Based Programming Graphical Programming
Syntax must be known to do programming Syntax is knowledge but is not required for
programming
The execution of the program is from top to
bottom
The execution of the program is from left to
right
To check for the error the program has to be
compiled or executed
Errors are indicated as we wire the blocks
Front panel design needs extra coding or
needs extra work
Front panel design is a part of programming
Text based programming is not interactive Graphical programming is highly interactive
This is the text based programming where
the programming is not conventional
method
The programming is data flow programming
Logical error finding is easy in large
programs
Logical error finding in large programs is
quiet complicated
Program flow is not visible Data flow is visible
It is Text based Programming It is icon based programming and wiring
Passing parameters to sub routine is difficult Passing Parameters to sub VI is easy
6 May 2015 19
20. Lab VIEW Terms and Their
Conventional Equivalents
Lab VIEW Conventional Language
VI Program
Function Function or Method
Sub VI Subroutine, Sub Program or
Object
front panel user interface
Block Diagram Program Code
G C, C++, Java, Pascal, BASIC, etc.
6 May 2015 20
21. Lab VIEW Programs Are Called
Virtual Instruments (VIs)
6 May 2015 21
Front Panel
•Controls = Inputs
•Indicators = Outputs
Block Diagram
•Accompanying “program” for front panel
•Components “wired” together
22. 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, 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 the block diagram acquires or
generates.
6 May 2015 22
24. Block Diagram
Every control or indicator on the front panel has a
corresponding terminal on the block diagram.
It contains-Terminals, Nodes, Wires
Wires connect each of the nodes on the block diagram,
including control and indicator terminals, functions and
structures.
6 May 2015 24
Node
Wire
Terminal
25. Basic wires used in block diagrams
and corresponding types
6 May 2015 25
Each wire has different style or color, depending on the data
type that flows through the wire:
26. Tools Palette
The Tools palette is available on the front panel and the block
diagram.
A tool is a special operating mode of the mouse cursor. When
you select a tool, the cursor icon changes to the tool icon.
Use the tools to operate and modify front panel and block
diagram objects.
Select View» Tools Palette from the taskbar to display the
Tools palette.
6 May 2015 26
27. Controls Palette
The Controls palette is only available on the front panel. The
Controls palette contains the front panel controls and
indicators you use to create the user interface.
Select View» Controls Palette or right-click the front panel
workspace to display the Controls palette.
6 May 2015 27
28. Functions Palette
The Functions palette is available only on the block diagram.
The Functions palette contains the objects you use to program
your VI, such as arithmetic, instrument I/O, file I/O, and
data acquisition operations.
Select View» Functions Palette from the taskbar or right-click
the block diagram workspace to display the Functions
palette.
6 May 2015 28
29. Status Toolbar
6 May 2015 29
Run Button
Continuous Run Button
Abort Execution
Pause Button
Text Settings
Align Objects
Distribute Objects
Reorder
Resize front panel objects
Execution Highlighting Button
Step Into Button
Step over Button
Step Out Button
31. Data flow programming
Block diagram does NOT execute left to right
Node executes when data is available to ALL input
terminals
Nodes supply data to all output terminals when
done
6 May 2015 31
32. Keyboard Shortcuts while
working with Lab VIEW
<Ctrl-S > Save a VI
<Ctrl-R> Run a VI
<Ctrl-F> Find object
<Ctrl-H> – Activate/Deactivate Context Help
Window
<Ctrl-B> – Remove Broken Wires From Block
Diagram
<Ctrl-E> – Toggle Between Front Panel and Block
Diagram
<Ctrl-Z> – Undo (Also in Edit Menu)
6 May 2015 32
33. Examples
☺ Divide two numbers and find the remainder
and quotient.
☺ Convert Celsius to Fahrenheit.
☺ Find whether the given number is odd or
even.
☺ Convert a binary number to a decimal
number.
☺Compute the given equations (X1+2)*log(X1)
using functions, Expression node and Express
formula for the given inputs.
☺Add two binary numbers and find the sum
and carry( half adder).
6 May 2015 33
34. Creating SUBVIs
A SubVI is a VI that can be used within another VI
Advantages
◦ Modular
◦ Easier to debug
◦ Don’t have to recreate code
◦ Require less memory
6 May 2015 34
35. Icon and Connector
6 May 2015 35
Icon
Connector
Terminals
An icon represents a VI in other block
diagrams
A connector shows available terminals for
data transfer
36. Steps to Create SubVI
Create the Icon
Create the Connector
Assign Terminals
Save the VI
Insert the VI into a Top Level VI
6 May 2015 36
37. Create the icon
6 May 2015 37
Right-click on the icon in the diagram or front panel
40. Saving the VI
Choose an Easy to Remember Location
Organize by Functionality
◦ Save Similar VIs into one directory (e.g. Math Utilities)
Organize by Application
◦ Save all VIs Used for a Specific Application into one
directory or library file (e.g. Lab 1 – Frequency Response)
◦ Library Files (.llbs) combine many VI’s into a single file,
ideal for transferring entire applications across computers
6 May 2015 40
41. Examples
Create a VI to find the average of two
numbers and convert a section of VI
into SubVI.
Create a VI to find roots of a quadratic
equation using SubVIs . Find both the
values of roots and the nature of roots.
6 May 2015 41
42. Programming Concepts of VI
Control Structures- For Loop and While Loop
Shift Registers and their functions
Feedback Nodes
Structures- Sequence and Case Structure
Formula Node
Arrays- Single and Multidimensional Array
Auto-indexing of Arrays
Functions for Manipulating Arrays
Creating Clusters Controls and Indicators
Waveform Charts
Single plot and Multiple Plot Waveform Graphs
XY Graphs and Intensity Graphs
Strings ,String Functions
File Input/output, File I/O Vis Functions
6 May 2015 42
43. Loops
Nearly all programs involve some sort of loop where all or
sections of the program must be repeated.
Both the While and For Loops are located on the Functions»
Structures palette.
The For Loop differs from the While Loop in that the For
Loop executes a set number of times.
A While Loop stops executing the sub diagram only if the
value at the conditional terminal exists.
6 May 2015 43FOR Loop While Loop
44. Drawing Loops
Select the structure required
Enclose the code to be
repeated (looped)
Wire the appropriate loop
conditions
o Runs according to input N number of
iterations
o Counts the number of iterations
6 May 2015 44
45. LAB VIEW Functions
What types of function are available
◦ Analysis
Signal processing
Statistics
Advanced math &
formulae
◦ Storage
File I/O
Zip
◦ ARM specific
Simulation
Read digital I/O
◦ +Many more!
6 May 2015 45
46. Wait Functions
6 May 2015 46
Wait until next ms Multiple
Functions» Time & Dialog palette
47. Contd….
6 May 2015 47
Wait (ms)
Functions»Time & Dialog palette
Time Delay
Functions»Time & Dialog palette
48. Accessing Previous Loop Data – Shift
Register
Available at left or right border of loop structures
Right-click the border and select Add Shift Register
Right terminal stores data on completion of iteration
Left terminal provides stored data at beginning of next
iteration
6 May 2015 48
Value 3
First Iteration Second Iteration Last Iteration
Initial Value
Before Loop
Begins
49. Additional Shift Register Elements
6 May 2015 49
Right-click the
left terminal
to add new
elements
Right-click the border
for a new shift register
50. Feedback Nodes
Appears automatically in a For Loop or While
Loop if you wire the output of a subVI, function, or
group of subVIs and functions to the input of that
same VI, function, or group.
Stores data when the loop completes an iteration,
sends that value to the next iteration of the loop,
and transfers any data type
6 May 2015 50
51. Contd…
6 May 2015 51
Wire from output to input to automatically create a feedback node
OR
Place a feedback node from the Functions»Structures palette
52. Local and Global Variables
Local Variable allows you to read or
write to a control or indicator on the
front panel.
It allows you to force a control’s value
with the code, or use an indicator to
store data.
It can store all types of data, such as
numeric values, strings, T/F values,
or arrays
6 May 2015 52
53. Contd….
A Global variable is identical in function to
a local variable. The difference between
them is where the data is saved.
A local variable saves the data to the front
panel of the VI that it’s in; this makes them
only be useable in that VI.
A global variable is used to pass
information from one VI to another
6 May 2015 53
54. Contd…
Global variable is located under structure
The global variable only has a front panel with no
block diagram
*if a certain data type is needed, the indicator
representation must be changed within the Global
Variable VI
6 May 2015 54
56. Select a Global Variable that is
already created
In order to select a Global Variable that has already been
created, right click on the block diagram and select “select a
VI”
Locate the created Global Variable and place it on the block
diagram
6 May 2015 56
58. Examples
Create a VI to find the factorial of the given number using
FOR loop and While Loop
Create a VI to find the sum of first n natural numbers using a
while loop with a feedback node.
Create a VI to change the state of the Boolean indicator n
times between TRUE and FALSE.
Create a Global VI which consists of a knob and a stop
button. Create another VI consisting of a waveform chart.
Update the values of Global Vis knob and plot Vis side in the
waveform chart. Press the stop button of the Global VI to stop
both the Vis.
6 May 2015 58
59. Arrays
6 May 2015 59
An array is like a list.
An array is a collection of elements
All elements in the array have the
same data type: Boolean, Double,
Int, String
60. Thinking About Arrays
Index 0 1 2 3 4 5 6 7
Element 2.4 5 6.7 4.8 1.4 3.6 7.4 1.3
6 May 2015 60
Array elements are accessed by their
index
Indices start at 0, not 1
This is a one dimensional array
Arrays can have more dimensions
2 dimensional array, like a table of
data
61. Arrays in LabVIEW
Arrays can be created
on the block diagram
On block diagram select
arrays sub palette
Select array constant and
drag onto block diagram
This creates an array shell
6 May 2015 61
62. Creating an Array on Block
Diagram
To finish creating the array
the data type the array
holds must be determined.
Drag a constant from a sub
palette into the elements
portion
This determines the data
type of the array
6 May 2015 62
index elements
after dragging numeric constant
into elements
63. 6 May 2015 63
Array expanded to show elements 0 through 10
Clicking on index array display other elements. The element on the far
left (or top) of the array has the index shown in the index box.
Light blue elements are elements that have not been initialized.
Array Constants on Block Diagram
66. 6 May 2015 66
Creating Arrays Via the Front Panel
Arrays can also be created via the
front panel
Click on the Array and Cluster sub
palette
click and drag an array to the
front panel and this creates an
array control shell
67. 6 May 2015 67
Creating Arrays Via the Front Panel
A data type must be added to the
array shell
drag a control or indicator of the
data type you want into the shell
Can change from double to int by
right clicking on elements and
selecting “data range”
click on icon under
“representation” and change to an
integer type
array shell
68. 6 May 2015 68
Array Functions
Build an array
Size an array
Form an array from a cluster or a cluster into
an array
Index an array
Find the max an min of an array
Insert and delete from an array or reshape
Sort a lD array
Convert an array to matrix, or a matrix to
array
69. Build and sizing an array
Complies multiple arrays or appends
elements to an n-dimensional array.
Sizing an array just shows the
number of elements in the array on
the front panel.
70. Index Array
Returns the element or sub-array of n-
dimension array at index.
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.
You also can add additional element or sub-
array terminals by resizing it.
71. Max and Min of an Array
Returns the maximum and minimum values
found in array, along with the indexes for each
value. The array can be an n-dimensional array
of any type.
Max/min index(es) is the index for the first
max/min value. If array is multidimensional,
max/min index(es) is an array whose elements
are the indexes for the first maximum/min
value in array.
Would be good to use if you needed to know
when a graph peaked or lowest value
72. Sorting an Array
Returns a sorted version of array with the
elements arranged in ascending order.
If array is an array of clusters, the function
sorts the elements by comparing the first
elements.
If the first elements match, the function
compares the second and subsequent elements.
73. Converting an Array to a Matrix
Converts an array to a matrix of
elements of the same type as the array
elements .
Can make each of the following
* to real matrix
* to column vector
* to complex matrix
* to complex column vector
74. Array => cluster or cluster =>array
Bundles each component input into a cluster
and assembles all component clusters into an
array of clusters. Each cluster contains a
single component. Input components must
be of the same type as the value wired to the
topmost component terminal.
Array to cluster converts a 1D array to a
cluster of elements of the same type as the
array elements.
75. Visual Programming Arrays in LabVIEW 75
Auto indexing
LabVIEW has a feature with loops
and arrays called auto indexing.
If you wish to carry out an operation
on every element of an array a loop is
required.
Assume we have an array and we
want to double every element.
77. Visual Programming Arrays in LabVIEW 77
Notes on Previous slide
No value wired to count terminal
Count based on length of array
Thick wire going in and coming out,
but thin inside the loop
◦ working with a single element of the
array
Must create array indicator to show
array when finished
◦ can be a bit tricky
78. Visual Programming Arrays in LabVIEW 78
Manipulating Arrays
Many functions for
working with arrays
initialize array
initial value
for all elements
size of the array
79. Visual Programming Arrays in LabVIEW 79
Getting the Length of an Array
array input
output is size
of array
80. Visual Programming Arrays in LabVIEW 80
Changing Values of Elements
Giving an array, set the value at position
2 (actually the 3rd element of the array)
to 1 more than its previous value
Uses Index Array and Replace Array
Subset
Index Array
array
index
value at element
Replace Array
Subset
array
index
new value for
element
resulting
array
81. Clusters
6 May 2015 81
Data structure that groups data together.
Data may be of different types.
Analogous to struct in C or a record in Pascal.
Elements must be either all controls or all
indicators.
Thought of as wires bundled into a cable.
82. Clusters Controls and Indicators
6 May 2015 82
1. Select a Cluster shell from
the Array & Cluster
subpalette
2. Place objects inside the shell
83. Building a Cluster
Clusters are built by bundling up a
collection of inputs and they are
complied into a cluster which can
then be manipulated to your liking.
They are perfect for organization and
complying data in a neat and uniform
way that is easily represented in the
front panel.
84. Bundling and Unbundling
Assembles a cluster from individual elements.
It can also be use to change the values of
individual elements in an existing cluster without
having to specify new values for all elements. To
do so, wire the cluster you want to change to the
middle cluster terminal of this function. When you
wire a cluster to this function, the function resizes
automatically to display inputs for each element in
the cluster. Also when you wire to the middle
terminal, all other inputs are optional.
85. Indexing A Cluster
Indexes a set of arrays and creates a
cluster array in which matches the
value of each element to a
corresponding location.
86. 86
Cluster Order
Elements have a logical order (start with 0).
To change order, right-click the border and select
Reorder Controls in Cluster...
87. 87
Using Clusters to Pass Data
to SubVIs
Use clusters to pass
several values to one
terminal
Overcomes 28-terminal
limit
Simplifies wiring
88. 88
Cluster Functions - Bundle
BundleBundle
ByNameCreate new cluster Modify existing cluster
Must have an existing
cluster to use this
function.
90. 90
Error Cluster
Use the error in and error out clusters in each VI
you use or build to handle errors in the VI.
The error clusters located on the
Controls»Array & Cluster palette include the
components of information shown.
91. 91
Error Cluster Details
Status is a Boolean value that
reports TRUE if an error occurred.
Most VIs, functions, and structures
that accept Boolean data also
recognize this parameter.
Code is a signed 32-bit integer that
identifies the error numerically. A
non-zero error code coupled with a
status of FALSE signals a warning
rather than a fatal error.
Source is a string that identifies
where the error occurred.
92. 92
Error Handling with Clusters
LabVIEW does not handle errors automatically.
In LabVIEW, you can make these error handling
decisions on the block diagram of the VI.
Error handling in LabVIEW follows the dataflow
model. Just as data flow through a VI, so can
error information.
Wire the error information from the beginning of
the VI to the end.
Error Cluster
93. Plotting Data
6 May 2015 93
Waveform Charts
Waveform and X-Y Graphs
Intensity Graphs
96. 96
Modifying Chart Properties
•Change the
appearance
•Set the format
and precision of
the axis
•Choose the plot
type
•Edit the scales
•Document the
chart
97. 97
Customizing Charts and
GraphsRight-click and select Visible Items to view the
following items:
Plot Legend
Digital Display
Scrollbar
X and Y Scale
Graph Palette
Scale Legend
Graph Palette
Scale
Legend
Zoom
Subpalette
98. 98
• Selected from the Graph subpalette
• Waveform Graph – Plot an array of numbers
against their indices
• XY Graph – Plot one array against another
Plot Legend
(point and line
styles)
Graph PaletteScale Legend
Graphs
99. 99
Uniform X axis
Initial X = 0.0
Delta X = 1.0
Uniform X axis
you specify point
spacing
Single-Plot Waveform Graphs
100. 100
Multiple-Plot Waveform Graphs
Each row is a
separate plot:
Initial X = 0
Delta X = 1
Each row is a
separate plot:
Bundle specifies
point spacing of the
X axis
101. 101
• Non-uniform X axis
• Separate X and Y arrays
define data points
XY Graphs
102. 102
Intensity Plots and Graphs
Useful in displaying terrain, temperature patterns,
spectrum analysis, and image processing
Data type is a 2D array of numbers; each number
represents a color
Use these options to set and display color mapping
scheme
Cursor also adds a third dimension
103. 103
•The waveform chart is a special numeric indicator
that displays one or more plots. The waveform
chart has the following three update modes:
–A strip chart shows running data continuously scrolling from left
to right across the chart.
–A scope chart shows one item of data, such as a pulse or wave,
scrolling partway across the chart from left to the right.
–A sweep works similarly to a scope except it shows the old data on
the right and the new data on the left separated by a vertical line.
•Waveform graphs and XY graphs display data
from arrays.
•Right-click a waveform chart or graph or its
components to set attributes of the chart and its
plots.
Summary
104. 6 May 2015 104
Structures
Structures are graphical representations of the
loops and case statements of text based
programming languages.
In text based programs, this can be accomplished
with statements like if else, case and so on.
Decision making with the select function.
105. 105
Simple Decision: Select Function
If Temp Scale is TRUE, pass top input;
if temp scale is FALSE, pass bottom input.
If the decision to be made is more complex than
a Select function can execute, a Case Structure
may be what is required.
106. 6 May 2015 106
Structures…..
For Loop
While Loop
Case Structure
Sequence structure
Event Structure
Timed Structure
107. 6 May 2015 107
Case Structure
Contains multiple sub diagrams, only one of
which executes depending on the input value
passed to the structure.
Boolean Case Structure Example:
If Temp Scale is TRUE, execute True case;
if temp scale is FALSE, execute False case.
109. 109
String Case
String input. Like the numeric input case, the value of the
string
determines which box to execute. Stress that the value much
match exactly or
the structure will execute the default case.
110. Sequence Structure
Flat Sequence Structure: It displays all the
frames at once and executes the frames from left to
right and when all the data values wired to a frame
are available, until the last frame executes.
6 May 2015 110
111. Contd…
Stacked Sequence Structure: It stacks each frame so
you see only one frame at a time and executes
frame 0, then frame 1,and so on until the last frame
executes.
6 May 2015 111
It can easily convert one into the other by selecting from its
pop-up menu, Replace with Stacked Sequence (to convert
from Flat to Stacked) or Replace>>Replace with Flat Sequence
(to convert from Stacked to Flat).
112. Event Structure
It waits until an event happens and then
executes the appropriate case to handle that
event.
6 May 2015 112
113. Contd…
6 May 2015 113
An event is an action that triggers a change
in state
User initiated
Button press
Mouse click
OS initiated
timeout
Software initiated
Message from another program
Variable reaches a specific value
114. Formula Node
In the Structures sub-palette .
Implement complicated equations.
Variables created at border.
Variable names are case sensitive.
Each statement must terminate with a semicolon (;)
Context Help Window shows available functions.
6 May 2015 114
115. 115
Decision Making with Formula Nodes
Two different ways of using an if-then statement in a Formula Node.
Both structures produce the same result.
116. 6 May 2015 116
String and File I/O
TOPICS:
How to create string controls and indicators
How to use several String functions
About file I/O operations
How to use the high-level File I/O VIs
How to use the low-level File I/O VIs
How to format text files for use in spreadsheets
117. 6 May 2015 117
Strings
A string is a sequence of displayable or non-displayable (ASCII)
characters.
Strings often are used to send commands to instruments, to
supply information about a test (such as operator name and
date), or to display results to the user.
Applications:
Creating simple text messages.
Passing numeric data as character strings to instruments and converting
the strings to numeric values.
Storing numeric data to disk. To store numeric data in an ASCII file,you
must convert numeric data to strings before writing the data to a disk
file.
118. 6 May 2015 118
Creating String Controls and
Indicators
String control/indicator is in the Controls»String
subpalette.
Normal display code display
Hex display
Password Display
123. 6 May 2015 123
Formatting Strings
Array to Spreadsheet String
Spreadsheet String To Array
Scan from string
Format into string
Format value
Scan value
Scan from File
Format into file
124. 6 May 2015 124
File Input and Output ( I/O)
Four Hierarchy Levels:
High-level File VIs
Intermediate File VIs and
Functions
Advanced File Functions
sub-palette
Express VIs
125. 125
• Write to Spreadsheet File
• Read from Spreadsheet File
• Write Characters to File
• Read Characters from File
• Read Lines from File
High-level File I/O VIs
126. 126
Write to File Example
• Open/Create/Replace opens the existing file TEST1.DAT
and generates refnum and error cluster
• Write File writes the data
• Close File closes the file
• Simple Error Handler checks for errors.
127. 127
Reading Data from a File
•Open/Create/Replace opens the file
•Read File reads the specified number of bytes from the file
•Close File closes the file
•Simple Error Handler checks for errors
128. 128
Formatting a Spreadsheet String
• Spreadsheets are popular tools for data handling and
analysis
• There are many formats for spreadsheet data. One of the
most popular is tab-delimited:
– Columns are separated by a tab character
– Rows are separated by an end-of-line
character
Tab End of Line
A spreadsheet yields:
129. 129
Creating a Spreadsheet File
Can replace Format Into String
and
Write File with Format Into File
in above example
130. 130
Write LabVIEW Measurement File
Includes the open, write, close and error
handling functions
Handles formatting the string with either a tab
or comma delimiter
Merge Signals function is used to combine data
into the dynamic data type
132. About plug-in data acquisition (DAQ)
boards.
About the organization of the DAQ VIs.
How to acquire and display an analog
signal.
How to perform a timed data acquisition.
How to acquire data from multiple analog
channels.
How to drive the digital I/O lines, and the
basics of buffered data acquisition.
DAQ Scope
133. 133
Overview and Configuration
Fundamental task of a DAQ
system is to measure or generate
real-world physical signals
DAQ system consists of:
•Transducers
•Signal Conditioning
•Plug-in DAQ device
•Driver
•Software
134. DAQ boards:
Analog I/O
Digital I/O
Counter/timer I/O
DAQ library supports all DAQ boards
LabVIEW uses the NI-DAQ driver-level software
Data Acquisition System Components
PLUG-IN DAQ BOARD: Measures (acquires),
processes, stores, and generates signals, as instructed
by software program. Examples: Analog and digital
signals’ input and output, counters, timers, etc.
COMPUTER with SOFTWARE: Control the DAQ board,
process, store, and display data, as instructed by software
program. Examples: LabVIEW application programs to acquire
data, simulate instruments, and generate results, etc.
SIGNAL CONDITIONING: Modify transducer signals
to match DAQ board specs/ranges. Examples: amplification
or attenuation, filtering, excitation, etc.
TRANSDUCERS: Sense the measured quantities
and change their properties or generate corresponding
electrical signals. Examples: strain gage, thermocouple,
accelerometer, potentiometer, etc.
Data Acquisition - DAQ
135. Transducers
Sense Phenomena
Produce Electrical Signal
Examples:
Thermocouples, Thermistors
Strain Gauges, RTDs
Pressure Transducers, Load Cells
Accellerometers, Microphones
Potentiometers, Etc..
136. Signal Conditioning
Condition Transducer Signals
Make Signal Suitable for DAQ Board
Examples:
Amplification/Attenuation
Linearization/Calibration
Filtering
Multiplexing (up to 3,072 channels)
Isolation, Excitations, Etc.
137. DAQ Hardware & Software
Configurations
Hardware:
Setting DIP Switches and Jumpers for Particular
Options/Applications
Newer and Plug-and-Play Boards are Software
Configured
Cabling, Signal Conditioning, Terminal Blocks, etc.
Software:
Set-up and Configuration Programs
Drivers: Interface between DAQ Board and Computer
DAQ Application Software (LabVIEW, C, Basic, etc.)
Data Acquisition
Data Analysis (Statistics, FFT, DSP, etc.)
Data Presentation (Graphing, Plotting, Tabulation, etc.)
141. 141
Data Acquisition in LabVIEW
Traditional NI-DAQ
Specific VIs for
performing:
• Analog Input
• Analog Output
• Digital I/O
• Counter operations
NI-DAQmx
Next generation driver:
• VIs for performing a
task
• One set of VIs for all
measurement types
142. 142
NI-DAQmx Data Acquisition
Single set of VIs used to perform
analog I/O, digital I/O, and counter
operations
DAQ Assistant Express VI
• Quickly and easily program the DAQ
device
• Creates a local task
• Most applications can use the DAQ
Assistant Express VI
143. 143
NI-DAQmx Data Acquisition
Task Types
Measurement
type
can be:
•Analog Input
•Analog Output
•Counter Input
•Counter Output
•Digital I/O
145. Analog Input Considerations
• Single-Ended vs. Differential
• Resolution
• Range
• Sampling Rate / Aliasing
• Averaging / Noise reduction
10
1 * 212
= 2.4 mV
20
1 * 212
= 4.8 mV
Adequately sampled
Aliased due to undersampling
8
3-bit ADC 16-bit ADC
Time
.
10 V range
12 bit
resolution
1X Gain
Aliasing
.
146. 146
Analog Input Task Timing and
Triggering
Configures the number of samples
and sample rate for the task
Configures the start and reference
triggers for the task
147. 147
Data Logging
It is often necessary to permanently store data
that is acquired from the DAQ device
LabVIEW includes the ability to read and write
a LabVIEW Measurement File
LabVIEW Measurement File is an ASCII text
file
149. 149
Analog Output Task Timing and
Triggering
Configures the number of
samples and sample rate for
the task
Configures the start and
reference triggers for the task
150. HOW do I make a DAQ device
provide a voltage???
151. The BASICS: You need 3 things…..
LabVIEW Application
MAX
DAQ Device
152. Voltage Output
Note the ANALOG side
of the USB devices near
your computers.
There should be terminals
labeled AO0 and AO1
AO stands for Analog
Output.
Most of the NI devices
have at least 2 such
terminals
For output we wire a
terminal and a ground.
153. Voltage Output
• We access the analog output functions via
LabVIEW. To do this we can access the DAQ
Assistant.
• We can right-mouse click and access
Functions on the Block Diagram.
• Select the DAQ Assistant on the OUTPUT
Menu
154. Voltage Output
• When the DAQ Assistant is selected you get 2 choices:
• “Acquire Signals”…what we have used so far
• “Generate Signals” choose this one for voltage output!
155. • Once you select Generate Signals choose Voltage
• The device or devices will appear. Choose either
one or both channels (depending on how many
signals must be generated.)
156.
157. 157
Counters
A counter is a digital timing
device
Typical uses of a counter:
• Event counting
• Frequency measurement
• Period measurement
• Position measurement
• Pulse generation
Gate
Source
Output
Count Register
Count register – Stores the current count of the counter
Source – Input that causes the counter to increment each time it toggles
Gate – Input that is used to enable or disable the function of the counter
Output – Signal that generates pulses or a series of pulses
158. 158
Digital Input and Output
Digital I/O
can read
from or write
to a line or an
entire digital
port
A digital port
is a collection
of digital
lines
159. Analog Input and Output VIs
AI Sample Channel
AO Update Channel
161. Digital Input and Output
Write to Digital Line Read from Digital Line
Write to Digital Port Read from Digital Port
162. DAQ Summary
Identify I/O Signal Types:
Transducers/Controllers
Choose a Signal Conditioning Method
Select a Data Acquisition (DAQ)
Device
Choose Terminals/Cables for the
Hardware
Select DAQ Software
166. DEMO Application
Sometimes we need more than just 5
or 10 volts
How can the LabVIEW output
function help us to run a pump or
motor?
Application: We need to use LabVIEW
to control a motor. The motor uses a
variable voltage from 60 to 120 volts
to adjust from top speed to low speed.
167. Contd..
In this case we would use a device with
the motor’s manual control electronics.
The controller will accept a grounded DC
signal and generates a proportional
output voltage.
This output can be supplied to the speed
setting circuit of the motor’s controller.
This will drive the motor at a speed
proportional to the signal that LabVIEW
sends to it.
168. DEMO Application
Main power supplied
By 120 VAC outlet
Control box
With SCR-based
potentiometers
0-10 VDC “control” volts from
LabVIEW
Power line
from control
Drive Motor
Turn-Table with experiment
169. Fast Fourier Transform
6 May 2015 169
It is a tool to connect between time domain
and frequency domain
Any waveform in the time domain can be
represented by weighted sum of sines and
cosines.
The sum waveform appears in the frequency
domain as amplitude and phase values at
each component (fo,2fo,3fo)
170. Why we exchange between time
domain and frequency domain?
6 May 2015 170
171. Why Fourier Transform?
6 May 2015 171
This example is a sound record analysis. The left picture is the sound
signal changing with time. However, we have no any idea about this
sound by the time record. By the Fourier transform, we know that this
sound is generated at 50Hz and 120Hz mixed with other noises.
172. Contd…
6 May 2015 172
It is used for analyzing and measuring
signals from plug in data acquisition
(DAQ) devices
It can measure the frequency components
within the signal.
FFT based measurements requires
digitization of a continues signal.
Acc to Nyquist Criteria ,the sampling
frequency Fs> 2Fm.if this criteria violated
a phenomenon k/s ALIASING.
176. Application
6 May 2015 176
Require fast response time such as
Transient analysis,
Vibrations and
Shock Testing using FFT Analysis
177. Power Spectrum
6 May 2015 177
Calculate the harmonics power in a signal
The power spectrum Sxx(f) of a time
domain signal x(t) is defined as
Sxx(f) =X(f)X*(f)
=|X(f)2|
X*(f)=complex conjugate
Power Spectrum is identical to the real part
of FFT.
It calculates the harmonic power in discrete
time real values sequence.