You are on page 1of 31

191EIC502T INDUSTRIAL INSTRUMENTATION - II

UNIT V VIRTUAL INSTRUMENTATION

Introduction to Virtual Instrumentation – Basics of Lab VIEW – FOR and WHILE loops – Structures – Arrays
and Clusters – Graphs and Charts – Introduction to DAQ – Data Acquisition with LabVIEW.

Virtual Instrumentation is the use of customizable software and modular measurement


hardware to create user-defined measurement systems, called virtual instruments.

• Advantages of Virtual Instruments versus Traditional Instruments

Flexibility
You can easily add additional functions such as a filter routine or a new data view to a
virtual instrument.

Storage
Today's personal computers have hard disks that can store dozens of gigabytes which is an
absolute plus if you want to process mass data like audio or video.

Display
Computer monitors usually have better color depth and pixel resolution than traditional
instruments. Also you can switch easily between different views of the data (graphical,
numerical). Virtual instrumentation combines mainstream commercial technologies. such
as C, with flexible software and a wide variety of measurement and control hardware, so
engineers and scientists can create user defined systems that meet their exact application
needs. With virtual
instrumentation, engineers and scientists reduce development time, design higher quality
products, and lower their design costs. Virtual instrumentation is necessary because it
delivers instrumentation with the rapid adaptability required for today’s concept, product,
and process design, development, and delivery. Only with virtual instrumentation can
engineers and scientists create the user-defined instruments required to keep up with the
world’s demands. The only way to meet these demands is to use test and control
architectures that are also software centric. Because virtual instrumentation uses highly
productive software, modular I/O, and commercial platforms, it is uniquely positioned to
keep pace with the required new idea and product development rate.

Virtual instruments versus traditional instruments

Every virtual instrument consists of two parts – software and hardware. A virtual
instrument typically has a sticker price comparable to and many times less than a similar
traditional instrument for the current measurement task. 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. A virtual instrument provides all the
software and hardware needed to accomplish the measurement or control task. In addition,
with a virtual instrument, engineers and scientists can customize the acquisition, analysis,
storage, sharing, and presentation functionality using productive, powerful software.
Layers of Virtual Instrumentation

• Application Software:
Most people think immediately of the application software layer. This is the primary
development environment for building an application.

• Test and Data Management Software: Above the application software layer the
test executive and data management software layer. This layer of software incorporates
all of the functionality developed by the application layer and provides
system-wide data management.

• Measurement and Control Services Software: The last layer is often overlooked,
yet critical to maintaining software development productivity.

Dataflow Programming
Block diagram executes dependent on the flow of data; 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
Help Options

Graphical programming in dataflow


LabVIEW is a graphical programming language that uses icons instead of lines of text to
create applications. In contrast to textbased programming languages, where instructions
determine program execution, LabVIEW uses dataflow programming, where the flow of
data determines execution order.

LabVIEW programs are called virtual instruments (VIs). Controls are inputs and indicators
are outputs.

Each VI contains three main parts:


• Front Panel – How the user interacts with the VI.
• Block Diagram – The code that controls the program.
• Icon/Connector – Means of connecting a VI to other VIs.

In LabVIEW, you build a user interface by using a set of tools and objects. The user
interface is known as the front panel. Users interact with the Front Panel when the
program is running. Users can control the program, change inputs, and see data updated in
real time. Controls are used for inputs such as, adjusting a slide control to set an alarm
value, turning a switch on or off, or to stop a program. Indicators are used as outputs.
Thermometers, lights, and other indicators display output values from the program. These
may include data, program states, and other information. Every front panel control or
indicator has a corresponding terminal on the block diagram. When a VI is run, values from
controls flow through the block diagram, where they are used in the functions on the
diagram, and the results are passed into other functions or indicators through wires.
VI PROGRAMMING TECHNIQUES
After Creating Front Panel Controls and Indicators, Switch to
Block Diagram <Ctrl-E>
• Move Front Panel Objects to Desired Locations Using
the Position/Size/Select Tool
• Place Functions On Diagram
• Wire Appropriate Terminals Together to Complete the Diagram.

Wiring
Icon and Connector
 Create the Icon
• Create the Connector
• Assign Terminals
• Save the VI

• Insert the VI into a Top Level VI
Save 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
Insert the SubVI into a Top Level VI
• Keystroke Shortcuts
– <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)
• Tab Key – Toggle Through Tools on Toolbar
• Tools » Options… – Set Preferences in LabVIEW
• VI Properties – Configure VI Appearance, Documentation, etc.

