This tutorial gives you an overview and talks about the fundamentals of LabVIEW.
Features of LabVIEW
– Signal and Image Processing
– Embedded System Programming
• (PC, DSP, FPGA, Microcontroller)
– Simulation and Prototyping
– And more …
– Automatic Controls and Dynamic Systems
– Mechatronics and Robotics
– And more …
– Circuits and Electronics
– Measurements and Instrumentation
Data Acquisition (DAQ)
“Data acquisition is the process of gathering or generating information in an automated fashion from analog and digital measurement sources such as sensors and devices under test.”
1. Graphical System Design
The term “scientific computing,” or “computational science”, has been used for many years to define the use of computers (software and hardware) for solving problems related to science and engineering, usually involving experimental or applied research, modeling, and simulation. In a simplistic definition, it refers to the use of computers in solving scientific problems. Scientific computing applications usually follow a three-step process: data acquisition, data analysis and data visualization/presentation.
This three-step approach has been one of the pillars of the NI (National Instruments) virtual instrumentation model as shown in Figure 1.1 since its original conceptualization in the early 1980s, and has been expanded into a more comprehensive model known as graphical system design shown in Figure 1.2. In this new model, the focus is to accelerate the research and development cycle, delivering mathematical models to embedded real-time computers faster and easier. This design-flow acceleration is achieved by using NI LabVIEW software and its G programming language as a common system-level design tool for all the different phases in the design-to-deployment flow.
Figure 1.1 Virtual instrumentation model.
Figure 1.2 Graphical system design model.
1.2 Graphical System Design (GSD) Model
In reality, the virtual instrumentation model is applied in each of the three phases of the graphical system design model as shown in Figure 1.3, because data acquisition, analysis and presentation functions are used in the design, prototyping and deployment phases.
Figure 1.3 Graphical system design and virtual instrumentation.
1.2.1 Design (Model)
In the design phase as shown in Figure 1.4, the researcher develops a mathematical model of the system, including sensors, actuators, plants and controllers, and simulates them under a variety of initial conditions and constraints. The researcher uses different numerical methods with the objective of validating the performance of the model and optimizing it.
Figure 1.4 The design phase of the graphical system design model.
In this phase, researchers can acquire reference data from files or databases and incorporate it into the model. A “virtual plant/process” is created, which can be used later for hardware-in-the-loop (HIL) tests. Results from the simulation process are saved for post-analysis and visualization and can be used to introduce changes into the model. This is usually a software-centric process with a strong focus on numerical methods/analysis and mathematics. However, for complex or computationally intensive models, high-performance computing (HPC) using grid computers, standard computers with graphical processing units (GPUs), and multicore based computers is a key factor. In those cases, the hardware has an important impact on the performance of the model solution and simulation. Multicore-ready software tools are scarce, but LabVIEW is multicore-aware. It provides the user with a powerful yet easy-to-use programming language that can take advantage of multicore processors and parallel programming.
1.2.2 Prototype (Lab)
If experimental validation of the model is required, researchers develop and test a prototype in the laboratory. Signal processing and analysis as well as visualization can be implemented online while data is being measured and acquired, or while the process is being controlled. The “virtual plant/process” defined in the previous phase can be used for HIL tests. The experimental results obtained in this phase can be used to modify and optimize the original model, which in turn may require additional experiments. Data captured can also be used for system identification and parameter estimation. Usually, this experimental (prototyping) phase is executed on standard PCs or PXI computers, using PCI/PXI data acquisition devices or external measuring devices connected to a PC via USB, Ethernet, GPIB, or serial ports.
This process as shown in Figure 1.5 is usually more software/hardware-centric because sensors, actuators, data acquisition devices, controllers, and the controlled/analyzed plant itself are all key
Figure 1.5 The prototyping phase of the graphical system design model.
elements in the experimental setup. Real-time operating systems (RTOSs) can be used when deterministic performance or higher reliability is required. Also, multicore-based computers can be used when higher computational performance is needed. Field-programmable gate arrays (FPGAs), digital signal processors (DSPs), and GPU processors can be used with the multicore main CPU, allowing LabVIEW to execute critical computations in specialized processors. For example, sets of 2D or 3D differential equations can be solved in real time, or large sets of matrices can be processed at high speed and in real time using parallel programming in multicore computers while sharing part of the signal processing load with an FPGA or a GPU. Data is shared between the multicore processors and an FPGA via DMA first-in-first-out memory buffers (FIFOs). Finally, technical data mining algorithms can be implemented by combining LabVIEW with NI DIAdem, an excellent tool for managing, analyzing, and reporting technical data collected during data acquisition and/or generated during the modelling, simulation or analysis phases.
1.2.3 Deployment (Field)
Finally, the model (controller, analyzer or both) is deployed in the field or lab using either a PC (desktop, server or industrial) or PXI, or it can be downloaded to a dedicated embedded controller such as CompactRIO, which usually operates in stand-alone mode and in real-time (deterministic) mode as shown in Figure 1.6. When using the LabVIEW Real-Time Module, symmetric multiprocessing (SMP) techniques can be easily applied. For large systems, with high-channel counts or involving modular instruments such as scopes, digital multimeters (DMMs), RF vector signal analyzers, and dynamic signal acquisition (DSA) devices, the PXI platform is more appropriate. The transition from the prototyping phase to the deployment phase can be very fast and efficient because the same set of tools used for prototyping can, in most cases, be applied to the final deployment of the system in the field.
Figure 1.6 The deployment phase of the graphical system design model.
In many cases, the system is deployed as a headless system (no monitors or interfaces to the user), executing the analysis/control algorithms in real time as a dedicated device. If on-the-field graphical user interfaces (GUIs) or operator interfaces (OIs) are needed, the LabVIEW Touch-Panel Module and industrial-grade monitors with touch-sensitive screens can be used locally. Remotely, data can be shared and visualized via Ethernet with applications developed using LabVIEW and the LabVIEW Datalogging and Supervisory Control Module running on one or more PCs distributed in a network.
1.3 Design Flow With GSD
Typical embedded system software and hardware design flows is shown in Figure 1.7.
Figure 1.7 Typical embedded system software and hardware design flow.
If you are creating custom hardware for final deployment, it is difficult to have the software and hardware developed in parallel as the software is never tested on representative hardware until the process reaches the system integration step. Additionally, you do not want the software development to be purely theoretical, because waiting until the system integration test to include I/O and test the design with real signals may mean that you discover problems too late to meet design deadlines. Most designers currently use a solution like an evaluation board to prototype their systems. However, these boards often only include a few analog and digital I/O channels and rarely include vision, motion, or ability to synchronize I/O. Additionally, designers often have to waste time developing custom boards for sensors or specialized I/O, just to complete a proof of concept.
Using flexible Commercial-off-the-shelf (COTS) prototyping platforms instead can truly streamline this process, as shown in Figure 1.8, and eliminates much of the work required for hardware verification and board design. Much like PCs today, in which case anyone can go to an
Figure 1.8 Stream-lined development flow with graphical system design.
electronics store and plug components such as memory, motherboards and peripheral together to create a PC, graphical system design strives to achieve the same standardization for prototyping platforms. The time has come for a new approach to electronic system design.
For most systems, a prototyping platform must incorporate the same components of the final deployed system. These components are often a real-time processor for executing algorithms deterministically, programmable digital logic for high-speed processing or interfacing the real-time processor to other components, and varied types of I/O and peripherals as shown in Figure 1.9. Finally, as with any system, if the off-the-shelf I/O doesn’t serve all of your needs, the platform should also be extensible and customizable when needed.
Figure 1.9 Typical components of an embedded system.
1.4 Virtual Instrumentation
Virtual instrumentation combines mainstream commercial technologies, such as the PC, with flexible software and a wide variety of measurement and control hardware. Engineers use virtual instrumentation to bring the power of flexible software and PC technology to test, control and design applications making accurate analog and digital measurements. Engineers and scientists can create user-defined systems that meet their exact application needs. Industries with automated processes, such as chemical or manufacturing plants use virtual instrumentation with the goal of improving system productivity, reliability, safety, optimization and stability. Virtual instrumentation is computer software that a user would employ to develop a computerized test and measurement system for controlling from a computer desktop, an external measurement hardware device, and for displaying, test or measurement data collected by the external device on instrument-like panels on a computer screen. It extends to computerized systems for controlling processes based on data collected and processed by a computerized instrumentation system. The front panel control function of the existing instrument is duplicated through the computer interface. The application ranges from simple laboratory experiments to large automation application.
Virtual instrumentation as shown in Figure 1.10 uses highly productive software, modular I/O and commercial platforms. National Instruments LabVIEW, a premier virtual instrumentation graphical development environment, uses symbolic or graphical representations to speed up development. The software symbolically represents functions. Consolidating functions within rapidly deployed graphical blocks further speeds up development.
Figure 1.10 Virtual instrumentation combines productive software, modular I/O and scalable platforms.
Another virtual instrumentation component is modular I/O, designed to be rapidly combined in any order or quantity to ensure that virtual instrumentation can both monitor and control any development aspect. Using well-designed software drivers for modular I/O, engineers and scientists quickly can access functions during concurrent operation.
The third virtual instrumentation element using commercial platforms, often enhanced with accurate synchronization, ensures that virtual instrumentation takes advantage of the very latest computer capabilities and data transfer technologies. This element delivers virtual instrumentation on a long-term technology base that scales with the high investments made in processors, buses and more.
In summary, as innovation mandates use of software to accelerate a new concept and product development, it also requires instrumentation to rapidly adapt to new functionality. Because virtual instrumentation applies software, modular I/O and commercial platforms, it delivers instrumentation capabilities uniquely qualified to keep pace with today’s concept and product development.
1.5 Virtual Instrument and Traditional Instrument
A traditional instrument is designed to collect data from an environment, or from a unit under test, and to display information to a user based on the collected data. Such an instrument may employ a transducer to sense changes in a physical parameter such as temperature or pressure, and to convert the sensed information into electrical signals such as voltage or frequency variations. The term “instrument” may also cover a physical or software device that performs an analysis on data acquired from another instrument and then outputs the processed data to display or recording means. This second category of instruments includes oscilloscopes, spectrum analyzers and digital millimeters. The types of source data collected and analyzed by instruments may thus vary widely, including both physical parameters such as temperature, pressure, distance, light and sound frequencies and amplitudes, and also electrical parameters including voltage, current and frequency.
A virtual instrument (VI) is defined as an industry-standard computer equipped with user-friendly application software, cost-effective hardware and driver software that together perform the functions of traditional instruments. Simulated physical instruments are called virtual instruments (VIs). Virtual instrumentation software based on user requirements defines general-purpose measurement and control hardware functionality. With virtual instrumentation, engineers and scientists reduce development time, design higher quality products, and lower their design costs. In test, measurement and control, engineers have used virtual instrumentation to downsize automated test equipment (ATE) while experiencing up to a several times increase in productivity gains at a fraction of the cost of traditional instrument solutions.
Virtual instrumentation is necessary because it is flexible. It delivers instrumentation with the rapid adaptability required for today’s concept, product and process design, development and delivery. Only with virtual instrumentation, engineers and scientists can create the user-defined instruments required to keep up with the world’s demands. To meet the ever-increasing demand to innovate and deliver ideas and products faster, scientists and engineers are turning to advanced electronics, processors and software. Consider modern cell phones. Most of them contain the latest features of the last generation, including audio, a phone book and text messaging capabilities. New versions include a camera, MP3 player, and Bluetooth networking and Internet browsing.
Virtual instruments are defined by the user while traditional instruments have fixed vendor-defined functionality. In a conventional instrument, the set of components that comprise the instrument is fixed and permanently associated with each other. Nevertheless, there is some software that understands these associations. Thus the primary difference between a virtual instrument and a conventional instrument is merely that the associations within a virtual instrument are not fixed but rather managed by software.
Every virtual instrument consists of two parts—software and hardware. A virtual instrument typically has a sticker price comparable to and many times less than a similar traditional instrument for the current measurement task. However, the savings compound over time, because virtual instruments are much more flexible when changing measurement tasks. By not using vendor-defined, prepackaged software and hardware, engineers and scientists get maximum user-defined flexibility. A traditional instrument provides them with all software and measurement circuitry packaged into a product with a finite list of fixed-functionality using the instrument front panel. A virtual instrument provides all the software and hardware needed to accomplish the measurement or control task. In addition, with a virtual instrument, engineers and scientists can customize the acquisition, analysis, storage, sharing and presentation functionality using productive, powerful software.
Without the displays, knobs and switches of a conventional, external box-based instrumentation products, a virtual instrument uses a personal computer for all user interaction and control. In many common measurement applications, a data acquisition board or card, with a personal computer and software, can be used to create an instrument. In fact, a multiple-purpose virtual instrument can be made by using a single data acquisition board or card. The primary benefits of apply data acquisition technology to configure virtual instrumentation include costs, size, and flexibility and ease of programming. The cost to configure a virtual instrumentation-based system using a data acquisition board or cards can be as little as 25% of the cost of a conventional instrument.
Traditional instruments and software-based virtual instruments largely share the same architectural components, but radically different philosophies as shown in Figure 1.11. Conventional instruments as compared to a virtual instrumentation can be very large and cumbersome. They also require a lot of power, and often have excessive amounts of features that are rarely, if ever used. Most conventional instruments do not have any computational power as compared to a virtual instrument. Since the virtual instrument is part of a person computer configuration, the personal computer’s computational as well as controlling capability can be applied into a test configuration. Virtual instruments are compatible with traditional instruments almost without exception. Virtual instrumentation software typically provides libraries for interfacing with common ordinary instrument buses such as GPIB, serial or Ethernet.
Figure 1.11 Traditional instruments (left) and software based virtual instruments (right).
Except for the specialized components and circuitry found in traditional instruments, the general architecture of stand-alone instruments is very similar to that of a PC-based virtual instrument. Both require one or more microprocessors, communication ports (for example, serial and GPIB), and display capabilities, as well as data acquisition modules. What makes one different from the other is their flexibility and the fact that we can modify and adapt the instrument to our particular needs. A traditional instrument might contain an integrated circuit to perform a particular set of data processing functions; in a virtual instrument, these functions would be performed by software running on the PC processor. We can extend the set of functions easily, limited only by the power of the software used. By employing virtual instrumentation solutions, we can lower capital costs, system development costs, and system maintenance costs, while improving time to market and the quality of our own products.
There is a wide variety of hardware devices available which we can either plug into the computer or access through a network. These devices offer a wide range of data acquisition capabilities at a significantly lower cost than that of dedicated devices. As integrated circuit technology advances, and off-the-shelf components become cheaper and more powerful, so do the boards that use them. With these advances in technology, comes an increase in data acquisition rates, measurement accuracy, precision and better signal isolation. Depending on the particular application, the hardware we choose might include analog input or output, digital input or output, counters, timers, filters, simultaneous sampling, and waveform generation capabilities.
Virtual instrumentation has achieved mainstream adoption by providing a new model for building measurement and automation systems. Keys to its success include rapid PC advancement; explosive low-cost, high-performance data converter (semiconductor) development; and system design software emergence. These factors make virtual instrumentation systems accessible to a very broad base of users.
Virtual instruments take advantage of PC performance increase by analyzing measurements and solving new application challenges with each new-generation PC processor, hard drive, display and I/O bus. These rapid advancements combined with the general trend that technical and computer literacy starts early in school, contribute to successful computer-based virtual instrumentation adoption. The virtual instrumentation driver is the proliferation of high-performance, low-cost analog-to-digital (ADC) and digital-to-analog (DAC) converters. Applications such as wireless communication and high-definition video impact these technologies relentlessly. Virtual instrumentation hardware uses widely available semiconductors to deliver high-performance measurement front ends. Finally, system design software that provides an intuitive interface for designing custom instrumentation systems furthers virtual instrumentation. Various interface standards are used to connect external devices to the computer. PC is the dominant computer system in the world today. VI is supported on the PC under Windows, Linux, Macintosh, Sun, and HP operating systems. All VI platforms provide powerful Graphical User Interfaces (GUIs) for development and implementation of the solutions.
1.6 Hardware and Software in Virtual Instrumentation
1.6.1 Role of Hardware in Virtual Instrumentation
Input/Output plays a critical role in virtual instrumentation. To accelerate test, control and design, I/O hardware must be rapidly adaptable to new concepts and products. Virtual instrumentation delivers this capability in the form of modularity within scalable hardware platforms. Virtual instrumentation is software-based; if we can digitize it, we can measure it. Standard hardware platforms that house the I/O are important to I/O modularity. Laptops and desktop computers provide an excellent platform where virtual instrumentation can make the most of existing standards such as the USB, PCI, Ethernet, and PCMCIA buses.
1.6.2 Role of Software in Virtual Instrumentation
Software is the most important component of a virtual instrument. With the right software tool, engineers and scientists can efficiently create their own applications by designing and integrating the routines that a particular process requires. You can also create an appropriate user interface that best suits the purpose of the application and those who will interact with it. You can define how and when the application acquires data from the device, how it processes, manipulates and stores the data, and how the results are presented to the user. With powerful software, we can build intelligence and decision-making capabilities into the instrument so that it adapts when measured signals change inadvertently or when more or less processing power is required. An important advantage that software provides is modularity. When dealing with a large project, engineers and scientists generally approach the task by breaking it down into functional solvable units. These subtasks are more manageable and easier to test, given the reduced dependencies that might cause unexpected behaviour. We can design a virtual instrument to solve each of these subtasks, and then join them into a complete system to solve the larger task. The ease with which we can accomplish this division of tasks depends greatly on the underlying architecture of the software.
A virtual instrument is not limited or confined to a stand-alone PC. In fact, with recent developments in networking technologies and the Internet, it is more common for instruments to use the power of connectivity for the purpose of task sharing. Typical examples include supercomputers, distributed monitoring and control devices, as well as data or result visualization from multiple locations. Every virtual instrument is built upon flexible, powerful software by an innovative engineer or scientist applying domain expertise to customize the measurement and control application. The result is a user-defined instrument specific to the application needs. Virtual instrumentation software can be divided into several different layers like the application software, test and data management software, measurement and control services software as shown in Figure 1.12.
Figure 1.12 Layers of virtual instrumentation software.
Most people think immediately of the application software layer. This is the primary development environment for building an application. It includes software such as LabVIEW, LabWindows/CVI (ANSI C), Measurement Studio (Visual Studio programming languages), Signal Express and VI Logger. Above the application software layer is the test executive and data management software layer. This layer of software incorporates all of the functionality developed by the application layer and provides system-wide data management. Measurement and control services software is equivalent to the I/O driver software layer. It is one of the most crucial elements of rapid application development. This software connects the virtual instrumentation software and the hardware for measurement and control. It includes intuitive application programming interfaces, instrument drivers, configuration tools, I/O assistants and other software included with the purchase of hardware. This software offers optimized integration with both hardware and application development environments.
1.7 Virtual Instrumentation for Test, Control and Design
Virtual instrumentation has been widely adopted in test and measurement areas. It has gradually increased addressable applications through continuous innovation and hundreds of measurement hardware devices. The benefits that have accelerated test development are beginning to accelerate control and design.
1.7.1 Virtual Instrumentation for Test
Test has been a long-proven field for virtual instrumentation. As the pace of innovation has increased, so too has the pressure to get new, differentiated products to market quickly. Consumer expectations continue to increase; in electronics markets, for example, disparate function integration is required in a small space and at a low cost. All of these conditions drive new validation, verification and manufacturing test needs. A test platform that can keep pace with this innovation is not optional; it is essential. The platform must include rapid test development tools adaptable enough to be used throughout the product development flow. The need to get products to market quickly and manufacture them efficiently requires high-throughput test. To test the complex multifunctional products that consumers demand requires precise, synchronized measurement capabilities. And as companies incorporate innovations to differentiate their products, test systems must quickly adapt to test the new features.
Virtual instrumentation is an innovative solution to these challenges. It combines rapid development software and modular, flexible hardware to create user-defined test systems. Virtual instrumentation delivers as shown in Figure 1.13 user-defined instruments and customizable hardware for test systems:
- Intuitive software tools for rapid test development
- Fast, precise modular I/O based on innovative commercial technologies
- A PC-based platform with integrated synchronization for high accuracy and throughput
Figure 1.13 User-defined instruments and customizable hardware for test systems.
Engineers and scientists have always been able to use virtual instrumentation software to create highly integrated user-defined systems using modular I/O, but they can now extend custom configurability to the hardware itself. This degree of user-configurability and transparency will change the way engineers build test systems.
1.7.2 Virtual Instrumentation for Industrial I/O and Control
PCs and PLCs both play an important role in control and industrial applications. PCs bring greater software flexibility and capability, while PLCs deliver outstanding ruggedness and reliability. But as control needs become more complex, there is a recognized need to accelerate the capabilities while retaining the ruggedness and reliabilities. Independent industry experts have recognized the need for tools that can meet the increasing need for more complex, dynamic, adaptive and algorithm-based control. The Programmable Automation Controllers (PACs) provide multidomain functionality (logic, motion, drives and process) and the concept of PAC supports multiple I/O types. Logic, motion and other function integrations are a requirement for increasingly complex control approaches. PACs deliver PC software flexibility with PLC ruggedness and reliability. LabVIEW software and rugged, real-time, control hardware platforms are ideal for creating a PAC.
1.7.3 Virtual Instrumentation for Design
The same design engineers that use a wide variety of software design tools must use hardware to test prototypes. Commonly, there is no good interface between the design phase and testing/validation phase, which means that the design usually must go through a completion phase and enter a testing/validation phase. Issues discovered in the testing phase require a design-phase reiteration as shown in Figure 1.14. The simulation test plays a critical role in the design and manufacture of today’s electronic devices.
Figure 1.14 Simulation test plays a critical role in the design and manufacture.
In reality, the development process has two very distinct and separate stages—design and test—which are two individual entities. On the design side, Electronic Design Automation (EDA) tool vendors undergo tremendous pressure to interoperate from the increasing semiconductor design and manufacturing group complexity requirements. Engineers and scientists are demanding the capability to reuse designs from one tool in other tools as products go from schematic design to simulation to physical layout. Similarly, test system development is evolving towards a modular approach. The gap between these two worlds has traditionally been neglected, first noticeable in the new product prototype stage. Traditionally, this is the stage where the product designer uses benchtop instruments to sanity-check the physical prototypes against their design for correctness. The designer makes these measurements manually, probing circuits and looking at the signals on instruments for problems or performance limitations. As designs iterate through this build-measure-tweak-rebuild process, the designer needs the same measurements again. In addition, these measurements can be complex—requiring frequency, amplitude and temperature sweeps with data collected and analyzed throughout. Because these engineers focus on design tools, they are reluctant to invest in learning to automate their testing. Systems with intrinsic-integration properties are easily extensible and adapt to increasing product functionality. When new tests are required, engineers simply add new modules to the platform to make the measurements. Virtual instrumentation software flexibility and virtual instrumentation hardware modularity make virtual instruments a necessity to accelerate the development cycle.
1.8 Virtual Instrumentation in The Engineering Process
Virtual instruments provide significant advantages in every stage of the engineering process—from research and design to manufacturing test.
1.8.1 Research and Development
In research and design, engineers and scientists demand rapid development and prototyping capabilities. With virtual instruments, we can quickly develop a program, take measurements from an instrument to test a prototype and analyze results—all in a fraction of the time required to build tests with traditional instruments. When we need flexibility, a scalable open platform is essential, from the desktop to embedded systems to distributed networks. The demanding requirements of research and development (R&D) applications require seamless software and hardware integration. Whether we need to interface stand-alone instruments using GPIB or directly acquire signals into the computer with a data acquisition board and signal conditioning hardware, virtual instrumentation software makes integration simple. With virtual instruments, we also can automate a testing procedure, eliminating the possibility of human error and ensuring the consistency of the results by not introducing unknown or unexpected variables.
1.8.2 Development Test and Validation
With the flexibility and power of virtual instruments, one can easily build complex test procedures. For automated design verification testing, one can create test routines in virtual instrumentation software and integrate software such as National Instruments Test Stand, which offers powerful test management capabilities. One of the many advantages these tools offer across the organization is code reuse. We develop code in the design process and then plug these same programs into functional tools for validation, test or manufacturing.
1.8.3 Manufacturing Test
Decreasing test time and simplifying development of test procedures are primary goals in manufacturing test. Virtual instruments combined with powerful test management software deliver high performance. These tools meet rigorous throughput requirements with a high-speed, multithreaded engine for running multiple test sequences in parallel. TestStand easily manages test sequencing, execution and reporting based on routines written in virtual instrumentation software. TestStand integrates the creation of test code in virtual instrumentation software. TestStand also can reuse code created in research and development or design and validation. If we have manufacturing test applications, we can take full advantage of the work already done in the product life cycle.
Manufacturing applications require software to be reliable, high in performance and interoperable. Virtual instruments offer all these advantages by integrating features such as alarm management, historical data trending, security, networking, industrial I/O and enterprise connectivity. With this functionality, we can easily connect to many types of industrial devices such as PLCs, industrial networks, distributed I/O and plug-in data acquisition boards. By sharing code across the enterprise, manufacturing can use the same applications developed in research and development or validation, and integrate seamlessly with manufacturing test processes.
1.9 Virtual Instruments beyond Personal Computer
Recently, commercial PC technologies have begun migrating into embedded systems. Examples include Windows CE, Intel x86-based processors, PCI and Compact PCI buses and Ethernet for embedded development. Virtual instrumentation relies on commercial technologies for cost and performance advantages; it has also expanded to encompass more embedded and real-time capabilities. LabVIEW runs on Linux as well as the embedded ETS real-time operating system from VenturCom on specific embedded targets. The option of using virtual instrumentation as a scalable framework that extends from the desktop to embedded devices should be considered a tool in the complete toolbox of an embedded systems developer. Ethernet now dominates as the standard network infrastructure for companies worldwide. In addition, the popularity of the Web interface in the PC world has overflowed into the development of cell phones, PDAs, and now industrial data acquisition and control systems. Embedded systems at one time meant stand-alone operation, or at most interfacing at a low level with a real-time bus to peripheral components. The increased demand for information at all levels of the enterprise (and in consumer products) requires you to network embedded systems while continuing to guarantee reliable and often real-time operation.
Virtual instrumentation software can combine one development environment for both desktop and real-time systems using cross-platform compiled technology; you can capitalize on the built-in Web servers and easy-to-use networking functionality of desktop software and target it to real-time and embedded systems. For example, you can use LabVIEW to simply configure a built-in Web server to export an application interface to defined secure machines on the network on Windows, and then download that application to run on a headless embedded system that can fit in the user’s hand. This procedure happens with no additional programming required on the embedded system. You then can deploy that embedded system, power it, connect to the application from a remote secure machine via Ethernet, and interface to it using a standard Web browser. For more sophisticated networking applications, you can graphically program TCP/IP or other methods with which you are already familiar in LabVIEW and then run them in the embedded system.
Embedded systems development is one of the fastest growing segments of engineering, and will continue to be for the foreseeable future as consumers demand smarter cars, appliances, homes, and so on. The evolution of these commercial technologies will propel virtual instrumentation into being more applicable to a growing number of applications. Leading companies that provide virtual instrumentation software and hardware tools need to invest in expertise and product development to serve this growing set of applications. Virtual instrumentation software platform, LabVIEW, includes the ability to scale from development for desktop operating systems, to embedded real-time systems to handheld personal digital assistant targets, to FPGA-based hardware, and even to enabling smart sensors.
Next-generation virtual instrumentation tools need to include networking technology for quick and easy integration of Bluetooth, wireless Ethernet and other standards. In addition to using these technologies, virtual instrumentation software needs a better way to describe and design timing and synchronization relationships between distributed systems in an intuitive way to help faster development and control of these often embedded systems. The virtual instrumentation concepts of integrated software and hardware, flexible modular tools, and the use of commercial technologies combine to create a framework upon which we can rapidly complete our systems development and also maintain them for the long term. Because virtual instrumentation offers so many options and capabilities in embedded development, it makes sense for embedded developers to understand and review these tools.
1.10 Graphical System Design Using LabVIEW
The development of VI is linked to the evolution of small inexpensive personal computers and progress in computer hardware and software. Graphical User Interfaces (GUIs) too played a vital role in the development of VI. While the original application of replacing the controls with a computer link used a command line interface, the use of sophisticated GUI became an essential component in the later versions of VI software. The major developments that helped VI become successful were development of low cost computer systems of adequate computing power, evolution of good GUI, development of standards for buses, and increasingly stable networking platforms. The computing power of the processors improved by leaps and bounds permitting the development of all these resource intensive techniques. Standardization and progress in computing hardware increased. Developments of various interfacing standards lead to a massive reduction in development effort. All these developments have occurred in parallel and have taken us to the situation where VI is the dominant tool for the development and implementation of instrumentation applications and systems.
The term “VI” owes a lot to the development of the Laboratory Virtual Instrument Engineering Workbench (LabVIEW) by National Instruments, Austin, Texas, USA. In 1983, National Instruments began to search for a way to minimize the time needed to program instrumentation systems. LabVIEW made its appearance as an interpreted package on the Apple Macintosh in 1986. LabVIEW 2 was released in 1990, and was a compiled package as against an interpreted package. The first reasonably stable graphical environment (Windows 3.0) made its appearance only in 1990.
In 1992, they introduced LabVIEW for Windows and LabVIEW for Sun based on the new portable architecture. LabVIEW 3 arrived in 1993 for Macintosh, Windows and Sun operating systems. LabVIEW 3 programs written on one platform could run on another. In 1999, LabVIEW became available for the Linux platform as well. LabVIEW 4, released in 1996, featured a more customizable development environment so that users could create their own workspace to match their industry, experience level and development habits. In addition, LabVIEW 4 added high-powered editing and debugging tools for advanced instrumentation systems, as well as OLE-based connectivity and distributed execution tools.
Networking support on smaller systems was first introduced in Version 5. LabVIEW 5 and 5.1 (in 1999) continued to improve on the development tool by introducing a built-in Web server, a dynamic programming and control framework (VI server), integration with ActiveX, and easy sharing of data over the Internet with a protocol called DataSocket. In 2000, LabVIEW 6 (sometimes called 6i) provided both an easy and intuitive programming interface. In 2001, LabVIEW 6.1 introduced event-oriented programming, remote Web control of LabVIEW.
Version 7 has expanded the horizon to make it simpler for the inexperienced user by providing various Express utilities and Assistants. LabVIEW has two closely related products—BridgeVIEW and LabVIEW RT (for realtime applications). BridgeVIEW can also be called LabVIEW industrial. The RT module of LabVIEW was originally designed to support distributed computing and real-time applications. LabVIEW RT is a hardware and software combination that allows you to take portions of your LabVIEW code and download them to be executed on a separate controller board with its own real-time operating system. In certain respects LabVIEW RT and the development of FPGA (Field Programmable Gate Array) support in LabVIEW overlap. It is possible to program FPGA modules to carry out many tasks which may be assigned to RT systems.
National Instruments released LabVIEW 8.5, the latest version of the graphical system design platform for test, control and embedded system development. LabVIEW 8.5 simplifies multicore as well as FPGA-based application development with its intuitive parallel dataflow language. NI LabVIEW 8.6 includes the platform installation DVDs, Block Diagram Cleanup, Quick Drop and Web services creation. In addition to these added tools to the LabVIEW development system, we can explore key new features in the LabVIEW modules and toolkits, including industrial function blocks in the LabVIEW Real-Time Module and new LabVIEW FPGA Module IP.
With the enhanced releases of LabVIEW graphical programming software, system-level engineers as well as domain experts with little to no embedded expertise can accurately work with systems of increased complexity and scale, thereby, drastically reducing the time from concept to prototype.
1.11 Graphical Programming and Textual Programming
Graphical programming is a visually-oriented approach to programming. Graphical programming is easier and more intuitive to use than traditional textual programming. Textual programming requires the programmers to be reasonably proficient in the programming language. Non-programmers can easily learn the graphical approach faster at less amount of time.
The main advantage of textual languages like C is that they tend to have faster graphical approach execution time and better performance than graphical programs. Textual programming environments are typically used in determining high throughput virtual instrumentation systems, such as manufacturing test systems.
Textual programming environments are popular and many engineers are trained to use these standardized tools. Graphical environments are better for nonprogrammers and useful for developing virtual instruments quickly and need to be reconfigured rapidly.
Virtual instrumentation is not limited to graphical programming but can be implemented using a conventional programming language. In R & D design characterization or in a troubling shooting situation Microsoft Excel (spreadsheet) or Microsoft Word (word processor) can be used. The most important task is to understand how to use standard analysis packages that can directly input data from the instruments and can be used to analyze, store and present the information in a useful format. Irrespective of whether it is classical or graphical environment any system with a graphical system design can be looked at as being composed of two parts—the user interface and the underlying code. The code in a conventional language like C comprises a number of routines while in the graphical language G it is a collection of icons interconnected by multi-colored lines. Table 1.1 compares text-based programming and graphical programming.
2. Introduction to LabVIEW
LabVIEW (Laboratory Virtual Instrument Engineering Workbench) is a graphical programming environment which has become prevalent throughout research labs, academia and industry. It is a powerful and versatile analysis and instrumentation software system for measurement and automation. Its graphical programming language called G programming is performed using a graphical block diagram that compiles into machine code and eliminates a lot of the syntactical details. LabVIEW offers more flexibility than standard laboratory instruments because it is software based. Using LabVIEW, the user can originate exactly the type of virtual instrument needed and programmers can easily view and modify data or control inputs. The popularity of the National Instruments LabVIEW graphical dataflow software for beginners and experienced programmers in so many different engineering applications and industries can be attributed to the software’s intuitive graphical programming language used for automating measurement and control systems.
LabVIEW programs are called virtual instruments (VIs), because their appearance and operation imitate physical instruments like oscilloscopes. LabVIEW is designed to facilitate data collection and analysis, as well as offers numerous display options. With data collection, analysis and display combined in a flexible programming environment, the desktop computer functions as a dedicated measurement device. LabVIEW contains a comprehensive set of VIs and functions for acquiring, analyzing, displaying, and storing data, as well as tools to help you troubleshoot your code.
All test, measurement and control applications can be divided into three main components and the key to virtual instrumentation is the ability to acquire, analyze and present data. LabVIEW can acquire data using the devices like GPIB, Serial, Ethernet, VXI, PXI Instruments, Data Acquisition (DAQ), PCI eXtensions for Instrumentation (PXI), Image Acquisition (IMAQ), Motion Control, Real-Time (RT) PXI, PLC (through OPC Server), PDA, and Modular Instruments. To help you analyze your data LabVIEW includes analysis functions for Differential Equations, Optimization, Curve Fitting, Calculus, Linear Algebra, Statistics and so on. Express VIs are specifically designed for measurement analysis, including filtering and spectral analysis. Signal Processing VIs for Filtering, Windowing, Transforms, Peak Detection, Harmonic Analysis, and Spectrum Analysis are provided. LabVIEW includes the following tools to help in presenting data on the computer; Graphs, Charts, Tables, Gauges, Meters, Tanks, 3D Controls, Picture Control, 3D Graphs and Report Generation. Over the Internet, Web Publishing Tools, Data socket (Windows Only), TCP/IP, VI Server, Remote Panels and Email are available to present data.
LabVIEW can communicate with hardware such as data acquisition, vision, and motion control devices, and GPIB, PXI, VXI, RS-232, and RS-485 devices. LabVIEW also has built-in features for connecting your application to the Web using the LabVIEW Web Server and software standards such as TCP/IP networking and ActiveX. Using LabVIEW, you can create test and measurement, data acquisitions, instrument control, datalogging, measurement analysis, and report generation applications. You also can create stand-alone executables and shared libraries, like DLLs, because LabVIEW is a true 32-bit compiler.
For new programmers, LabVIEW Express technology transforms common measurement and automation tasks into much higher-level, intuitive VIs. With Express technology, thousands of nonprogrammers have taken advantage of the LabVIEW platform to build automated systems quickly and easily. For experienced programmers, LabVIEW delivers the performance, flexibility and compatibility of a traditional programming language such as C or BASIC. In fact, the full-featured LabVIEW programming language has the same constructs that traditional languages have such as variables, data types, objects, looping and sequencing structures, as well as error handling. And with LabVIEW, programmers can reuse legacy code packaged as DLLs or shared libraries and integrate with other software using ActiveX, TCP and other standard technologies. The LabVIEW Family consists of NI LabVIEW Graphical Programming Software for Measurement and Automation, LabVIEW Real-Time Module, LabVIEW FPGA Module, LabVIEW PDA Module, LabVIEW Datalogging and Supervisory Control Module.
2.2 ADVANTAGES OF LabVIEW
The following are the advantages of LabVIEW:
- Graphical user interface: Design professionals use the drag-and-drop user interface library by interactively customizing the hundreds of built-in user objects on the controls palette.
- Drag-and-drop built-in functions: Thousands of built-in functions and IP including analysis and I/O, from the functions palette to create applications easily.
- Modular design and hierarchical design: Run modular LabVIEW VIs by themselves or as subVIs and easily scale and modularize programs depending on the application.
- Multiple high level development tools: Develop faster with application specific development tools, including the LabVIEW Statechart Module, LabVIEW Control Design and Simulation Module and LabVIEW FPGA Module.
- Professional Development Tools: Manage large, professional applications and tightly integrated project management tools; integrated graphical debugging tools; and standardized source code control integration.
- Multi platforms: The majority of computer systems use the Microsoft Windows operating system. LabVIEW works on other platforms like Mac OS, Sun Solaris and Linux. LabVIEW applications are portable across platforms.
- Reduces cost and preserves investment: A single computer equipped with LabVIEW is used for countless applications and purposes—it is a versatile product. Complete instrumentation libraries can be created for less than the cost of a single traditional, commercial instrument.
- Flexibility and scalability: Engineers and scientists have needs and requirements that can change rapidly. They also need to have maintainable, extensible solutions that can be used for a long time. By creating virtual instruments based on powerful development software such as LabVIEW, you inherently design an open framework that seamlessly integrates software and hardware. This ensures that your applications not only work well today but that you can easily integrate new technologies in the future.
- Connectivity and instrument control: LabVIEW has ready-to-use libraries for integrating stand-alone instruments, data acquisition devices, motion control and vision products, GPIB/IEEE 488 and serial/RS-232 devices, and PLCs to build a complete measurement and automation solution. Plug-and Play instrument drivers access the industry’s largest source of instrument drivers with several instruments from various vendors.
- Open environment: LabVIEW provides the tools required for most applications and is also an open development environment. This open language takes advantage of existing code; can easily intergrate with legacy systems and incorporate third party software with .NET, ActiveX, DLLs, objects, TCP, Web services and XML data formats.
- Distributed development: Can easily develop distributed applications with LabVIEW, even across different platforms. With powerful server technology you can offload processor-intensive routines to other machines for faster execution, or create remote monitoring and control applications.
- Visualization capabilities: LabVIEW includes a wide array of built-in visualization tools to present data on the user interface of the virtual instrument as chart, graphs, 2D and 3D visualization. Reconfiguring attributes of the data presentation, such as colours, font size, graph types, and more can be easily performed.
- Rapid development with express technology: Use configuration-based Express VIs and I/O assistants to rapidly create common measurement applications without programming by using LabVIEW signal Express.
- Compiled language for fast execution: LabVIEW is a compiled language that generates optimized code with execution speeds comparable to compiled C and developes high-performance code.
- Simple application distribution: Use the LabVIEW application builder to create executables(exes) and shared libraries (DLLs) for deployment.
- Target management: Easily manage multiple targets, from real-time to embedded devices including FPGAs, microprocessors, microcontrollers, PDAs and touch panels.
- Object–oriented design: Use object-oriented programming structures to take advantage of encapsulation and inheritance to create modular and extensible code.
- Algorithm design: Develop algorithms using math-oriented textual programming and interactively debug .m file script syntax with LabVIEW MathScript.
2.3 SOFTWARE ENVIRONMENT
There are three steps to create our application in the software environment:
- Design a user interface
- Draw our graphical code
- Run our program
A virtual instrument (VI) has three main components—the front panel, the block diagram and the icon/connector pane. In order to use a VI as a subVI in the block diagram of another VI, it is essential that it contains an icon and a connector. The two LabVIEW windows are the front panel (containing controls and indicators) and block diagram (containing terminals, connections and graphical code). The front panel is the user interface of the virtual instrument. The code is built using graphical representations of functions to control the front panel objects. The block diagram contains this graphical source code. In LabVIEW, you build a user interface or front panel with controls and indicators. Controls are knobs, push buttons, dials and other input devices. Indicators are graphs, LEDs and other displays. After you build the user interface, you can add code using VIs and structures to control the front panel objects. The block diagram contains this code. In some ways, the block diagram resembles a flowchart.
2.3.1 Front Panel Windows
When you open a new or existing VI, the front panel of the VI appears. The front panel is the interactive user interface for the VI. It is named a front panel because it stimulates the front panel of a physical instrument. Build the front panel with controls and indicators as shown in Figure 2.1.
One of the most powerful features that LabVIEW offers engineers and scientists is its graphical programming environment to design custom virtual instruments by creating a graphical user interface on the computer screen to
- Operate the instrumentation program
- Control selected hardware
- Analyze acquired data
- Display results
Figure 2.1 LabVIEW virtual instrument front panel.
The front panel can include knobs, push buttons, graphs and various other controls (which are user inputs) and indicators (which are program outputs). Controls are inputs used to simulate instrument input devices and supply data to the block diagram of the VI, and indicators are outputs displays used to simulate instrument output devices and display data the block diagram acquires or generates. The front panel is customized to emulate control panels of traditional instruments, create custom test panels, or visually represent the control and operation of processes.
2.3.2 Block Diagram Windows
The block diagrams accompany the program for the front panel. Front panel objects appear as terminals on the block diagram and the components wired together. After the front panel is built, codes are added using graphical representations of functions in the block diagram to control the front panel objects. The block diagram contains the graphical source code composed of nodes, terminals, and wires. The block diagram is the actual executable program as shown in Figure 2.2. The components of a block diagram are lower-level VIs, built-in functions, constants and program execution control structures. Wires have to be drawn to connect the corresponding objects together to indicate the flow of data between each of them. Front panel objects have analogous terminals on the block diagram so that data can pass easily from the user to the program and back to the user. Use Express VIs, standard VIs and functions on the block diagram to create our measurement code. Block diagram objects include the terminals, subVIs, functions, constants, structures and wires. LabVIEW is the easiest, most powerful tool for acquiring, analyzing and presenting real-world data. Terminals are entry and exit ports that exchange information between the panel and the diagram. Terminals are analogous to parameters and constants in text-based programming languages. Right-click the block diagram objects and select View As icon to change the icon view.
Figure 2.2 LabVIEW virtual instrument block diagram.
2.3.3 Icon/Connector Pane
To use a VI as a subVI, it must have an icon and a connector pane. Every VI displays an icon in the upper-right corner of the front panel and block diagram windows. An icon is a graphical representation of a VI. The icon can contain both text and images. To use a VI as a subVI, you need to build a connector pane. The connector pane is a set of terminals that correspond to the controls and indicators of that VI.
2.4 CREATING AND SAVING A VI
When you launch LabVIEW, the Getting Started window appears as shown in Figure 2.3. You can begin in LabVIEW by starting from a blank VI or project, opening an existing VI or project and modifying it, or opening a template from which to begin your new VI or project.
To open a new project from the Getting Started window, select the Empty Project option. A new, unnamed project opens, and you can add files to and save the project.
To open a new, blank VI that is not associated with a project, select the Blank VI option on the Getting Started window. A blank VI opens a blank front panel and blank block diagram.
To Create a VI or Project from a Template select File»New to display the New dialog box, which lists the built-in VI templates. You also can display the New dialog box by clicking the New link in the Getting Started window.
To open an existing VI select the Browse option in the Getting Started window to navigate to and open an existing VI.
The menus at the top of a VI window contain items common to other applications, such as Open, Save, Copy and Paste, and other items specific to LabVIEW. To save a new VI, select File»Save. If you have already saved your VI, select File»Save As to access the Save As dialog box to create a copy of the VI, or delete the original VI and replace it with the new one.
Figure 2.3 Getting Started window.
2.5 FRONT PANEL TOOLBAR
Table 2.1 provides the list of front panel toolbars buttons. Click the following toolbar buttons and pull-down menu to run and edit a VI.
2.6 BLOCK DIAGRAM TOOLBAR
Table 2.2 provides the details of the block diagram toolbar buttons. Click the following buttons on the block diagram toolbar to debug the VI.
LabVIEW has graphical, floating palettes help to create and run VIs. The three palettes are the Tools, Controls, and Functions palettes.
2.7.1 Tools Palette
The Tools palette shown in Figure 2.4 is available on both the front panel and the block diagram. You can create, modify, and debug VIs using the tools located on the floating Tools palette. A tool is a special operating mode of the mouse cursor. The cursor corresponds to the icon of the tool selected in the Tools palette. Use the tools to operate and modify the front panel and block diagram objects. You can manually choose the tool you need by selecting it on the Tools palette. Or select View»Tools Palette to display the Tools palette. Also you can press the <Shift> key and right-click to display a temporary version of the Tools palette at the location of the cursor. Table 2.3 provides the detailed function of each icon of the tools palette.
Figure 2.4 Tools palette.
2.7.2 Front Panel—Controls Palette
The Controls palette shown in Figure 2.5 is available only on the front panel. The Controls palette contains the controls and indicators which you can use to create the front panel. The Controls palette can be accessed from the front panel by selecting View»Controls Palette or by right-clicking an open space on the front panel window to display the Controls palette. The Controls palettes contain subpalettes of objects which you can use to create a VI. When you click a subpalette icon, the entire palette changes to the subpalette you selected. To use an object on the palettes, click the object and place it on the front panel.
Figure 2.5 Controls palette.
Table 2.4 lists the tools available in the toolbar of the Controls and Function palettes.
2.7.3 Block Diagram—Functions Palette
Use the Functions palette to create the block diagram. The Functions palette as shown in Figure 2.6 contains the sub VIs, functions, and constants that are available only on the block diagram. You can access the Functions palette from the block diagram by selecting View»Functions Palette. You can also right-click an open space on the block diagram to display the Functions palette. The VIs and functions located on the Functions palette depend on the palette view currently selected. The VIs and functions are located on subpalettes based on the types of VIs and functions.
Figure 2.6 Functions palette.
2.8 SHORTCUT MENUS
All LabVIEW objects have associated shortcut menus. To access the shortcut menu right-click the object and change the look or behavior of front panel and block diagram objects. The most often-used menu is the object shortcut menu. All LabVIEW objects and empty space on the front panel and block diagram have associated shortcut menus.
Use the shortcut menu items to change the look or behavior of front panel and block diagram objects. To access the shortcut menu, right-click the object, front panel or block diagram. To access the shortcut menu, right-click the object. Right-click the label as shown in Figure 2.7 to access its shortcut menu for front panel objects. Right-click the digital display to access its shortcut menu as shown in Figure 2.8. The shortcut menu for a meter is shown in Figure 2.9.
Figure 2.7 Label shortcut menu.
Figure 2.8 Display shortcut menu.
You can use the shortcut menu to create constants, controls and indicators. Right-click a function terminal and select Create»Constant, Create»Control, or Create»Indicator from the shortcut menu to create. To replace nodes, right-click the node and select Replace from the shortcut menu.
Figure 2.9 Meter shortcut menu.
2.9 PROPERTY DIALOG BOXES
Front panel objects also have property dialog boxes that you can use to change the look or behavior of front panel objects. Right-click the front panels object and select Properties from the shortcut menu to access the property dialog box for an object. Figure 2.10 shows the property dialog box for a meter. The options available on the property dialog box for an object are similar to the options available on the shortcut menu for that object.
Figure 2.10 Property dialog box for a meter.
2.10 FRONT PANEL CONTROLS AND INDICATORS
You can build the front panel with controls and indicators, which are the interactive input and output terminals of the VI, respectively. Controls are knobs, push buttons, dials and other input devices. Indicators are graphs, LEDs and other displays. Controls simulate instrument input devices and supply data to the block diagram of the VI. Indicators simulate instrument output devices and display data the block diagram acquires or generates.
Every control or indicator has a data type associated with it. They are numeric data type, Boolean data type and string data type as shown in Figure 2.11. The numeric data type shown in Figure 2.11(a) can be of various types such as integer or real. The two most commonly used numeric objects are the numeric control and the numeric indicator. The Boolean data type represents data that only has two parts, such as TRUE and FALSE or ON and OFF as in Figure 2.11(b). Use Boolean controls and indicators to enter and display Boolean (True or False) values. Boolean objects simulate switches, push buttons, and LEDs. Figure 2.11(c) shows the string data type which is a sequence of ASCII characters. Use string controls to receive text from the user such as a password or user name and indicators to display text to the user.
Figure 2.11 Numeric, Boolean and string data type.
To keep an object proportional to its original size as you resize it, press the <Shift> key while you drag the resizing handles or circles. To resize an object as you place it on the front panel, press the <Ctrl> key while you click to place the object and drag the resizing handles or circles.
2.11 BLOCK DIAGRAM
Block diagram objects include terminals, subVIs, functions, constants, structures and wires to transfer data among other block diagram objects.
Front panel objects appear as terminals on the block diagram. Figure 2.12 shows the front panel where two numeric values A and B need to be added and subtracted, and the block diagram for the corresponding front panel. Terminals are entry and exit ports that exchange information between the front panel and block diagram. Terminals are analogous to parameters and constants in text-based programming languages. Types of terminals include control or indicator terminals and node terminals. Control and indicator terminals belong to front panel controls and indicators. Data you enter into the front panel controls (A and B in the figure) enter the block diagram through the control terminals. The data then enter the Add and Subtract functions. When the Add and Subtract functions complete their calculations, they produce new data values. The data values flow to the indicator terminals, where they update the front panel indicators.
Figure 2.12 Front panel and its corresponding block diagram.
The terminals represent the data type of the control or indicator. You can configure front panel controls or indicators to appear as icon or data type terminals on the block diagram. By default, front panel objects appear as icon terminals. For example, a numeric icon terminal, shown in Figure 2.13, represents a numeric control on the front panel. A DBL terminal represents a double-precision, floating-point numeric control. To display a terminal as a data type on the block diagram, right-click the terminal and select View As Icon from the shortcut menu.
Figure 2.13 Default icon terminals can be viewed as data type terminal.
Nodes are objects on the block diagram that have inputs and/or outputs and perform operations when a VI runs. They are analogous to statements, operators, functions, and subroutines in text-based programming languages.Nodes can be functions, subVIs or structures. Structures are process control elements, such as Case structures, For loops, or While loops. The Add and Subtract functions in the previous figure are function nodes.
Functions are the fundamental operating elements of LabVIEW. Functions do not have front panels or block diagrams but do have connector panes. Double-clicking a function only selects the function. A function has a pale yellow background on its icon.
SubVIs are VIs that you build to use inside of another VI or that you access on the Functions palette. Any VI has the potential to be used as a subVI. When you double-click a subVI on the block diagram, its front panel and block diagram appear. The front panel includes controls and indicators. The block diagram includes wires, front panel icons, functions, possibly subVIs and other LabVIEW objects. The upper-right corner of the front panel and block diagram displays the icon for the VI. This is the icon that appears when you place the VI on a block diagram as a subVI. SubVIs also can be Express VIs. Express VIs are nodes that require minimal wiring because you configure them with dialog boxes. Use Express VIs for common measurement tasks. You can save the configuration of an Express VI as a subVI. Refer to the Express VIs topic of the LabVIEW Help for more information about creating a subVI from an Express VI configuration.
2.11.5 Express VIs and VIs
Express Vis are interactive VIs with configurable dialog page but Standard VIs are modularized VIs customized by wiring. LabVIEW uses colored icons to distinguish between Express VIs, VIs and functions on the block diagram. By default, icons for Express VIs appear on the block diagram as expandable nodes with icons surrounded by a blue field. Icons for VIs have white backgrounds, and icons for functions have pale yellow backgrounds. By default, most functions and VIs on the block diagram appear as icons that are not expandable, unlike Express VIs.
You can transfer data among block diagram objects through wires. Each wire has a single data source, but you can wire it to many VIs and functions that read the data. Wires are different colors, styles and thicknesses, depending on their data types as shown in Table 2.5. A broken wire appears as a dashed black line with a red X in the middle, as shown at left. Broken wires occur for a variety of reasons, such as when you try to wire two objects with incompatible data types. You must connect the wires to inputs and outputs that are compatible with the data that is transferred with the wire. You cannot wire an array output to a numeric input. In addition, the direction of the wires must be correct. You must connect the wires to only one input and at least one output. Also you cannot wire two indicators together. The components that determine wiring compatibility include the data type of the control and/or the indicator and the data type of the terminal. Press <Ctrl>-B to delete all broken wires or right-click and select Clean Up Wire to reroute the wire.
LabVIEW automatically wires objects as you place them on the block diagram. LabVIEW connects the terminals that best match and leave terminals that do not match unconnected. As you move a selected object close to other objects on the block diagram, LabVIEW draws temporary wires to show you valid connections. When you release the mouse button to place the object on the block diagram, LabVIEW automatically connects the wires. Toggle automatic wiring by pressing the spacebar while you move an object using the Positioning tool. You can adjust the automatic wiring settings by selecting Tools»Options and selecting Block Diagram from the top pull-down menu.
2.12 DATA TYPES
Data types indicate what objects, inputs and outputs you can wire together. For example, if a switch has a green border, you can wire a switch to any input with a green label on an Express VI. If a knob has an orange border, you can wire a knob to any input with an orange label. However, you cannot wire an orange knob to an input with a green label. Notice the wires are the same color as the terminal. The dynamic data type stores the information generated or acquired by an Express VI. The dynamic data type appears as a dark blue terminal. Most Express VIs accept and/or return the dynamic data type. You can wire the dynamic data type to any indicator or input that accepts numeric, waveform or Boolean data. Wire the dynamic data type to an indicator that can best present the data. Indicators include a graph, chart or numeric indicator.
2.13 DATA FLOW PROGRAM
LabVIEW follows a dataflow model for running VIs. A block diagram node executes when all its inputs are available. When a node completes execution, it supplies data to its output terminals and passes the output data to the next node in the dataflow path.
Visual Basic, C++, JAVA, and most other text-based programming languages follow a control flow model of program execution. In control flow, the sequential order of program elements determines the execution order of a program. For a data flow programming, consider a block diagram shown in Figure 2.14 that adds two numbers and then subtracts 50.00 from the result of the addition. In this case, the block diagram executes from left to right, not because the objects are placed in that order, but because the Subtract function cannot execute until the Add function finishes executing and passes the data to the Subtract function. A node executes only when data are available at all of its input terminals, and it supplies data to its output terminals only when it finishes execution.
Figure 2.14 Data flow program.
2.14 LabVIEW DOCUMENTATION RESOURSES
The programmer can use the Context Help window, the LabVIEW Help and the NI Example Finder to help build and edit VIs. The Context Help window displays basic information about LabVIEW objects when you move the cursor over each object. To toggle display of the Context Help window, select Help»Show Context Help, press <Ctrl-H> or click the Show Context Help Window button on the toolbar.
The LabVIEW Help contains detailed descriptions of most palettes, menus, tools, VIs and functions. It LabVIEW Help also includes step-by-step instructions for using LabVIEW features. Access LabVIEW Help by the following methods:
- Click the More Help button in the Context Help window
- Select Help»Search the LabVIEW Help
- Use the Click here for more help link in the Context Help window
- Right-click an object and select Help
The New dialog box contains many LabVIEW template VIs that you can use to start building VIs. However, these template VIs are only a subset of the hundreds of example VIs included with LabVIEW. You can modify any example VI to fit an application, or you can copy and paste from an example into a VI that you create. In addition to the example VIs that ship with LabVIEW, you also can access hundreds of example VIs on the NI Developer Zone at ni.com/zone. To search all examples using LabVIEW VIs, use the NI Example Finder. The NI Example Finder is the gateway to all installed examples and the examples located on the NI Developer Zone. To launch the NI Example Finder, select Help»Find Examples from the front panel or block diagram menu bar. You also can launch the NI Example Finder by clicking the arrow on the Open button on the LabVIEW dialog box and selecting Examples from the shortcut menu.
2.15 KEYBOARD SHORTCUTS