Unit-I & Ii PPT Vi

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 149

MT8071- VIRTUAL

INSTRUMENTATION
UNIT-I & II PPT MATERIAL
Introduction
What is an Instrument?
 Collect the data
Analysis Data
Display Information

e.g. Transducer, Oscilloscopes, Digital


Multi-meter

12/13/20
2
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.

12/13/20
3
Virtual Instrumentation Model

Design
(Modeling/Simulat Prototype Deployment
ion)

Data Acquisition
Analysis/Control
Results
(Reference
Data)

12/13/20
4
Virtual Instrumentation-Architecture

User Interface-Display and Control

Medical
Information Data Base
System Processing Module Interface
Interface

Sensor Interface

Sensor Module
Sensing (or Transducer)
Signal conditioning
A/D conversion
12/13/20
5
Historical Perspective
 Analog Measurement Devices
Data Acquisition and Processing
Devices
Digital processing based on general
purpose computing platform
 Distributed virtual instrumentation

12/13/20
6
Distributed Virtual
Instrumentation

Extranet
Internet
WAP
Gateway

Information
System Interface
Mobile
Telephony

Private
Networks
SMS Gateway

12/13/20
7
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.

12/13/20
8
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.

12/13/20
9
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.

12/13/20
10
Traditional Vs Virtual Instruments
Traditional Instruments Virtual Instruments
Vendor-defined User-defined
Function-specific, stand-alone with Application-oriented system with
limited connectivity 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 Fast turn on technology (1–2 year life
cycle) cycle)

Minimal economics of scale Maximum economics of scale


High development and maintenance Software minimizes development and
costs maintenance costs

12/13/20
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
12/13/20
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.
12/13/20
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.

12/13/20
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.

12/13/20
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 OS-based system.

12/13/20
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

12/13/20
17
Virtual Instrumentation in the
Engineering process
Development
Test and
Validation

Research and Manufacturing


Design Test

Manufacturing

12/13/20
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 The execution of the program is from left to
bottom right
To check for the error the program has to be Errors are indicated as we wire the blocks
compiled or executed
Front panel design needs extra coding or Front panel design is a part of programming
needs extra work
Text based programming is not interactive Graphical programming is highly interactive
This is the text based programming where The programming is data flow programming
the programming is not conventional
method
Logical error finding is easy in large Logical error finding in large programs is
programs 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
12/13/20
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

G C, C++, Java, Pascal, BASIC, etc.

12/13/20
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

12/13/20
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.

12/13/20
22
Lab VIEW front panel

12/13/20
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

12/13/20
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:

12/13/20
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.

12/13/20
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.

12/13/20
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.

12/13/20
28
Status Toolbar

Run Button Execution Highlighting Button

Continuous Run Button Step Into Button


Abort Execution
Step over Button
Pause Button
Step Out Button
Text
Settings
Align Objects

Distribute Objects

Reorder
12/13/20
Resize front panel 29
Types of Controls and Indicators

12/13/20
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

12/13/20
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)

12/13/20
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).

12/13/20
33
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

12/13/20
34
Icon and Connector

An icon represents a VI in other block


diagrams

A connector shows available terminals for


data transfer

12/13/20
35
Steps to Create SubVI
 Create the Icon
 Create the Connector
 Assign Terminals
 Save the VI
 Insert the VI into a Top Level VI

12/13/20
36
Create the icon
Right-click on the icon in the diagram or front panel

12/13/20
37
Create the Connector
Right click on the icon pane (front panel only)

12/13/20
38
Assign Terminals

12/13/20
6 May 2015 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 VI’s into a single file,
ideal for transferring entire applications across computers

12/13/20
40
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
12/13/20
41
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.

12/13/20 FOR Loop While Loop 43


4
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

12/13/20
43
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!
12/13/20
44
Wait Functions
Wait until next ms Multiple

Functions» Time & Dialog palette

12/13/20
45
Contd….
Wait (ms)

Functions»Time & Dialog palette

Time Delay