Loops and Charts


• For Loop
• While Loop
• Charts
 Multiplots
Charts
Waveform chart – special numeric indicator that can display a history of
values
Controls >> Graphs >> Waveform Chart
Wiring Data into Charts

Arrays & File I/O


• Build arrays manually
• Have LabVIEWbuild arrays automatically
• Write to a spreadsheet file
• Read from a spreadsheet file
Array Functions & Graphs
• Basic Array Functions
• Use graphs
• Create multiplots with graphs
Graphs
• Selected from the Graph palette of Controls menu
–Waveform Graph – Plot an array of numbers against their indices
–XY Graph – Plot one array against another
–Digital Waveform Graph – Plot bits from binary data

Strings
• A string is a sequence of displayable or non displayable characters (ASCII)
•Many uses – displaying messages, instrument control, file I/O
• String control/indicator is in the Controls»String subpalette

Clusters
• Data structure that groups data together
• Data may be of different types
• Analogous to struct in C
• Elements must be either all controls or all
indicators
• Thought of as wires bundled into a cable

Error Clusters
• Error cluster contains the following information:
– Boolean to report whether error occurred
– Integer to report a specific error code
– String to give information about the error

Error Handling Techniques


• Error information is passed from one subVI to the next
• If an error occurs in one subVI, all subsequent subVIs are not executed in the
usual manner
• Error Clusters contain all error conditions

Printing & Documentation

• Print From File Menu to Printer, HTML, Rich Text File


• Programmatically Print Graphs or Front Panel Images
• Document VIs in VI Properties » Documentation Dialog
• Add Comments Using Free Labels on Front Panel & Block Diagram

Printing
• File » Print… Gives Many Printing Options – Choose to Print Icon, Front
Panel, Block Diagram, VI Hierarchy, Included SubVIs, VI History
• Print Panel.vi (Functions » Application Control) Programmatically Prints a
Front Panel
• Generate & Print Reports (Functions » Report Generation) – Search in Find
Examples for Report Generation

Documenting VIs
• VI Properties » Documentation
– Provide a Description and Help Information for a VI
• VI Properties » Revision History
– Track Changes Between Versions of a VI
• Individual Controls » Description and Tip…
– Right Click to Provide Description and Tip Strip
• Use Labeling Tool to Document Front Panels & Block Diagrams
Simple VI Architecture
• Functional VI that produces results when run
– No “start” or “stop” options
– Suitable for lab tests, calculations
• Example: Convert C to F.vi

General VI Architecture
• Three Main Steps
– Startup
– Main Application
– Shutdown

Introduction to DAQ
• Data Acquisition – “Sampling of the real world to generate data that can be
analyzed and presented by a computer.” PC Based Data Acquisition System

Overview:
In the last few years, industrial PC I/O interface products have become
increasingly reliable, ccurate and affordable. PC-based data acquisition and
control systems are widely used in industrial and laboratory applications like
monitoring, control, data acquisition and automated testing.
Selecting and building a DA&C (Data Acquisition and Control) system that
actually does what you want it to do requires some knowledge of electrical
and computer engineering.
• Transducers and actuators
• Signal conditioning
• Data acquisition and control hardware
• Computer systems software

Data acquisition involves gathering signals from measurement sources and


digitizing the signals for storage, analysis, and presentation on a PC. Data
acquisition systems come in many different PC technology forms to offer
flexibility when choosing our system. We can choose from PCI, PXI, PCI
Express, PXI Express, PCMCIA, USB, wireless, and Ethernet data acquisition for
test, measurement, and automation applications.

Transducers:
Data acquisition systems have multiple components that work together to
gather and process information. They can be used to analyze information
regarding physical phenomena, such as temperature, voltage, and pressure.
However, because temperature, voltage, and pressure are all distinct different,
they require different systems of measurement and representation. In data
acquisition systems, a transducer serves as the component that translates raw
data into a comprehensible electrical signal. When a data acquisition system
uses DAQ (data acquisition hardware) the transducer also functions as a
sensor, gathering the data from which it will then generate a signal. As a result
of all the different variables data acquisition systems can measure, there are
several kinds of transducers. A transducer must be capable of generating
different signals depending on the particular phenomenon measured. Two
general types of signals commonly are used: analog and digital.
Transducer and Acutuator:
A transducer converts temperature, pressure, level, length, position, etc. into
voltage, current, frequency, pulses or other signals. An actuator is a device
that activates process control equipment by using pneumatic, hydraulic or
electrical power. For example, a valve actuator opens and closes a valve to
control fluid rate.

