86% found this document useful (7 votes)
1K views

LabVIEW Step by Step Guide Final

1. LabVIEW is a graphical programming development environment used to acquire, analyze, and present data. It features faster programming through a graphical interface and built-in tools for hardware integration. 2. The document outlines some key LabVIEW features including its dataflow programming model, multicore support, and applications in areas like embedded design, image processing, and industrial monitoring. 3. Examples of LabVIEW case studies are presented, including automating a washing machine production line using LabVIEW and CompactRIO hardware.

Uploaded by

tonissa
Copyright
© © All Rights Reserved
86% found this document useful (7 votes)
1K views

LabVIEW Step by Step Guide Final

1. LabVIEW is a graphical programming development environment used to acquire, analyze, and present data. It features faster programming through a graphical interface and built-in tools for hardware integration. 2. The document outlines some key LabVIEW features including its dataflow programming model, multicore support, and applications in areas like embedded design, image processing, and industrial monitoring. 3. Examples of LabVIEW case studies are presented, including automating a washing machine production line using LabVIEW and CompactRIO hardware.

Uploaded by

tonissa
Copyright
© © All Rights Reserved
You are on page 1/ 113

Ashraf AlMadhoun Ashraf Said AlMadhoun

Mechatronics System Engineer AlAzhar University


Mechatronic Engineer Embedded Systems Researcher & Developer, EngPal Co.
LabVIEW Step By Step Guide

By Ashraf AlMadhoun | Mechatronics Engineer


Course Goals
Understand the components of a Virtual
Instrument
Introduce LabVIEW and common LabVIEW
functions
Build a simple data acquisition application
Create a subroutine in LabVIEW
Work with Arrays.

Ashraf AlMadhoun | LabVIEW Step By 3


Step Guide
4
Laboratory Virtual Instrumentation Engineering Workbench

Compiled graphical development environment..


Development time reduction of 4~10 times..
Tools to: acquire, analyze, and present data..

Ashraf AlMadhoun 5
Mechatronic Engineer
110+ Countries
40+ Int. Branches
5000+ Employees
7500+ University
1000+ University in USA
150+ Textbooks
600 Alliance Partners
30000+ Companies
1000+ Products

Ashraf AlMadhoun 6
Mechatronic Engineer
Diversity of Applications

Telecom Automotive Semiconductors Electronics Computers

Advanced Food
ATE Military/Aerospace Petrochemical Textiles
Research Processing

Ashraf AlMadhoun 7
Mechatronic Engineer
Ashraf AlMadhoun 8
Mechatronic Engineer
Acquiring data and displaying it using an oscilloscope

Two parallel loops for acquiring data and displaying it using an oscilloscope

Ashraf AlMadhoun 9
Mechatronic Engineer
13Pages ~700Lines

Two parallel loops with different rates for acquiring data and displaying it using
an oscilloscope

Ashraf AlMadhoun 10
Mechatronic Engineer
66Pages ~4000Lines

Acquiring analog data from FPGA pin and


storing it

Ashraf AlMadhoun 12
Mechatronic Engineer
13
Ashraf AlMadhoun 14
Mechatronic Engineer
Data Flow
 Block diagram execution is
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
 If the computer running this
code had multiple processors,
these two pieces of code could
run independently without
additional coding

Ashraf AlMadhoun 15
Mechatronic Engineer
Ashraf AlMadhoun 16
Mechatronic Engineer
What is a Virtual Instrument (VI)?
Answer: a LabVIEW program
1. Front Panel * Conn. pane
available from
User interface (UI) FP only

– Controls = inputs
– Indicators = outputs

2. Block Diagram
Graphical source code
– Data travels on wires from control
terminals through functions to indicator
terminals
– Blocks execute by data flow

3. Icon/Connector Pane
• Graphical representation of a VI
• Means of connecting VIs (subVIs)

Ashraf AlMadhoun 17
Mechatronic Engineer
Ashraf AlMadhoun 18
Mechatronic Engineer
Ashraf AlMadhoun Spring Workshop 2011
19
Mechatronic Engineer 6th Feb - 10th Feb.
Ashraf AlMadhoun 20
Mechatronic Engineer
Ashraf AlMadhoun 21
Mechatronic Engineer
Common Data Types Found in LabVIEW

Ashraf AlMadhoun 22
Mechatronic Engineer
Ashraf AlMadhoun 23
Mechatronic Engineer
LabVIEW Key Features
 Faster Programming
– Graphical Programming
Program with drag-and-drop,
graphical function blocks
instead of writing lines of text

– Dataflow Representation
Easily develop, maintain, and understand code with an intuitive
flowchart representation

