Sie sind auf Seite 1von 177

Course Code: AEI-802

Course Name :Virtual Instrumentation

Subject Incharge:
Ms. Princy Randhawa
Assistant Professor

8/31/15

Introduction
What is an Instrument?
Collect the data
Analysis Data
Display Information
e.g. Transducer, Oscilloscopes,
Digital
Multi-meter
8/31/15

Virtual InstrumentationDefinition
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.

8/31/15

Virtual Instrumentation
Model

Data
Acquisition
(Reference
Data)

Analysis/Contr
ol

8/31/15

Results

Virtual Instrumentation-Architecture
User Interface-Display and
Control
Medical
Informatio
n
System
Interface

Processing
Module

Data
Base
Interface

Sensor Interface

Sensor
SensorModule
Module
Sensing
(or
Transducer)
Sensing (or Transducer)
Signal
Signalconditioning
conditioning
A/D
conversion
A/D conversion
8/31/15

Historical Perspective
Analog

Measurement Devices
Data Acquisition and Processing
Devices
Digital processing based on
general purpose computing
platform
Distributed virtual
instrumentation
8/31/15

Distributed Virtual
Instrumentation
Extranet

Internet
WAP
Gatew
ay
Mobile
Telephony

Information
System
Interface

SMS
Gateway

8/31/15

Private
Networks

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.

8/31/15

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.

8/31/15

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.

8/31/15

10

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 (510


year life cycle)

Fast turn on technology (12 year


life
cycle)

Minimal economics of scale

Maximum economics of scale

High development and


maintenance
costs

Software minimizes development


and
maintenance costs
8/31/15

11

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
8/31/15

12

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.
8/31/15

13

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.
8/31/15

14

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.

8/31/15

15

Contd.

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 OSbased system.
8/31/15

16

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
8/31/15

17

Virtual Instrumentation in the


Engineering process
Development
Development
Test and
Test and
Validation
Validation

Manufacturin
Manufacturin
g
g
Test
Test

Research
Research
and Design
and Design

Manufacturi
Manufacturi
ng
ng
8/31/15

18

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

8/31/15

19

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

C, C++, Java, Pascal, BASIC,


etc.

8/31/15

20

Lab VIEW Programs Are Called


Virtual Instruments (VIs)
Front

Panel

Controls = Inputs
Indicators = Outputs
Block

Diagram

Accompanying program for front panel


Components wired together

8/31/15

21

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.

8/31/15

22

Lab VIEW front panel

8/31/15

23

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.

Node
Terminal
Wire

8/31/15

24

Basic wires used in block


diagrams
and corresponding types
Each wire has different style or color, depending on
the data
type that flows through the wire:

8/31/15

25

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

8/31/15

26

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.

8/31/15

27

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.

8/31/15

28

Status Toolbar
Run Button

Execution Highlighting Button

Continuous Run
Button
Abort Execution

Step Into Button


Step over Button

Pause Button

Step Out Button

Text Settings
Align Objects
Distribute Objects
Reorder
Resize front panel
objects

8/31/15

29

Types of Controls and


Indicators

8/31/15

30

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

8/31/15

31

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)

8/31/15

32

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).

8/31/15

33

Creating SUBVIs

A SubVI is a VI that can be used within another VI

Advantages
Modular
Easier to debug
Dont have to recreate code
Require less memory

8/31/15

34

Icon and Connector

Icon

An icon represents a VI in other block


diagrams

Terminals

A connector shows available


terminals for data transfer
Connector

8/31/15

35

Steps to Create SubVI


Create

the Icon
Create the Connector
Assign Terminals
Save the VI
Insert the VI into a Top Level VI

8/31/15

36

Create the icon


Right-click on the icon in the diagram or front
panel

8/31/15

37

Create the Connector


Right click on the icon pane (front panel only)

8/31/15

38

Assign Terminals

8/31/15

39

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 VIs into a single
file, ideal for transferring entire applications across
computers

8/31/15

40

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.

8/31/15

41

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
8/31/15

42

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.

FOR Loop

8/31/15

While

43

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

8/31/15

44

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!
8/31/15

45

Wait Functions
Wait until next ms Multiple
Functions Time & Dialog
palette

8/31/15

46

Contd.
Wait (ms)
FunctionsTime & Dialog palette

Time Delay

FunctionsTime & Dialog palette

8/31/15

47

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

Value
3

Initial Value

Before Loop
Begins

First
Iteration

Second
Iteration
8/31/15

Last Iteration
48

Additional Shift Register


Elements
Right-click the
border for a new
shift register

Right-click
the
left terminal
to add new
elements

8/31/15

49

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

8/31/15

50

Contd
Wire from output to input to automatically create a
feedback node
OR
Place a feedback node from the FunctionsStructures
palette

8/31/15

51

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 controls
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
8/31/15

52

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 its in; this
makes them only be useable in that
VI.
A global variable is used to pass
information from one VI to another
8/31/15

53

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

8/31/15

54

Encode Message
Program

8/31/15

55

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

8/31/15

56

Decode Message
Program

8/31/15

57

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.

8/31/15

58