Functions»Time & Dialog palette

12/13/20
46
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 Last Iteration

12/13/20
47
Additional Shift Register Elements
Right-click the border for a new shift register

Right-click the
left terminal
to add new
elements

12/13/20
6 May 2015 48
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

12/13/20
6 May 2015 49
Contd…
 Wire from output to input to automatically create a feedback node
OR
 Place a feedback node from the Functions»Structures palette

12/13/20
6 May 2015 50
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
12/13/20
6 May 2015 51
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

12/13/20
6 May 2015 52
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

12/13/20
6 May 2015 53
Encode Message Program

12/13/20
6 May 2015 54
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

12/13/20
6 May 2015 55
Decode Message Program

12/13/20
6 May 2015 56
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.

12/13/20
6 May 2015 57
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

12/13/20
58
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 array
Arrays can have more dimensions
2 dimensional array, like a table of
data

12/13/20
59
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

12/13/20
60
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 index elements

portion
This determines the data
type of the array
after dragging numeric constant
into elements

12/13/20
61
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.

12/13/20
62
Two dimensional array

12/13/20
63
3-dimensional Array
Index (0,0,3)

12/13/20
64
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

12/13/20
65
Creating Arrays Via the
A
Front Panel
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 array shell
right clicking on elements and
selecting “data range”
click on icon under
“representation” and change to an
integer type

12/13/20
66
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
12/13/20
67
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.

12/13/20
6
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.

12/13/20
6
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

12/13/20
7
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.

12/13/20
7
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.

12/13/20
7
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.

12/13/20
Visual Programming Arrays in LabVIEW 73
Using Auto indexing

Array Indicator
12/13/20
Visual Programming Arrays in LabVIEW 74
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
12/13/20
Visual Programming Arrays in LabVIEW 75
Manipulating Arrays
Many functions for
working with arrays
 initialize array

initial value
for all elements

size of the array

12/13/20
Visual Programming Arrays in LabVIEW 76
Getting the Length of an Array

output is size
array input of array

12/13/20
Visual Programming Arrays in LabVIEW 77
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
value at element resulting
array
array
array
index

new value for


index Index Array element Replace Array
Subset

12/13/20
Visual Programming Arrays in LabVIEW 78
Clusters
 Data structure that groups data together.
 Data may be of different types.
 Elements must be either all controls or all
indicators.
 Thought of as wires bundled into a cable.

12/13/20
79
Clusters Controls and Indicators
1. Select a Cluster shell from 2. Place objects inside the
the Array & Cluster
shell
subpalette

12/13/20
80
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.

12/13/20
8
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.

12/13/20
8
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.

12/13/20
8
Cluster Order
 Elements have a logical order (start with 0).
 To change order, right-click the border and select
Reorder Controls in Cluster...

12/13/20
86 8
Using Clusters to Pass Data
to SubVIs
Use clusters to pass
several values to one
terminal
Overcomes 28-terminal
limit
Simplifies wiring

12/13/20
87 8
Cluster Functions - Bundle
Create new cluster Modify existing
cluster
Bundle
Bundle

Must have an existing


Name

cluster to use this


function.
By

12/13/20
86 8
Cluster Functions - Unbundle

Unbundle Unbundle By Name

12/13/20
87 8
Plotting Data

Waveform Charts

Waveform and X-Y Graphs

Intensity Graphs

12/13/20
93
8
Waveform Charts
Selected from the Controls»Graphs and Charts
palette

12/13/20
89 8
Wiring to Charts

Single-Plot Chart

Multiple-Plot Chart

12/13/20
90 9
Modifying Chart Properties
• Change the

appearance
• Set the format
and precision of
the axis
• Choose the plot
type
• Edit the scales
• Document the
chart
12/13/20
91 9
Customizing Charts and

RGigrhat-cplihcksand select Visible Items to


 view the following items:
Plot Legend Graph Palette
 Digital Display
 Scrollbar Zoom
Subpalette
 X and Y Scale
 Graph Palette
 Scale Legend Scale
