From the Inside Flap
LabVIEW Programming, Data Acquisition and Analysis first edition, is intended as an introductory text for students who wish to learn LabVIEW as part of their programming repertoire. It has also been written to serve practicing engineers, scientists, and researchers, and even those who have been programming with LabVIEW, who wish to learn LabVIEW programming from the ground up or update their knowledge on different techniques of G-programming.
The book was started as a reference book for the biannual G-programming workshop that I offer to the local research community as well as a supplementary textbook for an introductory computer science class that I have taught. The ultimate goal of this book is to provide the most important aspects of LabVIEW programming to the research community and students, whether it is for scientific programming or for personal use and experience, in the most concise way so that readers can quickly start programming with LabVIEW.Philosophy
There have already been many books published on LabVIEW programming, so why bother writing another one? The philosophy behind this book was not to write a huge volume with everything in it, nor to write a narrowly-focused technical manual. LabVIEW is a programming language, often referred to as G-language, and what beginning users need is to get the most essential techniques and understanding about where and how to start. Once the programming gets going, programmers can usually improve their skills on their own since they then know where to go with their questions and problems.
When the intention of a book is to deliver the most knowledge in the most concise way, caution must be exercised not to be so abstract that the book skips details about important topics, nor to be so verbose that the readers lose their focus. So the challenge in completing this book was to screen the topics that must be covered, and to present the material in layperson's terms so that anyone could understand them easily.
Programming should be fun; so should the learning process. If the learning part becomes wearisome, the fun in programming will never be accomplished. However, nothing can be fun at all times, so some material in this book may appear to be dull or dry. In these sections, every possible effort has been made to make them concise without losing the integrity of the information. Any topic that seemed to be useful only in rare cases was excluded.
If a book is about software, it can quickly become outdated as newer versions are introduced. In order to avoid such a case, all of the topics in this book are carefully selected and presented so that readers can comfortably apply the techniques to their applications regardless of their versions of LabVIEW. Such an effort can be seen clearly in many chapters, especially those about data acquisition. The result of such an endeavor is a book with key concepts in programming with LabVIEW. On the other hand, all of the examples and exercise problems are carefully selected so that they are not too general. The outcome of such an effort is template-like examples, especially in the latter part of this book, such as Chapters 11, 12, 14, and 15. The examples in the latter chapters naturally seem to be more practical and more directly related to real applications, since the early part of this book covers the basic tools of G-programming. Most of the examples are based on actual applications that I have written for private companies, so their usefulness should be apparent.
LabVIEW is a great programming language. It allows programmers to develop an application, either with or without data acquisition and instrument control, in the shortest time period with the greatest amount of functionality. When I first encountered LabVIEW, however, that was not my first impression since I was more used to text-based programming languages. It looked different, but did not seem to be as powerful. (Icons for programming?) However, it did not take long to upset such a prejudice. It is not too difficult to find consultants or LabVIEW programmers who try to do everything in their applications with LabVIEW. Therefore, I strongly believe that readers will soon agree with many experienced LabVIEW programmers and myself about the unlimited capability of LabVIEW.
During the process of completing this book, I kept in mind one thought: "Remember when I was first learning LabVIEW." Without putting yourself in other people's shoes, you never understand their problems. Interestingly enough, people tend to forget about their past problems once they solve them. However, I remembered my experiences with learning LabVIEW throughout the entire period of preparation for this book. Therefore, the book may sometimes seem to be too descriptive, especially to those with previous experience in LabVIEW, but this is intentional because most readers will not have had such experiences, and what seems to be obvious to one person may not be so to others.
As for the chapters about data acquisition and instrument control, all of the examples that come with LabVIEW are categorized by their functionality. I believe that it is often a waste of time to write a data acquisition or instrument control application from scratch. Instead, the examples in LabVIEW should be either directly implemented or used as a starting point. It is important to learn how to modify them for your application, not how to build them from the ground up. Such a strategy applies not only to data acquisition and instrument control cases, but to any application in general. Therefore, a categorized list follows immediately after the detailed discussion about each topic.
This book contains many examples as a template for your future use. If the examples were complete, they would most likely look so complicated that readers would hesitate even to study them in the first place. To make matters even worse, a complete example can hardly be useful for your application unless your application is exactly the same as what is shown in that particular example. Such complete examples can be used to show what can be done with LabVIEW, but they often become a mere showoff. Based on such a belief, all of the examples are carefully written so that they are simple enough to be understood, but their objective remains apparent. Then they can easily be expanded by readers for their own applications. Chapter 15, in particular, illustrates many examples that are extracted from actual applications written in LabVIEW and modified so that they show a unique functionality with a simple look. This is one of the most important principles behind this book: maintaining the simplicity for easy understanding and expandability while keeping each example practical and meaningful. (You are reading this because you want to learn something that can be used for your application, not to be impressed by LabVIEW.) Also, the content in this book is independent of different versions of LabVIEW and different platforms except for the locations of some VIs and functions. (VI stands for Virtual Instrumentation, which is the basic file unit in LabVIEW.) For instance, the Analysis subpalette in the Functions palette has been divided into two new subpalettes, Signal Processing and Mathematics, with some new VIs in LabVIEW 5.1. The information about such changes can be found in your LabVIEW package, and you can concentrate on learning the material in this book.
To summarize, this book is written to help anyone who intends to learn G-programming with LabVIEW, and start programming in the least amount of time while learning the most important aspects of LabVIEW programming. The topics are carefully selected so that readers can do almost anything with those covered in this book. The examples are extracted from the actual applications that I have written for companies and can be used as a template for your application. Data acquisition and instrument control chapters include lists of categorized LabVIEW examples, so that readers can easily decide which one to use where and when, after modifying them. The content in this book is independent of the version of LabVIEW, although version 3.0 or higher is recommended. The changes in the locations of some functions and VIs of LabVIEW can be found in your LabVIEW package.
Last but not least, LabVIEW is a powerful language, and it is worth spending some time on mastering it. I hope this book helps bring all readers the full power and the exultation of G-programming.Key Features
The major features of this book are the exercise problems at the end of each chapter except Chapters 1 and 15, and the accompanying hands-on exercise manual, which comes with a set of complete solution VIs. Also, an evaluation copy of LabVIEW is included on the accompanying CD-ROM, and readers can test or create their VIs with limited functionality.End-of-Chapter Problems
Whenever needed, a proper example is provided in the body of each chapter with step-by-step instructions. In addition to that, more problems are included at the end of each chapter, except for Chapters 1 and 15. If you intend to teach LabVIEW in a formal classroom environment, those exercise problems can be useful for weekly assignments or as stepping stones for term projects. Each problem set covers the material in each corresponding chapter, and the solutions to all of the problems are available to instructors upon their request. Any learning process cannot be complete without practice, and those problems will uphold such a principle.LabVIEW Evaluation Copy on CD-ROM
The accompanying CD-ROM contains an evaluation copy of LabVIEW with limited functionality. Therefore, even if you do not own the full version, you may be able to complete and run most of the examples in this book with the evaluation copy. Some of the examples may require the full version of LabVIEW to run.Accompanying Hands-on Exercise Manual
This is an extended version of the exercise manual that is being used for the biannual G-programming workshop that I have been offering to the research community in Virginia. Each problem has step-by-step instructions on how to create it, and the solutions to all of the problems are available. This manual is divided into six sections, and each one is designed to be finished each day, completing the entire sections within six days. The problems cover a broad range of important topics in G-programming: from the simple wiring technique to a complicated programming example, including data acquisition and instrument control. The problems for data acquisition are designed in such a way that any data acquisition device can be used.Contents of the Book
Chapter 1 begins with a brief review of the history of computers and programming languages since they are closely related. Following the review, the result of a case study is presented, where a comparison test was performed between LabVIEW and C++ on a group of college students. The purpose of such a case study was to see if a graphical language such as LabVIEW would have any benefit in the programming language and concept learning process over the text-based programming languages. Then the conventions in this textbook are summarized.
Chapter 2 introduces the basic structure of LabVIEW source files that have the extension .vi (Virtual Instrumentation) and continues with the objects in the Controls palette, and the functions and the VIs in the Functions palette. The importance of using shortcuts is discussed along with a list of useful ones.
Chapter 3 explains the concept behind sub VIs and how to create them. The various user option settings of sub VIs are presented and studied in detail. The effect of each of the settings and where it can be used are also discussed.
Chapter 4 explores the loops and conditional statements of LabVIEW. The unique features, such as autoindexing and shift registers, and the differences from those of text-based languages are highlighted. Also, Global Variables and Local Variables of LabVIEW are presented and compared to those of text-based languages. Since LabVIEW represents programming graphically in a two-dimensional diagram window, the execution order can sometimes be opaque and nebulous. Such a problem can be resolved by using the Sequence structure, and a detailed discussion about its usage is presented in this chapter.
Chapter 5 examines different ways of displaying data and explains different situations where each type is preferred to the others. It also describes how to prepare the data properly so that user specifications, such as display scales of each axis can be reflected correctly on the graphs. Such user specification can be controlled programmatically by Attribute Nodes, and their properties are explored in this chapter, too.
Chapter 6 introduces the two commonly used data types in LabVIEW: arrays and clusters. Each type has its advantages and disadvantages, and they are discussed in detail. Due to the similarity between the two types, LabVIEW functions for the two types are compared to distinguish them clearly. The correlation between memory usage and arrays and clusters is also studied.
Chapter 7 presents the prerequisite material for data acquisition, including sampling theorem, a brief preview of data acquisition VIs, different types of input signal modes, and different types of data acquisition, such as analog input, analog output, digital input and output, and counter operation. The sampling theorem is formally defined, and the effects of ideal sampling using the impulse train and of practical sampling using a square pulse train are mathematically driven for interested readers. This chapter also discusses what to look for when selecting a data acquisition device.
Chapter 8 provides detailed discussion of data acquisition. The first category of data acquisition, analog input (AI), is studied in detail. As mentioned earlier, all of the examples of LabVIEW pertaining to AI are categorized based on their functionality. Such an effort is made in order to help readers choose which one to use easily, since the size of the example pool is so large that it can be somewhat frustrating to find the proper one. The selection of the LabVIEW examples covers almost all of the possible data acquisition methods; therefore, learning how to use or modify which example should be your top priority, instead of building a new VI from scratch. Of course, a detailed discussion about each AI VI is presented for those who prefer to start a completely new VI on their own. However, it is worth emphasizing again that adapting prewritten LabVIEW examples to your application should be the first attempt.
Chapter 9 deals with the second category of data acquisition, analog output (AO), and comprises the complete discussion of every aspect of AO. All of the prewritten LabVIEW AO examples are studied and categorized based on their functionality. Due to the number of examples available, the sorted list will assist readers in deciding which one to select. In addition to the list of categorized AO examples, a detailed discussion of AO VIs is also presented for those who prefer to build their own AO application.
Chapter 10 covers the last two categories of data acquisition: digital input and output and counters. Different types, such as handshaking and pattern generation, of digital input and output acquisition methods are defined and studied. Buffered and non-buffered digital acquisition techniques are also illustrated using LabVIEW examples. A variety of tasks that can be performed using counters on a data acquisition board are described individually in detail. Some examples include frequency measurements of high and low frequency Transistor Transistor Logic (TTL) signals, event counting where counting the number of high states is the goal of the operation, and continuous or single burst TTL signal generation. All of the prewritten LabVIEW examples are again categorized in addition to the detailed discussion about the VIs to help readers create their own application.
Chapter 11 discusses one of the most important tasks in data acquisition: saving or reading data to or from a file. Without knowing how to save the data, all of the painstaking hours of the data acquisition process can turn out to be nothing but a waste of time. This chapter illustrates all of the possible ways of saving and reading data with template-like examples, and they can be implemented directly without any modification. Since all of the templates are using basic LabVIEW functions and VIs, readers can easily add more functionality to them at their will. Such intention also coincides with one of the most important principles of this book: being simple, but practical and meaningful.
Chapter 12 can be considered as a continuation of Chapter 11 since file input and output are closely related to string manipulation. This chapter also plays an important role in instrument control, which is the topic of the following chapter. In order to write the data in a meaningful way, the data need to be prepared properly, either before being saved or after being read. This chapter covers all of the techniques necessary to complete such preparation stages.
Chapter 13 introduces instrument control with LabVIEW. The functions and the VIs for General Purpose Interface Bus (GPIB), serial communication, and Virtual Instrument Software Architecture (VISA) are closely studied. Some simple troubleshooting procedures for serial communication are presented in this chapter.
Chapter 14 covers a variety of data analysis techniques. In the early part of the chapter, some important data analysis theories are reviewed for interested readers. The categories are linear and nonlinear system analysis, stochastic and deterministic data analysis, and time and frequency data analysis. Also, some useful digital signal processing techniques, such as decimation and interpolation, are reviewed. Then matrix and vector representation of data is discussed to prepare readers for linear algebra VIs, followed by the study of analysis VIs in LabVIEW. Some of the topics may seem too advanced for some readers, but they can safely be skipped without any deficiency in learning G-programming techniques, and readers can proceed to the analysis VI section.
Chapter 15, the last chapter of the book, covers many issues in creating application and stand-alone executables and concludes with an overall review and many additional important issues of G-programming, which are not covered in the previous chapters. It also presents several practical examples that are actually being used in many real-world applications. Readers will find those examples unique and directly applicable to their applications with a great amount of flexibility. Examples include dynamic sub VI load and unload, creating a professional startup screen, toggle switch design, and many more. Chapter 15 also presents an in-depth discussion about maximizing the efficiency of applications. How to cope with the overhead incurred by the large size of VIs is also one of the unique topics in this chapter. Some possible workarounds are suggested along with a test result. The last topic pertains to Application Builder, which allows LabVIEW users to create a stand-alone executable from a VI. Detailed discussion of its feature is included to assist readers in using it properly.
This book includes two appendices, which contain the material that could not be included in the main body of a chapter. Appendix A contains step-by-step instructions on how to create a Code Interface Node using Code Warrior Professional Release on Power Macintosh platforms, and sample C++ codes for 1-D array and 2-D array cases are attached at the end. Appendix B consists of the front panels and the diagram windows of each sub VI that are used for the error handler design example presented in Chapter 15. Those sub VIs can be used as a template to create your own error handler VIs.Flexibility in Coverage
Chapters 7 through 10 cover data acquisition, and Chapter 13 discusses instrument control. Therefore, if you are reading this book only for general programming with LabVIEW, you can skip those chapters. In addition, you can skip Chapter 14 if data analysis is not the purpose of your application. However, you should cover Chapter 15 regardless of your application type, since it covers many important topics that every LabVIEW programmer should know.
If you are using this book to teach yourself LabVIEW, you can first review each chapter while duplicating examples introduced in each chapter. Then you can use the exercise problems in the accompanying hands-on exercise manual to complete the learning process. The two books can be covered in parallel, too, since the order of topics in them is relatively independent.
If you intend to teach LabVIEW in a semester-long class, either as supplementary material or as a main topic, you can teach each chapter and as-
sign the end-of-chapter problems as weekly homework. The solutions to these problems are available to instructors upon their request by email to firstname.lastname@example.org. All of the topics except for those in Chapter 14 can be covered regardless of the level of students. Some of the material in Chap-
ter 14 may not be suitable for those without any system theory or stochastic data analysis background; therefore, the coverage of Chapter 14 can be optional. The examples in each chapter, especially in Chapter 15, can be used as a stepping stone for a project assignment. For example, students may be assigned to write a professional database application as a term project, utilizing all of the topics and techniques covered in Chapters 2 through 15, excluding Chapters 7-10, and 13-14.
The hands-on exercise manual can also be used in a week-long short course where both data acquisition and data analysis techniques are covered. In such a case, this book can be used as a reference, and each section in the hands-on exercise manual can be covered on a daily basis.
From the Back Cover
- Master LabVIEW programming hands-on!
- Learn through real-world data acquisition and analysis applications
- Dozens of key techniques presented through easy-to-adapt templates
- Extensively classroom-tested with professional engineers
- CD-ROM: Tools, templates, and complete LabVIEW evaluation version
Master LabVIEW programming from the ground up fast!
LabVIEW Programming, Data Acquisition and Analysis is your easy, hands-on guide to LabVIEW programming and data analysis. Whether you're learning LabVIEW from the ground up, or updating knowledge you already have, Jeffrey Beyon covers every key technique you need to build reliable, high-performance applications. You'll start with the basics: the structure of LabVIEW source files; using sub VIs; loops and conditional statements; data display; data types; and the prerequisites for data acquisition, including sampling theorems and data acquisition VIs. Next, Beyon covers every key category of data acquisition and analysis application analog and digital, input and output. Coverage includes:
- Practical techniques for data save/read, data conversion, and much more
- Tips and tricks for memory management, large file management, and more
- Implementing each leading data analysis VI
- Instrument control, counters, and more
- Avoiding and troubleshooting common LabVIEW programming problems
Most examples are presented in the form of software templates that are easy enough to understand quickly, and robust enough to serve as building blocks for real-world solutions. You'll find detailed, end-of-chapter review questions; an accompanying lab workbook is also available. Whether you're a field engineer, scientist, researcher, or student, there's no faster way to get results with LabVIEW!
- Complete library of LabVIEW tools and templates
- Full LabVIEW evaluation version
Companion lab workbook: Hands-On Exercise Manual for LabVIEW Programming, Data Acquisition and Analysis