Si Unit 3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 61

UNIT 3

Virtual instrumentation: Graphical programming techniques, Data types,


Advantages of Virtual instrumentation techniques, Concept of WHILE & FOR
loops, Arrays, Clusters & graphs, Structures: Case, sequence & Formula
nodes, Need of software-based instruments for industrial automation
Virtual Instrumentation (Introduction)

• The rapid adoption of the PC in the last 20 years catalyzed a revolution in instrumentation for testing,
measurement, and automation.

• One major development resulting from the ubiquity of the PC is the concept of virtual
instrumentation, which offers several benefits to engineers and scientists who require increased
productivity, accuracy, and performance.

• A virtual instrument consists of an industry-standard computer or workstation equipped with


powerful application software, cost-effective hardware such as plug-in boards, and driver software,
which together perform the functions of traditional instruments.
Virtual Instrumentation (Introduction)

• Virtual instrumentation is an interdisciplinary field that merges sensing, hardware, and


software technologies to create flexible and sophisticated instruments for control and
monitoring applications.

• Virtual instrumentation is the use of customizable software and modular measurement


hardware to create user-defined measurement systems, called virtual instruments.
History of Virtual Instrumentation
• A history of virtual instrumentation is characterized by a continuous increase of the flexibility
and scalability of measurement equipment. Starting from the first manual-controlled vendor-
defined electrical instruments, the instrumentation field has made great progress toward
contemporary computer-controlled, user-defined, sophisticated measuring equipment.
Instrumentation had the following phases:

• Analog measurement devices ( such as oscilloscopes etc.)

• Data Acquisition and Processing devices ( allowed processing of data)

• Digital Processing based on a general-purpose computing platform (interfacing of hardware


instruments with computers)

• Distributed Virtual Instrumentation


Virtual Instrumentation- Architecture
A virtual instrument is composed of the following blocks:

• Sensor Module
• Sensor Interface
• Information Systems Interface
• Processing Module
• Database Interface
• User Interface.
Sensor Module

