Upload
princy-randhawa
View
375
Download
13
Tags:
Embed Size (px)
Citation preview
April 15, 2023 1
Course Name :Virtual InstrumentationCourse Code: AEI-802
Subject Incharge: Ms. Princy Randhawa Assistant Professor
April 15, 2023 2
Introduction
What is an Instrument? Collect the dataAnalysis DataDisplay Information
e.g. Transducer, Oscilloscopes, Digital
Multi-meter
April 15, 2023 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.
April 15, 2023 4
Virtual Instrumentation Model
Design(Modeling
/Simulatio
n)
Prototype
Deployment
Results
Analysis/Control
Data Acquisition(Reference
Data)
April 15, 2023 5
Virtual Instrumentation-Architecture
Sensor ModuleSensing (or Transducer)
Signal conditioningA/D conversion
Processing Module
Sensor Interface
Data Base
Interface
Medical Informatio
nSystem
Interface
User Interface-Display and Control
April 15, 2023 6
Historical PerspectiveAnalog Measurement DevicesData Acquisition and Processing
DevicesDigital processing based on
general purpose computing platform
Distributed virtual instrumentation
April 15, 2023 7
Distributed Virtual Instrumentation
Internet
Information System
Interface
Private Networks
Mobile Telephony
WAP Gateway
Extranet
SMS Gateway
April 15, 2023 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.
April 15, 2023 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.
April 15, 2023 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.
April 15, 2023 11
Traditional Vs Virtual Instruments Traditional Instruments Virtual InstrumentsVendor-defined User-defined
Function-specific, stand-alone withlimited connectivity
Application-oriented system withconnectivity to networks, peripherals,and applications
Hardware is the key Software is the key
Expensive Low-cost, reusable
Closed, fixed functionality Open, flexible functionality leveragingoff familiar computer technology
Slow turn on technology (5–10 year life cycle)
Fast turn on technology (1–2 year lifecycle)
Minimal economics of scale Maximum economics of scale
High development and maintenancecosts
Software minimizes development andmaintenance costs
April 15, 2023 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
April 15, 2023 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.
April 15, 2023 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.
April 15, 2023 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.
April 15, 2023 16
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 OS-based system.
April 15, 2023 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
April 15, 2023 18
Virtual Instrumentation in the Engineering process
Development Test and
Validation
Research and Design
Manufacturing
Test
Manufacturing
April 15, 2023 19
Comparison of Text Based and Graphical ProgrammingText Based Programming Graphical ProgrammingSyntax 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
April 15, 2023 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.
April 15, 2023 21
Lab VIEW Programs Are Called Virtual Instruments (VIs)
Front Panel• Controls = Inputs• Indicators = Outputs
Block Diagram• Accompanying “program” for front panel• Components “wired” together
April 15, 2023 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.
April 15, 2023 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.
Node
Wire
Terminal
April 15, 2023 25
Basic wires used in block diagramsand corresponding types
Each wire has different style or color, depending on the data type that flows through the wire:
April 15, 2023 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.
April 15, 2023 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.
April 15, 2023 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.
April 15, 2023 29
Status Toolbar
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
April 15, 2023 31
Data flow programmingBlock 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
April 15, 2023 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)
April 15, 2023 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).
April 15, 2023 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
April 15, 2023 35
Icon and Connector
Icon
Connector
Terminals
An icon represents a VI in other block diagrams
A connector shows available terminals for data transfer
April 15, 2023 36
Steps to Create SubVICreate the IconCreate the ConnectorAssign TerminalsSave the VIInsert the VI into a Top Level VI
April 15, 2023 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
April 15, 2023 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.
April 15, 2023 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
April 15, 2023 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.
FOR Loop While Loop
April 15, 2023 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
iterationso Counts the number of iterations
April 15, 2023 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!
April 15, 2023 47
Contd….
Wait (ms)
Functions»Time & Dialog palette
Time Delay
Functions»Time & Dialog palette
April 15, 2023 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
Value 3
First Iteration
Second Iteration
Last Iteration
Initial Value
Before Loop Begins
April 15, 2023 49
Additional Shift Register Elements
Right-click the left terminal to add new elements
Right-click the border for a new shift register
April 15, 2023 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
April 15, 2023 51
Contd…Wire from output to input to automatically create a
feedback node OR Place a feedback node from the Functions»Structures
palette
April 15, 2023 52
Local and Global VariablesLocal 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
April 15, 2023 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
April 15, 2023 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
April 15, 2023 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
April 15, 2023 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.
April 15, 2023 59
ArraysAn 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
April 15, 2023 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
Array elements are accessed by their index Indices start at 0, not 1
This is a one dimensional arrayArrays can have more dimensions2 dimensional array, like a table of data
April 15, 2023 61
Arrays in LabVIEWArrays can be created
on the block diagramOn block diagram select
arrays sub palette Select array constant
and drag onto block diagram
This creates an array shell
April 15, 2023 62
Creating an Array on Block DiagramTo 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 constantinto elements
April 15, 2023 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
April 15, 2023 66
Creating Arrays Via the Front PanelArrays can also be created via
the front panelClick on the Array and Cluster
sub palette click and drag an array to the
front panel and this creates an array control shell
April 15, 2023 67
Creating Arrays Via the Front PanelA data type must be added to
the array shelldrag a control or indicator of
the data type you want into the shellCan 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
April 15, 2023 68
Array Functions
Build an arraySize an arrayForm an array from a cluster or a cluster
into an arrayIndex an arrayFind the max an min of an arrayInsert and delete from an array or
reshapeSort a lD arrayConvert an array to matrix, or a matrix
to array
Build and sizing an arrayComplies 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.
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.
Max and Min of an ArrayReturns 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 ArrayReturns 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 MatrixConverts 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 =>arrayBundles 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.
Arrays in LabVIEW 75Visual Programming
Auto indexingLabVIEW 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.
Arrays in LabVIEW 77Visual Programming
Notes on Previous slideNo 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
arrayMust create array indicator to
show array when finished◦can be a bit tricky
Arrays in LabVIEW 78Visual Programming
Manipulating ArraysMany functions for
working with arraysinitialize array
initial valuefor all elements
size of the array
79Visual Programming Arrays in LabVIEW
Getting the Length of an Array
array inputoutput is sizeof array
Arrays in LabVIEW 80Visual Programming
Changing Values of ElementsGiving 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 ArraySubset
array
index
new value forelement
resultingarray
April 15, 2023 81
ClustersData 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.
April 15, 2023 82
Clusters Controls and Indicators1. Select a Cluster shell
from the Array & Cluster subpalette
2. Place objects inside the shell
Building a ClusterClusters 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 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.
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
Cluster Order Elements have a logical order (start with 0). To change order, right-click the border and select
Reorder Controls in Cluster...
87
Using Clusters to Pass Data to SubVIs
Use clusters to pass several values to one terminal
Overcomes 28-terminal limit
Simplifies wiring
88
Cluster Functions - Bundle
Bu
nd
leB
un
dle
B
y
Nam
e
Create new cluster
Modify existing cluster
Must have an existing cluster to use this function.
90
Error ClusterUse 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
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
Error Handling with ClustersLabVIEW 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
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
Customizing Charts and GraphsRight-click and select Visible Items to view the
following items:Plot Legend Digital Display Scrollbar X and Y Scale Graph PaletteScale Legend
Graph Palette
Scale Legend
Zoom Subpalette
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 Palette
Scale Legend
Graphs
99
Uniform X axisInitial X = 0.0Delta X = 1.0
Uniform X axisyou specify point spacing
Single-Plot Waveform Graphs
100
Multiple-Plot Waveform Graphs
Each row is a separate plot: Initial X = 0Delta X = 1
Each row is a separate plot:Bundle specifies point spacing of the X axis
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
• 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
April 15, 2023 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
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.
April 15, 2023 106
Structures…..
For Loop
While Loop
Case Structure
Sequence structure
Event Structure
Timed Structure
April 15, 2023 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
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.
April 15, 2023 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.
April 15, 2023 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.
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).
April 15, 2023 112
Event Structure It waits until an event happens and
then executes the appropriate case to handle that event.
April 15, 2023 113
Contd… An event is an action that triggers a
change in stateUser initiated Button pressMouse click
OS initiatedtimeout
Software initiatedMessage from another programVariable reaches a specific value
April 15, 2023 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.
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.
April 15, 2023 116
String and File I/O
TOPICS:How to create string controls and indicatorsHow to use several String functionsAbout file I/O operationsHow to use the high-level File I/O VIsHow to use the low-level File I/O VIsHow to format text files for use in spreadsheets
April 15, 2023 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.
April 15, 2023 118
Creating String Controls and Indicators
String control/indicator is in the Controls»String subpalette.
Normal display \ code display
Hex displayPassword Display
April 15, 2023 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
April 15, 2023 124
File Input and Output ( I/O)
Four Hierarchy Levels:High-level File VIsIntermediate File VIs and
FunctionsAdvanced File Functions
sub-paletteExpress VIs
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
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
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
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
Creating a Spreadsheet File
Can replace Format Into String and Write File with Format Into File in above example
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
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
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
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 quantitiesand change their properties or generate corresponding
electrical signals. Examples: strain gage, thermocouple, accelerometer, potentiometer, etc.
Data Acquisition - DAQ
Transducers
Sense PhenomenaProduce Electrical Signal
Examples:Thermocouples, ThermistorsStrain Gauges, RTDsPressure Transducers, Load CellsAccellerometers, MicrophonesPotentiometers, Etc..
Signal ConditioningCondition Transducer SignalsMake Signal Suitable for DAQ
Board
Examples:Amplification/AttenuationLinearization/CalibrationFilteringMultiplexing (up to 3,072 channels)Isolation, Excitations, Etc.
DAQ Hardware & SoftwareConfigurations
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.)
139
Channels and Tasks
Signalsai 0
ai 1
ai 2
Sine Wave 1
Sine Wave 2
Sine Wave 3
Channel names
Tasks
Timing and Triggering
141
Data Acquisition in LabVIEW
Traditional NI-DAQSpecific VIs for performing:• Analog Input• Analog Output• Digital I/O• Counter operations
NI-DAQmxNext generation driver: • VIs for performing a
task• One set of VIs for all
measurement types
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
NI-DAQmx Data Acquisition Task Types
Measurement type can be:•Analog Input•Analog Output•Counter Input•Counter Output•Digital I/O
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 bitresolutio
n
1X Gain
Aliasing
.
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
Data LoggingIt is often necessary to permanently store
data that is acquired from the DAQ deviceLabVIEW includes the ability to read and
write a LabVIEW Measurement FileLabVIEW Measurement File is an ASCII text
file
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
Voltage OutputNote 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 Signals”…what 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.)
157
CountersA counter is a digital timing deviceTypical 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 counterSource – Input that causes the counter to increment each time it togglesGate – Input that is used to enable or disable the function of the counterOutput – Signal that generates pulses or a series of pulses
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
Digital Input and Output
Write to Digital LineRead from Digital Line
Write to Digital PortRead from Digital Port
DAQ SummaryIdentify I/O Signal Types:
Transducers/ControllersChoose a Signal Conditioning MethodSelect a Data Acquisition (DAQ)
DeviceChoose Terminals/Cables for the
HardwareSelect DAQ Software
Real measurements of a simple sine-harmonic
How come this if the measured signalis a simple sine-harmonic wave?
DEMO Application Sometimes we need more than
just 5 or 10 voltsHow 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 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.
DEMO Application
Main power suppliedBy 120 VAC outlet
Control boxWith SCR-basedpotentiometers
0-10 VDC “control” volts from LabVIEW
Power line from control
Drive Motor
Turn-Table with experiment
April 15, 2023 169
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 each component (fo,2fo,3fo)
April 15, 2023 171
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.
April 15, 2023 172
Contd… It is used for analyzing and measuring signals from plug in data acquisition (DAQ) devicesIt 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.
April 15, 2023 176
Application
Require fast response time such as Transient analysis, Vibrations and Shock Testing using FFT Analysis
April 15, 2023 177
Power Spectrum
Calculate the harmonics power in a signalThe 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.