Signal conditioning :
Signal conditioning circuits improve the quality of signals generated by
transducers before they are converted into digital signals by the PC's data-
acquisition hardware.
Examples of signal conditioning are signal scaling, amplification, linearization,
cold-junction compensation, filtering, attenuation, excitation, common-mode
rejection, and so on. One of the most common signal conditioning functions is
amplification. For maximum resolution the voltage range of the input signals
should be approximately equal to the maximum input range of the A/D
converter.
Amplification expands the range of the transducer signals so that they match
the input range of the A/D converter. For example, a x 10 amplifier maps
transducer signals which range from 0 to 1 V onto the range 0 to 10 V before
they go into the A/D converter.

TEMPERATURE DATA LOGGER WITH A DAQ970A / DAQ973A DAQ


systems can also be used to measure:
 AC to DC power converters

 Battery packs
 Medical devices

 Radio communication devices and more


VI-DAQ is VI library for using our abundant products, analog input and output,
digital input and output, and a counter input device ( PCI bus / PC card / USB
module). It is for LabVIEW of National Instruments. Various devices can be
used easily, without carrying out a complicated setup, since it is created with
the function form similar to the data acquisition VI of LabVIEW.
An intelligible interface

 VI-DAQ is created with the function form similar to the "data acquisition VI" of
LabVIEW. Since a complicated setup like driver form is unnecessary, the
system which used device of our company can create for a short period of
time.

Composition of VI-DAQ

 VI Runtime contained in VI-DAQ absorbs the difference in the device to be


used. A PCI/PCI Express bus board,CardBus and a USB module can create a
program using the same VI, without being conscious of the difference,
although the device drivers of each hardware differ.
DAQ Assistant

DAQ Assistant is a graphical interface for interactively creating, editing, and


running NI-DAQmx virtual channels and tasks. An NI-DAQmx virtual channel
consists of a physical channel on a DAQ device and the configuration
information for this physical channel, such as input range and custom scaling.
An NI-DAQmx task is a collection of virtual channels, timing and triggering
information, and other properties regarding the acquisition or generation. In
the following figure, DAQ Assistant is configured to perform a finite strain
measurement.
NI-DAQmx Create Virtual Channel

The NI-DAQmx Create Virtual Channel function creates a virtual channel and
adds it to a task. It can also be used to create multiple virtual channels and add
all of them to a task. When a task is not specified, the function creates a task.
The NI-DAQmx Create Virtual Channel function has numerous instances.
These instances correspond to the specific type of measurement or generation
the virtual channel(s) perform.

The inputs to the NI-DAQmx Create Virtual Channel function differ for each
instance of the function. However, certain inputs are common to most, if not
all, of the function's instances. For example, an input is required to specify
the physical channels (analog input and analog output), lines (digital),
or counter that the virtual channel(s) will use. Additionally, analog input,
analog output, and counter operations use minimum value and maximum
value inputs to configure and optimize the measurements and generations
based on the minimum and maximum expected values of the signals.
Furthermore, a custom scale can be applied to many types of virtual
channels. In the following LabVIEW block diagram, the NI-DAQmx Create
Virtual Channel VI is used to create a thermocouple virtual channel.
NI-DAQmx Trigger

Many data acquisition applications require synchronization of different


functional areas of a single device (e.g. analog output and counters). Others
require multiple devices to be synchronized. To achieve this synchronization,
trigger signals must be routed between the different functional areas of a
single device and between multiple devices. NI-DAQmx automatically
performs this routing. When using the NI-DAQmx Trigger function, all valid
trigger signals are available as the source input to the function. For example,
in the following NI-DAQmx Trigger VI, the start trigger signal for Device 2 is
available as the source of the start trigger for Device 1 without any explicit
routing being performed.
NI-DAQmx Timing

The NI-DAQmx Timing function configures the timing for hardware-timed


data acquisition operations. This includes specifying whether the operation
will be continuous or finite, selecting the number of samples to acquire or
generate for finite operations, and creating a buffer when needed.

For operations that require sample timing (analog input, analog output, and
counter), the Sample Clock instance of the NI-DAQmx Timing function sets
both the source of the sample clock, which could be an internal or external
source, and its rate. The sample clock controls the rate at which samples are
acquired or generated. Each clock pulse initiates the acquisition or generation
of one sample for each virtual channel included in the task.

Configuring Task Timing in LabVIEW

