【正文】
ng the Front Panel In the previous exercises, you added controls and indicators to the front panel using the Controls palette. You also can add controls and indicators from the block diagram. Complete the following steps to create controls and indicators. 4 1. Rightclick the Mean output in the Sample Compression Express VI and select Create187。Numeric Indicator to create a numeric indicator. 2. Rightclick the Mean output of the Sample Compression Express VI and select Insert Input/Output from the shortcut menu to insert the Enable input. 3. Rightclick the Enable input and select Create187。Control to create the Enable switch. 4. Rightclick the wire linking the Sine output in the Simulate Signal Express VI to the Signals input in the Signal Compression Express VI and select Create187。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 32. Tip You can rightclick any wire and select Clean Up Wire from the shortcut menu to have LabVIEW automatically arrange the wires for you. Figure 32. Block Diagram for the Reduce Samples VI 7. 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. 5 Configuring the VI to Run Continuously Until the User Stops It In 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 shown in Figure33. Figure 33. Placing the While Loop around the Express VIs Notice 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 While Loop executes the functions inside the loop until the user presses the STOP button. Controlling the Speed of Execution To 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 Control 6 palette and place it inside the loop. 2. Type .250 in the Time delay (seconds) text time delay specifies how fast the loop runs. With a .250 second time delay, the loop iterates once every quarter of a second. 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 Data Complete 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 palette and 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 an open 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 rectangle encloses the Build Table Express VI and the Table terminal, shown at left. A moving dashed outline called a marquee highlights the Build Table 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 VI to the Signals input of the Build Table Express VI. The block diagram should appear similar to Figure 34. 7 Figure 34. Block Diagram of the Re