Tutorial LabVIEW
23 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres
23 pages
English
Le téléchargement nécessite un accès à la bibliothèque YouScribe
Tout savoir sur nos offres

Description

Tutorial LabVIEW 1. Open and Run a VI Your objective is to open, run, and explore the components of a VI. Open the Temperature System Demo VI. • In the LabVIEW dialog box, click the Find Examples button to display the Find Examples dialog box. If you already opened a VI, select Help»Find Examples to display the Find Examples dialog box. • Click the Search tab and enter temperatures. • From the list of examples, double-click Temperature System Demo.vi to open the VI. You also can open the VI by selecting File»Open and navigating to labview\examples\apps\tempsys.llb\Temperature System Demo.vi. 1.1. Front Panel This VI simulates a temperature acquisition and analysis application. The VI compares the temperature value to a high and low value and displays the value on the chart, and plots a histogram of the data on another chart. • Run the VI by clicking the Run button in the toolbar. The button changes appearance to indicate that the VI is running. • Select Window»Show Tools Palette to display the Tools palette. • If the Automatic Tool Selection LED in the Tools palette is not lit, click the Automatic Tool Selection button to enable automatic tool selection. • Move the cursor over the slider in the System Controls section. LabVIEW selects the Operating tool. • Click and drag the slider to change the value. Notice the speed of the simulated acquisition changes as you change the value. • You operate LabVIEW controls just as you would similar ...

Informations

Publié par
Nombre de lectures 148
Langue English

Extrait

Tutorial LabVIEW  1. Open and Run a VI Your objective is to open, run, and explore the components of a VI. Open the Temperature System Demo VI. In the LabVIEW dialog box, click the Find Examples button to display the Find Examples dialog box. If you already opened a VI, select Help»Find Examples to display the Find Examples dialog box. Click the Search tab and enter temperatures. From the list of examples, double-click Temperature System Demo.vi to open the VI. You also can open the VI by selecting File»Open and navigating to labview\examples\apps\tempsys.llb\Temperature System Demo.vi. 1.1. Front Panel This VI simulates a temperature acquisition and analysis application. The VI compares the temperature value to a high and low value and displays the value on the chart, and plots a histogram of the data on another chart. Run the VI b clicking the Run button in the toolbar. The button changes appearance to indicate that the VI is running. Select Window»Show Tools Palette to display the Tools palette. If the Automatic Tool Selection LED in the Tools palette is not lit, click the Automatic Tool Selection button to enable automatic tool selection. Move the cursor over the slider in the System Controls section. LabVIEW selects the Operating tool. Click and drag the slider to change the value. Notice the speed of the simulated acquisition changes as you change the value. You operate LabVIEW controls just as you would similar real controls. Other ways to operate knob controls using the Operating tool include: Clicking the black region of the slider to move the slider to the value at the point you clicked. Clickin the digital display and entering a number. If you use this method, the Enter button appears on the toolbar. LabVIEW does not pass the value to the control until you click this button or press the <Enter> key. Click the Abort Execution button in the toolbar to stop the VI. 1.2. Block Diagram Display the block diagram for the Temperature System Demo VI by selecting Window»Show Diagram . This block diagram contains several basic elements of
 
1
LabVIEW programming, including structures, functions, and subVIs. You also can press the <Ctrl-E> keys to display the block diagram. Double-click the Temperature Status subVI icon to display the front panel of the subVI.  Click the Run Continuously button and adjust the value of the High Limit and Low Limit knobs. Notice the Temperature Status VI is a fully functional VI that performs basic comparisons between the Temperature and the High Limit and Low Limit values. When the temperature is greater than the High Limit, the Over Limit indicator turns red. When the temperature is less than the Low Limit, the Under Limit indicator turns blue. When you run the Temperature System Demo VI, it calls the Temperature Status subVI to perform this basic comparison. Click the Run Continuously button again to stop the VI from continuously running. Close the front panel for the Temperature Status VI by selecting File»Close . Do not close the Temperature System Demo VI, because you will use it in the next chapter.   2. Use the LabVIEW Help Utilities Your objective is to become familiar with the Context Help and the LabVIEW Help. If it is not already open from Chapter 1, open the Temperature System Demo VI by selecting File»Open and navigating to labview\examples\apps\tempsys.llb\Temperature System Demo.vi. 2.1. Context Help Display the block diagram by selecting Window»Show Diagram or by pressing the <Ctrl-E> keys. Display the Context Help window by selecting Help»Show Context Help or by pressing the <Ctrl-H> keys. The Context Help window displays information about the functions and wires as you move the cursor over each object. o Move the cursor over the Temperature Status VI icon. A description of the VI appears in the Context Help window. o Move the cursor over the terminals of the Temperature Status VI. LabVIEW selects the Wiring tool and the corresponding terminals blink in the Context Help window as the tool moves over them. o Move the cursor over a wire. The Context Help window displays the data type of the wire. 2.2. VI and Function Reference in the LabVIEW Help Move the cursor over the Initialize Array function, on the upper left of the block diagram. A blue link appears at the bottom of the Context Help window. This link displays the reference information for the Initialize Array function in the LabVIEW Help. The function reference information in the LabVIEW Help is more
 
