Part 4
Part 4
Timing a VI
Reasons To Use Timing
Wait Functions and Express VIs
Timing a VI
Why do you need timing in a VI?
• To control the frequency at which a loop executes.
• To provide the processor with time to complete other tasks, such as
processing the user interface.
Wait Functions
A wait function inside a loop:
• Allows the VI to sleep for a set amount of time.
• Allows the processor to address other tasks during the
wait time.
• Uses the operating system millisecond clock.
Elapsed Time Express VI
• Determines how much time elapses after some point in
your VI.
• Keeps track of time while the VI continues to execute.
• Does not provide the processor with
time to complete other tasks.
Demo
1. Efek dari Wait (ms) dan Wait until Next ms Multiple
(ms)
2. Efek dari Elapsed Time Express VI
G. Data Feedback in Loops
Shift Registers
Initializing Shift Registers
Default for Unwired Values
Compound Shift Registers
Data Feedback in Loops
• When programming with loops, you often need to know
the values of data from previous iterations of the loop.
• Shift registers transfer values from one loop iteration to the
next.
Shift Registers
• Right-click the border and select Add Shift Register from
the shortcut menu.
• Right shift register stores data on completion of an
iteration.
• Left shift register provides stored data at beginning of the
next iteration.
Initializing Shift Registers
Run once VI finishes Run again
Not
Initialized Output = 4 Output = 8
Shift
Register
Use Default if Unwired
Default values vary by data type:
Data Type Default Value
Numeric 0
Boolean FALSE
String Empty
Selector Terminal
Case Structures
Selector terminal data
types:
• Boolean
• True case and False
Case
• Error Cluster
• Error Case and No Error
Case
• Integer, string, or enum
• Structure can have any
number of cases.
• Include a Default
diagram to avoid listing
every possible input
value.
Enum Case Structure
• Gives users a list of items from which to select
• The case selector displays a case for each item in the
enumerated type control
Shortcut Menu
Use the shortcut
menu of a Case
structure to:
• Customize the structure and
diagrams.
• Remove or replace the
structure.
• Add, duplicate, remove, or
rearrange cases.
• Specify the Default case.
• Switch cases.
Error Case Structure
Use Case structures inside VIs to execute the code if
there is no error and skip the code if there is an error.
Input and Output Tunnels
You can create multiple input and output tunnels.
• Inputs tunnels are available to all cases if needed.
• You must define each output tunnel for each case.
Demo
1. Membuat Case Structure
2. Menggunakan Case Structure dalam Aplikasi
3. Menambahkan, mengurangi dan menduplikasi case
4. Input dan Output Tunnel
Summary—Quiz
1. If an input to a function is marked with a red dot
(known as a coercion dot), what does the dot
indicate?
a) Data was transferred into a structure.
b) A For Loop was configured with a conditional terminal.
c) A For Loop iteration terminal is unwired.
d) The value passed into a node was converted to a different
representation.
Summary—Quiz
2. Which structure must run at least one time?
a) While Loop
b) For Loop
Summary—Quiz
3.Which is only available on the block diagram?
a) Control
b) Constant
c) Indicator
d) Connector Pane
Summary—Quiz
4. Which mechanical action causes a Boolean control in the FALSE state to
change to TRUE when you click it and stay TRUE until LabVIEW has read
the value?
a) Switch Until Released
b) Switch When Released
c) Latch Until Released
d) Latch When Released