Ashraf AlMadhoun 24
Mechatronic Engineer
LabVIEW Key Features
 Hardware Integration
– I/O and Communication
Connect to any instrument or sensor with built-in libraries and
thousands of instrument drivers

– Plug-and-Play Hardware
Seamlessly integrate NI plug-and-play devices for
USB, PCI, PXI, Wi-Fi, Ethernet, GPIB, and more

Ashraf AlMadhoun 25
Mechatronic Engineer
Report
Generation & Embedded
Data Storage Design

Software
Development Control Design
& Deployment & Simulation

Industrial
Image & Signal
Monitoring
Processing
& Control
26
Embedded Design
 Real-Time Module
 FPGA Module
 Microprocessor SDK
 Statechart Module
 Mobile Module
 DSP Module
 Embedded Module for ARM
 C-Code Generator
 Robotics Module

Ashraf AlMadhoun 27
Mechatronic Engineer
Image & Signal Processing
 Vision Development Module
 MathScript RT Module
 Advanced Signal Processing Toolkit
 Digital Filter Design Toolkit
 Adaptive Filter Toolkit
 Sound & Vibration Measurement Toolkit
 Spectral Measurements Toolkit
 Modulation Toolkit
 Vision Builder for Automated Inspection
 Math Interface Toolkit
 Real-Time Vision Development Bundle

Ashraf AlMadhoun 28
Mechatronic Engineer
Industrial Monitoring & Control
 Data Logging & Supervisory Control
 Wireless Sensor Network Module
 Touch Panel Module
 Motion Assistant
 SoftMotion Module
 OPC Servers
 Instrument Control
 Test Automation & Validation

Ashraf AlMadhoun 29
Mechatronic Engineer
LabVIEW Key Features
 Multicore Programming
– Automatic Multithreading
Handle large data sets and complex algorithms faster because
LabVIEW inherently runs on multiple threads
– Execution Highlighting
Easily optimize code for parallel execution
using built-in debugging and
Visualization tools

Ashraf AlMadhoun 30
Mechatronic Engineer
Ashraf AlMadhoun 31
Mechatronic Engineer
Ashraf AlMadhoun 32
Mechatronic Engineer
LabVIEW Case Studies

Ashraf AlMadhoun 33
Mechatronic Engineer
Automating a Washing Machine Line Using
LabVIEW and Compact RIO

Ashraf AlMadhoun 34
Mechatronic Engineer
Ashraf AlMadhoun 35
Mechatronic Engineer
Ashraf AlMadhoun 36
Mechatronic Engineer
Ashraf AlMadhoun 37
Mechatronic Engineer
Run LabVIEW

Start from a blank VI:


New»Blank VI

Start from an example:


Examples»Find
Examples…

Ashraf AlMadhoun 38
Mechatronic Engineer
LabVIEW Programs Are Called Virtual Instruments
(VIs)

Front Panel
Controls = Inputs •
Indicators = Outputs •

Block Diagram
Accompanying “program” for front •
panel
Components “wired” together •

Ashraf AlMadhoun | LabVIEW Step By 39


Step Guide
VI Front Panel
Front Panel Icon
Toolbar

Boolean
Control Graph
Legend

Waveform
Graph

Plot Scale
Legend Legend

Ashraf AlMadhoun | LabVIEW Step By 40


Step Guide
VI Block Diagram
Block
Diagram
Toolbar Divide
Function

SubVI

Graph
Terminal

Wire
Data

While Loop Numeric Timing Boolean Control


Structure Constant Function Terminal

Ashraf AlMadhoun | LabVIEW Step By 41


Step Guide
Express VIs, VIs and Functions
• Express VIs: interactive VIs with configurable dialog page
• Standard VIs: modularized VIs customized by wiring
• Functions: fundamental operating elements of
LabVIEW; no front panel or block diagram
Function

Express VI Standard
VI
Ashraf AlMadhoun | LabVIEW Step By 42
Step Guide
Controls and Functions Palettes

Controls Palette
(Front Panel Window)

Functions Palette
(Block Diagram Window)

Ashraf AlMadhoun | LabVIEW Step By 43


Step Guide
Tools Palette
• Floating Palette
• Used to operate and modify
front panel and block diagram
objects.
Automatic Selection Tool

Operating Tool Scrolling Tool

Positioning/Resizing Tool Breakpoint Tool

Labeling Tool Probe Tool

Wiring Tool Color Copy Tool

Shortcut Menu Tool Coloring Tool

Ashraf AlMadhoun | LabVIEW Step By 44


Step Guide
Status Toolbar

Run Button

