Virtual Instrumentation Janani R
Virtual Instrumentation Janani R
Janani R
Assistant Professor
Electronics and Instrumentation Engineering
Sri Chandrasekharendra Saraswathi Viswa Mahavidyalaya University
Table of Contents
Introduction to LabVIEW
Objective : The main aim of this chapter to know graphical system design
model, how GSD is differ from Textual Programming, how to create, save a
LabVIEW program.
Pre-requisite :
I Basic Engineering Mathematics
I Basic Programming Language
Introduction
I The term scientific computing has been used for many years define the use of
computers for solving problems related to science and engineering, usually
involving experimental or applied research, modeling and simulation.
I In simple it refers to the use of computers in solving scientific problems.
I Scientific computing applications usually follow a three-step process : data
acquisition, data analysis and data visualisation
I This three step approach has been used by National Instruments and
developed Virtual Instrumentation Model, which has been then expanded into
a more comprehensive model known as Graphical System Design shown in Fig.
Introduction
Virtual Instrumentation Model
Design (Model)
I In the design phase as shown in fig. the researcher develops a mathematical
model of the system, including sensors, actuators, plants and controllers, and
simulates them under a variety of initial conditions and constraints.
I The researcher uses different numerical methods with the objective of
validating the performance of the model and optimizing it.
In this phase, researchers can acquire reference data from files or databases and
incorporate it into the model.
A "Virtual plant/process" is created, which can be used later for
hardware-in-the-loop(HIL) tests.
Results from the simulation process are saved for post analysis and visualization
and can be used to introduce changes into the models.
This is usually a software-centric process with a strong focus on numerical
methods/analysis and mathematics
Prototype Lab :
I If experimental validation of the model is required, researchers develop and
test a prototype in the laboratory. Signal processing and analysis as well as
visualization can be implemented online while data is being measured and
acquired, or while the process is being controlled.
I This process as shown in Figure is usually more software/hardware-centric
because sensors, actuators, data acquisition devices, controllers, and the
controlled/analyzed plant itself are all key elements in the experimental setup.
Deployment - Field :
I Finally, the model (controller, analyzer or both) is deployed in the field or lab
using either a PC (desktop, server or industrial) or PXI, or it can be
downloaded to a dedicated embedded controller such as CompactRIO, which
usually operates in stand-alone mode and in real-time (deterministic) mode as
shown in Figure
I When using the LabVIEW Real-Time Module, symmetric multiprocessing
(SMP) techniques can be easily applied.
I In many cases, the system is deployed as a headless system (no monitors or
interfaces to the user), executing the analysis/control algorithms in real time
as a dedicated device. If on-the-field graphical user interfaces (GUIs) or
operator interfaces (OIs) are needed, the LabVIEW TouchPanel Module and
industrial-grade monitors with touch-sensitive screens can be used locally
Virtual Instrument
I A traditional instrument is designed to collect data from an environment, or
from a unit under test, and to display information to a user based on the
collected data.
I Such an instrument may employ a transducer to sense changes in a physical
parameter such as temperature and to convert the sensed information into
electrical signals.
I The term “instrument” may also cover a physical or software device that
performs an analysis on data acquired from another instrument and then
outputs the processed data to display or recording means.
I This second category of instruments includes oscilloscopes, spectrum analyzers
and digital millimeters.
I The types of source data collected and analyzed by instruments vary widely,
including both physical parameters like temperature, pressure, distance, and
also electrical parameters like voltage
Virtual Instrument
I A virtual instrument (VI) is defined as an industry-standard computer
equipped with userfriendly application software, cost-effective hardware and
driver software that together perform the functions of traditional instruments.
I With virtual instrumentation, engineers and scientists reduce development
time, design higher quality products, and lower their design costs.
I Virtual instrumentation is necessary because it is flexible. It delivers
instrumentation with the rapid adaptability required for today’s concept,
product and process design, development and delivery.
I Only with virtual instrumentation, engineers and scientists can create the
user-defined instruments required to keep up with the world’s demands.
I Virtual instruments are defined by the user while traditional instruments have
fixed vendor-defined functionality.
Virtual Instrument
I Every virtual instrument consists of two parts—software and hardware.
I A virtual instrument typically has a sticker price comparable to and many times
less than a similar traditional instrument for the current measurement task.
I A traditional instrument provides them with all software and measurement
circuitry packaged into a product with a finite list of fixed-functionality using
the instrument front panel.
I A virtual instrument provides all the software and hardware needed to
accomplish the measurement or control task.
I In addition, with a virtual instrument, engineers and scientists can customize
the acquisition, analysis, storage, sharing and presentation functionality using
productive, powerful software.
Virtual Instrument
I Without the displays, knobs and switches of a conventional, external
box-based instrumentation products, a virtual instrument uses a personal
computer for all user interaction and control.
I In many common measurement applications, a data acquisition board or card,
with a personal computer and software, can be used to create an instrument.
I In fact, a multiple-purpose virtual instrument can be made by using a single
data acquisition board or card.
I The primary benefits of apply data acquisition technology to configure virtual
instrumentation include costs, size, and flexibility and ease of programming
Traditional Instruments
I Traditional instruments and software-based virtual instruments largely share
the same architectural components, but radically different philosophies as
shown in Figure.
I Conventional instruments as compared to a virtual instrumentation can be
very large and cumbersome.
I They also require a lot of power, and often have excessive amounts of features
that are rarely, if ever used.
I Most conventional instruments do not have any computational power as
compared to a virtual instrument.
I Virtual instruments are compatible with traditional instruments almost without
exception.
Role of Hardware
I Input/Output plays a critical role in virtual instrumentation. To accelerate
test, control and design,I/O hardware must be rapidly adaptable to new
concepts and products.
I Virtual instrumentation delivers this capability in the form of modularity within
scalable hardware platforms.
I Virtual instrumentation is software-based ; if we can digitize it, we can
measure it.
I Standard hardware platforms that house the I/O are important to I/O
modularity.
I Laptops and desktop computers provide an excellent platform where virtual
instrumentation can make the most of existing standards such as the USB,
PCI, Ethernet, and PCMCIA buses.
Role of Software
I Software is the most important component of a virtual instrument.
I With the right software tool, engineers and scientists can efficiently create
their own applications by designing and integrating the routines that a
particular process requires.
I You can also create an appropriate user interface that best suits the purpose
of the application and those who will interact with it.
I You can define how and when the application acquires data from the device,
how it processes, manipulates and stores the data, and how the results are
presented to the user.
I When dealing with a large project, engineers and scientists generally approach
the task by breaking it down into functional solvable units.
Role of Software
I A virtual instrument is not limited or confined to a stand-alone PC.
I In fact, with recent developments in networking technologies and the Internet,
it is more common for instruments to use the power of connectivity for the
purpose of task sharing.
I Every virtual instrument is built upon flexible, powerful software by an
innovative engineer or scientist applying domain expertise to customize the
measurement and control application.
I Virtual instrumentation software can be divided into several different layers like
the application software, test and data management software, measurement
and control services software as shown in Figure
Comparison
Text-based programming Graphical Programming
1 Syntax must be known Syntax is knowledge
to do programming but it is not required for
programming.
2 The execution of the program The execution of program
is from top to bottom is from left to right
3 To check for the error Errors are indicated as we
the programs has to be wire the blocks
compiled or executed
4 Front Panel design needs extra Front Panel design is a part
coding or needs extra work of programming
5 Text based programming Graphical Programming is
is non interactive highly interactive
Comparison
Text-based programming Graphical Programming
6 This is text-based programming The programming is Data
where the programming is a Flow programming
conventional method
7 Logical Error finding is easy Logical Error finding in large
in large programs programs is complicated
8 Program flow is not visible Data flow is visible
9 It is test-based programming It is icon based
programming and wiring
10 Passing parameters to Sub Passing parameters to Sub
routine is difficult VI is easy
Advantages of LabVIEW
Advantages
I Graphical User Interface
I Drag-and-Drop built-in functions
I Modular design and hierarchical design
I Multiple high level development tools
I Professional Development Tools
I Multi platforms
I Reduces cost and preserves investment
I Flexibility and scalability
I Connectivity and instrument control
Advantages of LabVIEW
Advantages
I Open environment
I Distributed development
I Visualization capabilities
I Rapid development with express technology
I Compiled language for fast execution
I Simple application distribution
I Target management
I Object-oriented design
I Algorithm design
Software Environment
Software Environment
I Three steps to create our application
Design a user interface.
Draw our graphical code.
Run our program.
I A Virtual instrument (VI) has three main components- the front panel, the
block diagram and the icon/connector pane.
I The two LabVIEW windows are the front panel (containing controls and
indicators) and block diagram (containing terminals, connections and
graphical code).
I The front panel is the user interface of the virtual instrument.
I The code is built using graphical representations of functions to control the
front panel objects.
I The block diagram contains this graphical source code.
Software Environment
Software Environment
I In LabVIEW, you build a user interface or front panel with controls and
indicators.
I Controls are knobs, push buttons, dials and other input devices.
I Indicators are graphs, LEDs and other displays.
I After you build the user interface you can add code using VIs and structures to
control the front panel objects.
Software Environment
Launch LabVIEW
Software Environment
Launch LabVIEW
Creating a VI
Launch Labview
Figure – Blank VI
Creating a VI
Launch Labview
Creating a VI
Launch Labview
Step Into :To open a node and pause. When you click the
Step Into button again, it executes the first action and
pauses at the next action of the subVI or structure. You also
can press Ctrl and down arrow keys. Single-stepping through
a VI steps through the VI node by node. Each node blinks to
denote when it is ready to execute. By stepping into the node,
you are ready to single-step inside the node.
Data Types
I Numeric data type are of integer or real. The two most commonly used
numeric objects are the numeric control, numeric indicator
I Boolean data type represents data that only has two parts, such as TRUE and
FALSE or ON and OFF. Boolean objects simulate switchesm push buttons
and LEDs.
I String data type which is a sequence of ASCII characters. Use string controls
to receive text from the user such as a password or user name and indicators
to display text to the user.
Block Diagram
Block Diagram
Terminals
I Front panel object appear as terminals on the block diagram.
I Terminals are entry and exit ports that exchange information between the
front panel and block diagram.
I Terminals are analogous to parameters and constants in text-based
programming languages. Types of terminals include control or indicator
terminals and node terminals.
I Control and indicator terminals belong to front panel controls and indicators.
I Data you enter into the front panel controls enter the block diagram through
the control terminals.
I The terminals represent the data type of the control or indicator.
I You can configure front panel controls or indicators to appear as icon or data
type terminals on the block diagram.
I By default, front panel objects appear as icon terminals.
I To display a terminal as a data type on the block diagram, right-click the
terminal and select View As Icon from the shortcut menu
Block Diagram
Functions
I Functions are the fundamental operating elements of LabVIEW.
I Functions do not have front panels or block diagrams but do have connector
panes.
I Double-clicking a function only selects the function.
I A function has a pale yellow background on its icon.
Block Diagram
Wires
I You can transfer data among block diagram objects through wires.
I Each wire has a single data source, but you can wire it to many VIs and
functions that read the data.
I Wires are different colors, styles and thicknesses, depending on their data
types.
I A broken wire appears as a dashed black line with a red X in the middle.
I Broken wires occur for a variety of reasons, such as when you try to wire two
objects with incompatible data types.
I You must connect the wires to inputs and outputs that are compatible with
the data that is transferred with the wire.
I You cannot wire an array output to a numeric input.
I In addition, the direction of the wires must be correct. You must connect the
wires to only one input and at least one output.
I You cannot wire two indicators together
I <Ctrl+B> to delete all broken wires or right click and select Clean Up Wire
to reroute the wire.
Keyboard Shortcuts
Summary
Summary
I Virtual instruments (VIs) have three main parts — the front panel, the block
diagram, and the icon and connector pane.
I The front panel is the user interface of a LabVIEW program and specifies the
inputs and displays the outputs of the VI.
I Place controls (inputs) and indicators (outputs) in the front panel window.
I Control terminals have thicker borders than indicator terminals.
I All front panel objects have property pages and shortcut menus.
I The block diagram contains the executable graphical source code composed of
nodes, terminals, wires, and functions on the block diagram to create
measurement code.
I Use the Wiring tool to connect diagram objects.
Summary
Summary
I To change a control to an indicator or to change an indicator to a control,
right-click the object and select Change to Indicator or Change to Control
from the shortcut menu. The broken Run button appears on the toolbar to
indicate the VI is non executable. Click the broken Run button to display the
Error list window, which lists all the errors.
I Various debugging tools and options such as setting probes and breakpoints,
execution highlighting, and single stepping are available.
I Use the Search button on the Controls and Functions palettes to search for
controls, VIs and functions.
I All LabVIEW objects and empty space on the front panel and block diagram
have associated shortcut menus, which you access by right-clicking an object,
the front panel or the block diagram.
I Use execution highlighting, single-stepping, probes and breakpoints to debug
VIs by animating the flow of data through the block diagram.
I Use the Help menu to display the Context Help window and the LabVIEW
Help, which describes most palettes, menus, tools, VIs, functions and features.
Problems
Problems
Problems
Problems
Y = (A ∗ B ∗ C ) + (D ∗ E )
.
Y = mx + C
7 Convert Celsius to Fahrenheit
F = (1.8 ∗ C + 32)
Assignment
1 Divide two numbers and glow an LED if the result of the division is infinity
(i.e the divisor is zero)
2 Create NOT, AND, OR gates using NAND gate and verify their truth table.
3 The population of a town is 80,000 and the percentage of men is 52. The
percentage of total literacy is 48. If the total percentage of literate men is 35
of the total population, build a VI to find the total number of illiterate men
and women.
4 Find the equivalent gray code for a given BCD.
5 Find the equivalent BCD of an input binary value.
6 Design a 4 x 1 multiplexer with enable and select options.
7 From the given two numeric inputs, find the maximum value and minimum
value.
Table of Contents
1 Introduction
2 Modular Programming in Labview
3 Creating an Icon, Building a connector pane
4 Displaying SUBVIs, Creating SUBVIs, Editing SUBVIs.
5 Repetition and Loops
6 Shift Registers
7 Feedback nodes
8 Local and Global Variables
Introduction-Modular Programming
Objective :
Pre-requisite :
I Create Numeric Controls
I Create Numeric Indicators
I Basic Data Types
I Basic Functions and Logic
Introduction
I Modular programming refers to the idea that programs are easier to read, to
write, to debug, and to maintain if they are divided into smaller subprograms.
I Benefits of Modular Programming
1 It makes our programs easier to write because individual components can be
independently written and tested.
2 It makes the main part of the code easier to read since long code sections are
replaced with simple functions (whose internal code is hidden in another file)
3 Individual components can be reused in other programs
I The main program simply acts as an outline or driver, triggering execution of
the program units that accomplish the tasks.
Modular Programming
I Modular programming helps manage changes and debug the block diagram
quickly.
I Modularity defines the degree to which your VI is composed of discrete
components such that a change to one component has minimal impact on
other components.
I These components are called modules or subVIs.
I Modularity increases the readability and reusability of your VIs.
I A VI within another VI is called a subVI.
I A subVI corresponds to a subroutine in text-based programming languages.
I You can reuse a subVI in other VIs. If you use a VI as a subVI, the icon
identifies the subVI when it is called from the block diagram of another VI.
Creating an Icon
I The default icon of a VI contains a number that indicates how many new VIs
you have opened since launching LabVIEW. You can create custom icons to
replace the default icon by completing the following steps :
1 Right-clicking the icon in the upper-right corner of the front panel or block
diagram and select Edit Icon from the shortcut menu to display the Icon Editor
dialog box.
2 Double-click the hatched box which will select the entire icon. Delete the
selected portion.
3 Double-click the rectangular box which will create a border for the icon.
4 Use the line/pencil tool to draw.
5 Double-click the Edit Text tool ‘A’ to edit the required text.
6 Choose the Text Tool Font to edit font, font size, color and alignment of the
text.
7 Use the Select Color tool to choose the background color of the icon.
8 Use the Fill With Color tool to change the background color of the icon.
9 Click OK to save the icon.
Creating an Icon
I Use the Edit menu to cut, copy and paste images from and to the icon.
I When you select a portion of the icon and paste an image, LabVIEW resizes
the image to fit into the selection area.
I You also can drag a graphic from anywhere in the file system and place it in
the upper-right corner of the front panel.
I LabVIEW converts the graphic to a 32×32 pixel icon. Depending on the type
of monitor you use, you can design a separate icon for monochrome, 16-color
and 256-color mode.
I Use the Copy from option on the right side of the Icon Editor dialog box to
copy from a color icon to a black-and-white icon and vice versa.
I After you select a Copy from option, click the OK button to complete the
change.
Displaying SubVIs
I You can convert a section of a VI into a subVI by using the positioning tool to
select the section of the block diagram.
I Then select Edit»Create SubVI as from the menu to convert the selected
portion into a subVI. SubVI created with default icon.
I An icon for the new subVI replaces the selected section of the block diagram.
I LabVIEW creates controls and indicators for the new subVI, automatically
configures the connector pane based on the number of control and indicator
terminals you selected, and wires the subVI to the existing wires.
FOR Loops
I The For Loop is located on the Functions » Programming » Structures
Palette. Select the For Loop from the palette and use the cursor to drag a
selection rectangle to create a new For Loop or around the section of the
block diagram you want to repeat.
I You also can place a While Loop on the block diagram, right-click the border
of the While Loop, and select Replace with For Loop from the shortcut menu
to change a While Loop to a For Loop.
I N The value is the count terminal ’N’ indicates how many times to repeat the
subdiagram. A VI will not run if it contains a For Loop that doen not have a
numeric value wired to the count terminal
I i The iteration terminal ’i’ contains the number of completed iterations. The
iteration count always starts at zero.
I If you wire 0 or a negative number to the count terminal, the loop does not
execute and the outputs contain the default data for that data type
WHILE Loops
I A While Loop executes a subdiagram until a condition is met.
I The While Loop is similar to a Do Loop or a Repeat-Until Loop in text-based
programming languages.
I The While Loop always executes at least once.
I The For Loop differs from the While Loop in that the For Loop executes a set
number of times.
I A While Loop stops executing the subdiagram, only if the expected value at
the conditional terminal exists.
I In LabVIEW, the WHILE Loop is located on the Functions » Programming »
Structures palette.
I You also can place a For Loop on the block diagram, right-click the border of
the For Loop, and select Replace with While Loop from the shortcut menu to
change a For Loop to a While Loop.
I The While Loop contains two terminals, namely Conditional Terminal and
Iteration Terminal.
I The Conditional Terminal is used to control the execution of the loop, whereas
the Iteration Terminal is used to know the number of completed iterations.
WHILE Loops
I The While Loop executes the subdiagram until the conditional terminal, and
receives a specific Boolean value. The default behavior and appearance of the
conditional terminal is Stop if True.
I When a conditional terminal is Stop if True, the While Loop executes its
subdiagram until the conditional terminal receives a TRUE value.
I When a conditional terminal is Continue if True, the While Loop executes its
subdiagram until the conditional terminal receives a FALSE value.
I The iteration terminal ‘i’ (an output terminal), contains the number of
completed iterations.The iteration count always starts at zero. During the first
iteration, the iteration terminal returns 0.
Structure Tunnels
I Tunnels feed data into and out of structures.
I The tunnel appears as a solid block on the border of the loop. The block is the
color of the data type wired to the tunnel.
I Data passes out of a loop after the loop terminates.
I When a tunnel passes data into a loop, the loop executes only after data
arrives at the tunnel.
I The iteration terminal is connected to a tunnel.
I The value in the tunnel does not pass to the Iteration Number indicator until
the While Loop has finished execution.
I Only the last value of the iteration terminal displays in the Iteration Number
indicator.
Shift Registers
I A shift register transfers any data type and automatically changes to the data
type of the first object wired to the shift register.
I The data you wire to the terminals of each shift register must be the same
type.
I You can add more than one shift register to a loop.
I If you have multiple operations that use previous iteration values within our
loop, you can use multiple shift registers to store the data values from those
different processes in the structure.
I Initializing Shift Registers :
Initialize a shift register by wiring a control or constant to the shift register
terminal on the left side of the loop.
If you do not initialize the shift register, the loop uses the value written to the
shift register when the loop last executed or the default value for the data type
if the loop has never executed.
Shift Registers
I Stacked Shift Registers :
Stacked shift registers remember values from multiple previous iterations and
carry those values to the next iterations.
To create a stacked shift register, right-click the left terminal and select Add
Element from the shortcut menu.
I Replacing Tunnels with Shift Registers :
Tunnels can be replaced with shift registers wherever necessary. To replace a
tunnel into a shift register, right-click the tunnel and select Replace with Shift
Register.
If no tunnel exists on the loop border opposite of the tunnel you right-clicked,
LabVIEW automatically creates a pair of shift register terminals.
If one or more than one tunnel exists on the loop border opposite of the tunnel
you right-clicked, the mouse pointer will turn to the symbol of a shift register.
Shift Registers
I Replacing Shift Registers with Tunnels :
Replace shift registers with tunnels when you no longer need to transfer values
from one loop iteration to the next.
To replace a shift register with a tunnel, right-click the shift register and select
Replace with Tunnels.
If you replace an output shift register terminal with a tunnel on a For Loop, the
wire to any node outside the loop breaks because the For Loop enables
auto-indexing by default.
Right click the auto-indexed tunnel and select Disable Indexing on the tunnel to
correct the broken wire.
This problem does not occur in While Loops because auto-indexing is disabled
by default in While Loops.
Feedback Nodes
I When the output of a node is connected directly to the input, the feedback
node is generated automatically. The feedback node appears automatically in
a For Loop or While Loop if we wire the output of a node or group of nodes to
the input of that node or group of nodes.
I Like a shift register, the feedback node stores data when the loop completes
an iteration, sends that value to the next iteration of the loop, and transfers
any data type.
I Use the feedback node to avoid unnecessarily long wires in loops.
I The feedback node arrow indicates the direction in which the data flows along
the wire.
I The arrow automatically changes direction if the direction of data flow
changes.
Control Timing
I When a loop finishes executing an iteration, it immediately begins executing
the next iteration unless it reaches a stop condition.
I Most applications need precise control of the frequency or timing of the
iteration to be maintained between successive operations of the loop.
I You can use a wait function in the loop to wait an amount of time in
milliseconds before the loop re-executes.
I LabVIEW consists of two wait functions.
I A wait function is placed inside a loop to allow a VI to sleep for a set amount
of time. This allows your processor to address other tasks during the wait
time. Wait functions use the operating system millisecond clock. They are
Wait Until Next ms Multiple and Wait (ms) functions
Control Timing
I Wait Until Next ms Multiple
The Wait Until Next ms Multiple function monitors a millisecond counter and
waits until the millisecond counter reaches a multiple of the time you specify.
You can place this function within a loop to control the loop execution rate. For
this function to be effective, your code execution time must be less than the
time specified for this function.
The execution rate for the first iteration of the loop is indeterminate.
I Wait (ms)
The Wait (ms) function adds the wait time to the code execution time.
The Wait (ms) function waits until the millisecond counter counts to an
amount equal to the input you specify. This function guarantees that the loop
execution rate is at least the amount of the input you specify.
Global Variables
I Global variables are built-in LabVIEW objects. You can use variables to access
and pass data among several VIs that run simultaneously.
I A local variable shares data within a VI ; a global variable also shares data, but
it shares data with multiple VIs.
I When you create a global variable, LabVIEW automatically creates a special
global VI, which has a front panel but no block diagram.
I Add controls and indicators to the front panel of the global VI to define the
data types of the global variables. Select a global variable from the Functions
palette and place it on the block diagram.
I Double-click the global variable node to display the front panel of the global
VI. Place controls and indicators on this front panel the same way you do on a
standard front panel.
I A global variable front panel with a numeric, a string, and a cluster containing
a digital and a Boolean control. The toolbar does not show the Run, Stop or
related buttons as a normal front panel.
Global Variables
I After you finish placing objects on the global VI front panel, save it and return
to the block diagram of the original VI. You then must select which object in
the global VI that you want to access.
I Right-click the global variable node and select a front panel object from the
Select Item shortcut menu. The shortcut menu lists all the front panel objects
that have owned labels.
I You also can use the operating tool or labeling tool to click the local variable
node and select the front panel object from the shortcut menu. If you want to
use this global variable in other VIs, select Functions » All Functions » Select
a VI.
I The global variable is associated with the first front panel object with an
owned label that you placed in the global VI.
I Right-click the global variable node you placed on the block diagram and
select a front panel object from the Select Item shortcut menu to associate the
global variable with the data from another front panel object
Summary
Modular Programming
I Modularity increases the readability and reusability of your VIs.
I A VI within another VI is called modules or subVI.
I SubVIs correspond to a subroutine in text-based programming languages.
I The upper-right corner of the front panel and block diagram displays the icon
for the VI.
I After you build a VI front panel and block diagram, build the icon and the
connector pane to use the VI as a subVI.
I Right-click the icon in the upper-right corner of the front panel or block
diagram and selecting Edit Icon, you can create custom icons to replace the
default icon.
I Right-click the icon in the upper-right corner of the front panel and select
Show Connector.
I The connector pane is a set of terminals that correspond to the controls and
indicators of that VI. Define connections by assigning a front panel control or
indicator to each of the connector pane terminals using the wiring tool.
I Load subVIs using the Select a VI option in the All Functions palette or
dragging the icon onto a new diagram.
Summary
Assignment
1 Create a VI to compute full adder logic using half ladder logic as sub VI.
2 Create a VI to find the decimal equivalent of a binary number using sub VI.
3 Create a VI to find the Grey code equivalent of a BCD number using sub VIs.
4 Create a VI to find the average of two numbers and convert a section of a VI
into a subVI.
5 Create a subVI to compute the average of five students marks
Problems
6 Factorial of the given number using FOR Loop and Shift Register.
Solution : The front panel has the number and its factorial, while the block
diagram contains the codes to solve the factorial.
7 Sum of first n natural numbers using a WHILE Loop with a feedback node..
Solution : Given a number n, the sum of first n natural numbers is obtained
when the program is run.
8 To change the state of the Boolean indicator n times between TRUE and
FALSE.
Solution : Build the front panel with Boolean indicator and numeric indicator.
Problems
Assignment
Table of Contents
Introduction-Arrays
Objective : The main aim of this chapter to know about various functions can
be performed in arrays using LabVIEW software environment
Pre-requisite :
I Create Numeric Controls
I Create Numeric Indicators
Introduction to Arrays
I A group of homogeneous elements of a specific data type is known as an array.
I Arrays hold a sequence of data elements,usually of the same size and same
data type placed in contiguous memory locations.
I Individual elements are accessed by their position in the array.
I The position is given by an index, which is also called as subscript
I Some arrays are multi-dimensional, generally one -and two- dimensional arrays
are the most common.
I You can build arrays of numeric, boolean, path, string and cluster data types.
I You cannot create arrays of arrays
Arrays
Arrays
Arrays
2D Arrays
I A 2D arrays stores elements in a grid.
I It requires a column index and a row index to locate an element both of which
are zero-based.
I To create a 2D array on the front panel, right click the index display of the
array and select Add Dimension from the shortcut menu.
Arrays
Initializing Arrays
I When an array is initialized, define the number of elements in each dimension
and contents of each element.
I An uninitialized array has a dimension but no elements.
I An uninitialized array control with all the elements are dimmed indicating that
the array is uninitialized.
Arrays
Arrays
Arrays
Arrays
Array Functions
I Array functions are used to create and manipulate arrays.
I Common array operations such as Extracting individual data elements from an
array, inserting, deleting or replacing data elements using array functions.
I Array functions including Index Array, Replace Array Subset, Insert Into Array,
Delete From Array and Array Subset
I Index Array :The input to the index array function is a 1D array. By providing
the index value in the output, get the array element corresponding to the
index value.
I Index Array : When connecting a 2D array as input, the function automatically
resizes to get two index inputs one for the row index and other for column
index.
Arrays
Auto Indexing
I For loops and While loops can index and accumulate arrays at their
boundaries. This is known as auto-indexing.
I If you wire an array to a For Loop or While Loop input terminal, can read and
process every element in that array by enabling auto-indexing.
I When you auto-index an array output tunnel, the output array receives a new
element from every iteration of the loop.
I The wire from the output tunnel to the array indicator becomes thicker as it
changes to an array at the loop border.
I Disable auto-indexing by right clicking the tunnel and selecting Disable
Indexing from the menu.
I Disable auto-indexing if need only the last value passed to the tunnel.
I To enable auto-indexing, right click a tunnel and selectEnable Indexing
Clusters
Introduction
I Clusters group data elements of mixed types.
I Example of a Cluster is the LabVIEW error cluster, which combines a Boolean
control(status), a numeric control (Code) and a string control (source).
I A cluster is similar to a record or a struct in text-based programming
languages.
I If front panel contains more than 28 controls and indicators that want to pass
to another VI, some of them grouped into a cluster and assign the cluster to a
terminal on the connector pane.
Clusters
Clusters
Clusters
Clusters
Clusters
Cluster Operations
I The main cluster operations are bundle, unbundled, bundle by name and
unbundle by name.
I Use the cluster functions to create and manipulate clusters.
I Some of the tasks which can be performed
Extract individual data elements from a cluster.
Add individual data elements to a cluster
Break a cluster out into its individual data elements
I The Bundle function assembles individual components into a single new
cluster and allows to replace elements in an existing order.
I The Unbundle function splits a cluster into its individual components.
I When it is required to operate on a fe elements and not the entire cluster
elements, can use the Bundle by Name function.
I They are referenced by names rather than by position.
I The Unbundle by Name function returns the cluster elements whose names are
specified.
Clusters
Assembling Clusters
I The Bundle function assembles a cluster from individual elements. This
function can also be used to change the values of individual elements in an
existing cluster without having to specify new values for all elements.
I When you wire a cluster to this function, the function resizes automatically to
display inputs for each elements in the cluster.
Place the Bundle function on the block diagram.
If necessary, resize the Bundle function to include the number of inputs you
intend to use as elements in the cluster. One cannot leave an input unwired
Wire front panel control terminals or outputs from VIs and functions to the
elementinputs of the Bundle function. The order in which you wire the inputs
determines the cluster element order
Right click the Output Cluster terminal and select Create » Indicator. LabVIEW
returns the bundled cluster in the cluster output.
Clusters
Assembling Clusters
I The Bundle By Name function is used to replace one or more elements in an
existing cluster.
I This function refers to cluster elements by name instead of by their position in
the cluster.
I After you wire the node to an input cluster, right-click the name terminals to
select elements from the shortcut menu.
I Use the operating tool to click the name terminals and select from a list of
cluster elements.
I All inputs are required.
I The new value for both the elements must be given, otherwise LabVIEW
shows an error.
Clusters
Disassembling Clusters
I The Unbundle function splits a cluster into each of its individual elements.
I When you wire a cluster to this function, the function resizes automatically to
display outputs for each element in the cluster wired.
I the connector pane displays the default data types for this polymorphic
function.
I Unbundling elements from clusters accesses and arranges all elements in a
cluster in their cluster element order.
I After unbundle elements from cluster, can wire each element to VIs, functions
and indicators.
I This method of unbundling a cluster is useful if you need to access all the
elements in a cluster.
I The steps to unbundle elements from a cluster is place the unbundled function
on the block diagram and then wire a cluster to the Unbundle function.
I The data type representation of every element appears as element outputs.
Clusters
Disassembling Clusters
I The Unbundle By Name function returns the cluster elements whose names
you specify.
I Do not have to keep track of the order of the elements within the cluster.
I This function does not require the number of elements to match the number
in the cluster.
I After you wire a cluster to this function, you can select an individual element
from the function.
I The connector pane displays the default data types for this polymorphic
function
Clusters
Disassembling Clusters
I Unbundling elements from clusters by name accesses and arranges the
elements in a cluster by name in their cluster element order.
I A cluster element must have a label for you to unbundle the element by name.
I After you unbundle an element(s) from a cluster by name, you can wire the
element(s) to a VI, function and indicator. This method of unbundling a
cluster is useful if you need to access one element from a cluster that includes
elements of the same data type.
I You also can unbundle all the elements from a cluster without using the name.
I The steps to unbundle elements from a cluster by name are first place the
Unbundle By Name function on the block diagram.
I Then wire a cluster to the Unbundle By Name function. The first element in
the cluster element order appears as an element output
Clusters
Clusters
Summary
Summary
I Clusters group data elements of mixed types.
I Elements of clusters must be all controls or all indicators or constants.
I The size of components in a cluster is fixed.
I Cluster elements are accessed through the cluster order.
I If a front panel contains more than 28 controls and indicators that you want
to used programmatically, group some of them into a cluster and assign the
cluster to a terminal on the connector pane to eliminate cluster on the block
diagram.
I To create a cluster control or indicator, select a cluster on the Functions » All
Functions » Array and Cluster palette, place it on the front panel, and drag
controls or indicators into the cluster shell.
I Use the cluster functions located on the Functions » All Functions » Cluster
palette to create and manipulate clusters.
I Arrays and Clusters are inter-convertible but only under certain conditions.
Arrays - Clusters
1 Create a 1D numeric array using the Build Array function which gets array
elements from numeric controls.
Arrays - Clusters
2 Create a 1D numeric array from loops(For and While) using random numbers
and obtain the reverse of the array
Arrays - Clusters
Arrays - Clusters
4 Create a 1D numeric array which consists of ten elements and rotate it ten
times. For each rotation display the equivalent binary number of the first
array element in the form of a Boolean array. Also display the reversed
Boolean array. Provide delay to view the rotation
Arrays - Clusters
Arrays - Clusters
Arrays - Clusters
Arrays - Clusters
Assignment
Assignment Questions
Table of Contents
Objective : The main aim of this chapter to know various types of graphs and
charts, structures and file I/O functions.
Pre-requisite :
I Good Knowledge of arrays and clusters.
I Good Knowledge in For and While Loop
Introduction :
I Graphical display of data is an important aspect of programming in LabVIEW.
I VIs with graph usually collects the data in an array and then plots the data to
the graph to obtain a waveform.
I Charts and graphs let you display plots of data in a graphical form.
I Charts interactively plot data, appending new data to old so that you can see
the current value in the context of previous data, as the new data become
available.
I Graphs plot pre-generated arrays of values in a more traditional fashion
without retaining previously-generated data
Plotting Data
Waveform Graphs
I Waveform Graphs and Charts : Display data typically acquired at a constant
rate.
I XY Graphs : Display data acquired at a non-constant rate and data for
multivalued functions.
I Intensity Graphs and Charts : Display 3D data on a 2D plot by using color to
display the values of the third dimension.
I Digital waveform graphs : Display data as pulses or groups of digital lines.
I Windows 3D Graphs : Display 3D data on a 3D plot in an ActiveX object on
the front panel.
Plotting Data
Waveform Graphs
I LabVIEW includes the waveform graph and chart to display data typically
acquired at a constant rate.
I The waveform graph displays one or more plots of evenly sampled
measurements.
I The waveform graph plots only single-valued functions, as in y = f (x), with
points evenly distributed along the x-axis, such as acquired time-varying
waveforms.
I The waveform graph can display plots containing any number of points.
I The graph also accepts several data types, which minimizes the extent to
which you must manipulate data before you display it
Plotting Data
Waveform Graphs
1 Displaying a Single Plot on Waveform Graphs : The waveform graph accepts
Several data types for single plot waveform graphs
A single array of values, interprets the data as points on the graph and
increments the x index by one starting at zero.
A cluster of an initial x value, a delta x and an array of y data.
The waveform data type, which carries the data, start time and delta t of a
waveform.
The dynamic data type, which is for use with Express VIs.
When the dynamic data type includes a single numeric value or single channel,
the graph plots the single value and automatically formats the plot legend and
x-scale time stamp.
2 Displaying a Multiple Plot on Waveform Graphs : The waveform graph accepts
Plotting Data
Waveform Charts
I The waveform chart is a special type of numeric indicator that displays one or
more plots of data typically acquired at a constant rate.
I Waveform charts can display single or multiple plots.
I The waveform chart maintains a history of data or buffer from previous
updates.
I Displaying a Single Plot on Waveform Charts :
1 If you pass the chart a single value or multiple values at a time, LabVIEW
interprets the data as points on the chart and increments the x index by one
starting at x = 0.
2 The chart treats these inputs as new data for a single plot. The waveform chart
accepts the waveform data type which carries the data, start time and delta t of
a waveform.
I Displaying a Multiple Plot on Waveform Charts :
1 Waveform charts can display multiple plots together using the Bundle function
located on the Cluster palette.
2 The Bundle function bundles the outputs of the three VIs to plot on the
waveform chart.
3 To pass data for multiple plots to a waveform chart, you can bundle the data
together into a cluster of scalar numeric values, where each numeric represents
a single point for each of the plots.
Janani R (SCSVMV) VIRTUAL INSTRUMENTATION 7 / 36
Unit-4 Plotting Data and Structure
Plotting Data
XY Graphs
I The XY graph is a general-purpose, Cartesian graphing object that plots
multivalued functions, such as circular shapes or waveforms with a varying
time base.
I It displays any set of points, evenly sampled or not.
I The XY graph can display plots containing any number of points.
I It also accepts several data types, which minimizes the extent to which you
must manipulate data before you display it.
I Displaying a single plot on XY Graphs :The XY Graphs accepts
1 Three data types of single-plot XY graphs.
2 cluster that contains an x array and a y array
3 an array of points where a point is a cluster that contains an x value and a y
value
4 an array of complex data in which the real part is plotted on the x-axis and the
imaginary part is plotted on the y-axis
Plotting Data
XY Graphs
I Displaying a Multiple plot on XY Graphs :The XY Graphs accepts
1 Three data types for displaying multiple plots.
2 An array of plots where a plot is a cluster that contains an x array and a y array.
3 An array of clusters of plots where a plot is an array of points.
4 A point is a cluster that contains an x value and a y value.
5 An array of clusters of plots where a plot is an array of complex data, in which
the real part is plotted on the x-axis and the imaginary part is plotted on the
y-axis.
Plotting Data
3D Graphs
I With the 3D graphs, you can visualize three-dimensional data and alter the
way that data appears by modifying the 3D graph properties.
I LabVIEW includes the following types of 3D graphs :
1 3D surface graph : Draws a surface in 3D space.
2 3D parametric surface graph : Draws a parametric surface in 3D space.
3 3D curve graph : Draws a line in 3D space
I Use the 3D graphs in conjunction with the 3D Graph VIs to plot curves and
surfaces.
I A curve contains individual points on the graph, each point having an x, y and
z coordinates.
I The VI then connects these points with a line. A curve is ideal for visualizing
the path of a moving object, such as the flight path of an airplane.
I A surface plot uses x, y and z data to plot points on the graph.
I The surface plot then connects these points forming a three-dimensional
surface view of the data.
Plotting Data
Plotting Data
Plotting Data
Plotting Data
Plotting Data
Structure
Case structures
Sequence structure
Customizing structures
Timed structures and Formula nodes
Event structure.
Creating String control and applications
Basic of File I/O format
Structure
Case Structure
I Structures are graphical representations of the loops and case statements of
text-based programming languages.
I There are cases when a decision must be made in a program.
I In text-based programs, this can be accomplished with statements like if-else,
case and so on.
I LabVIEW includes many different ways of making decisions.
I The simplest of these methods is the select function located in the functions
palette.
I This function selects between two values dependent on a Boolean input.
I Use structures on the block diagram to repeat blocks of code and to execute
code conditionally or in a specific order.
I Like other nodes, structures have terminals that connect them to other block
diagram nodes, execute automatically when input data are available, and
supply data to output wires when execution is complete.
Structure
Case Structure
I Each structure has a distinctive, resizable border to enclose the section of the
block diagram that executes according to the rules of the structure.
I The section of the block diagram inside the structure border is called a
subdiagram.
I The terminals that feed data into and out of structures are called tunnels.
I A tunnel is a connection point on a structure border.
I Use the following structures located on the Structures palette to control how a
block diagram executes processes :
Structure
Case Structure
I For Loop—Executes a subdiagram a set number of times.
I While Loop—Executes a subdiagram until a condition occurs.
I Case structure—Contains multiple subdiagrams, only one of which executes
depending on the input value passed to the structure.
I Sequence structure—Contains one or more subdiagrams that execute in
sequential order.
I Event structure—Contains one or more subdiagrams that execute depending
on how the user interacts with the VI.
I Timed Structures—Execute one or more subdiagrams with time bounds and
delays.
I Diagram Disable Structure—Has one or more subdiagrams, or cases, of
which only the enabled subdiagram executes.
I Conditional Disable Structure—Has one or more subdiagrams, or cases,
exactly one of which LabVIEW uses for the duration of execution, depending
on the configuration
Structure
Structure
Struture
You must wire an integer, Boolean value, string, or enumerated type value to
the selector terminal
You can position the selector terminal anywhere on the left border of the
Case structure.
If the data type of the selector terminal is Boolean, the structure has a TRUE
case and a FALSE case.
If the selector terminal is an integer, string, or enumerated type value, the
structure can have any number of cases.
Specify a default case for the Case structure to handle out-of-range values.
Otherwise, you must explicitly list every possible input value.
Structure
Structure
Structure
Sequence Structure
I A sequence structure contains one or more subdiagrams, or frames, that
execute in sequential order. Within each frame of a sequence structure, as in
the rest of the block diagram, data dependency determines the execution order
of nodes.
I Use the sequence structures to control the execution order when natural data
dependency does not exist and flow-through parameters are not available.
There are two types of sequence structures— the Flat Sequence structure and
the Stacked Sequence structure.
Structure
Sequence Structure
1 Flat Sequence Structure
The Flat Sequence structure, displays all the frames at once and executes the
frames from left to right and when all data values wired to a frame are
available, until the last frame executes.
The data values leave each frame as the frame finishes executing.
When you add or delete frames in a Flat Sequence structure, the structure
resizes automatically.
2 Stacked Sequence Structure
The Stacked Sequence structure, 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.
The Stacked Sequence structure returns data only after the last frame executes.
Use the Stacked Sequence structure if you want to conserve space on the block
diagram.
To convert a Stacked Sequence structure to a Flat Sequence structure,
right-click the Stacked Sequence structure and select Replace»Replace with Flat
Sequence from the shortcut menu.
To pass data from one frame to any subsequent frame of a Stacked Sequence
structure, use a sequence local terminal shown
Structure
Customizing Structure
1 Placing Structures on the Block Diagram
Select a structure on the Structures palette. The cursor becomes a small icon of
the structure.
Click the block diagram where you want to place the top corner of the structure
and move the cursor down and to the right or left.
Click the block diagram again when the structure is the size you want.
2 Placing Objects inside Structures
Place the Case structure on the block diagram.
Place the Tick Count (ms) function inside the structure.
Move the Tick Count (ms) function close to the border of the structure. Notice
that when you place or move an object in a structure near the structure border,
the structure resizes to add space for that object. To disable the automatic
resizing behavior for a structure, right-click the structure border and select Auto
Grow from the shortcut menu to remove the checkmark.
Move the Tick Count (ms) function outside the structure.
Place another structure around the Tick Count (ms) function.
Structure
Select the second structure and delete it. Notice that you also deleted the
function inside the structure.
Select the Case structure and delete it. Notice that you did not delete the
function because it was not inside the structure
3 Removing Structures without Deleting Objects in the Structure
I Right-click the structure you want to remove.
I Select Remove For Loop from the shortcut menu or the similar option for any
of the other structures
4 Resizing Structures
I Move the positioning tool over the structure border. Resizing handles appear
at the corners of the structure and in the middle of each structure border.
I Move the cursor over a resizing handle to change the cursor to the resizing
cursor.
I Use the resizing cursor to drag the resizing handles until the dashed border
outlines the size you want.
I Release the mouse button. The structure reappears in its new size
Struture
Timed Strucutres
1 Use timed structures on the block diagram to repeat blocks of code and to
execute code in a specific order with time bounds and delays.
2 Each timed structure has a distinctive, resizable border to enclose a section of
the block diagram that executes according to the rules of the structure.
3 The section of the block diagram inside the structure border is called a
subdiagram.
4 A timed structure has Input and Output nodes that feed data into and out of
the structure to provide configuration data and return error and timing
information.
5 Timed structures can also have terminals on the structure border that feed
data into and out of the structure subdiagrams.
Timed Loop—Executes a subdiagram until a condition is met or interminably.
Timed Sequence—Executes multiple subdiagrams in sequence.
Timed Loop with Frames—Executes multiple subdiagrams in sequence until a
condition is met or interminably. Add frames to a Timed Loop to create a
Timed Loop with frames
Struture
Formula Nodes
I The Formula Node is a convenient text-based node you can use to perform
mathematical operations on the block diagram.
I In addition to text-based equation expressions, the Formula Node can accept
text-based versions of If statements, While loops, For loops, and Do loops
which are familiar to C programmers.
I Formula Nodes are useful for equations that have many variables or are
otherwise complicated and for using existing text-based code. You can copy
and paste the existing text-based code into a Formula Node rather than
recreating it graphically.
I Formula Nodes use type checking to make sure that array indexes are numeric
data and that operands to the bit operations are integer data.
I Formula Nodes also check to make sure array indexes are in range.
Struture
Formula Nodes
I When you work with variables, remember the following points :
There is no limit to the number of variables or equations in a Formula Node.
No two inputs and no two outputs can have the same name, but an output can
have the same name as an input.
Declare an input variable by right-clicking the Formula Node border and
selecting Add Input from the shortcut menu. You cannot declare input variables
inside the Formula Node.
Declare an output variable by right-clicking the Formula Node border and
selecting Add Output from the shortcut menu. The output variable name must
match either an input variable name or the name of a variable you declare inside
the Formula Node.
You can change whether a variable is an input or an output by right-clicking it
and selecting Change to Input or Change to Output from the shortcut menu.
You can declare and use a variable inside the Formula Node without relating it
to an input or output wire.
You must wire all input terminals.
Variables can be floating-point numeric scalars whose precision depends on the
configuration of your computer. You also can use integers and arrays of numeric
values for variables.
Variables cannot have units.
Structure
Formula Nodes
I Creating Formula Nodes
Place a Formula Node on the block diagram.
Review the available functions and operators you can use.
Use the labeling tool or the operating tool to enter the equations you want to
calculate inside the Formula Node. Each assignment must have only a single
variable on the left side of the assignment (=). Each assignment must end with
a semicolon ( ;). Confirm that you are using the correct Formula Node syntax.
If a syntax error occurs, click the broken Run button to display the Error list
window. LabVIEW marks the syntax error with a symbol.
Create an input terminal for each input variable by right-clicking the Formula
Node border and selecting Add Input from the shortcut menu. Type the variable
name in the terminal that appears. You can edit the variable name at any time
using the labeling tool or the Operating tool, except when the VI is running.
Variable terminals are case sensitive. There is no limit to the number of
terminals or equations in a Formula Node. You can change a terminal type or
remove a terminal.
Create an output terminal for each output variable by right-clicking the Formula
Node border and selecting Add Output from the shortcut menu. Type the
variable name in the terminal that appears. You can edit the variable name at
any time using the labeling tool or the operating tool, except when the VI is
running. Output variables have thicker borders than input variables.
Janani R (SCSVMV) VIRTUAL INSTRUMENTATION 32 / 36
Unit-4 Plotting Data and Structure
Summary
A Case structure has two or more subdiagrams, or cases. Only one
subdiagram is visible at a time, and the structure executes only one case at a
time.
If the case selector terminal is a Boolean value, the structure has a TRUE
case and a FALSE case. If the selector terminal is an integer, string, or
enumerated type value, the structure can have up to 231 – 1 cases.
Inputs are available to all subdiagrams of a Case structure, but subdiagrams
do not need to use each input. If output tunnel is not defined, in all cases it
appears as white square.
When creating a subVI from a Case structure, wire the error input to the
selector terminal, and place all subVI codes within the No Error case to
prevent the subVI from executing if it receives an error.
Timed Loop—Executes a subdiagram until a condition is met or interminably.
Timed Sequence—Executes multiple subdiagrams in sequence.
Timed Loop with Frames—Executes multiple subdiagrams in sequence until a
condition is met or interminably. Add frames to a Timed Loop to create a
Timed Loop with frames.
Formula Nodes are useful for equations that have many variables. Each
equation statement must terminate
Janani R (SCSVMV)
with a semicolon ( ;).
VIRTUAL INSTRUMENTATION 34 / 36
Unit-4 Plotting Data and Structure
Summary
The waveform chart is a special numeric indicator that displays one or more
plots.
The waveform chart has the following three update modes :
1 A strip chart shows running data continuously scrolling from left to right
across the chart.
2 A scope chart shows one item of data, such as a pulse or wave, scrolling
partway across the chart from left to the right.
3 A sweep display is similar to an EKG display. 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.
You can display more than one plot on a graph using the Build Array
function located on the Functions»All Functions»Array palette and the
Bundle function located on the Functions»All Functions»Cluster palette for
charts and XY graphs. The graph becomes a multiplot graph when you wire
the array of outputs to the terminal.
Janani R (SCSVMV) VIRTUAL INSTRUMENTATION 35 / 36
Unit-4 Plotting Data and Structure
Summary
Use the File I/O VIs and functions located on the Functions»File I/O palette
to handle all aspects of file I/O.
When writing to a file, you open, create, or replace a file, write the data and
close the file.Similarly, when you read from a file, you open an existing file,
read the data and close the file.
To access a file through a dialog box, do not wire file path in the
Open/Create/Replace File VI.
To write data to a spreadsheet file, you must format the string as a
spreadsheet string, which is a string that includes delimiters, such as tabs.
Use the Format Into File function to format string, numeric, path and
Boolean data as text and write the text to a file.
Table of Contents
Data Acquisition
Data Acquisition
Transducers
I A transducer is a device that converts a physical phenomenon into a
measurable electrical signal, such as voltage or current.
I The ability of a DAQ system to measure different phenomena depends on the
transducers to convert the physical phenomena into signals measurable by the
DAQ hardware.
I Transducers are synonymous with sensors in DAQ systems.
I There are specific transducers for many different applications, such as
measuring temperature, pressure or fluid flow.
I Different transducers have different requirements for converting phenomena
into a measurable signal.
I Some transducers may require excitation in the form of voltage or current.
I Other transducers may require additional components and even resistive
networks to produce a signal.
Data Acquisition
Signals
I The appropriate transducer converts the physical phenomena into measurable
signals. Signals can be categorized into two groups. Analog and Digital signals.
I Analog signals
An analog signal can be at any value with respect to time. A few examples of
analog signals include Voltage, Temperature, Pressure, Sound and Load.
The three primary characteristics of an analog signal include level, shape and
frequency.
Level gives vital information about the measured analog signal since analog
signals can take on any value. The intensity of a light source, the temperature
in a room, and the pressure inside a chamber are all examples that demonstrate
the importance of the level of a signal.
Some signals are named after their specific shape—sine, square, sawtooth and
triangle. The shape of an analog signal can be as important as the level,
because measuring the shape of an analog signal allows further analysis of the
signal, including peak values, DC values and slope.
Unlike the level or shape of the signal, frequency cannot be directly measured.
The signal must be analyzed using software to determine the frequency
information. This analysis is usually done using an algorithm known as the
Fourier transform.
Data Acquisition
Signals
I Digital Signals
A digital signal cannot take on any value with respect to time. Instead, a digital
signal has two possible levels : High and Low.
Digital signals generally conform to certain specifications that define the
characteristics of the signal.
The state of a digital signal is essentially the level of the signal—on or off, high
or low.
Monitoring the state of a switch—open or closed—is a common application
showing the importance of knowing the state of a digital signal.
The rate of a digital signal defines how the digital signal changes state with
respect to time.
Data Acquisition
Signal Conditioning
I Signal conditioning is the process of measuring and manipulating signals to
improve accuracy, isolation, filtering, and so on.
I Many stand-alone instruments and DAQ devices have built-in signal
conditioning.
I Signal conditioning also can be applied externally, by designing a circuit to
condition the signal or by using devices specifically made for signal
conditioning.
I Signal conditioning accessories amplify low-level signals and then isolate and
filter them for more accurate measurements.
I Common types of signal conditioning are amplification, isolation, multiplexing,
filtering, transducer excitation and linearization.
I Signal conditioning maximizes the accuracy of a system, allows sensors to
operate properly and guarantees safety.
I Signal conditioning accessories can be used in a variety of applications
including amplification, attenuation, isolation, bridge completion, simultaneous
sampling, sensor excitation, multiplexing, etc.
Data Acquisition
Signal Conditioning
I Amplification
Amplification is the most common type of signal conditioning.
Amplifying electrical signals improves accuracy in the resulting digitized signal
and reduces the effects of noise.
By amplifying a signal near the device, any noise that attached to the signal is
also amplified.
Amplifying near the signal source results in the largest signal-to-noise ratio
(SNR).
I Isolation
Another common signal conditioning application is isolating the transducer
signals from the computer for safety purposes.
The system being monitored may contain high-voltage transients that could
damage the computer without signal conditioning.
An additional reason for isolation is ensuring that the readings from the plug-in
DAQ device are unaffected by differences in ground potentials or common-mode
voltages.
When the DAQ device input and the signal being acquired are each referenced
to ‘ground’, problems occur if there is a potential difference in the two grounds.
Data Acquisition
Signal Conditioning
I Multiplexing
A common technique for measuring several signals with a single measuring
device is multiplexing.
Signal conditioning hardware for analog signals often provides multiplexing for
use with slowly changing signals like temperature.
The ADC samples one channel, switches to the next channel, samples it,
switches to the next channel, and so on.
I Filtering
The purpose of a filter is to remove unwanted signals from the signal that you
are trying to measure.
A noise filter is used on DC-class signals, such as temperature, to attenuate
higher frequency signals that can reduce your measurement accuracy.
AC-class signals, such as vibration, often require a different type of filter known
as an antialiasing filter.
Like the noise filter, the antialiasing filter is also a lowpass filter ; however, it
requires a very steep cutoff rate, so it almost completely removes all signal
frequencies that are higher than the input bandwidth of the device.
Data Acquisition
Signal Conditioning
I Transducer Excitation
Signal conditioning systems can generate excitation, which some transducers
require for operation.
Strain gauges and RTDs require external voltage and currents, respectively, to
excite their circuitry into measuring physical phenomena.
This type of excitation is similar to a radio that needs power to receive and
decode audio signals.
Signal conditioning modules for these transducers usually provide these signals.
I Linearization
Another common signal conditioning function is linearization. Many
transducers, such as thermocouples, have a nonlinear response to changes in the
physical phenomena you measure.
LabVIEW can linearize the voltage levels from transducers so you can scale the
voltages to the measured phenomena.
LabVIEW provides scaling functions to convert voltages from strain
gauges,RTDs, thermocouples, and thermistors.
Data Acquisition
Data Acquisition
Data Acquisition
Data Acquisition
Data Acquisition
DAQ Assistant
I The DAQ Assistant is a graphical interface for interactively creating, editing,
and running NIDAQmx virtual channels and tasks.
I A NI-DAQmx task is a collection of virtual channels, timing and triggering
information, and other properties regarding the acquisition or generation.
I DAQ Assistant provides an interactive guide to configuring, testing and
acquiring measurement data.
I DAQ Assistant is completely menu-driven and you will encounter fewer errors.
It drastically decreases the time to your first measurement
Data Acquisition
DAQ Assistant
I Launch the DAQ Assistant
1 Open LabVIEW and create a New VI. Switch to the block diagram (Ctrl+E).
2 DAQ Assistant Express VI is located in the Input subpalette of the Functions
palette. Place the DAQ Assistant on the block diagram by dragging and
dropping it from the Functions palette. The Assistant should automatically
launch when you drop the VI on the diagram.
3 It is also available at Express»Output»DAQ Assistant. In the Advanced
Functions palette, the DAQ Assistant Express VI is located in the NI
Measurements » DAQmx sub-palette. The Create New window opens up for
task configuration when the DAQ Assistant is placed on the block diagram.
Measurement type can be Analog Input, Analog Output, Counter Input,
Counter Output and Digital I/O.
4 Once you have located the DAQ Assistant Express VI in the appropriate
location, select it from the palette and drop it on the block diagram of your VI.
By default, the properties page should pop up, allowing you to configure your
task. The first step is to select your type of measurement.
Data Acquisition
DAQ Assistant
I Create a Task
1 On the first screen, select Analog Input for your Measurement Type.
2 Next, select Voltage.
3 The next screen lets you select the physical channel (or channels) for which you
are creating this task. All supported data acquisition hardware devices should
appear in the tree control and you can expand them to view a list of the
physical channels that you can select for your task. To select more than one
channel, hold down the Ctrl button while clicking on the channel names.
4 Click Finish to move on to the configuration stage
Data Acquisition
DAQ Assistant
I Configure a Task
After you create a task, you can configure channel-specific settings such as
scaling, input limits and terminal configuration. You also can configure
task-specific settings such as timing and triggering.
1 Specify the input limits. You can use the default values of 5 for Max and –5 for
Min if you do not know the theoretical limits for the signal you are measuring.
2 Select the terminal configuration you used for the signal.
3 On the Task Timing tab, select Acquire N Samples. Enter 100 for Samples To
Read and -enter 1000.00 for Rate (Hz).
I Test the task
1 Launch the test panel for your task by clicking the Test button at the top of the
screen.
2 The test runs once automatically. Click the Start button to run the test again.
Notice that the graph displays the acquired signal.
3 Click the Close button when you are done. If necessary, modify the settings for
the task and retest the task.
4 After the test panel closes, click the OK button. The DAQ Assistant saves the
voltage task, containing all the configuration information you entered, to MAX.
You have created your voltage task.
Data Acquisition
DAQ Hardware
I The DAQ hardware acts as the interface between the computer and the
outside world. It primarily functions as a device that digitizes incoming analog
signals so that the computer can interpret them.
I Other data acquisition functionality includes Analog Input/Output, Digital
Input/Output, Counter/Timers and Multifunction which is a combination of
analog, digital, and counter operations on a single device.
I A typical desktop DAQ system has three basic types of hardware a terminal
block, a cable and a DAQ device
I After you have converted a physical phenomenon into a measurable signal with
or without signal conditioning, you need to acquire that signal.
I To acquire a signal, you need a terminal block, a cable, a DAQ device and a
computer.
I This hardware combination can transform a standard computer into a
measurement and automation system.
Data Acquisition
DAQ Hardware
I Terminal Block and Cable
A terminal block provides a place to connect signals. It consists of screw or
spring terminals for connecting signals and a connector for attaching a cable to
connect the terminal block to a DAQ device.
The type of terminal block you should choose depends on two factors—the
device and the number of signals you are measuring.
A terminal block with 68 terminals offers more ground terminals to connect a
signal to than a terminal block with 50 terminals.
Having more ground terminals prevents the need to overlap wires to reach a
ground terminal, which can cause interference between the signals.
Data Acquisition
DAQ Hardware
I DAQ Signal Accessory
The DAQ Signal Accessory is a customized terminal block designed for learning
purposes.
It has 3 Connectors, Quadrature Encoder, Relay, Digital Trigger, 4 LEDs
(reverse logic), Counter I/O, Function Generator, Function Generator Frequency
Control, Temperature Sensor, Temperature Sensor Noise Control, Analog Input
and Analog Output.
The three different cable connectors accommodate many different DAQ devices
and spring terminals to connect signals.
You can access three analog input channels, one of which is connected to the
temperature sensor and two analog output channels.
The DAQ Signal Accessory includes a function generator with a switch to select
the frequency range of the signal, and a frequency knob.
The function generator can produce a sine wave or a square wave. A connection
to ground is located between the sine wave and square wave terminal.
The DAQ Signal Accessory also has a relay, a thermocouple input and a
microphone jack.
Data Acquisition
DAQ Hardware
I DAQ Device
Before a computer-based measurement system can measure a physical signal
such as temperature, a sensor or transducer, must convert the physical or real
world signal into an electrical one such as voltage or current.
You must use signal conditioning accessories to condition the signals before the
plug-in DAQ device converts them to digital information.
The computer receives raw data through the DAQ device. The application you
write presents and manipulates the raw data in a form you can understand.
The software also controls the DAQ system by commanding the DAQ device
when and from which channels to acquire data.
Typically, DAQ software includes drivers and application software.
Most DAQ devices have four standard elements : analog input, analog output,
digital I/O, and counters.
You can transfer the signal you measure with the DAQ device to the computer
through a variety of different bus structures.
Data Acquisition
DAQ Hardware
I DAQ Device
Analog Input Circuitry has a multiplexer (mux). This switch has multiple input
channels but only lets one at a time through to the instrumentation amplifier.
The instrumentation amplifier either amplifies or attenuates your signal.
Analog-to-Digital Converter (ADC) converts an analog signal to a digital
number and is used for analog input.
The applications are circuit testing, power supply testing, dynamometer testing,
weather station, geophysical studies and filter analysis.
Digital-to-Analog Converter (DAC) converts a digital number to an analog
signal and is used for analog output. The applications are control systems,
function generator, tone generator and servo motor control.
Depending on your application, there are several different classes of PC-based
data acquisition devices that you can use :
Analog Input/Output
Digital Input/Output
Counter/Timers
Multifunction—a combination of analog, digital and counter operations