You are on page 1of 63

UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

JCB 30304
DATA ACQUISITION SYSTEM
CHAPTER 1 : INTRODUCTION
MISS NUR FAZIRA HARIS
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

CHAPTER 1 : INTRODUCTION
1. Tools, controls and functions palette
2. Data Types
3. Conversation
4. Parallel data flow
5. Create indicator/controls/constant
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Objectives:
 Develop an idea of what LabVIEW really is.
 Learn what "graphical programming language" and "dataflow
programming" mean.
 Peruse the introductory examples that come installed with LabVIEW using
the NI Example Finder.
 Get a feel for the LabVIEW environment.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

WHAT IS LabVIEW?
 LabVIEW, short for Laboratory Virtual Instrument Engineering Workbench, is a
programming environment in which you create programs using a graphical
notation (connecting functional nodes via wires through which data flows).
 In this regard, it differs from traditional programming languages like C, C++, or
Java, in which you program with text.
 LabVIEW is much more than a programming language. It is an interactive
program development and execution system designed for people, like scientists
and engineers, who need to program as part of their jobs.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

WHAT IS LabVIEW?
C language
Dataflow programming language

uses icons instead of lines of text to create programs

The graphical approach of LabVIEW allows non-programmers to


build programs by dragging and dropping virtual representations of lab
equipment with which they are already familiar.

Cross-platform
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

WHAT IS LabVIEW?
 The LabVIEW development environment works on computers running Windows,
Mac OS X, or Linux. LabVIEW can create programs that run on those platforms,
as well as Microsoft Pocket PC, Microsoft Windows CE, Palm OS, and a variety of
embedded platforms, including Field Programmable Gate Arrays (FPGAs), Digital
Signal Processors (DSPs), and microprocessors.
 Using the very powerful graphical programming language that many LabVIEW
users affectionately call "G" (for graphical), LabVIEW can increase your
productivity by orders of magnitude.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

WHAT IS LabVIEW?
 Programs that take weeks or months to write using conventional programming
languages can be completed in hours using LabVIEW because it is specifically
designed to take measurements, analyze data, and present results to the user.
 And because LabVIEW has such a versatile graphical user interface and is so easy
to program with, it is also ideal for simulations, presentation of ideas, general
programming, or even teaching basic programming concepts.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

WHAT IS LABVIEW?
 LabVIEW program imitate the appearance and operation of physical
instruments, such as oscilloscope and multimeters, LabVIEW programs are
called virtual instruments, or more commonly VI.
 VIs have front panels and block diagrams. The front panel is the user
interface. The block diagram is the programming behind the user
interface.
 After you build the front panel, you add code using graphical
representations of functions to control the front panel objects.
 The front panel code on the block diagram is graphical code, also known
as G code or block diagram code.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

How does LabVIEW work?


 LabVIEW programs are called:
 Virtual Instruments (VIs)
 because their appearance and operation imitate actual
instruments.
 However, they are analogous to main programs, functions and
subroutines from popular language like C, Fortran, Pascal, …
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

LabVIEW CHARACTERISTICS
 LabVIEW have the following characteristics:
 A graphical and compile nature
 Represented graphically, with icon and wire instead of with text.
 Dataflow and/or event-based programming
 LabVIEW programs execute according to dataflow programming instead of the procedural approach
found in most text based-programming.
 Multi-target and platform capabilities
 LabVIEW application can target multicore processors and other parallel hardware.
 Object-oriented flexibility
 LabVIEW provides tools and functions so that you can use object-oriented programming techniques in
G code.
 Multi-threading possibilities
 Enables code to have automatic parallelism. In LabVIEW environment, the compiler and execution
system working together, automatic run codes in parallel when possible.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

LabVIEW Conventions
 Front panel items
 Controls and indicators

 Block diagram items


 Program structures (loops, case structures, math, etc.)

 Controls vs. Indicators


 Wires attach to controls on the right (give values)
 Wires attach to indicators on the left (receive values)

 Wiring colors
 Wires are color coded to correspond to data types
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Launching the LabVIEW Environment

Use the Getting Started window to


create new projects and VIs. You can
create items from scratch or from
templates and samples.

LabVIEW Getting Started Window


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

The Getting Started screen


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

How does LabVIEW work?


Front panel Block Diagram

Ctrl+E

Block diagram toolbar


Continuous run Clean Up diagram
Pause

Run Stop
Reorder objects
Debugging features
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

LabVIEW Programs Are Called Virtual Instruments (VIs)

 Front Panel
