Table Of ContentVIRTUAL INSTRUMENTATION
USING LabVIEW
Jovitha Jerome
Professor and Head
Department of Instrumentation and Control Systems Engineering
PSG College of Technology
Coimbatore, Tamil Nadu
New Delhi-110001
2010
Rs. 375.00
VIRTUAL INSTRUMENTATION USING LabVIEW
Jovitha Jerome
© 2010 by PHI Learning Private Limited, New Delhi. All rights reserved. No part of this book may be
reproduced in any form, by mimeograph or any other means, without permission in writing from the
publisher.
Warning and Disclaimer
While every precaution has been taken in the preparation of this book, the author and the publisher do not guarantee
the accuracy, adequacy, or completeness of any information contained in this book. Neither is any liability assumed
by the author and the publisher for any damages or loss to your data or your equipment resulting directly or indirectly
from the use of the information or instructions contained herein.
Trademark Acknowledgements
LabVIEWTM is the registered trademark of National InstrumentsTM. Use of any product or service name in this book
should not be regarded as affecting the validity of any trademark or service mark.
ISBN-978-81-203-4030-5
The export rights of this book are vested solely with the publisher.
Published by Asoke K. Ghosh, PHI Learning Private Limited, M-97, Connaught Circus,
New Delhi-110001 and Printed by Mudrak, 30-A, Patparganj, Delhi-110091.
To
My Husband, Daughter and Son
M. Jerome Benjamin
Arumika Jerome
Jude Prabu Jerome
CCCCCOOOOONNNNNTTTTTEEEEENNNNNTTTTTSSSSS
Foreword................................................................................................................................... xix
Preface....................................................................................................................................... xxi
1 GRAPHICAL SYSTEM DESIGN.......................................................... 1–19
1.1 INTRODUCTION.....................................................................................................1
1.2 GRAPHICAL SYSTEM DESIGN (GSD) MODEL................................................2
1.2.1 Design (Model).............................................................................................2
1.2.2 Prototype (Lab).............................................................................................3
1.2.3 Deployment (Field).......................................................................................4
1.3 DESIGN FLOW WITH GSD...................................................................................5
1.4 VIRTUAL INSTRUMENTATION............................................................................6
1.5 VIRTUAL INSTRUMENT AND TRADITIONAL INSTRUMENT.......................7
1.6 HARDWARE AND SOFTWARE IN VIRTUAL INSTRUMENTATION.............10
1.6.1 Role of Hardware in Virtual Instrumentation ...........................................10
1.6.2 Role of Software in Virtual Instrumentation.............................................10
1.7 VIRTUAL INSTRUMENTATION FOR TEST, CONTROL AND DESIGN .......12
1.7.1 Virtual Instrumentation for Test.................................................................12
1.7.2 Virtual Instrumentation for Industrial I/O and Control............................13
1.7.3 Virtual Instrumentation for Design............................................................13
1.8 VIRTUAL INSTRUMENTATION IN THE ENGINEERING PROCESS.............14
1.8.1 Research and Development........................................................................14
1.8.2 Development Test and Validation..............................................................14
1.8.3 Manufacturing Test.....................................................................................14
v
vi Contents
1.9 VIRTUAL INSTRUMENTS BEYOND PERSONAL COMPUTER.....................15
1.10 GRAPHICAL SYSTEM DESIGN USING LabVIEW..........................................16
1.11 GRAPHICAL PROGRAMMING AND TEXTUAL PROGRAMMING ..............17
SUMMARY..........................................................................................................................18
REVIEW QUESTIONS .......................................................................................................19
2 INTRODUCTION TO LabVIEW......................................................... 20–46
2.1 INTRODUCTION...................................................................................................20
2.2 ADVANTAGES OF LabVIEW...............................................................................21
2.3 SOFTWARE ENVIRONMENT..............................................................................23
2.3.1 Front Panel Windows.................................................................................23
2.3.2 Block Diagram Windows...........................................................................24
2.3.3 Icon/Connector Pane ..................................................................................25
2.4 CREATING AND SAVING A VI..........................................................................25
2.5 FRONT PANEL TOOLBAR...................................................................................26
2.6 BLOCK DIAGRAM TOOLBAR............................................................................27
2.7 PALETTES..............................................................................................................28
2.7.1 Tools Palette ...............................................................................................28
2.7.2 Front Panel—Controls Palette....................................................................29
2.7.3 Block Diagram—Functions Palette............................................................30
2.8 SHORTCUT MENUS.............................................................................................31
2.9 PROPERTY DIALOG BOXES ..............................................................................32
2.10 FRONT PANEL CONTROLS AND INDICATORS..............................................33
2.11 BLOCK DIAGRAM ...............................................................................................34
2.11.1 Terminals.....................................................................................................34
2.11.2 Nodes ..........................................................................................................35
2.11.3 Functions.....................................................................................................35
2.11.4 SubVIs.........................................................................................................35
2.11.5 Express VIs and VIs ..................................................................................35
2.11.6 Wires...........................................................................................................35
2.12 DATA TYPES .........................................................................................................36
2.13 DATA FLOW PROGRAM......................................................................................36
2.14 LabVIEW DOCUMENTATION RESOURSES .....................................................37
2.15 KEYBOARD SHORTCUTS...................................................................................38
SUMMARY..........................................................................................................................38
MISCELLANEOUS SOLVED PROBLEMS .......................................................................39
REVIEW QUESTIONS .......................................................................................................45
EXERCISES ........................................................................................................................46
Contents vii
3 MODULAR PROGRAMMING............................................................ 47–64
3.1 INTRODUCTION...................................................................................................47
3.2 MODULAR PROGRAMMING IN LabVIEW......................................................48
3.3 BUILD A VI FRONT PANEL AND BLOCK DIAGRAM ..................................49
3.4 ICON AND CONNECTOR PANE ........................................................................49
3.5 CREATING AN ICON ...........................................................................................50
3.6 BUILDING A CONNECTOR PANE.....................................................................51
3.6.1 Assigning Terminals to Controls and Indicators.......................................52
3.6.2 Confirming Terminal Connections.............................................................53
3.6.3 Deleting Terminal Connections..................................................................53
3.6.4 Setting Required, Recommended, and Optional Inputs and Outputs......54
3.7 DISPLAYING SUBVIs AND EXPRESS VIs AS ICONS OR
EXPANDABLE NODES.........................................................................................54
3.8 CREATING SUBVIs FROM SECTIONS OF A VI..............................................55
3.9 OPENING AND EDITING SUBVIs .....................................................................57
3.10 PLACING SUBVIs ON BLOCK DIAGRAMS.....................................................57
3.11 SAVING SUBVIs....................................................................................................57
3.12 CREATING A STAND-ALONE APPLICATION..................................................57
3.12.1 Building the Application and Installer ......................................................58
3.12.2 Application (EXE) Build Specification.....................................................58
SUMMARY..........................................................................................................................58
MISCELLANEOUS SOLVED PROBLEMS .......................................................................59
REVIEW QUESTIONS .......................................................................................................64
EXERCISES ........................................................................................................................64
4 REPETITION AND LOOPS............................................................... 65–90
4.1 INTRODUCTION...................................................................................................65
4.2 FOR LOOPS ...........................................................................................................65
4.3 WHILE LOOPS......................................................................................................67
4.4 STRUCTURE TUNNELS.......................................................................................70
4.5 TERMINALS INSIDE OR OUTSIDE LOOPS.....................................................71
4.6 SHIFT REGISTERS................................................................................................71
4.6.1 Initializing Shift Registers..........................................................................73
4.6.2 Stacked Shift Registers ..............................................................................74
4.6.3 Replacing Tunnels with Shift Registers....................................................74
4.6.4 Replacing Shift Registers with Tunnels....................................................75
4.7 FEEDBACK NODES..............................................................................................75
4.7.1 Initializing a Feedback Node.....................................................................76
4.8 CONTROL TIMING...............................................................................................77
viii Contents
4.9 COMMUNICATING AMONG MULTIPLE LOOPS ............................................79
4.10 LOCAL VARIABLES.............................................................................................79
4.11 GLOBAL VARIABLES..........................................................................................81
SUMMARY..........................................................................................................................83
MISCELLANEOUS SOLVED PROBLEMS .......................................................................83
REVIEW QUESTIONS .......................................................................................................89
EXERCISES ........................................................................................................................89
5 ARRAYS..................................................................................... 91–114
5.1 INTRODUCTION...................................................................................................91
5.2 ARRAYS IN LabVIEW..........................................................................................91
5.3 CREATING ONE-DIMENSIONAL ARRAY CONTROLS, INDICATORS
AND CONSTANTS................................................................................................92
5.4 CREATING TWO-DIMENSIONAL ARRAYS......................................................93
5.5 CREATING MULTIDIMENSIONAL ARRAYS....................................................94
5.6 INITIALIZING ARRAYS.......................................................................................94
5.7 DELETING ELEMENTS, ROWS, COLUMNS AND PAGES WITHIN ARRAYS... 95
5.8 INSERTING ELEMENTS, ROWS, COLUMNS AND PAGES INTO ARRAYS....96
5.9 REPLACING ELEMENTS, ROWS, COLUMNS, AND PAGES
WITHIN ARRAYS..................................................................................................97
5.10 ARRAY FUNCTIONS............................................................................................98
5.11 AUTO INDEXING ...............................................................................................100
5.12 CREATING TWO-DIMENSIONAL ARRAYS USING LOOPS........................100
5.13 IDENTIFICATION OF DATA STRUCTURE (SCALAR AND ARRAY)
USING WIRES.....................................................................................................101
5.14 USING AUTO-INDEXING TO SET THE FOR LOOP COUNT......................101
5.15 MATRIX OPERATIONS WITH ARRAYS..........................................................102
5.15.1 Converting an Array to a Matrix.............................................................103
5.15.2 Converting a Matrix to an Array.............................................................103
5.16 POLYMORPHISM................................................................................................104
SUMMARY........................................................................................................................106
MISCELLANEOUS SOLVED PROBLEMS .....................................................................106
REVIEW QUESTIONS .....................................................................................................113
EXERCISES ......................................................................................................................113
6 CLUSTERS.................................................................................115–130
6.1 INTRODUCTION.................................................................................................115
6.2 CREATING CLUSTER CONTROLS AND INDICATORS................................116
6.3 CREATING CLUSTER CONSTANT ..................................................................117
Contents ix
6.4 ORDER OF CLUSTER ELEMENTS..................................................................117
6.5 CLUSTER OPERATIONS....................................................................................118
6.6 ASSEMBLING CLUSTERS.................................................................................118
6.7 DISASSEMBLING CLUSTERS ..........................................................................120
6.8 CONVERSION BETWEEN ARRAYS AND CLUSTERS .................................121
6.9 ERROR HANDLING............................................................................................122
6.10 ERROR CLUSTER...............................................................................................123
SUMMARY........................................................................................................................124
MISCELLANEOUS SOLVED PROBLEMS .....................................................................124
REVIEW QUESTIONS .....................................................................................................129
EXERCISES ......................................................................................................................130
7 PLOTTING DATA........................................................................131–159
7.1 INTRODUCTION.................................................................................................131
7.2 TYPES OF WAVEFORMS...................................................................................131
7.3 WAVEFORM GRAPHS........................................................................................132
7.3.1 Displaying a Single Plot on Waveform Graphs......................................132
7.3.2 Displaying Multiple Plots on Waveform Graphs....................................132
7.4 WAVEFORM CHARTS........................................................................................133
7.4.1 Displaying a Single Plot on Waveform Charts.......................................134
7.4.2 Displaying Multiple Plots on Waveform Charts.....................................134
7.5 WAVEFORM DATA TYPE..................................................................................135
7.6 XY GRAPHS.........................................................................................................135
7.6.1 Displaying a Single Plot on XY Graphs..................................................136
7.6.2 Displaying Multiple Plots on XY Graphs................................................136
7.7 INTENSITY GRAPHS AND CHARTS...............................................................136
7.7.1 Intensity Charts.........................................................................................137
7.7.2 Intensity Graphs .......................................................................................138
7.7.3 Using Color Mapping with Intensity Graphs and Charts ......................138
7.8 DIGITAL WAVEFORM GRAPHS.......................................................................139
7.8.1 Digital Waveform Data Type...................................................................140
7.9 3D GRAPHS.........................................................................................................141
7.10 CUSTOMIZING GRAPHS AND CHARTS........................................................142
7.10.1 Using Multiple X- and Y-Scales...............................................................142
7.10.2 Autoscaling...............................................................................................142
7.10.3 Formatting X- and Y-Scales......................................................................142
7.10.4 Using the Graph Palette...........................................................................143
7.10.5 Customizing Graph and Chart Appearance.............................................143
7.10.6 Exporting Images of Graphs, Charts, and Tables...................................143
x Contents
7.11 CUSTOMIZING GRAPHS...................................................................................144
7.11.1 Using Graph Cursors................................................................................144
7.11.2 Using Graph Annotations.........................................................................145
7.12 CUSTOMIZING 3D GRAPHS ............................................................................146
7.13 CUSTOMIZING CHARTS...................................................................................146
7.13.1 Configuring Chart History Length...........................................................146
7.13.2 Configuring Chart Update Modes ...........................................................147
7.13.3 Using Overlaid and Stacked Plots...........................................................147
7.14 DYNAMICALLY FORMATTING WAVEFORM GRAPHS...............................148
7.15 CONFIGURING A GRAPH OR CHART...........................................................148
7.16 DISPLAYING SPECIAL PLANES ON THE XY GRAPH.................................149
7.16.1 Displaying a Nyquist Plane .....................................................................149
7.16.2 Displaying a Nichols Plane .....................................................................150
7.16.3 Displaying an S Plane..............................................................................150
7.16.4 Displaying a Z Plane................................................................................151
SUMMARY........................................................................................................................152
MISCELLANEOUS SOLVED PROBLEMS .....................................................................153
REVIEW QUESTIONS .....................................................................................................159
EXERCISES ......................................................................................................................159
8 STRUCTURES.............................................................................160–193
8.1 INTRODUCTION.................................................................................................160
8.2 CASE STRUCTURES ..........................................................................................161
8.2.1 Case Selector Values and Data Types.....................................................162
8.2.2 Input and Output Tunnels........................................................................162
8.2.3 Using Case Structures for Error Handling..............................................163
8.3 SEQUENCE STRUCTURES................................................................................163
8.3.1 Flat Sequence Structure ...........................................................................163
8.3.2 Stacked Sequence Structure.....................................................................163
8.3.3 Using Sequence Structures.......................................................................164
8.3.4 Avoiding Overuse Sequence Structures...................................................164
8.3.5 Adding and Removing Sequence Local Terminals.................................165
8.4 CUSTOMIZING STRUCTURES .........................................................................166
8.4.1 Placing Structures on the Block Diagram...............................................166
8.4.2 Placing Objects inside Structures ............................................................166
8.4.3 Removing Structures without Deleting Objects in the Structure...........167
8.4.4 Resizing Structures...................................................................................167
8.4.5 Adding Cases to the Middle of an Ordered List ...................................167
8.4.6 Adding, Duplicating and Deleting Subdiagrams ....................................168
Description:The book introduces the students to the graphical system design model and its different phases of functionality such as design, prototyping and deployment. It explains the basic concepts of graphical programming and highlights the features and techniques used in LabVIEW to create Virtual Instruments