2
detailed than the information in the Context Help window. Most VIs and functions that ship with LabVIEW have links in the Context Help window to detailed VI and function reference in the LabVIEW Help. Click the blue link at the bottom of the Context Help window to view the function reference information in the LabVIEW Help. 2.3. How To Instructions in LabVIEW Help In addition to VI and function reference information, the LabVIEW Help contains overview and procedural information about LabVIEW features. Select Help»VI, Function, and How-To Help to display the LabVIEW Help. When you are finished with this tutorial, use the Contents, Index, and Search tabs to browse the LabVIEW Help to learn more about LabVIEW. 2.4. Printed and PDF Documentation and Full Text Searches LabVIEW includes extensive documentation for new and experienced LabVIEW users. All LabVIEW manuals and Application Notes are also available as PDFs. You must have Adobe Acrobat Reader 4.0 or later installed to view the PDFs. Refer to the Adobe Systems Incorporated Web site to download Acrobat Reader. Refer to the NI Product Manuals Library for updated documentation resources. The LabVIEW Bookshelf is a powerful front end for all the printed and PDF documentation. You can search PDF versions of all the LabVIEW manuals and Application Notes. In LabVIEW, open the LabVIEW Bookshelf by selecting Help»Search the LabVIEW Bookshelf.  In the LabVIEW Bookshelf, click the Search to display a search dialog box. Enter temperature for your search string and click Search. Note the different results, separated by document. Double-click one of the documents to view the results. Click the Next Highlight button to go to the next highlighted instance of temperature.  Perform a more specific search. Click the Search button to perform a new search. Enter single-buffered analog output and click Search.  Double-click the document listed to view the results. When you are finished, close Acrobat Reader.  
 
3
3. Create a VI Your objective is to build a simple VI that converts a Celsius temperature reading to Fahrenheit. 3.1. Front Panel Open a new front panel by selecting File»New VI or by pressing <Ctrl-N> . If you closed all VIs, click the New VI button in the LabVIEW dialog box. Select Window»Show Controls Palette to display the Controls palette. You also can access a temporary Controls palette by right-clicking an open area of the front panel. Select a thermometer from the Controls»Numeric palette and place it on the front panel. Type deg C in the label text box and click the Enter button on the toolbar or click anywhere on the front panel to complete the new label. If the label is not highlighted, double-click the label to highlight the label and enter the text for the label. If you click outside the text box without entering text, the label defaults to thermometer. To show the label again, right-click the control and select Visible Items»Label from the shortcut menu. By default, a thermometer is an indicator because it displays a data value. In this VI, however, use the deg C thermometer as a control because it is the data source. Right-click the deg C thermometer and select Change to Control from the shortcut menu. To make it easier to precisely enter a value into the deg C thermometer, make the Digital Display visible. To do this, right-click the thermometer and select Visible Items»Digital Display from the shortcut menu. Now that you have a thermometer control for the Celsius temperature, you need an indicator to display the Fahrenheit value. Select another thermometer from the Controls»Numeric palette and place it on the front panel.  Label this thermometer deg F as you did in step 3 and make the Digital Display visible as you did in step 5. Because this thermometer will display temperatures in degrees Fahrenheit, change the scale of the thermometer so it can display readings higher than 100 degrees. To change the scale of the deg F thermometer, double-click the topmost value of the   scale and type 212, which is the Fahrenheit equivalent of 100 degrees Celsius, the highest visible value on the deg C thermometer.  Press the <Enter> key. (Optional) Use the Positioning tool to rearrange or resize objects. Move the cursor  over the center of an object to select the Positioning tool. o To move an object, click the object and release the mouse button to select the object. A moving dashed outline called a marquee highlights the object. Drag the object to move it.
 
4
  
 
o To resize an object, move the cursor over a corner of the object to display resizing handles . Move the Positioning tool over a resizing handle to change the tool to the resizing cursor. Use the resizing cursor to drag the resizing handles until the dashed border outlines the size you want, and release the mouse button. Your front panel should look similar to the following image.  
3.2. Block Diagram
 