• The sensor module detects the physical signal and transforms it into
electrical form, conditions the signal, and transforms it into a digital form
for further manipulation.
• Sensor: Senses the physical quantity
• Signal conditioning part: transforms the signal into digital form for further
manipulation
• A/D converter
Sensor Interface
There are many interfaces used for communication between sensor modules and the computer.
According to the type of connection, sensor interfaces can be classified as wired and wireless:
Wired Interfaces
• GPIB
• Small Computer Systems Interface (SCSI)
• System buses (PCI extension for Instrumentation PXI or VME Extensions for Instrumentation
(VXI)
• Serial buses (RS232 or USB interfaces).
Wireless Interfaces
• Typical interfaces include the 802.11 family of standards
• Bluetooth, or GPRS/GSM interface
Processing Module
The integration of microprocessors/ microcontrollers of general Analytic functions define clear functional
Use allowed the flexible implementation of sophisticated relations among input parameters. Some of
processing Functions. the common analyses used in virtual
instrumentation include spectral analysis,
filtering, windowing, transforms, peak
detection, or curve fitting.
Artificial intelligence technologies, such as
neural networks, fuzzy logic, and expert
systems, are applied in various applications,
including sensor fusion to high-level sensors,
system identification, prediction, system
control, complex measurement procedures,
calibration, and instrument fault detection and
isolation. Various nonlinear signal processing,
including fuzzy logic and neural networks,
are also common tools in the analysis of
biomedical signals.
Data Base Interface
• Computerized instrumentation allows measured data to be stored for offline
processing, or to keep records. Several currently available database technologies are
Xtensible Markup Language (XML) and SQL Server and Oracle.

• Many virtual instruments use Database Management Systems(DBMSs). They


provide efficient management of data and standardized insertion, update, deletion,
and selection. Most of 8 these DBMSs provided a Structured Query Language (SQL)
interface, enabling transparent execution of the same programs over a database from
different vendors.
Information System Interface
• Virtual instruments are increasingly integrated with other information systems, such as hospital
information systems. They can be used to create executive dashboards, supporting decision
support, real-time alerts, and predictive warnings.

• Some virtual interface toolkits, such as LabVIEW, provide mechanisms for customized
components, such as ActiveX objects, that allow communication with another information
system, hiding details of the communication from virtual interface code.

• In Web-based applications this integration is usually implemented using Unified Resource


Locators (URLs). Each virtual instrument is identified with its URL, receiving configuration
settings via parameters. The virtual instrument store the results of the processing in a database
identified with its URL.
User Interface, Display and Control

• Terminal User Interface

• Graphical User Interface

• Multimodal User Interface


Advantages of VI
• Engineers and scientists need an application that is flexible and can create
solutions to different problems, VI fulfills their requirements without replacing the
entire device because of the application software installed on the PC and the wide
range of available plug-in hardware.
• Performance enhancement
• Platform-independent nature
• Flexibility
• Low cost
• Plug-in and networked hardware capability
• System time consumption can be calculated
• Setup and configuration time is less
• Graphical representation of programs
Comparison of traditional instruments and
Virtual instruments
Graphical Programming Techniques
• It is a technique where visual block connections are used to code instead of text code; this
makes it easy for noncoders to implement algorithms.

• Graphical programming refers to the process of creating a computer program by using


graphical elements and interfaces, rather than writing codes in traditional programming
language.

• This approach is often used in fields where visual representation of systems is important

such as in robotics, automation, simulations, and game development.


Some common graphical programming
techniques are:
• Flowcharts

• Block-based programming: This approach involves dragging and dropping visual blocks or
elements that represent code constructs. Scratch is an example of block-based programming.

• LabVIEW( Laboratory Virtual Instrument Engineering Workbench)

• Simulink

• Graphical User Interfaces( GUIs): GUI programming involves designing user interfaces
through graphical elements like buttons, sliders, menus and windows Tools like Qt, Tkinker,
and JavaFX allow developers to create GUI applications.
Some common graphical programming
techniques are:
• Visual Scripting in game engines

• Automated Test Environments

• Data flow programming

• CAD (Computer-Aided Design) Software: CAD Software like AutoCAD, SolidWorks, and
Blender use graphical interfaces for designing and modeling objects in various industries
including engineering, architecture, and animation.

• Node-based programming
Difference between Graphical programming
and Text based programming
Graphical Programming Text-based Programming
Proper syntax is not required Text-based coding requires syntax
information
The execution of the program is from The execution of the program is from
left to right top to bottom
Errors are indicated as we wire the To check the errors program has be
block compiled or executed
Graphical programming is highly Text-based programming is not
interactive interactive.
Logical error finding becomes a Logical error finding is easy
complex task
Icon based programming Programs are written in text
LabVIEW – Laboratory Virtual Instrument
Engineering Workbench
• Graphical programming language that allows for instrument control, data acquisition, and
pre/post-processing of acquired data

• LabVIEW relies on graphical symbols rather than textual language to describe programming
actions

• The principle of dataflow, in which functions execute only after receiving the necessary data,
straightforwardly governs execution.
Components of LabVIEW
• Graphical programming: LabVIEW uses a graphical programming language called G, which is
based on dataflow programming.

• Instrument control: LabVIEW provides tools for interfacing with a wide range of instruments and
sensors.

• Data Acquisition: LabVIEW includes libraries and drivers for data acquisition hardware, allowing
users to acquire and process data from sensors, cameras, and other data sources.

• Real-time and FPGA Programming: Real-time systems are used for time-critical applications
while FPGA programming provides hardware-level customization for high-speed and parallel
processing tasks.
Components of LabVIEW
• User interface design: LabVIEW enables the creation of custom user interfaces (UIs) for visualization
of data and control of the systems.

• Math and Analysis Functions: LabVIEW includes a wide range of built-in math and signal processing
functions making it well-suited for applications that require data analysis and processing.

• Integration with other languages: LabVIEW can be integrated with other programming languages like
C, C++, and . NET.

• Third-party Add-ons: LabVIEW community and NI offer a variety of third-party add-ons, libraries,
and toolkits.
How does a LabVIEW work?
• LabVIEW programs are
called:
• Virtual Instruments (VIs)
because their appearance and
operation imitate actual
instruments.
LabVIEW Programs Are Called Virtual Instruments (VIs)
Each VI has 2 Windows
Front Panel
• User Interface (UI)
– Controls = Inputs
– Indicators = Outputs
Block Diagram
• Graphical Code
– Data travels on wires from
controls through functions to
indicators
– Blocks execute by Dataflow
Controls Palette (Place items on the Front Panel Window)
(Controls & Indicators)
Control: Customize
Numeric Palette View

Indicator:
Numeric Slide
Functions (and Structures) Palette

(Place items on the


Block Diagram Window)

Structure:
While Loop
Status Toolbar

Run Button

Continuous Run Button

Abort Execution

Additional Buttons on the


Diagram Toolbar

Execution Highlighting Button


Retain Wire Values Button
Step Function Buttons
Demonstration 1: Creating a VI
Front Panel Window

Graph
Indicator

Block Diagram Window

Output
Terminal
Boolean
Control
Input
Terminals
Dataflow Programming
• Block diagram execution
– 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

* However, Sequence structure forces


flow
Debugging Techniques
• Finding Errors
Click on broken Run button.
Window showing error appears.
• Execution Highlighting
Click on Execution Highlighting button; data
flow is animated using bubbles. Values are
displayed on wires.
• Probes
Right-click on wire to display probe and it shows
data as it flows through wire segment.

You can also select Probe tool from Tools palette


and click on wire.
What are Data types?
Data type is a data storage format that contains a specific type or range of values.
When a computer program stores data in a variable, each variable must be assigned a
specific data type.
• Some common data types include:
• Integers
• Floating Point Numbers
• Characters
• Strings
• Arrays
Data Types Used in LabVIEW
• LabVIEW software uses different data types to store and convey information to and from different parts of the
program.

• Data types cannot be interconnected

• There are some unique colors assigned to each data type. Commonly used data types in LabVIEW are:
• BOOLEAN
• NUMERIC
• STRING
• ARRAY
• CLUSTER
• WAVEFORM
BOOLEAN Data Type

• Consists of only two values:


• True (1)
• False(0)
• Provides output in the form of 0 or 1.
• Indicated by a GREEN data wire
• LabVIEW stores the Boolean data as 8-bit wires.
Numeric Data Types
• Integers: Integers are a sub-type of numeric data, where only whole numbers can be
represented. This means no decimal points are allowed. They are available in several sizes,
ranging from 8-32 bits, and are indicated by blue outlines and wires. Integers can either be
signed or unsigned, meaning one of the bits indicates whether the number is positive or

negative.
Double-precision Floating Points (Doubles)
• Doubles are another sub-type of numeric data. Unlike integers, they can represent a
decimal number. A double has 15-digit precision, as some of the memory places the

decimal point. Numeric indicators and controls of doubles are outlined in orange.
String data type
• String data type stores text data—everything from names, status messages, detailed
descriptions, and converted data to be written to files. Strings move along pink wires from
icons with a pink outline.

• Controlling instruments by sending text commands to instruments and returning data in the
form of either ASCII or binary string which can then be converted to numeric values.
Arrays

• Group of specific data types


• Determine by thicker data wires
• Stores numeric, string, double, or Boolean data types
• Size of array increases according to the number of
elements
CLUSTERS
• Consists of different data types in a single unit
• Indicated by thicker BROWN Colour for numeric and PINK colour for other
Graphs/Waveform data types
• The waveform data type that is used to store and display periodic signal measurement i.e.
the waveform creates a graph and charts of the particular data.
• It provides you with exact and precise information about your data in charts and graphs
form.
Enumerated Data types
• ENUMS are the combination of data types mainly consisting of a pair of data values i.e. a
string and a numeric value.
• For example, we can have an Enum to hold the four weather seasons, in which case we'll
have a numeric value for each one: 0-"spring", 1-"summer", 2-"autumn", and 3-"winter"
Structures in LabVIEW
• Structures are graphical representations of loops and case statements
of text-based programming languages.
• In text-based programs this can be accomplished with
if, else, and case statements
• In graphical programming it is done with sub-diagrams and with
conditions
• Decision-making by a function
What are loops?
• It is a process where a set of instructions is repeated in a sequence a specified number of
times or until a specified condition is made.
• When a set of instructions is executed again it is called a loop.
• The programmer uses loops to cycle through values, repeated functions or many other
things.
TYPES OF LOOPS
• For loop
• While loop
For Loop
for (initialization; condition; iteration)
{
//body of for loop
}
When the loop is executed, the initialization condition is executed first,
followed by the condition check. If the condition is met, the body of the loop
is executed, followed by the iteration statement. The condition is then
checked again to determine whether the loop will iterate further or
terminate.
Flowchart of For loop
While loop

• A while loop programming repeatedly executes a target statement as long as the given
statement is true.
While(condition)
{
Statements
}
• Here statement may be a block of statements
• The loop iterates until the condition is true.
• When the condition becomes False, the program control passes to the next statement
after the loop.
Flowchart of While loop
Using Loops in VIs
• LabVIEW consists of for and while loop
• Loops are used to control repetitive operations in virtual instruments
• They are used to perform an action frequently with variation in
details.
While loop example
Ex: This program converts temperature in degrees to
Fahrenheit.
Using Loops in LabVIEW
• The virtual instrument program is working fine but we have to run the
program again and again for different values of input temperature in
degrees Celsius, which is not convenient.
• So here we can use the loops in virtual instrumentation
Adding While loop
With a while loop and without a while loop
Example of While Loop
• This example run until either the user clicks the stop button or
number of iterations is greater than 10.
For Loop
• A For Loop executes a sub-diagram a set number of times. The Figure below shows an
empty For Loop in LabVIEW.
• A For loop executes its sub-diagram n times, where n is the value wired to the count (N)
terminal. The iteration (i) terminal provides the current loop iteration count, which ranges
from 0 to n-1.
For Loop
• After you create a For Loop, you can use shift registers to pass values from one iteration to the next.
• If you wire an array to a For Loop, you can read and process every element in that array by enabling
auto-indexing.
• You also can enable auto-indexing by configuring a For Loop to return an array of every value
generated by the loop.
• You can add a conditional terminal to configure a For Loop to stop when a Boolean condition or an
error occurs. A For Loop with a conditional terminal executes until the condition occurs or until all
iterations are complete, whichever happens first.
• To add a conditional terminal to a For Loop, right-click the For Loop border and select Conditional
Terminal from the shortcut menu. You must wire the conditional terminal and either wire the count
terminal or auto-index an input array for the loop to execute and for the VI to run.

You might also like