Page 1
1
LabVIEW 7.1 寒假短期教學課程
歐陽丞修
2006/02/06
Page 2
寒假短期訓練課程Lab 303
2
LabVIEW 7.1
LabVIEW 簡介
LabVIEW (Laboratory Virtural Instrument Engineering Workbench )
虛擬儀表 (VI,Virtual Instrument) 量測、呈現與分析資料 G 語言 (Graphic Language)
Page 3
寒假短期訓練課程Lab 303
3
LabVIEW 7.1
虛擬儀表 (Virtual Instrument)• Virtual instrument has all main properties of the real one, being „only” computer program.
Page 4
寒假短期訓練課程Lab 303
4
LabVIEW 7.1
Virtual Instrumentation With LabVIEW
人機介
面程式方
塊
Page 5
寒假短期訓練課程Lab 303
5
LabVIEW 7.1
開啟 LabVIEW 開始 => 程式集 =>National Instrument LabVIEW 7.1
Page 6
寒假短期訓練課程Lab 303
6
LabVIEW 7.1
開啟新 VI
Page 7
寒假短期訓練課程Lab 303
7
LabVIEW 7.1
程式方塊圖
人機介面
Front Panel
Block Diagram
Page 8
寒假短期訓練課程Lab 303
8
LabVIEW 7.1
建立 VI 程式
工具面板
控制面板
狀態面板
Page 9
寒假短期訓練課程Lab 303
9
LabVIEW 7.1
Operating Tool
Positioning/Resizing Tool
Labeling Tool
Wiring Tool
Shortcut Menu Tool
• Floating Palette• Used to operate and modify
front panel and block diagram objects.
Scrolling Tool
Breakpoint Tool
Probe Tool
Color Copy Tool
Coloring Tool
工具面版
Automatic Selection Tool
Page 10
寒假短期訓練課程Lab 303
10
LabVIEW 7.1
Run Button
Continuous Run Button
Abort Execution
Pause/Continue Button
Text Settings
Align Objects
Distribute Objects
Reorder
Resize front panel objects
Execution Highlighting Button Step Into Button
Step Over Button
Step Out Button
Additional Buttons on the Diagram Toolbar
狀態面版
Page 11
寒假短期訓練課程Lab 303
11
LabVIEW 7.1
LabVIEW 介面 控制元 (Input) 與顯示元 (Output)
Front Panel
Page 12
寒假短期訓練課程Lab 303
12
LabVIEW 7.1
控制元接點 接線 節點 顯示元接點
Block Diagram
Page 13
寒假短期訓練課程Lab 303
13
LabVIEW 7.1
程式方塊之接線型式
Floating-point Number
橘色
Interger Number 藍色
Boolean 綠色
String 粉紅色
Page 14
寒假短期訓練課程Lab 303
14
LabVIEW 7.1
Wiring Tips – Block Diagram
Wiring “Hot Spot”
Clean Up Wiring
Use Automatic Wire Routing
Click To Select Wires
Page 15
寒假短期訓練課程Lab 303
15
LabVIEW 7.1
數值運算
Page 16
寒假短期訓練課程Lab 303
16
LabVIEW 7.1
布林運算
Page 17
寒假短期訓練課程Lab 303
17
LabVIEW 7.1
比較運算
Page 18
寒假短期訓練課程Lab 303
18
LabVIEW 7.1
簡易計算機練習
Page 19
寒假短期訓練課程Lab 303
19
LabVIEW 7.1
簡易計算機練習
Page 20
寒假短期訓練課程Lab 303
20
LabVIEW 7.1
建立子程式 (SubVIs)
A SubVI is a VI that can be used within another VI
Similar to a subroutine Advantages
Modular Easier to debug Don’t have to recreate code Require less memory
Page 21
寒假短期訓練課程Lab 303
21
LabVIEW 7.1
Steps to Create a SubVI
Create the Icon Create the Connector Assign Terminals Save the VI Insert the VI into a Top Level VI
Page 22
寒假短期訓練課程Lab 303
22
LabVIEW 7.1
建立子程式 (SubVI)
Page 23
寒假短期訓練課程Lab 303
23
LabVIEW 7.1
建立子程式 (SubVI)
Page 24
寒假短期訓練課程Lab 303
24
LabVIEW 7.1
呼叫子程式
Page 25
寒假短期訓練課程Lab 303
25
LabVIEW 7.1
呼叫子程式
若為常數有何好
處
SubVI 內容
Page 26
寒假短期訓練課程Lab 303
26
LabVIEW 7.1
呼叫子程式
Page 27
寒假短期訓練課程Lab 303
27
LabVIEW 7.1
架構 - 迴圈控制
Page 28
寒假短期訓練課程Lab 303
28
LabVIEW 7.1
迴圈種類 C語言 for (i=0;i<10;i++)
{
…
}
i=0; while (i<10) { … i++; }
For Loop While Loop
i=0; do { … i++; } while (i<10)
Do … While Loop
Page 29
寒假短期訓練課程Lab 303
29
LabVIEW 7.1
For Loop
次數 (N)
目前執行完畢的迴圈數
Page 30
寒假短期訓練課程Lab 303
30
LabVIEW 7.1
For Loop
(0~N-1)
for (i=0;i<10;i++) { … }
位移暫存器
Page 31
寒假短期訓練課程Lab 303
31
LabVIEW 7.1
位移暫存器
Page 32
寒假短期訓練課程Lab 303
32
LabVIEW 7.1
For Loop
結果有何差異 ??
Page 33
寒假短期訓練課程Lab 303
33
LabVIEW 7.1
While Loop
目前執行的迴圈次數 狀態接點
Page 34
寒假短期訓練課程Lab 303
34
LabVIEW 7.1
While Loopi=0; while (i<10) { … i++; }
i=-1; do { … i++; } while (i<10)
Page 35
寒假短期訓練課程Lab 303
35
LabVIEW 7.1
While Loop
錯誤 !! 正確 !!
Page 36
寒假短期訓練課程Lab 303
36
LabVIEW 7.1
While Loop
等效
Page 37
寒假短期訓練課程Lab 303
37
LabVIEW 7.1
圖形函式
Page 38
寒假短期訓練課程Lab 303
38
LabVIEW 7.1
For Loop & While Loop 練習
Page 39
寒假短期訓練課程Lab 303
39
LabVIEW 7.1
For Loop & While Loop 練習
Page 40
寒假短期訓練課程Lab 303
40
LabVIEW 7.1
模擬雜訊
Page 41
寒假短期訓練課程Lab 303
41
LabVIEW 7.1
模擬雜訊
Page 42
寒假短期訓練課程Lab 303
42
LabVIEW 7.1
Case structure
Page 43
寒假短期訓練課程Lab 303
43
LabVIEW 7.1
Case structure
Page 44
寒假短期訓練課程Lab 303
44
LabVIEW 7.1
Case structure
if (Number >= 0) then Square Root Value= SQRT (Number)else Square Root Value = -99999 Display Error Messageend if
Page 45
寒假短期訓練課程Lab 303
45
LabVIEW 7.1
Case structure 應用
Page 46
寒假短期訓練課程Lab 303
46
LabVIEW 7.1
Case structure 應用
Page 47
寒假短期訓練課程Lab 303
47
LabVIEW 7.1
Formula Node
Page 48
寒假短期訓練課程Lab 303
48
LabVIEW 7.1
Formula Node
Page 49
寒假短期訓練課程Lab 303
49
LabVIEW 7.1
Formula Node
Page 50
寒假短期訓練課程Lab 303
50
LabVIEW 7.1
Sequence Structure
Stacked Sequence Structure Flat Sequence Structure
Page 51
寒假短期訓練課程Lab 303
51
LabVIEW 7.1
Stacked Sequence Structure
逐頁執行…
Page 52
寒假短期訓練課程Lab 303
52
LabVIEW 7.1
Stacked Sequence Structure
Page 53
寒假短期訓練課程Lab 303
53
LabVIEW 7.1
Flat Sequence Structure
由左而右逐頁執行…
Page 54
寒假短期訓練課程Lab 303
54
LabVIEW 7.1
Event Structure
Page 55
寒假短期訓練課程Lab 303
55
LabVIEW 7.1
Adding an ArrayFrom the Controls >> All Controls >> Array and
Cluster subpalette, select the Array Shell
Drop it on the screen.
Page 56
寒假短期訓練課程Lab 303
56
LabVIEW 7.1
Adding an Array (cont.)
Place data object into shell (i.e. Numeric Control)
Page 57
寒假短期訓練課程Lab 303
57
LabVIEW 7.1
Creating an Array with a Loop
Page 58
寒假短期訓練課程Lab 303
58
LabVIEW 7.1
Creating 2D Arrays
Page 59
寒假短期訓練課程Lab 303
59
LabVIEW 7.1
Creating an Array with a Loop
Page 60
寒假短期訓練課程Lab 303
60
LabVIEW 7.1
Formula Node
Page 61
寒假短期訓練課程Lab 303
61
LabVIEW 7.1
Thanks for your attention!
Page 62
寒假短期訓練課程Lab 303
62
LabVIEW 7.1
參考資訊 Example programs (Help» Find Examples…) LabVIEW Student Edition
(www.ni.com/labviewse) Web resources (ni.com)
NI Developer Zone (zone.ni.com)Application Notes Info-labview newsgroup (www.info-labview.org/) Instrument Driver Library (www.ni.com/idnet)