Continuous Run Button Additional Buttons on


the Diagram Toolbar
Abort Execution

Pause/Continue Button Execution Highlighting


Button
Text Settings
Step Into Button
Align Objects
Step Over Button
Distribute Objects
Step Out Button
Reorder

Resize front panel


objects

Ashraf AlMadhoun | LabVIEW Step By 45


Step Guide
Open and Run a Virtual Instrument
Example finder

Ashraf AlMadhoun | LabVIEW Step By 46


Step Guide
Creating a VI
Front Panel Window

Block Diagram Window

Control Indicator
Terminals Terminals

Ashraf AlMadhoun | LabVIEW Step By 47


Step Guide
Creating a VI – Block Diagram

Ashraf AlMadhoun | LabVIEW Step By 48


Step Guide
Wiring Tips – Block Diagram
Wiring “Hot Spot” Click To Select Wires

Use Automatic Clean Up Wiring


Wire Routing

49 Ashraf AlMadhoun | LabVIEW Step By


Help Options

Context Help
• Online help
• Lock help
• Simple/Complex Diagram help
• Ctrl + H

Online reference
• All menus online
• Pop up on functions in diagram to access online info directly

Ashraf AlMadhoun | LabVIEW Step By 50


Step Guide
End of Introduction To LabVIEW
- Now you let’s learn more by doing a simple Led
Example

Ashraf AlMadhoun | LabVIEW Step By 51


Step Guide
Exercise 1 - Convert °C to °F

1 degree Celsius = 33.8

Ashraf AlMadhoun | LabVIEW Step By 52


Step Guide
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.
• Probe
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
Ashraf AlMadhoun | LabVIEW Step By 53
Step Guide
Section II – SubVIs

What is a subVI?
Making an icon and
connector for a subVI
Using a VI as a subVI

Ashraf AlMadhoun | LabVIEW Step By 54


Step Guide
Block Diagram Nodes
Icon Expandable Node Expanded Node

• Function Generator VI
• Same VI, viewed three different ways
• Yellow field designates a standard VI
• Blue field designates an Express VI

Ashraf AlMadhoun | LabVIEW Step By 55


Step Guide
SubVIs
A SubVI is a VI that can be used within another VI
Similar to a subroutine
Advantages
• Modular
• Easier to debug
• Don’t have to recreate code
• Require less memory

Ashraf AlMadhoun | LabVIEW Step By 56


Step Guide
Icon and Connector

An icon represents a VI in other


Icon block diagrams
Terminals
A connector shows available
terminals for data transfer
Connector

Ashraf AlMadhoun | LabVIEW Step By 57


Step Guide
SubVIsSub VIs

Ashraf AlMadhoun | LabVIEW Step By 58


Step Guide
Steps to Create a SubVI
1. Create the Icon
2. Create the Connector
3. Assign Terminals
4. Save the VI
5. Insert the VI into a Top Level VI

Ashraf AlMadhoun | LabVIEW Step By 59


Step Guide
Create the Icon
Right-click on the icon in the
block diagram or front panel

60 Ashraf AlMadhoun | LabVIEW Step By


Create the Connector
Right click on the icon pane (front panel only)

Ashraf AlMadhoun | LabVIEW Step By 61


Step Guide
Assign Terminals

Ashraf AlMadhoun | LabVIEW Step By 62


Step Guide
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

Ashraf AlMadhoun | LabVIEW Step By 63


Step Guide
Insert the SubVI into a Top Level
VI
Accessing user-made subVIs
Functions >>All Functions >> Select a VI
Or
Drag icon onto target diagram

Ashraf AlMadhoun | LabVIEW Step By 64


Step Guide
Tips for Working in LabVIEW
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)
Tools » Options… – Set Preferences in LabVIEW
VI Properties – Configure VI Appearance,
Documentation, etc.

Ashraf AlMadhoun | LabVIEW Step By 65


Step Guide
Section III – Data Acquisition
DAQ Device
 Data acquisition (DAQ) basics
 Connecting Signals
 Simple DAQ application
Computer
Sensors
Cable

Terminal Block

Ashraf AlMadhoun | LabVIEW Step By 66


Step Guide
Data Acquisition in LabVIEW

Traditional NI-DAQ NI-DAQmx


Specific VIs for Next generation driver:
performing: • VIs for performing a
• Analog Input task
• Analog Output • One set of VIs for all
• Digital I/O measurement types
• Counter operations

Ashraf AlMadhoun | LabVIEW Step By 67


Step Guide
DAQ – Data Acquisition
Temperature Acquisition using the DAQ Assistant

68 Ashraf AlMadhoun | LabVIEW Step By