• Controls = Inputs
• Indicators = Outputs

 Block Diagram
• Accompanying “program” for
front panel
• Components “wired” together
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

A front panel and the


associated block
diagram.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

LabVIEW Front panel


The front panel window is
the user interface for the
VI.

You can create front panel


window with controls and
indicators, which are the
interactive input and
output terminals of the VI,
respectively.

Used to display Controls or Indicators


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

The front panel toolbar.


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

The Text Settings pull-down menu.


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

The Align Objects pull-down menu.


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

LabVIEW Block Diagram


• After you create the
front panel window, you
add code using
graphical
representations of
functions to control the
front panel objects.

• The block diagram


windows contains this
graphical source code.

• Front panel objects


appears as terminals on
the block diagram.

- Actual program - Invisible to user


- Read left to right
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

The Distribute Objects pull-down menu.


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

The Resize Objects pull-down menu.


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Manipulating Controls and Indicators


 Right click on an indicator to
 Change to control
 Change format or precision

 Right click on a control to


 Change to indicator
 Change mechanical action (whether to latch
open or closed, and what to use as
default…)
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

An example of a shortcut menu.


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Icon and Connector Pane


 Icon and connector pane allows you to use and view VI in
another VI.
 A VI that is used in another VI is called subVI, which is
similar to a function nin a text-based programming
language.
 To use a VI as a subVI, it must have an icon and a connector
pane.
 Every VI displays an icon in the upper right corner of the front panel window
and block diagram window.
 An icon is a graphical representation of a VI.
 The icon can contain both text and images. The default icon contains a number
that indicates how many new VI you opens after launching the LabVIEW.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Tools Palette
• LabVIEW automatically selects the tool needed
• Available on the front panel and the block diagram
• A tool is a special operating mode of the mouse cursor
• Use the tools to operate and modify front panel and
block diagram objects
• To show the tools palette, select
Window»Show Tools Palette

27
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

TOOLS PALETTE
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

CONTROL PALETTE
Insert a boolean control
(button or switch)
Insert a digital
indicator or control
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Add a numeric
FUNCTION PALETTE operator (+,-,…)
Add a structure such as for,
while, and case statements Add a boolean
operator (and, or…)

Timing/dialog
Comparison

File I/O
Signal analysis

Data Acquisition
Mathematical
Functions
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

subpalettes
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

TOOLBAR
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

SUBPALETTES
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

TERMINAL
 The terminals represent the data type of the control or indicator.
 You can configure front panel controls or indicators to appear as icon or data
type terminals on the block diagram.
 By default, front panel objects appear as icon terminals. For example,
a knob icon terminal, shown as follows, represents a knob on the front
panel.
 The DBL at the bottom of the terminal represents a data type of double-precision,
floating-point numeric.
 A DBL terminal, shown as follows, represents a double-precision, floating-point
numeric control.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Terminals
 When you place a control (or indicator) on
the FRONT PANEL
 LabVIEW automatically creates a
corresponding control (or indicator)
terminal on the BLOCKDIAGRAM
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Control? or Indicator?

 Controls = Inputs from the user = Source Terminals

 Indicators = Outputs to the user = Destinations


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Manipulating Controls and Indicators

 Right click on an indicator to


 Change to control
 Change format or precision

 Right click on a control to


 Change to indicator
 Change mechanical action (whether to latch open
or closed, and what to use as default…)
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

LabVIEW Block Diagram


 Actual program

 Invisible to user

 Read left to right,


like a book

 Where the MAGIC


happens!
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Wiring Connections
 Wires transport data through the block diagram

 Wire color indicates variable type

 A red “X” means something is wrong!


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Wires

A LabVIEW VI is held together by wires connecting nodes


and terminals; they deliver data from one source terminal to
one or more destination terminals.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

NODES
 Nodes are objects on the block diagram that have inputs and/or outputs
and perform operations when a VI runs.
 They are analogous to statements, operators, functions, and subroutines
in text-based programming languages.
 The Add functions in the previous figure are examples of nodes.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

WIRES
 You transfer data among block diagram objects through wires. In the
previous figure, wires connect the control and indicator terminals to the
Add functions.
 Each wire has a single data source, but you can wire it to many VIs and
functions that read the data.
 Wires are different colors, styles, and thicknesses, depending on their
data types.
 A broken wire appears as a dashed black line with a red X in the middle.
 Broken wires occur for a variety of reasons, such as when you try to wire
