当前位置:文档之家› 音频信号发生器毕业设计论文 翻译 英文--

音频信号发生器毕业设计论文 翻译 英文--

本科毕业设计(论文)外文翻译原文Expanding the Features of a VIYou can choose one of many LabVIEW VI templates to use as a starting point. However, sometimes you need to build a VI for which a template is not available. This chapter teaches you how to build and customize a VI without using a template.Building a VI f rom a Blank TemplateIn the following exercises, you will open a blank VI and add Express VIs and structures to theblock diagram to build a new VI. You will build a VI that generates a signal, reduces the number of samples in the signal, and displays the resulting data in a table on the front panel. When you complete the exercises, the front panel of the VI will look similar to the front panel in Figure 3-1.You can complete the exercises in approximately 30 minutes.F i gure 3-1. Front Panel for the R educe Samples VIOpening a Blank VIIf no template is available for the task you want to create, you can start with a blank VI and add Express VIs to accomplish the specific task. Complete the following steps to open a blank VI.1.In the LabVIEW dialog box, click the arrow on the New button and select BlankVIfrom the shortcut menu or press the <Ctrl-N> keys to open a blank VI.Notice that a blank front panel and block diagram appear.Note You also can open a blank VI by selecting Blank VI from the Create new list in The New dialog box or by selecting File»New VI from the front panel or block diagram menu bar.2. If the Functions palette is not visible, right-click any blank space on the block diagramto bring up the temporary version of the Functions palette. Click the thumbtack,shown at left, in the upper left corner of the Functions palette toplace the palette on the screen.Note You can right-click on a blank space on the block diagram or the front panel to bring up the Functions or Controls palettes.Adding an Express VI that Simulates a SignalComplete the following steps to find the Express VI you want to use and then add it to the block diagram.1. If the Context Help window is not visible, press the <Ctrl-H> keys to open theContext Help window. You also can press the Show Context Help Window button, shown at left, to open the Context Help window.2. Select the Input palette on the Functions palette and move the cursor over the ExpressVIs on the Input palette.Notice that the Context Help window displays information about the function of each Express VI.3. From the information provided in the Context Help window, find theExpress VI thatcan output a sine wave signal.4. Select the Express VI and place it on the block diagram. The Configure SimulateSignal dialog box appears.5. Idle the cursor over the various options in the Configure Simulate Signal dialog box,such as Frequency (Hz), Amplitude, and Samples per second (Hz). Read the information that appears in the Context Help window.6. Configure the Simulate Signal Express VI to generate a sine wave with a frequency of10.7 a nd amplitude of 2.7. Notice how the signal displayed in the Result Preview window changes to reflect theconfigured sine wave.8. Close the Configure Simulate Signal dialog box.9. Move the cursor over the Simulate Signal Express VI and read the information thatappears in the Context Help window.Notice that the Context Help window nowdisplays the configuration of the Simulate Signal Express VI.10.Save this VI as Reduce Samples.vi t o an easily accessible location.Modifying the SignalComplete the following steps to use the LabVIEW Help to search for the Express VI that reduces the number of samples in a signal.1. Select Help»VI, Function, & How-To Help to open the LabVIEW Help.2. Click the Search tab and type sample compression in the Type in the word(s) tosearch for text box.Notice that this word choice reflects what you want this Express VI to do—compress, or reduce, the number of samples in a signal.3. Select the Sample Compression Express VI topic to display the topic that describesthe Sample Compression Express VI.4. After you read the description of the Express VI, click the Place on the block diagram button, shown at left, to select the Express VI.5. Move the cursor to the block diagram.Notice how LabVIEW attaches the Sample Compression Express VI to the cursor.6. Place the Sample Compression Express VI on the block diagram to the right of theSimulate Signal Express VI.7. Configure the Sample Compression Express VI to reduce the signal by a factor of 25using the mean of these values.8. Close the Configure Sample Compression dialog box.9. Using the Wiring tool, wire the Sine output in the Simulate Signal Express VI to theSignals input in the Sample Compression Express VI.Customizing the Front PanelIn the previous exercises, you added controls and indicators to the front panel using theControls palette. You also can add controls and indicators from the block diagram. Complete the following steps to create controls and indicators.1. Right-click the Mean output in the Sample Compression Express VI and select Create»Numeric Indicator to create a numeric indicator.2. Right-click the Mean output of the Sample Compression Express VI and select Insert Input/Output from the shortcut menu to insert the Enable input.3. Right-click the Enable input and select Create»Control to create the Enable switch.4. Right-click the wire linking the Sine output in the Simulate Signal Express VI to the Signals input in the Signal Compression Express VI and select Create»Graph Indicator.Notice that you can create controls and indicators from the block diagram. When you reate controls and indicators using this method, LabVIEW automatically creates terminals that are labeled and formatted correctly.5. Using the Wiring tool, wire the Mean output in the Sample Compression Express VI to the Sine terminal. Notice that the Merge Signals function appears.6. Arrange the objects on the block diagram so that they appear similar to Figure 3-2.Tip You can right-click any wire and select Clean Up Wire from the shortcut menu to have LabVIEW automatically arrange the wires for you.Figure 3-2. Block Diagram for the R educe Samples VI7. Display the front panel.Notice that the controls and indicators you added automatically appear on the front panel with labels that correspond to their function.8. Save this VI.Configuring the VI to Run Continuously Until the User Stops ItIn the current state, the VI runs once, generates one signal, then stops executing. To run the VI until a condition is met, you can add a While Loop to the block diagram. Complete the following steps to add a While Loop.1. Display the front panel and run the VI.Notice how the VI runs once and then stops. Also notice how there is no STOP button.2. Display the block diagram and select the While Loop on the Execution Control palette.3. Move the cursor to the upper left corner of the block diagram. Place the top left corner of the While Loop here.4. Click and drag the cursor diagonally to enclose all the Express VIs and wires, as shownin Figure3-3.Figure 3-3. Placing the While Loop a round the E xpress VIsNotice that the While Loop, shown at left, appears with a STOP button wired to the condition terminal. This While Loop is configured to stop when the user clicks the STOP button.5. Display the front panel and run the VI.Notice that the VI now runs until you click the STOP button. A WhileLoop executes the functions inside the loop until the user presses the STOP button.Controlling the Speed of ExecutionTo plot the points on the waveform graph more slowly, you can add a time delay to the block diagram. Complete the following steps to control the speed at which the VI executes.1. On the block diagram, select the Time Delay Express VI on the Execution Controlpalette and place it inside the loop.2. Type .250 i n the Time delay (seconds) text box.This time delay specifies how fast theloop runs. With a .250 second time delay, the loop iterates once every quarter of asecond.3. Close the Configure Time Delay dialog box.4. Save this VI.5. Display the front panel and run the VI.6. Click the Enable switch and notice the change on the graph.Notice how if the Enable switch is on, the graph displays the reduced signal. If the Enable switch is off, the graph does not display the reduced signal.7. Click the STOP button to stop the VI.Using a Table to Display DataComplete the following steps to display a collection of mean values in a table on the front panel.1. On the front panel, select the Express Table indicator on the Text Indicators paletteand place it on the front panel to the right of the waveform graph.2. Display the block diagram.Notice that the Table terminal appears wired to the Build Table Express VI automatically.3. If the Build Table Express VI and the Table terminal are not selected already, click anopen area on the block diagram to the left of the Build Table Express VI and the Table terminal. Drag the cursor diagonally until the selection rectangleencloses the Build Table Express VI and the Table terminal, shown atleft. A moving dashed outline called a marquee highlights the BuildTable Express VI, the Table terminal, and the wire joining the two.4. Drag the objects into the While Loop to the right of the Mean terminal.Notice that the While Loop automatically resizes to enclose the Build Table Express VI and the Table termial.5. Using the Wiring tool, wire the Mean terminal of the Sample Compression Express VIto the Signals input of the Build Table Express VI.The block diagram should appear similar to Figure 3-4.Figure 3-4. Block Diagram of the Reduce Samples VI6. Display the front panel and run the VI.7. Click the Enable switch.The table displays the mean values of every 25 samples of the sine wave. Notice if the Enable switch is off, the table does not record the mean values.8. Stop the VI.9. Experiment with properties of the table by using the Table Properties dialog box. Forexample, try changing the number of columns to one.10. Save and close this VI.SummaryThe following topics are a summary of the main concepts you learned in this chapter.Using the LabVIEW Help ResourcesYou can use the Context Help window and the LabVIEW Help to learn more about Express VIs. Both provide information that describe the functionality of the Express VI and how to configure the Express VI.The following is a summary of the different ways you learned to use the help resources in this chapter.• The Context Help window displays basic information about LabVIEW objects when you move the cursor over each object. Objects with context help information includeVIs, structures, palettes, and dialog box components.• When you place an Express VI on the block diagram, the Context Help window displays a brief description of the Express VI and information about how youconfigured the Express VI.• You can find and select an Express VI and other block diagram objects in the LabVIEW Help. Click the Place on the block diagram button to select a block diagram object and place it on the block diagram.• To navigate the LabVIEW Help, use the Contents, Index, and Search tabs. Use the Contents tab to get an overview of the topics and structure of the help. Use the Index tab to find a topic by keyword. Use the Search tab to search the help for a word or phrase.Customizing the Block Diagram CodeThere are many controls, indicators, Express VIs, and structures that you can use to customize a VI. To customize a VI, you can create controls and indicators, control when a VI stops running, and display generated data in a table.Creating Controls and IndicatorsCreate controls and indicators that are wired to Express VIs from the block diagram by right-clicking the Express VI input, output, or wire, and selecting an option from the Create shortcut menu.Controlling When a VI Stops RunningUse the While Loop to continually run the code enclosed within the loop. The While Loop stops running when a stop condition is met. When you place or move an object in a While Loop near the border, the loop automatically resizes to add space for that object. The Execution Control palette includes objects that let you control the number of times a VI runs, as well as the speed at which the VI runs.Displaying Data in a TableThe table indicator displays collected data. Use the Build Table Express VI to build a table of collected data.Acquiring Data and Communication with InstrumentsThis chapter introduces you to the Express VIs you use for data acquisition and instrument communication on a PC running Windows.Refer to the LabVIEW Measurements Manual for information about data acquisition and instrument communication on all platforms.Acquiring a SignalIn the following exercises, you will use the DAQ Assistant Express VI to create an NI-DAQmx task. Refer to the Taking an NI-DAQmx Measurement in LabVIEW help tutorial for information about additional methods you can use to create NI-DAQmx tasks. To launch this help tutorial, select Help»Taking an NI-DAQmx Measurement in LabVIEW.Note The following exercises require that you have installed NI-DAQmx and an NI-DAQmx-supported device. Refer to the National Instruments Web site at/daq for the list of NI-DAQmx-supported devices. If you do not have NI-DAQmx installed or an NI-DAQmx-supported device, refer to the LabVIEWMeasurements Manual for information about using Traditional NI-DAQ for dataacquisition.Complete the following exercises to create an NI-DAQmx task that continuously takes a voltage reading and plots the data on a waveform graph.You can complete the exercises in approximately 30 minutes.Creating an NI-DAQmx TaskIn NI-DAQmx, a task is a collection of one or more channels, timing, triggering, and other properties that apply to the task itself. Conceptually, a task represents ameasurement or generation you want to perform. For example, you can create a task to measure temperature from one or more channels on a DAQ device. Complete the following steps to create and configure a task that reads a voltage level from a DAQ device.1. Open a new VI.2. Select the DAQ Assistant Express VI, shown at left, on the Input palette and place it onthe block diagram. The DAQ Assistant launches and a Create New dialog boxappears.3. Click the Analog Input button to display the Analog Input options.4. Select Voltage to create a new voltage analog input task.The dialog box displays a listof channels on each DAQ device installed. The number of channels listed depends on the number of channels you have on the DAQ device.5. In the My Physical Channels listbox, select the physical channel to which the signal isconnected, such as ai0, and then click the Finish button. The DAQ Assistant opens a new window, shown in Figure 4-1, which displays options for configuring the channel you selected to complete a task.Figure 4-1.Configuring a Task Using the D AQ Assistant6. In the Input Range section of the Settings tab, enter 10 f or the Max value and enter -10 f or the Min value.7. In the Task Timing tab, select the Acquire N Samples option.8. Enter a value of 1000 i n the Samples To Read input box.Testing the TaskYou can test the task to verify that you correctly configured the channel. Complete the following steps to confirm that you are acquiring data.1. Click the Test button, shown at left. An Analog Input Test Panel dialog box appears.2. Click the Start button once or twice to confirm that you are acquiring data, and thenclick the OK button to return to the DAQ Assistant.3. Click the OK button to return to the block diagram.4. Save this VI as Read Voltage.vi t o an easily accessible location.Graphing Data from a DAQ DeviceUsing the task you created in the previous exercise, you can graph the data acquired from a DAQ device. Complete the following steps to plot the data from the channel in a waveform graph and change the name of the signal.1. On the block diagram, right-click the data output and select Create» Graph Indicator.2. Display the front panel.3. Run the VI three or four times and observe the waveform graph.Notice that Voltage a ppears in the waveform graph plot legend.4. Display the block diagram.5. Right-click the DAQ Assistant Express VI and select Properties to rename thechannel.6. Right-click Voltage in the Channel List listbox and select Rename to display the Rename a channel or channels dialog box.Tip You also can select the name of the channel and press the <F2> key to access the Rename a channel or channels dialog box.7. In the New Name text box, enter First Voltage Reading, and click the OK button.8. Click the OK button to apply this configuration and return to the block diagram.9. Display the front panel and run the VI.Notice that First Voltage Reading appears in the waveform graph plot legend.10. Save this VI.Editing an NI-DAQmx TaskYou can add a channel to the task so that you can compare two separate voltage readings. You also can customize the task to acquire the voltage readings continuously. Complete the following steps to add a new channel to the task and acquire data continuously.1. Display the block diagram and double-click the DAQ Assistant Express VI to add anew channel.2. Click the Add Step button, shown at left, to open the Add Channels To Task dialogbox.3. Select any unused physical channel in the My Physical Channels listbox.4. Click the OK button to return to the DAQ Assistant.5. Rename the channel Second Voltage Reading.6. In the Task Timing tab, select the Acquire Continuously option.When you set timingand triggering options in the DAQ Assistant, these options apply to all the channels in the Channel List.7. Click the OK button to apply this configuration and return to the block diagram.8. Place a While Loop around the DAQ Assistant Express VI and the graph indicator wired to the data output. The block diagram should appear similar to Figure 4-2.4-4Figure 4-2.Block Diagram for the Read Voltage VIVisually Comparing Two Voltage ReadingsBecause you have two voltage readings displayed on a graph, you can customize the plotsto distinguish between the two. Complete the following steps to customize the plot coloron the waveform graph.1. On the front panel, expand the plot legend to include two plots.2. Run the VI.Notice two plots now appear in the graph and the plot legend automatically updates to include both plot names.3.Right-click First Voltage Reading and select Color from the shortcut menu. Using theColor picker, select a color, such as yellow, so that the plot is easy to read. Change the plot color of Second Voltage Reading.4. Save this VI.Communicating with an InstrumentInstrument drivers simplify instrument control and reduce test program development timeby eliminating the need to learn the programming protocol for each instrument. Use an instrument driver for instrument control when possible. National Instruments provides instrument drivers for a wide variety of instruments. Visit the NI Instrument Driver Network at /idnet t o find a driver for your instrument.If a driver is not available for your instrument, you can use the Instrument I/O Assistant Express VI to communicate with your instrument. Complete the following exercises to communicate with an instrument.Selecting an InstrumentBefore communicating with an instrument, you must select the instrument with which you want to communicate. Complete the following steps to select an instrument using the Instrument I/O Assistant Express VI.1.Make sure you turn on the instrument you want to use. The instrument must bepowered on to use the Instrument I/O Assistant Express VI.2. Select the Instrument I/O Assistant Express VI on the Input palette and place it on theblock diagram.3. Click the Show Help button, shown at left, in the upper right corner of the InstrumentI/O Assistant dialog box.Notice how the Show Help button displays the help to the right of the dialogbox. The help window on top contains procedural information about usingthe Instrument I/O Assistant. The help window below provides context-sensitive help about various controls and indicators in the dialog box.4. Follow the procedures in the help window on top to select the instrument with whichyou want to communicate.5. If necessary, configure the properties of the instrument.6. Click the Hide Help button, shown at left, in the upper right corner of the InstrumentI/O Assistant dialog box to minimize the help window.Acquiring and Parsing Information for an InstrumentAfter selecting the instrument, you can send commands to the instrument to retrieve data. In this exercise, you will learn to use the Instrument I/O Assistant Express VI to acquire and parse identification information for an instrument. Complete the following steps to communicate with your instrument.1. Click the Add Step button, and select Query and Parse.2. Enter *IDN? i n the Enter a command text box.*IDN? i s a query that most instruments recognize. The response is an identificationnumber string that describes the instrument. If the instrument does not accept thiscommand, refer to the reference manual for the instrument for a list of commands the instrument does understand.3. Click the Run Sequence button.The Instrument I/O Assistant sends the command to the instrument, and the instrument returns its identification information.4. Parse the instrument name as an ASCII string. You also can use Instrument I/OAssistant to parse ASCII numbers and binary data.5. Click the Parsing help button, shown at left, in the Instrument I/O Assistant dialogbox for more information about parsing data.6. Assign a name to the token in the Token name text box.A token is a parsed data selection.7. Click the OK button to return to the block diagram.Notice that the name that you entered in the Token name text box is theoutput of the Instrument I/O Assistant Express VI, shown at left.SummaryThe following topics are a summary of the main concepts you learned in this chapter.DAQ Assistant Express VIYou can use the DAQ Assistant Express VI to graphically configure channels or common measurement tasks. Using the DAQ Assistant Express VI, you can interactively build a measurement channel or task.Place the DAQ Assistant Express VI on the block diagram to configure channels and tasks for use with NI-DAQmx for data acquisition.NI-DAQmx is a programming interface for communicating with data acquisition devices. You can use the DAQ Assistant Express VI to control devices supported in NI-DAQmx.Refer to the Taking an NI-DAQmx Measurement in LabVIEW help tutorial for information about the DAQ Assistant. To launch this help tutorial, select Help»Taking an NI-DAQmx Measurement in LabVIEW.Refer to the National Instruments Web site at /daq for information about devices supported in NI-DAQmx. If your device is not supported in NI-DAQmx, refer to the LabVIEW Measurements Manual for information on using Traditional NI-DAQ for data acquisition.TasksIn NI-DAQmx, a task is a collection of one or more channels, timing, triggering, and other properties that apply to the task itself. Conceptually, a task represents a measurement or generation you want to perform.For example, you can configure a collection of channels for analog input operations. After you create a task, you do not have to configure the channels individually to perform analoginput operations but instead access the single task. After you create a task, you can add or remove channels from that task.Refer to the Channels Versus Tasks section of Chapter 5, Creating a Typical Measurement Application, of the LabVIEW Measurements Manual for more information on channels and tasks.Instrument I/O Assistant E xpress V IAn instrument driver is a set of software routines that control a programmable instrument. Each routine corresponds to a programmatic operation such as configuring, reading from, writing to, and triggering the instrument. National Instruments offers thousands of instrument drivers online. Visit the NI Instrument Driver Network at /idnet t o find a driver for your instrument.If a driver is not available for your instrument, you can use the Instrument I/O Assistant Express VI to communicate with your instrument. You can use the Instrument I/O Assistant to communicate with a serial, Ethernet, or GPIB instrument and graphically parse the response. Start the Instrument I/O Assistant by placing the Instrument I/O Assistant Express VI on the block diagram or by double-clicking the Instrument I/O Assistant Express VI icon on the block diagram.Refer to the Instrument I/O Assistant Help for information about communicating with an external device.。

相关主题