Data Acquisition Terminology
Resolution - Determines How Many Different
Voltage Changes Can Be Measured
Larger Resolution  More Precise Representation of
Signal
Range - Minimum and Maximum Voltages
Smaller range  More Precise Representation of
Signal
Gain - Amplifies or Attenuates Signal for Best Fit
in Range

Ashraf AlMadhoun | LabVIEW Step By 69


Step Guide
Hardware Connections
SC-2075
BNC-2120

NI-ELVIS
SCB-68

70 Ashraf AlMadhoun | LabVIEW Step By


Exercise 2 – Simple Data Acquisition
Complete Convert C to F.vi, then create Thermometer.vi.

71 Ashraf AlMadhoun | LabVIEW Step By


Section IV – Loops and Charts
 For Loop
 While Loop
 Charts
 Multiplots

Ashraf AlMadhoun | LabVIEW Step By 72


Step Guide
Loops

While Loops
• Have Iteration Terminal
• Always Run at least Once
• Run According to Conditional
Terminal

• For Loops
• Have Iteration Terminal
• Run According to input N of
Count Terminal

Ashraf AlMadhoun | LabVIEW Step By 73


Step Guide
Loops (cont.)
1. Select the loop 2. Enclose code to be repeated

3. Drop or drag additional nodes and then wire

Ashraf AlMadhoun | LabVIEW Step By 74


Step Guide
Charts

Waveform chart – special numeric


indicator that can display a
history of values
Controls >> Graph Indicators
>> Waveform Chart

75 Ashraf AlMadhoun | LabVIEW Step By


Wiring Data into Charts
Single Plot Charts Multiplot Charts

Ashraf AlMadhoun | LabVIEW Step By 76


Step Guide
Exercise 3 – Using loops
Students build Use a loop.vi.

Ashraf AlMadhoun | LabVIEW Step By 77


Step Guide
Section V – Arrays & File I/O
 Build arrays manually
 Have LabVIEW build arrays automatically
 Write to a spreadsheet file
 Read from a spreadsheet file

Ashraf AlMadhoun | LabVIEW Step By 78


Step Guide
Adding an Array to the Front Panel
From the Controls >> All Controls >> Array and
Cluster subpalette, select the Array Shell

Drop it on the screen.

Ashraf AlMadhoun | LabVIEW Step By 79


Step Guide
Adding an Array (cont.)
Place data object into shell (i.e. Numeric Control)

Ashraf AlMadhoun | LabVIEW Step By 80


Step Guide
Creating an Array with a Loop
Loops accumulate arrays at their boundaries

Ashraf AlMadhoun | LabVIEW Step By 81


Step Guide
Creating 2D Arrays

Ashraf AlMadhoun | LabVIEW Step By 82


Step Guide
File I/O
File I/O – passing data to and from files
- Files can be binary, text, or spreadsheet
- Write/Read LabVIEW Measurements file (*.lvm)
Writing to LVM file Reading from LVM file

Ashraf AlMadhoun | LabVIEW Step By 83


Step Guide
Write LabVIEW Measurement File
Includes the open, write, close and error handling
functions
Handles formatting the string with either a tab or
comma delimiter
Merge Signals function is used to combine data into
the dynamic data type

Ashraf AlMadhoun | LabVIEW Step By 84


Step Guide
Section VI – Array Functions &
Graphs
Basic Array Functions
Use graphs
Create multiplots with graphs

Ashraf AlMadhoun | LabVIEW Step By 85


Step Guide
Array Functions – Basics
Functions >> All functions>> Array

Ashraf AlMadhoun | LabVIEW Step By 86


Step Guide
Array Functions – Build Array

Ashraf AlMadhoun | LabVIEW Step By 87


Step Guide
Graphs

Selected from the Graph palette of Controls menu


Controls>>All Controls>>Graphs
Waveform Graph – Plot an array of
numbers against their indices
Express XY Graph – Plot one array against
another
Digital Waveform Graph – Plot bits from
binary data

88 Ashraf AlMadhoun | LabVIEW Step By


Graphs

Right-Click on the Graph and choose Properties


to Interactively Customize

Ashraf AlMadhoun | LabVIEW Step By 89


Step Guide
Exercise 5 – Using Waveform
Graphs

Ashraf AlMadhoun | LabVIEW Step By 90


Step Guide
Section VII – Strings, Clusters, & Error
Handling
 Strings
 Creating Clusters
 Cluster Functions
 Error I/O

Ashraf AlMadhoun | LabVIEW Step By 91


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

Ashraf AlMadhoun | LabVIEW Step By 92


Step Guide
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

Ashraf AlMadhoun | LabVIEW Step By 93


Step Guide
Creating a Cluster
1. Select a Cluster shell 2. Place objects inside the shell

Controls >> All Controls >> Array & Cluster

94 Ashraf AlMadhoun | LabVIEW Step By


Cluster Functions
• In the Cluster subpalette of the Functions>>All
functions palette
• Can also be accessed by right-clicking on the cluster
terminal

(Terminal labels
reflect data type)
Bundle

Bundle By Name
Ashraf AlMadhoun | LabVIEW Step By 95
Step Guide
Cluster Functions

Unbundle

Unbundle By Name

Unbundled cluster
in the diagram

Ashraf AlMadhoun | LabVIEW Step By 96


Step Guide
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

Ashraf AlMadhoun | LabVIEW Step By 97


Step Guide
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
Automatic Error Handling

error clusters

98 Ashraf AlMadhoun | LabVIEW Step By


Section VIII - Case & Sequence
Structures, Formula Nodes

Ashraf AlMadhoun | LabVIEW Step By 99


Step Guide
Case Structures
In the Structures subpalette of Functions palette

Enclose nodes or drag them inside the structure

Stacked like a deck of cards, only one case visible

Functions >> Execution control

100 Ashraf AlMadhoun | LabVIEW Step By


Sequence Structures
In the Execution Control subpalette of Functions palette
Executes diagrams sequentially
Right-click to add new frame

Ashraf AlMadhoun | LabVIEW Step By 101


Step Guide
Formula Nodes
In the Structures subpalette
Implement complicated equations
Variables created at border
Variable names are case sensitive
Each statement must terminate with a semicolon (;)
Context Help Window shows available functions
Note semicolon

Ashraf AlMadhoun | LabVIEW Step By 102


Step Guide
Section IX – 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

Ashraf AlMadhoun | LabVIEW Step By 103


Step Guide
Printing
File » Print… Gives Many Printing Options
Choose to Print Icon, Front Panel, Block Diagram, VI Hierarchy,
Included SubVIs, VI History
Print Panel.vi (Programmatically Prints a Front Panel)
Functions » All Functions » Application Control
Generate & Print Reports (Functions » Output »
Report)

104 Ashraf AlMadhoun | LabVIEW Step By


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

Ashraf AlMadhoun | LabVIEW Step By 105


Step Guide
Section X – Basic Programming
Architecture
• Simple VI Architecture
• General VI Architecture
• State Machine Architecture

Ashraf AlMadhoun | LabVIEW Step By 106


Step Guide
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

107 Ashraf AlMadhoun | LabVIEW Step By


General VI Architecture
Three Main Steps
Startup
Main Application
Shutdown

108 Ashraf AlMadhoun | LabVIEW Step By


State Machine Architecture
Advantages
Can go from any state to any other
Easy to modify and debug
Disadvantages
Can lose events if two occur at the
same time
States:
0: Startup
1: Idle
2: Event 1
3: Event 2
4: Shutdown

Ashraf AlMadhoun | LabVIEW Step By 109


Step Guide
Section XI – Remote Front Panels
• View & Control LabVIEW Front Panels from a
Web Browser
• Requires no programming
• Remote clients see “live” front panel updates
• Multiple clients can view the same panel
simultaneously
• Only one client can control the front panel at a
time

Ashraf AlMadhoun | LabVIEW Step By 110


Step Guide
Remote Panel Web Publishing Tool
Tools » Web Publishing Tool…•

•Click Save to Disk


and VI is embedded
into an HTML file

•After file is saved, it


can be reopened and
customized in any
HTML editor

Ashraf AlMadhoun | LabVIEW Step By 111


Step Guide
Remote Front Panels - Resources
• NI Developer Zone
(zone.ni.com)
• Search for Remote
Front Panel
• Tutorials &
Instructions Are
Available for
Download
• Information on
Incorporating Web
Cameras into Remote
Panel Applications

112 Ashraf AlMadhoun | LabVIEW Step By


Section XII – Additional Topics
Property Nodes
Local Variables
Global Variables
DataSocket
Binary File I/O

Ashraf AlMadhoun | LabVIEW Step By 113


Step Guide
Where Do I Go From Here?
Example programs (Help» Find Examples…)
LabVIEW Student Edition (www.ni.com/labviewse)
Web resources (ni.com)
NI Developer Zone (zone.ni.com)
Application Notes
Info-labview newsgroup (www.info-labview.org/)
Instrument Driver Library (www.ni.com/idnet)

Ashraf AlMadhoun | LabVIEW Step By 114


Step Guide

You might also like