【正文】
顯示前面板,運行 VI。 5. 利用連線工具,將 Sample Compression Express VI 的 Mean 輸出端連接到 Sine 控件終端。您也可以在程序框圖中添加控制件和顯示件。 4. 熟悉該 Express VI 的描述后,點擊在左邊 Place on the block diagram 按鈕,來選擇該 Express VI。注意,此時 Context Help 窗口內(nèi)顯示出 Simulate Signal Express VI的配置。 注意 , Context Help 窗口中顯示每個 Express VI 的功能的信息。 注意: 在 New 對話框的 Create new 列表內(nèi)單擊 Blank VI,或者從前面板或程序框圖的菜單欄中單擊 FileNew VI,都可以打開一個空 VI。 利用空模板創(chuàng)建新的 VI 在下面的練習(xí)中,你將要打開一個空的 VI,并在程序框圖中添加 Express VIs 和結(jié)構(gòu),來創(chuàng)建一個新的 VI 程序。 用 A4 紙 打印。 年月日等的填寫,用阿拉伯?dāng)?shù)字書寫 , 要符合 《關(guān)于出版物上數(shù)字用法的試行規(guī)定》 , 如“ 2020 年 2 月 26 日”。 大約需要 30 分鐘完成本練習(xí)。 11 注意:您可以在程序框圖或前面板的空白區(qū)右擊,來提取出 Functioins 選板或 Controls 選板。 5. 將光標(biāo)在 Configure Simulate Signal 對話框的各個選項上移動,例如 Frequency (Hz), Amplitude, 和 Samples per second (Hz),查看 Context Help 窗口內(nèi)顯示的信 息。 1. 單擊 HelpVI, Function, amp。 6. 在程序框圖內(nèi),把 Sample Compression Express VI 放置在 SimulateSignal Express VI 的右邊。 2. 右擊 Smaple Compression VI 的 Mean 輸出,從快捷菜單中單擊 Insert Input/Output,來插入 Enable 輸入端。 提示 您可以右擊任何連線,從快捷菜單中單擊 Clean Up Wire,使 LabVIEW 自動整理連線。 3. 移動光標(biāo)至程序框圖的左上角,在此放置 While Loop 邊框的左上角。完成下面的步驟,來控制 VI 的執(zhí)行速度。 6. 點擊 Enable 開關(guān),注意波形圖的變化。對角線拖拉光標(biāo),直到選擇矩形區(qū)包含 Build Table Express VI 和 Table 連線終端,如左圖所示。表格顯示正弦波每 25 個采樣點的平均值。 下面是在本章中您學(xué)到的利用幫助資源的不同方法的一個總結(jié)。使用 Index 標(biāo)簽可以由關(guān)鍵詞來查找一個主題。 Execution Control 選板包含的 對象可以讓你 控制 VI 程序運行的次數(shù)和速度。 注意:下面的練習(xí)要求已經(jīng)安裝了 NIDAQmx 和支持 NIDAQmx 的設(shè)備。按以下的步驟創(chuàng)建并設(shè)定一個從 DAQ 設(shè)備中讀取電壓值的 任務(wù)。 DAQ Assistant 會打開一個新窗口,如圖 41 所示,顯示了用于設(shè)定通道的選項。出現(xiàn)一個 Analog Input Test Panel對話 框。 3. 運行 VI 三至四次并觀察波形圖。 9. 顯示程序框圖并運行 VI。 3. 在 My Physical Channels 列表中選擇一個未使用的通道。 圖 42 Read Volage VI 的程序框圖 直觀的比較兩個電壓讀數(shù) 由于在曲線圖上有兩個電壓讀數(shù),可以定制圖表加以區(qū)別。 4. 保存這個 VI。使用 Instrumen I/O Assistant Express VI 按照如下的步驟選定儀器。 4. 按照幫助窗口中上方的流程選定需要通信的儀 器。儀器會回應(yīng)一個用于描述儀器的識別字符串。 7. 點擊 OK 鍵返回程序框圖。選擇 HelpTaking an NIDAQ Measurement in LabVIEW 啟動幫助指南。 在 LabVIEW Measurement Manual (測量手冊 )中獲得更多關(guān)于通道和 任務(wù)的信息,請參見第五章中的 Channels Versus Tasks 部分中的 Creating a Typical Measurement Application。 參見 Instrument I/O Assistant Help 獲取更多關(guān)于與外部設(shè)備進(jìn)行通信的信息。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