Open the block diagram by selecting Window»Show Diagram , or by clicking the block diagram window behind the front panel window. You also can press <Ctrl-e> to switch between the front panel and block diagram windows. Notice the objects on the block diagram. These objects are terminals that correspond to the thermometer control and indicator you placed on the front panel. To convert a Celsius temperature value to Fahrenheit, multiply the Celsius value by 1.8 and add 32. Use the functions on the Functions»Numeric palette to build a block diagram that does this. Select Window»Show Functions Palette to show the Functions palette. You also can access a temporary Functions palette by right-clicking an open area of the block diagram. Select a Multiply function from the Functions»Numeric palette and drag it to the block diagram. Before you click the mouse button to drop the Multiply function on the block diagram, drag the function just to the right of the deg C terminal. Notice when you hold the function close to the terminal, LabVIEW automatically draws a wire to one of the terminals on the Multiply function. When LabVIEW draws a wire between the function and the deg C terminal, click the mouse button to place the function on the block diagram. Notice the deg C terminal is wired to the Multiply function. (Optional) If you placed the Multiply function without a wire connection to the deg C terminal, wire them together by completing the following steps.
5
 
 
o Move the cursor over the black arrow on the right side of the deg C terminal. The terminal blinks, and LabVIEW selects the Wiring tool. o Click the deg C terminal to tack a wire to the terminal. You do not need to hold down the mouse button. o Move the cursor to a terminal on the Multiply function until the terminal blinks. o Click to tack down the wire and wire the two terminals together. You need to multiply the deg C value by 1.8. Right-click the unwired input terminal on the Multiply function and select Create»Constant . LabVIEW creates a numeric constant value and wires it to the input terminal, with the numeric value highlighted for you to enter a value. Type 1.8 and click the Enter button, or click anywhere on the block diagram. You need to add 32 to complete the calculation. Select an Add function from the Functions»Numeric palette and drag it to the block diagram. Before you click the mouse to place the Add function on the block diagram, drag the function just to the right of the output terminal of the Multiply function. When a wire that connects the output terminal of the Multiply function and one of the input terminals of the Add function appears, click the mouse button to place the function on the block diagram. LabVIEW automatically wires the two functions together. If the functions are not wired together, use the Wiring tool as described in step 4. Right-click the unwired input terminal of the Add function and select Create»Constant , as you did in step 4. Type 32 and click the Enter button or click anywhere on the block diagram. Now that youve multiplied the deg C value by 1.8 and added 32, you need to pass the value to the deg F terminal. Wire the output terminal of the Add function to the deg F terminal, as described in step 4. Your block diagram is now complete, and should look similar to the following image.
 Select File»Save and save the VI as Convert C to F.vi in the labview\activity directory. 3.3. Running the VI On the front panel, double-click the digital display of the deg C thermometer and enter 37, which is normal body temperature in Celsius.
6
Run the VI by clicking on the Run button. Notice that LabVIEW converts the Celsius temperature to 98.6 degrees Fahrenheit and displays it on the deg F thermometer and its digital display. Enter other values in the deg C thermometer and run the VI. Close the VI by selecting File»Close to close the VI.  4. Document a VI Your objective is to document a VI that you have created. 4.1. Front Panel If it is not already open from Chapter 3, open the Convert C to F VI by selecting File»Open and navigating to labview\activity\solution\Convert C to F.vi. Select File»VI Properties and select Documentation from the pull-down menu to display the documentation properties of the VI. Type the description for the VI, as shown in the following illustration, and click the OK button.
 
 
 Right-click the deg C thermometer and select Description and Tip from the shortcut menu. Type the description and tip information for the control, as shown in the following illustration, and click the OK button.
7
 
 Right-click the deg F thermometer and select Description and Tip from the shortcut menu. Enter Displays the calculated Fahrenheit temperature for the description, and Fahrenheit temperature for the tip. Click the OK button. Move the cursor over the deg C thermometer. Notice the information you entered in  the “deg C” Tip field of the Description and Tip dialog box shows up as a tip strip. Select Help»Show Context Help to display the Context Help window. Move the cursor over the deg C thermometer and then over the deg F thermometer. Notice the information you entered in the Description and Tip dialog box appears in the Context Help window.  Move the cursor over the icon in the upper right corner of the block diagram or front panel window. The description you entered in the Documentation page of the VI Properties dialog box appears in the Context Help window. Save the VI.  5. Debug a VI Your objective is to use the probe tool and the probe window and to examine data flow in the block diagram using execution highlighting. 5.1. Probes If it is not already open from Chapter 4, open the Convert C to F VI by selecting File»Open  and navigating to labview\activity\solution\Convert C to F.vi. Block Diagram Select Window»Show Diagram . If the Tools palette is not open, select Window»Show Tools Palette .
 
8
Select the Probe tool from the Tools palette and click the wire coming out of the Multiply function. A Probe window appears with the title [1] Probe and a yellow glyph with the number of the probe appears on the wire, as shown in the following illustration. If automatic tool selection is enabled and you move the cursor over objects on the front panel or block diagram, LabVIEW automatically selects the corresponding tool from the Tools palette. However, you must manually select the Breakpoint, Probe, and Coloring tools.
 
 Front Panel Return to the front panel. Move the Probe window so you can view the probe value and both of the thermometer values. Run the VI. The value at the probe appears in the [1] Probe window.  Close the [1] Probe window by clicking the close box at the top of the Probe window title bar. 5.2. Execution Highlighting and Single-Stepping Another useful debugging technique is to examine the flow of data in the block diagram using the execution highlighting feature. Block Diagram On the block dia ram, begin execution highlighting by clicking the Highlight Execution button , in the toolbar. The Highlight Execution button changes to an illuminated light bulb . Click the Run button to run the VI. Notice that execution highlighting animates the VI block diagram execution. Moving dots represent the flow of data through the VI. Also notice that data values appear on the wires and display the values contained in the wires at that time, as shown in the following block diagram, just as if you had probed the wire.
  Begin single-stepping by clicking the Step Into button in the toolbar.
 
9
Click the Step Over button until the VI finishes executing. Finish executing the block diagram by clicking the Step Out button in the toolbar. Clicking this button completes all remaining steps in the block diagram.
 6. Search for Example VIs Your objective is to become familiar with the example VIs, which demonstrate the basic graphical programming elements in LabVIEW. LabVIEW includes hundreds of example VIs you can use and incorporate into your own VIs. You can modify an example to fit your application, or you can copy and paste from one or more examples into your own VI. In the LabVIEW dialog box, click the Find Examples button to display the Find Examples dialog box. If you already opened a VI, select Help»Find Examples to display the Find Examples dialog box. On the Browse tab, navigate to the Industry Applications»Analysis category. You also can search by keyword on the Search tab. Double-click Temperature System Demo to open this example VI. Click the Run button on the front panel toolbar to see how the VI runs. Click the sliders, knobs, and other controls to see how they affect the data. Stop the program by moving the Acquisition switch to the off position. Close the example and use the Find Examples dialog box to browse or search for other example VIs. 6.1. VI Templates In addition to the example VIs, LabVIEW includes several VI templates you can use to create common VIs, including state machines, custom dialog boxes and about boxes, and continuous analog input. Access the VI templates by selecting File»New and selecting Start from template.  7. Create a Multiplot Chart Your objective is to create a chart that can accommodate more than one plot. 7.1. Front Panel Open the Random Average VI by selecting File»Open and navigating to labview\activity\Random Average.vi. Select Window»Show Tools Palette to display the Tools palette. If the Automatic Tool Selection LED in the Tools palette is not lit, click the Automatic Tool Selection button to enable automatic tool selection. Modify the front panel as shown in the following illustration.
 
10
 
 
 o Use the Positioning tool to drag out the plot legend to include two plots. Move the Positioning tool over the corner of the legend to display resizing handles . Move the Positioning tool over a resizing handle to change the tool to the resizing cursor, which you drag out to enlarge the legend. o Rename Plot 1 to Random Average by double-clicking the label and entering the new text. You can resize the label area by using the Positioning tool to drag either of the left corners. o Change the plot style of the Current Value plot. Right-click the plot and select the plot style from the Common Plots shortcut menu. o Change the color of the Current Value plot. Right-click the plot and select the Color shortcut menu. Select a light blue color from the color picker that appears. 7.2. Block Diagram Show the block diagram by selecting Window»Show Diagram or pressing <Ctrl-e>.   Right-click the wire between the Divide function and the Random Plot terminal and select Insert from the shortcut menu. From the temporary Functions palette that appears, hold down the mouse button and select the Functions»Cluster»Bundle  function. Add an additional element to the Bundle function. o Move the cursor over the node to display the resizing circles at the top and bottom of the node. o Move the cursor over one of the circles to change the cursor to a resizing handle. o Drag the border of the node vertically or horizontally to add terminals to the node.
11
  • Univers Univers
  • Ebooks Ebooks
  • Livres audio Livres audio
  • Presse Presse
  • Podcasts Podcasts
  • BD BD
  • Documents Documents