two objects with incompatible data types.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Wiring Techniques

 Automatic Wiring
 Use Context Help Window when wiring
 Right-click wire and select Clean Up Wire
 Tip Strips
 Automatic wire routing
 Right-click terminals and select Visible
Items»Terminals

View the terminal connections to a function


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Broken wires
If you connect more than
one source or no source
at all to a wire,

LabVIEW
DISAGREES with what you’re
doing, and the
wire will appear broken
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

TRY THIS
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Messy vs. Clean Wiring

CLEAN: Easy to troubleshoot

MESSY: What is going on?


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Basic wires used in block diagrams


and corresponding types

Each wire has different style or color, depending on the data


type that flows through the wire:

Scalar 1D array 2D array Color


Floating-point orange
number
Integer number blue
Boolean green
String pink
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

RUN BUTTON
 The Run button, which looks
like an arrow, starts VI
execution when you click on
it

 It changes appearance when


a VI is actually running.

 When a VI won’t compile, the


run button is broken
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Running LabVIEW Programs


 ALMOST ALWAYS put your
program in some sort of
loop that can be stopped
with a control

 AVOID using the red “x” to


stop your program
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Running LabVIEW Programs

 ALMOST ALWAYS put your


program in some sort of loop
that can be stopped with a
control

 AVOID using the red “x” to stop


your program
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

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
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Context Help
 To display the Context Help window, select
Help»Show Context Help, press the <Ctrl-H> keys, or press the Show
Context Help Window button in the toolbar
 Move cursor over object
to display help
 Connections:
Required – bold
Recommended – normal
Optional - dimmed

52
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

LabVIEW Help
 Click the More Help button in the Context Help window
 Select Help»VI, Function, & How-To Help

 Click the sentence Click here for more help in the Context Help window.

 Contains detailed descriptions of most palettes, menus, tools, VIs, and


functions, step-by-step instructions for using LabVIEW features, links to
the LabVIEW Tutorial, PDF versions of all the LabVIEW manuals and
Application Notes, and technical support resources.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Debugging Techniques
 Finding Errors

 Click on broken Run button. A window showing the error appears Execution
Highlighting

 Click on Execution Highlighting button; data flow is animated using bubbles.


Values are displayed on wires.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Debugging Techniques
 Probe

Right-click on wire and select probe and it shows data as it flows through the wire segment

 Breakpoints

Right-click on wire and select Set Breakpoint; pause execution at the breakpoint.

 Conditional Probe
Combination of a breakpoint and a probe. Right-click on wire and select custom probe.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Debugging Techniques
Step Into, Over, and Out buttons for Single Stepping

Click on Step Into button to enable single stepping


Once Single Stepping has begun, the button steps
into nodes

Click on Step Over button to enable single stepping


or to step over nodes

Click on Step Out button to step out of nodes


UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Creating a VI - Front Panel Window

Block Diagram Window

Control Indicator
Terminals Terminals
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Example 1: Craps
 From the functions – numeric
panel insert a pair of dice
 From the Controls panel insert a
numeric digital indicator (on the
front panel)
 Use the wiring tool to connect
the two (in the wiring diagram)
and click the “run” button
repeatedly.
 Numbers from 0.00 to 1.00
should be displayed in the front
panel
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

Example 1: Craps (continued)


 Delete the wire
 Add a multiplication node and a
numeric constant to allow
multiplication by 5
 Add an addition node and numeric
constant to allow addition of 1
 Add a mathematical “Round to
Nearest” node.
 Make a second copy of this
structure to represent a second
die and wire them together
through an addition node with an
This wiring diagram simulates the rolling output to a numeric constant
of 2 dice and their addition to form a number
from 2 through 12.
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

EXERSICE 1
Exercise 1 - Convert °C to °F
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

EXERSICE 2
Exercise 2: Simple Calculator VI
 Create program simulating basic calculator
 Able to add, subtract, and multiply
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

EXERSICE 3
 Exercise 3: Simple Calculator VI
 Front panel of program must have:
 1 slide to control 3 different arithmetic operations (add +; subtract -; multiply *)
 3 LED (Boolean) indicators to show which arithmetic operation is selected
 Two numeric controls for inputting numbers
 One numeric indicator to display results
 Back panel should have:
 A case statement to control arithmetic operations
UNIVERSITI KUALA LUMPUR (UNIKL), MALAYSIAN INSTITUTE of INDUSTRIAL TECHNOLOGY (MITEC)

THANK YOU

You might also like