3325_C000.fm Page i Tuesday, August 22, 2006 2:25 PM Half Title Page LabVIEW™ Advanced Programming Techniques SECOND EDITION 3325_C000.fm Page ii Tuesday, August 22, 2006 2:25 PM 3325_C000.fm Page iii Tuesday, August 22, 2006 2:25 PM Title Page 3325_C000.fm Page iv Tuesday, August 22, 2006 2:25 PM CRC Press Taylor & Francis Group 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742 © 2007 by Taylor & Francis Group, LLC CRC Press is an imprint of Taylor & Francis Group, an Informa business No claim to original U.S. Government works Printed in the United States of America on acid-free paper 10 9 8 7 6 5 4 3 2 1 International Standard Book Number-10: 0-8493-3325-3 (Hardcover) International Standard Book Number-13: 978-0-8493-3325-5 (Hardcover) This book contains information obtained from authentic and highly regarded sources. Reprinted material is quoted with permission, and sources are indicated. A wide variety of references are listed. Reasonable efforts have been made to publish reliable data and information, but the author and the publisher cannot assume responsibility for the validity of all materials or for the conse- quences of their use. No part of this book may be reprinted, reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, please access www. copyright.com (http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC) 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged. Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without intent to infringe. Library of Congress Cataloging-in-Publication Data Bitter, Rick. LabVIEW : advanced programming techniques / Richard Bitter, Taqi Mohiuddin, Matthew R. Nawrocki. -- 2nd ed. p. cm. ISBN 0-8493-3325-3 (alk. paper) 1. Computer programming. 2. LabVIEW. 3. Computer graphics. I. Mohiuddin, Taqi. II. Nawrocki, Matt. III. Title. QA76.6.B5735 2006 005.1--dc22 2006044686 Visit the Taylor & Francis Web site at http://www.taylorandfrancis.com and the CRC Press Web site at http://www.crcpress.com 3325_C000.fm Page v Tuesday, August 22, 2006 2:25 PM Preface and Acknowledgments As the power of the standard personal computer has steadily evolved, so have the capabilities of LabVIEW. LabVIEW has simplified the working lives of thousands of scientists, engineers, and technicians, and has increased their productivity. Auto- mation has reduced the costs and increased the manufacturing outputs of factories around the world. Cycle times for product development have been shortened and quality of many products has steadily improved. LabVIEW does not get credit for all of these improvements, but has without question played a valuable role in many organizations for accomplishing these goals. In our earlier experiences with LabVIEW, we found that adequate coverage of key topics was lacking. Subjects that are useful to users without a formal background in computer science such as approaches to software development, exception han- dling, and state machines were very difficult to find. In addition, newer areas such as multi-threading and ActiveX are even harder to locate and sometimes documen- tation is non-existent. Part of our intent in this book is to cover these topics that are difficult to find in other books on LabVIEW. The chapters in this book are written in a manner that will allow readers to study the topic of interest without having to read the contents in sequential order. Users of LabVIEW with varying levels of expertise will find this book beneficial. Proficiency with a programming language requires an understanding of the language constructs and the tools needed to produce and debug code. The first two chapters provide an overview of LabVIEW’s Integrated Development Environment, programming constructs, and main features. These chapters are meant to supplement LabVIEW’s documentation, and provide some good background information for programmers new to the language. Effective programmers have an understanding of programming techniques that are applicable to a large number of programming problems. Programming tools such as state machines that simplify logic of handling various occurrences and the use of instrument drivers are two such programming tools. Exception handling is left out of more applications than we want to discuss (including some of our own), but we have included a chapter specifically on exception handling in LabVIEW. Advanced programmers understand the operation of the language they are work- ing with and how it interacts with the system. We present a chapter on multi- threading’s impact on LabVIEW. Version 5.0 was LabVIEW’s debut into the world of multi-threaded capable programming languages. A number of the issues that occur with multi-threading programming were abstracted from the programmer, but a working knowledge of muti-threaded interactions is needed. 3325_C000.fm Page vi Tuesday, August 22, 2006 2:25 PM Object Oriented Programming (OOP) is commonly employed in languages such as C++ and Java. LabVIEW programmers can realize some of the benefits to such an approach as well. We define key terms often used in OOP, give an explanation of object analysis and introduce you to applying these concepts within a LabVIEW environment. We also present two chapters on ActiveX and .NET. An explanation of related technologies such as Component Object Model (COM) and Object Linking and Embedding (OLE) is provided along with the significance of ActiveX. A description on the use of ActiveX in LabVIEW applications is then provided. We follow this up with several useful examples of ActiveX/.NET such as embedding a browser on the front panel, use of the tree view control, and automating tasks with Microsoft Word, Excel, and Access. This book would not have been possible without the efforts of many individuals. First, we want to thank our friends at National Instruments. Ravi Marawar was invaluable in his support for the completion of this book. We would also like to thank Norma Dorst and Steve Rogers for their assistance. Our publishers at CRC Press, Nora and Helena have provided us with guidance from the first day we began working on this edition until its completion. We haven’t forgotten about the first edition publishing support of Dawn and Felicia. If not for their efforts, this book may not have been successful enough to warrant a second edition. A special thanks to Tim Sussman, our colleague and friend. He came through for us at times when we needed him. Also thanks to Greg Stehling, John Gervasio, Jeff Hunt, Ron Wegner, Joe Luptak, Mike Crowley, the Tellabs Automation team (Paul Mueller, Kevin Ross, Bruce Miller, Mark Yedinak, and Purvi Shah), Ted Lietz, and Waj Hussain (if it weren’t for Waj, we would have never written the papers which got us to writing this book). Finally, we owe many thanks for the love and support of our families. They had to put up with us during the many hours spent on this book. We would like to begin by apologizing to our wives for the time spent working on the second edition that could not be spent on the households! A special appreciation goes out to the loving wives who dealt positively with our absences — Thanks to Claire, Sheila, and Jahanara! Thank you moms and dads: Auradker and Mariam Mohiuddin, Rich and Madalyn Bitter, Barney and Veronica Nawrocki. For moral support we thank Jaha- nara, Mazhar, Tanweer, Faheem, Firdaus, Aliyah and Asiya, Matt Bitter, Andrea and Jerry Lehmacher; Sheila, Reilly, Andy, Corinne, Mark, and Colleen Nawrocki, Sue and Steve Fechtner. 3325_C000.fm Page vii Tuesday, August 22, 2006 2:25 PM The Authors Rick Bitter graduated from the University of Illinois at Chicago in 1994. He has presented papers at Motorola and National Instruments-sponsored symposia. Rick currently develops performance testing applications as a Senior Software Engineer. Taqi Mohiuddin graduated in electrical engineering from the University of Illinois at Chicago in 1995. He obtained his MBA from DePaul University. He has worked with LabVIEW since 1995, beginning with version 3.1, ranging in various telecom- munications applications. He has presented papers on LabVIEW at Motorola and National Instruments conferences. Matt Nawrocki graduated from Northern Illinois University in 1995. He has written papers and has done presentations on LabVIEW topics at Motorola, National Instru- ments, and Tellabs. 3325_C000.fm Page viii Tuesday, August 22, 2006 2:25 PM 3325_book.fm Page ix Monday, August 21, 2006 2:07 PM Contents Chapter 1 Introduction to LabVIEW....................................................................1 1.1 Virtual Instruments...........................................................................................1 1.1.1 The Front Panel....................................................................................2 1.1.2 Block Diagram.....................................................................................2 1.1.3 Executing VIs.......................................................................................3 1.1.4 LabVIEW File Extensions...................................................................5 1.2 LabVIEW Projects...........................................................................................5 1.3 Help..................................................................................................................6 1.3.1 Built-in Help........................................................................................7 1.3.2 Websites................................................................................................8 1.4 Data Flow Programming..................................................................................8 1.5 Menus and Palettes..........................................................................................9 1.6 Front Panel Controls......................................................................................11 1.6.1 User Control Sets...............................................................................12 1.6.1.1 Numeric...............................................................................13 1.6.1.2 Boolean...............................................................................15 1.6.1.3 String & Path......................................................................16 1.6.1.4 Ring & Enum, List & Table...............................................18 1.6.1.5 Array, Cluster, and Matrix..................................................20 1.6.1.6 Graphs and Charts..............................................................22 1.6.1.7 String & Path and I/O........................................................24 1.7 Block Diagram Functions..............................................................................26 1.7.1 Structures............................................................................................26 1.7.1.1 Sequence Structure.............................................................27 1.7.1.2 Case Structure.....................................................................30 1.7.1.3 For Loop.............................................................................32 1.7.1.4 While Loop.........................................................................37 1.7.1.5 Event Structure...................................................................38 1.7.1.6 Disable Structure................................................................38 1.7.1.7 Timed Structure..................................................................39 1.7.1.8 Formula Node.....................................................................41 1.7.2 Numeric, Boolean, String, and Comparison.....................................42 1.7.3 Array and Cluster...............................................................................45 1.7.4 Timing................................................................................................47 1.7.5 Dialog and User Interface..................................................................48 1.7.6 File I/O...............................................................................................49 1.7.7 Instrument I/O, Connectivity, and Communication..........................51 1.7.8 Creating Connectors...........................................................................52 1.7.9 Editing Icons......................................................................................54
Description: