- 1 What Exactly Is LabVIEW, and What Can It Do for Me?
- 2 Demonstration Examples
- 3 Wrap It Up!
- 4 Additional Activities
1.2 Demonstration Examples
Okay, you have enough reading for now. To get an idea of how LabVIEW works, you can open and run a few existing LabVIEW programs.
Whether you are using the full or evaluation version of LabVIEW, just launch it. Make sure you can access the Everyone directory from the CD or your hard drive, as described in the Preface; it contains the activities for this book. After launching LabVIEW, a dialog box will appear. To open an example, select Open VI and choose the one you want.
Throughout this book, use the left mouse button (if you have more than one) unless we specifically tell you to use the right one. On MacOS computers, <command>-click when right-mouse functionality is necessary. In most LabVIEW situations, the <control> key on Windows will correspond to <command> on Macs, <meta> on Suns, and <alt> on Linus and HP machines.
1.2.1 Activity 1-1: Temperature System Demo
Open and run the VI called Temperature System Demo.vi by following these steps:
Launch LabVIEW if you haven't already.
Select Open from the File menu, or click the Open VI button if you have the LabVIEW start-up dialog box.
Next, open the Everyone directory or folder by double-clicking on it. Then select the libary CH1.LLB (Note: A library in LabVIEW, noted with the .llb extension, is a virtual directory of VI files. You can only see what's inside a library from LabVIEWto the operating system, it looks like a single file). Finally, open Temperature System Demo.vi. (If you have the full version of LabVIEW, you can also find this example under examples/apps/tempsys.llb). After a few moments, the Temperature System Demo front panel window appears, as shown in Figure 1.7. The front panel contains numeric controls, Boolean switches, slide controls, knob controls, charts, graphs, and a thermometer indicator.
Figure 1.7 Temperature System Demo test front panel window.
Run the VI by clicking on the Run button. The button changes appearance to indicate that the VI is running. The Toolbar, which is the row of icons on the top bar of the screen, also changes, since editing functionality won't be necessary while the VI is running.
Notice also that the Abort button becomes active in the Toolbar. You can press it to abort program execution.
Temperature System Demo.vi simulates a temperature monitoring application. The VI makes temperature measurements and displays them in the thermometer indicator and on the chart. Although the readings are simulated in this example, you can easily modify the program to measure real values. The Update Period slide controls how fast the VI acquires the new temperature readings. LabVIEW also plots high and low temperature limits on the chart; you can change these limits using the Temperature Range knobs. If the current temperature reading is out of the set range, LEDs light up next to the thermometer.
This VI continues to run until you click the Acquisition switch to off. You can also turn the data analysis on and off. The Statistics section shows you a running calculation of the mean and standard deviation, and the Histogram plots the frequency with which each temperature value occurs.
Use the cursor, which takes on the personality of the Operating tool while the VI is running, to change the values of the high and low limits. Highlight the old high or low value, either by clicking twice on the value you want to change, or by clicking and dragging across the value with the Operating tool. Then type in the new value and click on the enter button, located next to the run button on the Toolbar.
Change the Update Period slide control by placing the Operating tool on the slider, and then clicking and dragging it to a new location.
You can also operate slide controls using the Operating tool by clicking on a point on the slide to snap the slider to that location, by clicking on a scroll button to move the slider slowly toward the arrow, or by clicking in the slide's digital display and entering a number.
Even though the display changes, LabVIEW does not accept the new values in digital displays until you press the enter button, or click the mouse in an open area of the window.
Try adjusting the other controls in a similar manner.
Stop the VI by clicking on the Acquisition switch.
Examine the Block Diagram
The block diagram shown in Figure 1.8 represents a complete LabVIEW application. You don't need to understand all of these block diagram elements right nowwe'll deal with them later. Just get a feel for the nature of a block diagram. If you already do understand this diagram, you'll probably fly through the first part of this book!
Open the block diagram of Temperature System Demo.vi by choosing Show Diagram from the Windows menu.
Examine the different objects in the diagram window. Don't panic at the detail shown here! These structures are explained step by step later in this book.
- Open the contextual Help window by choosing Show Context Help from the Help menu. Position the cursor over different objects in the block diagram and watch the Help window change to show descriptions of the objects. If the object is a function or subVI, the Help window will describe the inputs and outputs as well.
LabVIEW's power lies in the hierarchical nature of its VIs. After you create a VI, you can use it as a subVI in the block diagram of a higher-level VI, and you can have as many layers of hierarchy as you need. To demonstrate this versatile ability, look at a subVI of Temperature System Demo.vi.
Open the Temperature Status subVI by double-clicking on its icon.
The front panel shown in Figure 1.9 springs to life.
Icon and Connector
The icon and connector provide the graphical representation and parameter definitions needed if you want to use a VI as a subroutine or function in the block diagrams of other VIs. They reside in the upper-right corner of the VI's front panel window. The icon graphically represents the VI in the block diagram of other VIs, while the connector terminals are where you must wire the inputs and outputs. These terminals are analogous to parameters of a subroutine or function. You need one terminal for each front panel control and indicator through which you want to pass data to the VI. The icon sits on top of the connector pattern until you choose to view the connector.
By using subVIs, you can make your block diagrams modular and more manageable. This modularity makes VIs easy to maintain, understand, and debug. In addition, you can often create one subVI to accomplish a function required by many different VIs.
Now run the top-level VI with both its window and the Temperature Status subVI window visible. Notice how the subVI values change as the main program calls it over and over.
Select Close from the File menu of the Temperature Status subVI. Do not save any changes.
Select Close from the File menu of Temperature System Demo.vi, and do not save any changes.
Selecting Close from the File menu of a VI diagram closes the block diagram window only. Selecting Close on a front panel window closes both the panel and the diagram.
1.2.2 Activity 1-2: Frequency Response Example
This example measures the frequency response of an unknown "black box." A function generator supplies a sinusoidal input to the black box. (Hint: It contains a bandpass filter, which lets only certain signal components through it.) A digital multimeter measures the output voltage of the black box. Although this VI uses subVIs to simulate a function generator and a digital multimeter, real instruments could easily be hooked up to a real black box to provide real-world data. You would then use subVIs to control data acquisition, GPIB transfers, or serial port communication to bring in or send out real data instead of simulating it.
You will open, run, and observe the VI in this activity.
Select Open from the File menu to open the VI, or click the Open VI button if you have the LabVIEW dialog box.
Select the EVERYONE directory and then CH1.LLB. Finally, double-click on Frequency Response.vi. (If you have the full version of LabVIEW, you can also find this example under examples/apps/_freqresp.llb.) The front panel shown in Figure 1.11 should appear.
Run the VI by clicking on the Run button. You can specify the amplitude of the input sine wave and the number of steps the VI uses to find the frequency response by changing the Amplitude control and the Number of Steps control, and then run the VI again. You can also specify the frequency sweep by inputting the upper and lower limits with the Low Frequency and High Frequency knobs. Play with these controls and observe the effect they have on the output of the "black box."
Open and examine the block diagram by choosing Show Diagram from the Window menu.
Close the VI by selecting Close from the File menu. These exercises should give you a basic feel for LabVIEW's programming environment. With LabVIEW, you'll find writing powerful applications (and debugging them) to be a snap! Read on to learn how!