0% found this document useful (0 votes)
41 views

JCB30304 Data Acquisition System: Chapter 3: Structures

The document discusses different structures in LabVIEW for controlling the order of execution, including sequences and local/global variables. It explains that sequences allow forcing code to execute in a specific order by placing code blocks or "frames" in sequence. Local variables transfer data within a VI and allow passing data between parallel loops, while global variables access and pass data among multiple simultaneously running VIs. The document provides examples and best practices for using these structures.

Uploaded by

cap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

JCB30304 Data Acquisition System: Chapter 3: Structures

The document discusses different structures in LabVIEW for controlling the order of execution, including sequences and local/global variables. It explains that sequences allow forcing code to execute in a specific order by placing code blocks or "frames" in sequence. Local variables transfer data within a VI and allow passing data between parallel loops, while global variables access and pass data among multiple simultaneously running VIs. The document provides examples and best practices for using these structures.

Uploaded by

cap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

JCB30304

DATA ACQUISITION SYSTEM

CHAPTER 3: STRUCTURES
CHAPTER 3 STRUCTURES

LOOPS SEQUENCES

CASE
STRUCTURES
4 LOCAL
VARIABLES

"A positive attitude awakens inner strength, energy, motivation and initiative."
SEQUENCES

The only difference between a good day and a bad day is your attitude. ~Dennis S. Brown
Sequence Structures
 But in LabVIEW, you can’t always predict the order
of execution. For example, in this code, which
function executes first: the Subtract or the Greater
Than?

 Sequence structures can be used to


force code to execute in a specific
sequence.
Frames in Sequence Structures
 The code to be executed sequentially is entered on
subdiagrams called frames. The analogy is to
frames of movie film, which are projected one after
another.
Sequence Structures
 But in LabVIEW, you can’t
always predict the order of
execution. For example, in
this code, which function
executes first: the Subtract or
the Greater Than?
 Sequence structures can be
used to force code to execute
in a specific sequence.
Frames in Sequence Structures
 The code to be executed sequentially is entered on
subdiagrams called frames. The analogy is to
frames of movie film, which are projected one after
another.
Flat or Stacked?
 LabVIEW has two kinds of Sequence structures:
 Flat Sequence structures, in which the frames are laid
out side by side, as in the image on the previous slide.
 Stacked Sequence structures, in which the frames are
“stacked” like a deck of cards, with only one visible at
a time.
Flat or Stacked? (Continued)
 The two kinds of Sequence structure are similar. The
main difference is how much space they take up on the
block diagram. But there are other differences, such as:
 If data is wired out through a tunnel from a frame in a Flat
Sequence structure, the data passes out as soon as that
frame finishes executing.
 If data is wired out through a tunnel from a frame in a
Stacked Sequence structure, the data does not pass out until
the entire structure finishes executing.
Use Sequence Structures Only When
Necessary
 Sequence structures serve a valid purpose, but they
also tend to hide parts of the program and
interfere with the natural flow of data in LabVIEW.
 Avoid using them unless you have a situation where
you need to guarantee the order of execution, and
LabVIEW’s natural data flow does not provide such
a guarantee.
EXAMPLE & EXERSICE
 Problem 8.11 page 191
 Problem 8.12 page 191
Problem 8.11
Problem 8.12
LOCAL VARIABLES

Attitude is a little thing that makes a big difference. -Winston Churchill


Local Variables
 Local variables transfer data within a single VI and
allow data to be passed between parallel loops.
 They also break the dataflow programming
paradigm.
 Use local variables to read or write to one of the
controls or indicators on the front panel of a VI.
Local Variables
 Two ways to create a local variable:
 Right-click
on an object’s terminal, select
Create>>Local Variable.
Local Variables

A local variable
icon for the object
appears on the
block diagram
Local Variables
 Another way is to select the Local Variable from the Structures palette.
 Create the front panel and select a local variable from the Functions
palette and place it on the block diagram. The local variable node, shown
as follows, is not yet associated with a control or indicator.
 To associate a local variable with a control or indicator, right-click the local
variable node and select Select Item from the shortcut menu.
 LabVIEW uses owned labels to associate local variables with front panel
objects, so label the front panel controls and indicators with descriptive
owned labels.
 Owned label becomes variable name and select whether you want to read
or write to the local variable.
Local Variables
 The expanded shortcut menu lists all the front panel
objects that have owned labels as shown in Figure.
Global Variables
 Use global variables to access and pass data among several VIs
that run simultaneously.
 When you create a global variable, LabVIEW automatically creates
a special global VI, which has a front panel but no block diagram.
 Add controls and indicators to the front panel of the global VI to
define the data types of the global variables it contains.
 In effect, this front panel is a container from which several VIs can
access data.
Global Variables
 Select a global variable, shown as follows, from the Functions palette
and place it on the block diagram.
 Double-click the global variable node to display the front panel of
the global VI. Place controls and indicators on this front panel the
same way you do on a standard front panel.
 LabVIEW uses owned labels to identify global variables, so label
the front panel controls and indicators with descriptive owned labels.
 You can create several single global VIs, each with one front panel
object, or if you want to group similar variables together, you can
create one global VI with multiple front panel objects.
Global Variables
 After you finish placing objects on the global VI front panel, save it
and return to the block diagram of the original VI. You must then
select the object in the global VI that you want to access. Click the
global variable node and select a front panel object from the
shortcut menu. The shortcut menu lists all the front panel objects in the
global VI that have owned labels. You also can right-click the global
variable node and select a front panel object from the Select Item
shortcut menu.
 If you create a copy of a global variable node, LabVIEW associates
the new global variable node with the global VI of the variable
node you copy it from.
EXERSICE AND EXAMPLE
THANK YOU…

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy