Graphical Programming Using LabVIEW™: Fundamentals and advanced techniques
2: Technological University of San Luis Rio Colorado, Mexico
In this book, the authors focus on efficient ways to program instrumentation and automation systems using LabVIEW™, a system design platform and development environment commonly used for data acquisition, instrument control, and industrial automation on a variety of operating systems.
Starting with the concepts of data flow and concurrent programming, the authors go on to address the development of state machines, event programming and consumer producer systems. Chapters cover the following topics: Introduction to LabVIEW™, debugging tools, structures, SubVIs, structures - LabVIEW™ features, organizing front panel and block diagram, using software resources, using hardware resources, implementing test machines with a basic architecture, controlling the user interface, error handling, responding to the user interactions, the ATM review project, communication between loops at different rates, preventing race conditions, advanced use of software resources, and real-time programming.
This book helps undergraduate and graduate students learn how to identify the most suitable design patterns depending on the application, and how to implement them in conjunction with data acquisition and instrumentation control systems. It is also a helpful resource for engineers and scientists who want to implement binary files to record data, control the user interface and implement efficient ways of programming.
Inspec keywords: virtual instrumentation; user interfaces; specification languages; formal specification; data acquisition
Other keywords: finite state machines; LabVIEW; data acquisition; user interfaces; power amplifiers; specification languages; radio networks; virtual instrumentation; formal specification
Subjects: General and management topics; User interfaces; Formal methods; High level languages; Computerised instrumentation; Computerised instrumentation; General electrical engineering topics
- Book DOI: 10.1049/PBPC046E
- Chapter DOI: 10.1049/PBPC046E
- ISBN: 9781839534607
- e-ISBN: 9781839534614
- Page count: 344
- Format: PDF
-
Front Matter
- + Show details - Hide details
-
p.
(1)
-
Part I: Fundamentals
1 Introduction to LabVIEW™
- + Show details - Hide details
-
p.
3
–30
(28)
This chapter gives an introduction to LabVIEW™, it will allow the reader to become familiar with the use of the software, it will explain the development environment, starting with the project explorer, how to properly structure projects and types of files in LabVIEW™, it will explain the definition of a virtual instrument and its parts, exposing the different functions available in the toolbars, the function and control palettes, an introduction to data types, how to build a virtual instrument and it will finish explaining about the inherent parallelism of LabVIEW™ and in what manner this graphical language executes a program by the concept of Data Flow.
2 Debugging tools
- + Show details - Hide details
-
p.
31
–37
(7)
This chapter explains the use of debugging tools to correct unexpected behavior in the program. The tools of "Highlight Execution", execution by "Steps", "Breakpoints" and "Probes" are studied. In addition, practical examples are presented to implement the conjunction use of these tools in debugging programming errors.
3 Structures
- + Show details - Hide details
-
p.
39
–54
(16)
Structures are nodes that execute the code that exists within them, just like any node, structures can have inputs and/or outputs. In order to execute a structure, it must have all its inputs available, in the same way, the structure will provide information through its output terminals until its execution ends. There are different types of structures such as for loops, while loops, cases, events, sequences, among others as shown in Figure 3.1. Structures can be used intuitively by developers who have experience in text-based programming; however, there are certain characteristics of the structures in LabVIEW™ that you can take advantage to develop sophisticated applications avoiding being redundant in the code [8].
This chapter explains the use of basic structures such as: for loops, while loops, cases, and sequences. It also explains the feedback in loops using shift registers and feedback nodes, as well as the different data types that can be used in the selection terminal of case structure. Finally, different methods are studied for timing, giving the time to the processor to attend different tasks.
4 SubVIs
- + Show details - Hide details
-
p.
55
–63
(9)
One of the main objectives of any program is scalability [12], this can be understood as the ability of a virtual instrument to implement new functionalities without significantly affecting the existing code. This scalability can be achieved by using modularity efficiently, which is performed in LabVIEW™ using SubVIs. This chapter explains how to create SubVIs from existing code, create SubVIs from a VI, specify the type for connection in the connector pane, and create custom icons and some techniques and conventions to implement SubVIs efficiently.
5 Structures - LabVIEW™ features
- + Show details - Hide details
-
p.
65
–75
(11)
One of the main applications of structures is working with arrays for iterative operations, ordering, and even searching information [13]. In this context, this chapter presents different approaches in which structures can be used to create and process arrays. In addition, with the aim to share data between parallel loops, the concept of variables is introduced. Finally, the concept of race conditions is explained to avoid some common problems using variables, and Formula Nodes are presented to have a structured way to implement mathematical formulas in text mode.
6 Organizing front panel and block diagram
- + Show details - Hide details
-
p.
77
–85
(9)
During the code implantation in graphical programming languages, it is desirable to take care of the organization and cleanliness of the code, this is in order to increase its readability. In this sense, when there are multiple cables whose use is closely related, clusters are recommended [15]. This chapter explains how to create clusters to group data, it also explains how to create *.ctl files (control type files), this for the implementation of custom controls, type definitions, and strict type definitions, which allow the programmer to determine the appearance and functionality characteristics that want to be kept between custom controls.
7 Using software resources
- + Show details - Hide details
-
p.
87
–101
(15)
This chapter explains the concept of resources and how they are accessed in LabVIEW™. As the access to resources is similar for software and hardware resources, this chapter will be focused on software resources, and hardware resources will be explained in the following chapters. The scope of this chapter is first to use software resources by high-level VIs and then to use them by low-level VIs; practical cases will be introduced, and several examples of the adequate use of each of them will be provided. In summary, this chapter introduces resources and presents practical cases and different approaches to solving them using files. Finally, structured forms to organize and present the information are taught.
8 Using hardware resources
- + Show details - Hide details
-
p.
103
–123
(21)
This chapter describes the use of hardware resources and their typical implementation. The chapter begins by explaining what NI MAX™ is, an essential tool for hardware configuration and testing. Practical examples are provided for the use of data acquisition systems (using DAQs) and libraries to communicate with Arduino. In addition, communication through different computer ports using VISA libraries is addressed. Finally, instrument control through instrument drivers and VISA libraries is presented.
9 Implementing test machines with a basic architecture
- + Show details - Hide details
-
p.
125
–132
(8)
The efficient programming of a test machine depends on the scalability of the code, and the use of an architecture that different programmers can understand. In these cases, the use of state machine design pattern is a widely accepted implementation by the programmer community, allowing flexibility to program different kinds of tests and configurations on a single machine [20]. This design pattern is explained in detail and practical examples of its implementation are presented.
-
Part II: Advanced techniques
10 Controlling the user interface
- + Show details - Hide details
-
p.
135
–147
(13)
The convenience of a software is tightly related to the feedback that the program can provide, this through different signals or visual changes in the interface. In the same way, it is expected that the program can execute specific methods that are transversal and common among similar programs [21]. This chapter explains how to modify different properties of objects and how to call different types of methods at runtime. In addition, it will be explained what they are and how to create control references that allow calling properties and methods from SubVIs.
11 Error handling
- + Show details - Hide details
-
p.
149
–160
(12)
Error handling is a fundamental feature in an application, without a mechanism to notify the user that an error has occurred and the cause of it, the program would simply stop working. It is for this reason that this chapter explains how to manage errors properly, it begins by defining errors and warnings, custom errors will be created and appropriate ways to stop a program and display errors will be explained.
12 Responding to the user interactions
- + Show details - Hide details
-
p.
161
–181
(21)
As a program responds swiftly to the user's actions, it feels comfortable and works naturally with it. In this sense, traditional techniques such as polling can lose user actions. For this reason, in this chapter, the use of event structures is explained, which is an asynchronous communication structure that allows responding to all user actions, the chapter starts by describing what it is and how to use the event structure, it will show the use of data event nodes and event filter nodes, after that, an event state machine will be implemented, and finally, an example of Event-Driven State Machine will be implemented.
13 The ATM review project
- + Show details - Hide details
-
p.
183
–267
(85)
This chapter aims to review the topics covered so far in the book. The project consists of a VI that simulates an ATM that will require a card number and a PIN to log in and it will allow to check balance, change PIN, make withdrawals, and exit.
14 Communication between loops at different rates
- + Show details - Hide details
-
p.
269
–281
(13)
The inherent parallelism of LabVIEW™ allows concurrent execution of tasks, however, without an efficient mechanism to let the efficient communication between loops, the produced information that is communicated between parallel loops can be duplicated or lost. In this sense, this chapter explains the use of asynchronous communication methods between loops such as producer-consumer design pattern and event-driven producer-consumer design pattern, which allow solving some classic problems in this type of programming [23].
15 Preventing race conditions
- + Show details - Hide details
-
p.
283
–290
(8)
Race conditions are common errors in parallel applications. These occur when the order in execution of events produces information loss due to a variable being written from different parts of the program. Therefore, this chapter explains race conditions and how to prevent them. Additionally, the use of functional global variables to avoid race conditions is presented, in addition, practical examples for their use are explained.
16 Advanced use of software resources
- + Show details - Hide details
-
p.
291
–301
(11)
The way in which the information is written in a file depends on the application, for example, it is not the same to write information referring to text that the user is providing as part of a form than writing the information that is being acquired from data acquisition system (DAQ), in this sense, you need to know efficient ways to work with this kind of information. Therefore, this chapter explains the different types of available files, how to create multichannel files for acquisition tasks, and functions for using relative paths. Other functions to implement sophisticated solutions with files will be explored.
17 Real-time programming
- + Show details - Hide details
-
p.
303
–318
(16)
Several applications require dedicated systems for their implementation. Some examples are aerospace systems, specialized laboratories, or acquisition and processing systems for medical applications [28]. In this sense, a nondedicated system is not the best option to solve these tasks. In this sense, industrial systems such as CompactRIO™ allow solutions completely dedicated to the specific function. This chapter introduces the use of these systems, which, together with the previously studied tools, will help the developer implement sophisticated solutions.
-
Back Matter
- + Show details - Hide details
-
p.
(1)