The following LabVIEW block diagram demonstrates the use of the Sample
Clock instance of the NI-DAQmx Timing VI to configure a continuous analog
output generation with an external sample clock.
Most counter operations do not require sample timing because the signal
being measured provides the timing. The Implicit instance of the NI-DAQmx
Timing function should be used for these applications. In the following
LabVIEW block diagram, the Implicit instance of the NI-DAQmx Timing VI is
used to configure a buffered pulse width acquisition to be finite with a
specified number of samples.

NI-DAQmx Start Task

As mentioned in the Introduction, the state model used by NI-DAQmx


eliminates unnecessary reconfiguring to obtain a high level of efficiency and
maximize performance. This state model consists of five states in which a task
can reside. Detailed information concerning each of these states is available in
the NI-DAQmx Help under NI-DAQmx Key Concepts»Channels and Tasks
in NI-DAQmx»Tasks in NI-DAQmx»Task State Model.

The NI-DAQmx Start Task function explicitly transitions a task to the running
state. In the running state, the task performs the specified acquisition or
generation. A task will be implicitly transitioned to the running state and
automatically started if the NI-DAQmx Start Task function is not used when
the NI-DAQmx Read function executes. This implicit transition also occurs if
the NI-DAQmx Start Task function is not used and the NI-DAQmx Write
function executes with its auto start input specified accordingly.
Although it is not always required, using the NI-DAQmx Start Task function to
explicitly start a task involving a hardware-timed acquisition or generation is
preferred. Furthermore, if the NI-DAQmx Read function or the NI-DAQmx
Write function will be executed multiple times, such as in a loop, the NI-
DAQmx Start Task function should also be used.

NI-DAQmx Read

The NI-DAQmx Read function reads samples from the specified acquisition
task. The different instances of the function allow for the type of acquisition
(analog, digital, or counter), the number of virtual channels, the number of
samples, and the data type to be selected. After the specified number of
samples have been transferred from the FIFO on the DAQ board to the PC
Buffer in RAM, the NI-DAQmx Read function moves samples from the PC
Buffer to the Application Development Environment (ADE) Memory.
Reading Data in LabVIEW

The following figures shows four examples of the different instances of the NI-
DAQmx Read VI.

Instances of the NI-DAQmx Read function that are capable of reading multiple
samples include an input to specify the number of samples per channel to
read when the function executes. For finite acquisitions, by specifying
a number of samples per channel of -1, the function waits for all of the
requested samples to be acquired and then reads these samples. Specifying
a number of samples per channel of -1 for a continuous acquisition results
in the function reading all of the samples that are currently available in the
buffer when the function executes. In the following LabVIEW block diagram,
the NI-DAQmx Read VI has been configured to read multiple samples from
multiple analog input virtual channels and return the data as waveforms.
Furthermore, since the number of samples per channel input has been
wired to a constant value of 10, each time the VI executes it will read 10
samples from each virtual channel.

NI-DAQmx Wait Until Done

The NI-DAQmx Wait Until Done function waits for the data acquisition
operation to complete before finishing. This function should be used to ensure
that the specified acquisition or generation is complete before the task is
stopped. Most commonly, the NI-DAQmx Wait Until Done function is used
with finite operations. Once this function has finished executing, the finite
acquisition or generation is complete and the task can be stopped without
disturbing the operation. Additionally, the timeout input allows a maximum
wait time to be specified. If the acquisition or generation does not complete
within this amount of time, the function exits and an appropriate error is
generated.

NI-DAQmx Clear Task

The NI-DAQmx Clear Task function clears the specified task. If the task is
currently running, the function first stops the task and then releases all of its
resources. Once a task has been cleared, it cannot be used unless it is
recreated. Thus if a task will be used again, the NI-DAQmx Stop Task function
should be used to stop the task but not to clear it. For continuous operations,
the NI-DAQmx Clear Task function should be used to stop the actual
acquisition or generation.

NI-DAQmx Properties

Attribute[CVI]

Property [.NET]

NI-DAQmx Properties provide access to all of the properties associated with a


data acquisition operation. These properties can be set by writing to the NI-
DAQmx Properties, and the current values of the properties can be read from
the NI-DAQmx Properties as well. Many properties can be set using the NI-
DAQmx functions discussed previously. The Sample Clock
Source and Sample Clock Active Edge properties, for instance, can be set
using the NI-DAQmx Timing function. However, some of the less frequently
used properties can only be accessed through the NI-DAQmx Properties.

You might also like