【正文】
on about the DAQ Assistant. To launch this help tutorial, select Help187。Taking an NIDAQmx Measurement in LabVIEW. Refer to the National Instruments Web site at supported in NIDAQmx. If your device is not supported in NIDAQmx, refer to the LabVIEW Measurements Manual for information on using Traditional NIDAQ for data acquisition. Tasks In NIDAQmx, 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 analog 1 input 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 Express VI An 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 driver for your instrument. If a driver is not available for your instrument, you can use the Instrument I/O Assistant Express VI to municate with your instrument. You can use the Instrume nt I/O Assistant to municate with a serial, Ether, 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 doubleclicking the Instrument I/O Assistant Express VI icon on the block diagram. Refer to the Instrument I/O Assistant Help for information about municating with an external device. 2 出 版 社: National Instruments 起 止 頁: 31— 47 出版 日期: 2021年 4月 擴展 VI 的特性 您可以選擇多個 LabVIEW VI模板中的一個來創(chuàng)建您的 VI。然而 ,在某些情況下模板并不適用于您需要創(chuàng)建的 VI程序。本章將教會您如何在不使用模板的情況下創(chuàng)建和定制一個 VI 程序。 利用空模板創(chuàng)建新的 VI 在下面的練習(xí)中,您將要打開一個空的 VI,并在程序框圖中添加 Express VIs 和結(jié)構(gòu),來創(chuàng)建一個新的 VI 程序。新的 VI 程序?qū)崿F(xiàn)產(chǎn)生信號、減少信號的采樣點,并在前面板的表格中顯示最終數(shù)據(jù)。當(dāng)您完成練習(xí)時, VI 程序的前面板如圖 31 所示。 大約需要 30 分鐘完成本練習(xí)。 圖 31 Reduce Samples VI 的前面板 打開一個空 VI 如果沒有模板適合您需要實現(xiàn)的任務(wù),您可以從一個新 VI 開始,添加 Express VIs 來實現(xiàn)指定的任務(wù)。完成下面的步驟來打開一個空 VI。 1. 在 LabVIEW 對話框,點擊 New 按鈕上的箭頭,從快捷菜單中單擊 Blank VI 或快捷鍵 CtrlN,來打開一個空 VI。 注意,一個空前面板和程序框圖也同時顯示。 3 注意 在 New 對話框的 Create new 列表內(nèi)單擊 Blank VI,或者從前面板或程序框圖的菜單欄中單擊 FileNew VI,都可以打開一個空 VI。 2. 如果 Functions 選板不可見,在程序框圖內(nèi)的任何空白區(qū)右擊,即會跳出 Functions 選板。點擊在 Functions 選板左上方的圖釘圖標(biāo),如左圖所示,則把該模板放置在屏幕上。 注意 您可以在程序框圖或前面板的空白區(qū)右擊,來提取出 Functioins 選板或 Controls 選板。 添加一個模擬信號的 Express VI 完成下面的步驟, 查找您想要使用的 Express VI,并將其添加到程序框圖中。 1. 如果 Context Help 窗口沒有出現(xiàn),可以按 CtrlH 鍵打開它。您也可以按 Show Context Help Window(如左圖所示),打開 Context Help 窗口。 2. 在 Functioins 選板中選擇 Input 選板,將光標(biāo)移至 Input 選板中的 Express VIs 上。 注意, Context Help 窗口中顯示每個 Express VI 的功能的信息。 3. 通過 Context Help 窗口提供的信息,找到可以輸出一個正弦波信號的 Express VI。 4. 選擇 Express VI 并將其放置到程序框圖內(nèi),出現(xiàn) Configure Simulate Signal 對話框。 5. 將光標(biāo)在 Configure Simulate Signal 對話框的各個選項上移動,例如 Frequency (Hz), Amplitude, 和 Samples per second (Hz),查看 Context Help 窗口內(nèi)顯示的信息。 6. 配置 Simulate Signal Express VI,以產(chǎn)生一個頻率為 、振幅為 2的正弦波。 7. 注意 Result Preview 窗口內(nèi)顯示的信號,自動改變來反映您配置的正弦波。 8. 關(guān)閉 Configure Simulate Signal 對話框。 9. 將光標(biāo)移動至 Simulate Signal Express VI,并讀取 Context Help窗口內(nèi)顯示的信息。注意,此時 Context Help 窗口內(nèi)顯示出 Simulate Signal Express VI的配置。 10. 保存此 VI 到容易找到的位置,命名為 Reduce 。 調(diào)整信號 完成下面的步驟,利用 LabVIEW Help,查找可以使信號采樣點減少的 Express VI。 1. 單擊 HelpVI, Function, amp。HowTo Help,打開 LabVIEW Help。 2. 點擊 Search 標(biāo)簽,在 Type in the word(s) to search for 文本框內(nèi)鍵入 sample pression。 4 注意,該單詞的選擇反映出您需要 Express VI 壓縮還是減少信號采樣點。 3. 選擇 Sample Compression Express VI 主題,來顯示描述該 Sample Compression Express VI 的信息。 4. 熟悉該 Express VI 的描述后,點擊在左邊 Place on the block diagram 按鈕,來選擇該 Express VI。 5. 移動光標(biāo)到程序框圖。 注意, LabVIEW 使 Sample Compression Express VI 跟隨著光標(biāo)移動。 6. 在程序框圖內(nèi),把 Sample Compression Express VI 放置在 SimulateSignal Express VI 的右邊。 7. 配置 Sample Compression Express VI,指定平均因子為 25,來減少信號的樣本點數(shù)。 8. 關(guān)閉 Configure Sample Compression 對話框。 9. 利用連線工具,將 Simulate Signal Express VI 的 Sine 輸出端連接到 Sample Compression Express VI 的 Signals 輸入端。 定制前面板 在前面的練習(xí)中,利用 Controls 選板,在前面板中添加控制件和顯示。您也可以在程序框圖中添加控制件和顯示件。完成下面的步驟在程序框圖中創(chuàng)建控制件和顯示件。 1. 右擊 Smaple Compression VI 的 Mean 輸出,單擊 CreateNumeric Indicator 來創(chuàng)建一個數(shù)字顯示件。 2. 右擊 Smaple Compression VI 的 Mean 輸出,從快捷菜單中單擊 Insert Input/Output,來插入 Enable 輸入端。 3. 右擊 Enable 輸入端,單擊 CreateControl 來創(chuàng)建 Enable 開關(guān)控件。 4. 右擊 Simulate Signal Express VI 的 Sine 輸出和 Signal Compression Express VI 的 Signals 輸入之間的連線,單擊 CreateGraph Indicator。 注意,您可以從程序框圖中創(chuàng)建控制件和顯示件。利用這種方法創(chuàng)建控制件和顯示件, LabVIEW 自動創(chuàng)建正確標(biāo)注和格式化的連線終端。 5. 利用連線工具,將 Sample Compression Express VI 的 Mean 輸出端連接到 Sine 控件終端。 注意,合并信號函數(shù) (Merge Signal Function)出現(xiàn)。 6. 排列程序框圖中的對象,如圖 32 所示。 提示 您可以右擊任何連線,從快捷菜單中單擊 Clean Up Wire,使 LabVIEW 自動整理連線。 5 圖 32 Reduce Samples VI 的程序框圖 7. 顯示前面板。 注意,您添加的控制件和顯示件自動在前面板上顯示,且有與它們的功能對應(yīng)的標(biāo)注。 8. 保存此 VI 程序。 設(shè)定 VI 連續(xù)運 行至用戶停止 在目前狀態(tài)下,此 VI 一旦運行,產(chǎn)生一個信號就停止運行。為了在某條件滿足前 VI 可一直運行,可在程序框圖中加入 While 循環(huán) (While Loop)。 1. 顯示前面板,運行 VI。 注意 VI 運行后就停止,且沒有 STOP 按鈕。 2. 顯示程序框圖,在 Execution Control 選板中選擇 While Loop。 3. 移動光標(biāo)至程序框圖的左上角,在此放置 While Loop 邊框的左上角。 4. 點擊并對角拖拉,使之包括所有的 Express VIs 和連線,如圖 33 所示。 圖 33 放置環(huán)繞