Legend

12/13/20
92 9
Graphs
• 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)

Scale Legend Graph Palette

12/13/20
93 9
Single-Plot Waveform Graphs
Uniform X axis
Initial X = 0.0
Delta X = 1.0

Uniform X axis
you specify point
spacing

12/13/20
94 9
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

12/13/20
95 9
XY Graphs
• Non-uniform X axis
• Separate X and Y arrays
define data points

12/13/20
96 9
Intensity Plots and Graphs

 Useful indisplaying 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

12/13/20
97 9
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.

12/13/20
98 9
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.

12/13/20
6 May 2015 104
9
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.

12/13/20
105 1
Structures…..
For Loop

While Loop

Case Structure

Sequence structure

Event Structure

Timed Structure

12/13/20
6 May 2015 101
1
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.

12/13/20
6 May 2015 102
1
Boolean and Numeric Cases

Wire all possible outputs of the case structure

12/13/20
103 1
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.

12/13/20
104 1
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.

12/13/20
6 May 2015 105
1
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).

12/13/20
6 May 2015 106
1
Event Structure
 It waits until an event happens and then
executes the appropriate case to handle that
event.

12/13/20
6 May 2015 107
1
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

12/13/20
6 May 2015 108
1
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.

12/13/20
6 May 2015 109
1
Decision Making with Formula Nodes

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


Both structures produce the same result.

12/13/20
115 1
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

12/13/20
6 May 2015 111
1
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.

12/13/20
6 May 2015 112
1
Creating String Controls and
Indicators
 String control/indicator is in the Controls»String
subpalette.
Normal display \ code display

Hex display
Password Display

12/13/20
6 May 2015 113
1
String Functions

String Length

Concatenate Strings

12/13/20
114 1
String Functions
String Subset

Match Pattern

12/13/20
115 1
Converting Numerics to Strings:
Build String

12/13/20
116 1
Converting Strings to Numerics:
Scan From String

12/13/20
117 1
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

12/13/20
6 May 2015 118
1
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

12/13/20
6 May 2015 119
1
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

12/13/20
120 1
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.

12/13/20
121 1
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

12/13/20
122 1
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

A spreadsheet yields:

Tab End of Line

12/13/20
123 1
Creating a Spreadsheet File

Can replace Format Into String


and
Write File with Format Into File
in above example

12/13/20
124 1
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

12/13/20
125 1
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.

12/13/20
6 May 2015 126
1
Boolean and Numeric Cases

Wire all possible outputs of the case structure

12/13/20
127 1
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.

12/13/20
128 1
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.

12/13/20
6 May 2015 129
1
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).

12/13/20
6 May 2015 130
1
Event Structure
 It waits until an event happens and then
executes the appropriate case to handle that
event.

12/13/20
6 May 2015 131
1
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

12/13/20
6 May 2015 132
1
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.

12/13/20
6 May 2015 133
1
Decision Making with Formula Nodes

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


Both structures produce the same result.

12/13/20
115 1
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

12/13/20
6 May 2015 135
1
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.

12/13/20
6 May 2015 136
1
Creating String Controls and
Indicators
 String control/indicator is in the Controls»String
subpalette.
Normal display \ code display

Hex display
Password Display

12/13/20
6 May 2015 137
1
String Functions

String Length

Concatenate Strings

12/13/20
138 1
String Functions
String Subset

Match Pattern

12/13/20
139 1
Converting Numerics to Strings:
Build String

12/13/20
140 1
Converting Strings to Numerics:
Scan From String

12/13/20
141 1
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

12/13/20
6 May 2015 142
1
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

12/13/20
6 May 2015 143
1
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

12/13/20
144 1
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.

12/13/20
145 1
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

12/13/20
146 1
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

A spreadsheet yields:

Tab End of Line

12/13/20
147 1
Creating a Spreadsheet File

Can replace Format Into String


and
Write File with Format Into File
in above example

12/13/20
148 1
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

12/13/20
149 1

You might also like