16
1 E LabVIEW 的基礎練習 一、目的 藉由簡單的練習對LabVIEW程式設計有初步的認識。 二、實驗操作 本實驗分成兩大部分:第壹部分是 LabVIEW 程式的簡單練習,共有 13 個實做練習。 第壹部分、LabVIEW 程式設計基礎篇 既然已經上過 LabVIEW 的第一堂課,相信同學們都對於 LabVIEW 的工作環境有一些基本的認識 了,那麼廢話不多說,就從實做例題開始練習吧! Tip1 … 鍵盤捷徑 Ctrl+N 建立一個新的 VI Ctrl+B 將程式方塊圖中所有壞線移除 Ctrl+R 執行目前的的 VI Ctrl+T 將人機介面與程式方塊圖左右並列 Ctrl+W 關閉目前的的 VI Ctrl+E 在人機介面/程式方塊圖之間切換 Ctrl+H 顯示隱藏 Help 視窗 Shift+滑鼠右鍵 呼叫工具面版 Tip2 … 圖釘 按右鍵可分別在人機介面及程式方塊圖上呼叫出控制面版(Control)與函數面版(Function) ,但若經常使 用到某個子面版,想將它固定在螢幕上,則可以在此面版左上角的圖釘上點一下使它立起,即可擁有 此固定的視窗,並可將它移動至你想要的位置,不想要時也可以關閉它。 Tip3 … 區域變數(Local Variable) 當一個變數必須同時出現在其他許多小程式時,就要用到分身變數。產生方法如下:

E LabVIEW 的基礎練習 - ezphysics.nchu.edu.twezphysics.nchu.edu.tw/.../LabVIEWpractice.pdf · 1 E LabVIEW 的基礎練習 一、目的 藉由簡單的練習對LabVIEW程式設計有初步的認識。

  • Upload
    hatuyen

  • View
    224

  • Download
    0

Embed Size (px)

Citation preview

  • 1

    LabVIEW

    LabVIEW

    LabVIEW 13

    LabVIEW

    LabVIEW LabVIEW

    Tip1

    Ctrl+N VI Ctrl+B

    Ctrl+R VI Ctrl+T

    Ctrl+W VI Ctrl+E /

    Ctrl+H Help Shift+

    Tip2

    (Control)(Function)

    Tip3 (LocalVariable)

  • 2

    (1) (2) (3)

    (Numeric)

    x y

    5+31

    =2x

    y

    Tip4

    LabVIEW

    Functions> Programming>Structures>Formula Node

    Add Input Add Output

    1+2+3+4= 23 xxxy

    (Boolean)

  • 3

    LED

    RoundLED RoundLED

    Functions>Programming>Boolean>NumberToBooleanArray

    LabVIEW (SequenceCaseForLoopWhileLoop)

    (0~9) Using (Case)

    (Case)

    0 (0,Default)

    0 ; 1 (1) 1

    0~9

  • 4

    (0~9) Using (ForLoop)

    N 0 99 10 8

  • 5

    10 8 8 0 15 15 10 5

    1 5 1

    Tip5

    (1).Wait(ms) Functions>AllFunctions>Wait(ms)

    VI ()

    (2).WaitUntilNextmsMultiple Functions>AllFunctions>WaitUntilNextmsMultiple

    LabVIEWVI

    Tip6

    For Loop While Loop

    millisecondtimervalue

    Wait(ms)

    millisecondstowait

    millisecondtimervalue

    Wait Until Next ms Multiple

    millisecondmultiple

  • 6

    Using (WhileLoop)+ (ShiftRegister)

    i 0 0+1=1 1 111 False

    1

    i=11+1=2 2 211 False

    2 1

    i=10 10+1=111111 True

    2 x

    02 12 22 02 12 22

    ( )

  • 7

    02 1 1 01 20+21 2 10 01 21+21 3 11

    012 20+20+21 4 100 012 21+20+21 5 101 012 20+21+21 6 110 012 21+21+21 7 111

    Loop 0

    2 x Functions > Mathematics > Elementary & Special Functions > Power of 2

    LED

    LED

    2 Functions>Programming>Numeric>Scale by Power of

    2( ex~ 027 = 7)

    Functions > Programming > Array > Build Array

    LED

    Add Dimension

  • 8

    LED I 123 111=7 027 10=2 022 i 1 02 12 i=11

    (WaveformChart) (WaveformGraph)

    (WaveformChart)

    X Y Y X

    Y

    X LabVIEW

  • 9

    Functions > Mathematics > > Elementary & Special Functions > Trigonometric > Sine

    Function>Programming>Waveform>Analog waveform>Waveform Measurements>Amplitude and Levels

    Function > Propramming>Waveform > Analog waveform > Waveform Min Max

    WaveformChart

  • 10

    LabVIEW For Loop

    51 i=50 100502 0=sin N=101 sine (

    )

    Bundle()

    Functions>Programming>Cluster,

    Class,& Variant> Bundle

    Bundle

    Tips for Chart

    >Data Operations> Clear Chart

    --

    >Properties>Appearance>()Show x scroll bar

    1024 Chart History

    Length 100,000

    >Chart History Length

    Y overlaid ;

    Y stacked

    >Overlay Plots / Stack Plots

  • 11

    (Graph)

    LabVIEW

    (Waveform graph)XY (XY graph)(Intensity Graph)

    XY

    (1) (WaveformGraph)

    For Loop

    Y X

    ( 0=0X ) X X 1( 1=X ) (X ) 0X X

  • 12

    1D 2D

    0X X Cluster 2D Cluster Array

    2D

    (Transpose)

    102 210

  • 13

    (2) XY (XYGraph)XY XY

    XY

    ()Functions>Mathematics>Elementary&Special Functions>Trigonometric>Sine&Cosine

    i=0 sin0=0cos0=1 ; i=25 5.0sin =1 5.0cos =0 ; i=50 sin =0 cos = -1 ; i=75 1-=5.1sin 0=5.1cos X Y

    i XY (0,1)(1,0)(0,-1)(-1,0) 101

    XY XY

  • 14

    I/O

    I/O LabVIEW

    Function>FileI/O FileI/O

    ;

    Write to spreadsheet. viRead from spreadsheet. vi

    VI /

    WriteToSpreadsheetFile

    WriteToSpreadsheetFile 2D 1D

    (Excel,WordPad,Origin)

    LabVIEW

    (row)(ex:Excel)(column)

    2D

    ReadFromSpreadsheetFile

    ReadFromSpreadsheetFile offset (row)

  • 15

    ( True)(

    True)

    A B A B

    Excel Origin

  • 16

    Transpose() Excel Origin

    1. LabVIEW

    2. LabVIEW

    3. LabVIEW

    4. http://www.phys.ncku.edu.tw/ultracold/paper/aroma.pdf5. http://intelligent.mech.yzu.edu.tw/course/experiment/experiment_handout/MEexperiment_2006.doc6. http://www.gauss.com.tw/logic/ch1/12.htm7. http://www.cinelformacao.com/labview/files/usb6008/usb6008intro.htm8. http://www.pt.ntu.edu.tw/hmchai/PTcomputer/hLabVIEW/LabVIEWindex.htm