Arrays
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

8/31/15

59

Thinking About Arrays


Index

Element 2.4

6.7

4.8

1.4

3.6

7.4

1.3

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
8/31/15

60

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

8/31/15

61

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

index

elements

after dragging numeric constan


into elements

8/31/15

62

Array Constants on Block


Diagram

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.

8/31/15

63

Two dimensional array


Index(2,4)

8/31/15

64

3-dimensional Array
Index
(0,0,3)

8/31/15

65

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

8/31/15

66

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
8/31/15

array shell

67

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

8/31/15

68

Build and sizing an


array
Complies

multiple arrays or
appends elements to an ndimensional array.
Sizing an array just shows the
number of elements in the array
on the front panel.

Index Array
Returns the element or sub-array of ndimension 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.

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

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.

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

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.

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.

Visual Programming

Arrays in LabVIEW

75

Using Auto indexing

Array Indicator
Visual Programming

Arrays in LabVIEW

76

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
Visual Programming

Arrays in LabVIEW

77

Manipulating Arrays
Many

functions for
working with arrays
initialize array

initial value
for all elements

size of the array

Visual Programming

Arrays in LabVIEW

78

Getting the Length of an


Array
array input

output is size
of array

Visual Programming

Arrays in LabVIEW

79

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
resulting
value at element
Subset
array
array

array

index
index Index Array

new value for


element

Visual Programming

Replace Array
Subset

Arrays in LabVIEW

80

Clusters
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.

8/31/15

81

Clusters Controls and


Indicators
1. Select a Cluster shell
from the Array &
Cluster subpalette

2. Place objects inside the shell

8/31/15

82

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.

Bundling and
Unbundling
Assembles

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.

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.

Cluster Order
Elements have a
To change order,

logical order (start with 0).


right-click the border and select
Reorder Controls in Cluster...

86

Using Clusters to Pass


Data to SubVIs
Use clusters to pass
several values to one
terminal

Overcomes

28terminal limit
Simplifies

87

wiring

Cluster Functions Bundle


Create new
Modify existing
cluster

Bundle
By
Name

Bundle

cluster

Must have an
existing cluster to
use this function.

88

Cluster Functions Unbundle

Unbundle

Unbundle By Name

89

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
ControlsArray & Cluster palette include
the components of information shown.

90

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.

91

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

92

Plotting Data
Waveform Charts

8/31/15

93

Waveform Charts

Selected from the ControlsGraphs and Charts palett

94

Wiring to Charts
Single-Plot Chart

Multiple-Plot Chart

95

Modifying Chart
Properties

Change the
appearance
Set the format
and precision
of the axis
Choose the
plot type
Edit the scales
Document the
chart
96

Customizing Charts and


Right-click
Graphsand select Visible Items to view th
following items:
Plot Legend
Digital Display
Scrollbar
X and Y Scale
Graph Palette
Scale Legend

Graph
Palette
Zoom
Subpalette

Scale
Legend

97

Graphs
Selected from the Graph subpalette
Waveform Graph Plot an array of
numbers against their indices
XY Graph Plot one array against
Plot Legend
another
(point and
line styles)

Graph
Palette

Scale Legend

98

Single-Plot Waveform Graphs


Uniform X axis
Initial X = 0.0
Delta X = 1.0

Uniform X axis
you specify point
spacing

99

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

100

XY Graphs
Non-uniform X axis
Separate X and Y
arrays
define data points

101

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

102

Summary
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.
103

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.

8/31/15

10

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.
105

Structures..
For Loop

8/31/15

10

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.

8/31/15

10

Boolean and Numeric


Cases

Wire all possible outputs of the case structure

108

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.

109

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.

8/31/15

11

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.

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).
8/31/15

11

Event Structure

It waits until an event happens and


then executes the appropriate case to
handle that event.

8/31/15

11

Contd

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

8/31/15

11

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.

8/31/15

11

Decision Making with Formula


Nodes

Two different ways of using an if-then statement in a Formula


Node.
Both structures produce the same result.

115

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

8/31/15

11

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
8/31/15

11

Creating String Controls


and Indicators

String control/indicator is in the


ControlsString subpalette.

Normal display

Password
Display

\ code
display

Hex display

8/31/15

11

String Functions
String Length

Concatenate Strings

119

String Functions
String Subset

Match Pattern

120

Converting Numerics to Strings: Build String

121

Converting Strings to Numerics:


Scan From String

122

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
8/31/15

12

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

8/31/15

12

High-level File I/O VIs


Write to Spreadsheet File
Read from Spreadsheet
File
Write Characters to File
Read Characters from File
Read Lines from File

125

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.

126

Reading Data from a


Open/Create/Replace opens the file
File
Read File reads the specified number of bytes from the
file

Close File closes the file


Simple Error Handler checks for errors

127

Formatting a Spreadsheet
Spreadsheets are popular tools for data handling
String
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

A spreadsheet yields:

Tab End of Line

128

Creating a Spreadsheet
File

Can replace Format Into


String and
Write File with Format Into
File
in above example
129

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

130

DAQ
Data
Acquisition

DAQ Scope
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.

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

133

Data Acquisition DAQ

DAQ boards:

Analog I/O
SIGNAL
CONDITIONING:
Modify
transducer
signals
COMPUTER
withthe
SOFTWARE:
Control
the DAQ board,
Digital
PLUG-IN
DAQ
BOARD:
Measures
(acquires),
TRANSDUCERS:
Sense
measured
quantities
I/O
to match
DAQ
board
specs/ranges.
Examples:
amplification
process,
store,
and
display
data,corresponding
asinstructed
instructed
by
software
processes,
and
generates
signals,
as
stores,
and change
their properties
or generate
Counter/timer
I/O
or attenuation, filtering, excitation, etc.

program.
Examples:
LabVIEW
application
programs to acquire
by software
program.
Examples:
Analog
and digital
electrical
signals.
Examples:
strain
gage,
thermocouple,
DAQ
library
supports
all DAQ
boards
data,
simulate
instruments,
and
generate
results, etc.
signals
input
and
output,
counters,
timers,
etc.
accelerometer,
potentiometer,
etc.
LabVIEW
uses
the
NI-DAQ
driver-level
software
Data Acquisition System Components

Transducers
Sense Phenomena
Produce Electrical Signal

Examples:
Thermocouples,

Thermistors
Strain Gauges, RTDs
Pressure Transducers, Load Cells
Accellerometers, Microphones
Potentiometers, Etc..

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.

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.)

DAQ Hardware
Configuration

Measurement & Automation Explorer (MAX)

138

Channels and Tasks


Channel names
Signals

ai 0
ai 1
ai 2

Sine Wave 1
Sine Wave 2
Sine Wave 3

Tasks

Timing and Triggering

139

The DAQ Signal


Accessory

Data Acquisition in
LabVIEW
NI-DAQmx
Next generation
driver:
VIs for performing a
task
One set of VIs for all
measurement types

Traditional NI-DAQ
Specific VIs for
performing:
Analog Input
Analog Output
Digital I/O
Counter
operations

141

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

142

NI-DAQmx Data Acquisition


Task Types
Measurement
type
can be:
Analog Input
Analog Output
Counter Input
Counter
Output
Digital I/O

143

Analog Input
Analog
Input task
is specific
to the
measurem
ent

144

Analog Input Considerations


Single-Ended vs. Differential

10 V range
Resolution
10
Range

1 * 212

= 2.4. mV

1X Gain
Sampling Rate / Aliasing

Aliasing

20
1 * 212

= 4.8 mV

12 bit
resolution

Time

Adequately sampled

Aliased due to undersampling

Averaging / Noise reduction


3-bit ADC

16-bit
ADC

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

146

It

Data Logging

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

147

Analog Output
Analog Output
task is specific
to the
generation
type

148

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

149

HOW do I make a DAQ device


provide a voltage???

The

BASICS:
things..
LabVIEW
Application

You need 3
MAX

DAQ Device

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.

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

Voltage Output

When the DAQ Assistant is selected you get 2 choices:


Acquire Signalswhat we have used so far
Generate Signals choose this one for voltage output!

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.)

Counters
A counter is a digital
timing device
Typical uses of a counter:
Gate
Output
Event counting
Frequency measurement
Count Register
Period measurement
Position measurement
Source
Pulse generation

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

157

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

158

Analog Input and Output VIs

AI Sample Channel

AO Update Channel

Waveform Input and Output VIs

AI Acquire Waveform

AO Generate Waveform

Digital Input and


Output

Write to Digital LineRead from Digital Line

Write to Digital PortRead from Digital Port

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

Signal/Magnitude Resolution

Signal/Sampling
Resolution

Sampling/Time Resolution (Speed)

Real measurements
of a simple sine-harmonic

How come this if the measured


signal
is a simple sine-harmonic wave?

NO
Alias.

ZERO
Aliasing

sing
a
i
l
A

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.

Contd..
In this case we would use a device with
the motors 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 motors controller.
This will drive the motor at a speed
proportional to the signal that LabVIEW
sends to it.

DEMO Application
Turn-Table with experiment
Main power supplied
By 120 VAC outlet

0-10 VDC control volts from


LabVIEW
Control box
With SCR-based
potentiometers

Drive Motor

Power line
from control

Fast Fourier Transform


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

8/31/15

16

Why we exchange between


time domain and frequency
domain?

8/31/15

17

Why Fourier Transform?


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.

8/31/15

17

Contd
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
8/31/15
a phenomenon k/s
ALIASING.

17

Real
signal

nal
g
i
s
ed
l
p
Sam

MC
MX
CIX
*
Pro
f.
M.
Kos
tic

Real
signal

nal
g
i
s
ed
l
p
Sam

MC
MX
CIX
*
Pro
f.
M.
Kos
tic

Real
signal

na
g
i
s
ed
l
p
Sam

MC
MX
CIX
*
Pro
f.
M.
Kos
tic

Application

Require fast response time such


as
Transient analysis,
Vibrations and
Shock Testing using FFT
Analysis

8/31/15

17

Power Spectrum
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
8/31/15
time real values sequence.

17