Professional Documents
Culture Documents
Signals, Spectra and Signal Processing: Activity No. 1 - Getting Familiar With Labview (Part I)
Signals, Spectra and Signal Processing: Activity No. 1 - Getting Familiar With Labview (Part I)
Name:__________________________________
Date Performed: _________________________
Rating:__________________________
Date Submitted: __________________
LabVIEW constitutes a graphical programming environment that allows one to design and analyze a
system in a shorter time as compared to text-based programming environments. LabVIEW graphical
programs are called virtual instruments (VIs). VIs run based on the concept of data flow programming. This
means that execution of a block or a graphical component is dependent on the flow of data, or more
specifically a block executes when a data is made available at all of its inputs. Output data of the block are
Page 1
In this activity as well as in the next activity, the LabVIEW environment will be explored and basic VIs
will be created.
2. Two new windows should appear: the Block Diagram (BD) window and the Front Panel (FP) window,
as shown below.
Page 2
Note: It is encouraged that a folder be created where VIs can be organized by activity. It is possible that
future activities will use VIs that were created in earlier activities. Also, ensure that a regular back-up of files
be done as the computers in the laboratory are shared by everyone.
An FP contains the user interfaces of a VI shown in BD. Inputs to a VI are represented by so-called
controls. Knobs, pushbuttons and dials are a few examples of controls. Outputs from a VI are represented
by so-called indicators. Graphs, LEDs (light indicators), and meters are a few examples of indicators.
Page 3
LEDs palette
All of these can be accessed via the controls palette by right-clicking on an empty space on the front panel
or via View > Controls Palette.
A BD contains terminal icons, nodes, wires and structures. Terminal icons are interfaces through which
data are exchanged between an FP and a BD. Terminal icons correspond to controls or indicators that
appear on an FP. Whenever a control or indicator is placed on an FP, a terminal icon gets added to the
corresponding BD.
Place a numeric control on the front panel (right-click on an empty space on FP or View > Controls
Palette, Express, Numeric Control). Click on Num Ctrl and then drop onto the FP.
Page 4
Notice that when a numeric control is placed onto the FP, a terminal icon of the same name appeared on
the BD, as shown. The FP and BD windows can be switched by pressing Ctrl+E.
Note: When opening saved VIs, only the FP appears (try this by closing act01-01.vi and then opening the
file again). Use Ctrl+E to make BD appear in this case.
Rename this Numeric Control as x by typing x when the Numeric label is selected (at the instance that a
control or indicator is placed, its label is automatically selected). Note that the numeric control FP and its
corresponding terminal icon in the BD are renamed. Put another Numeric Control and two Numeric
Indicators and name them as y, Sum, and Average respectively.
Page 5
3. A node represents an object which has input and/or output connectors and performs a certain function.
A subVI (a VI that is used in another VI) and functions are examples of nodes. Functions and subVIs can
only be placed in the BD. The Functions palette be accessed by clicking View > Functions Palette or by
right-clicking empty space in the BD.
Page 6
Place an Add function in the block diagram. This can be accessed in the Functions > Express > Arith &
Comparison > Numeric. Click and drop the Add node in the BD.
Note: Use the Search button in the Functions palette to search for BD functions. Type the name of the
function (or some parts of it) and look for it in the list that the query generates. Then either double-click the
selection to open the location of the function, or drag and drop the name from the list onto the BD.
Page 7
Place a Divide function in the BD. The Add function will get the sum of the two inputs x and y, while the
Divide function will divide the sum by 2 to get their average.
Note: Make the label of the nodes visible by right-clicking the node, select Visible Items and checking the
Label option.
4. Wires establish the flow of data in the BD. To connect the x control icon with the Add function, click on
the x terminal icon, and then click on the one of the inputs of the Add function.
Activity No. 1 Getting Familiar with LabVIEW (Part I)
Page 8
When it is fully connected, it becomes a solid line, whose color depends on the data type that it carries.
There are basically three data types that LabVIEW supports: numeric, Boolean, and string. Numeric data
represent numbers, which can be floating-point numbers (numbers with fractional parts) or integers (whole
numbers). Boolean data represent those that have only two states: 1 or 0. String data represent
alphanumeric characters. The table below summarizes the wire color representation of data types and their
dimensions.
Note: These color representations are also applicable to the borders of terminal icons.
Activity No. 1 Getting Familiar with LabVIEW (Part I)
Page 9
Note: Broken wires occur for a variety of reasons, such as when two objects with incompatible data types
are wired. Broken wires can be removed by pressing Ctrl+B.
Note: Terminal icons, by default, are viewed as icon. For more compact BDs, right-click on a terminal icon,
then uncheck the View As Icon option.
Page 10
Since the average of x and y must be taken and displayed in the Average indicator, the sum of the two
inputs should be divided by two. The first input to the Divide function is the sum of the two inputs; the
second input should be a constant. To insert a constant, right-click on the other input of the Divide function
and choose Create > Constant. Type the number 2 when the constant node appears.
Note: Observe all the screenshots before the above screenshot. The Run arrow in the previous
screenshots are broken, which means that the program contains error and it cannot be executed. Once the
program is error-free, the icon appears like the one shown above.
5. Save the program. Test the functionality of the program by putting values in the controls of the FP and
clicking the Run button.
Page 11
Note: After building the block diagram, it can be made more compact and professional looking by clicking
the Clean Up Diagram icon
in the BD window.
Page 12
2. To assign controls and indicators to the connector pane, click on one of the slots of the pane and click a
control or indicator to be assigned on that slot. Remember, controls are assigned to the left of the
connector pane while indicators are assigned to the right.
Page 13
Note: A subVI can also be created from a section of a VI. Use the Help function of LabVIEW to find out how
to do this. Click Help > LabVIEW Help, or press Ctrl+? or F1 to bring out the Help window of LabVIEW.
On the left pane, select the Search tab, then type Creating SubVIs from Sections of a VI to list topics
related to this. This should generate an article about creating subVIs from a section of a VI.
Activity 1.3 Using Structures and SubVIs
1. Create a new VI named as act01-03. This VI will show the sum and average of two input values in a
continuous fashion. The two inputs can be altered by the user. If the average of the two inputs becomes
greater than a preset threshold value, a LED warning light is lit.
Page 14
Input 1 and Input 2 are Knobs. The size of the knobs can be adjusted by selecting it and dragging
the edges of the selection to the desired size. Right-click the Input 1 knob and choose Properties;
the Knob Properties window appears. Click the Data Type tab. The default data type of this
control is Double Precision (DBL). Change this to Byte (I8) type. Click OK. Note: This step can
also be accomplished by right-clicking the knob then choosing Representation > Byte (I8). For the
Input 2 knob, leave the data type as double precision. For both of the knobs, set both to zero,
right-click the knob, then choose Data Operations > Make Current Value Default to make the
default value of the knobs 0.
The Warning LED is a Rounded LED indicator. The Average is a Gauge. The Sum is a Numeric
Indicator. Place all of these in the FP and resize them accordingly.
3. At this point, there should be five terminal icons in the BD, corresponding to the controls and indicators
in the FP. Build the BD as shown.
Page 15
The Sum and Average subVI, which is the VI created in the previous activities, can be obtained
by right-clicking an empty space in the BD, then choose Select a VI.., which brings the Select a VI
to Open window. Choose act01-01.vi. Note that this VI has two inputs and two outputs. To verify
the labels of the inputs and outputs, roll the mouse over the VI. The Sum output of the subVI is
connected to the Sum indicator, while the Average output is connected to the Average indicator.
To enable the LED warning when the average reaches a value of at least 9, a Greater Or Equal?
node is used. The first input of the Greater Or Equal? node should be the Average output of the
Sum and Average subVI, while the second output is a constant 9. Note: The color of the Warning
data is green, indicating it only accepts 1 or 0 as input (Boolean data type).
4. For the VI to run continuously, the program must be enclosed in a While structure. The While structure
makes the function inside it run continuously (or stop indefinitely) until a condition is met. In this case, it is
required that the program runs until a Stop button is pressed. The While structure is accessed by rightclicking an empty space in the BD, choose Express > Exec Control > While Loop. Drag the mouse until
the entire program in the BD is enclosed within the While structure. The final FP and BD should look like
the one below.
Note: Notice that when the While structure is placed, a Stop button is automatically inserted. This is the
necessary condition that the loop will terminate. In general, a While loop must have a terminating condition
or it will run indefinitely.
A structure in LabVIEW is represented by a graphical enclosure. The graphical code enclosed by a
structure is repeated or executed conditionally. A loop structure is equivalent to a for-loop or a while-loop
statement encountered in text-based programming languages, while a case structure is equivalent to an if-
Page 16
Page 17
Page 18
Place the Random Number (0-1) function in the BD. The Random Number (0-1) function
generates a random number from 0 to 1.
Create an indicator in the output of the Random Number (0-1) function and name it as Current
Output.
Place a Time Delay function in the BD. The Time Delay function causes the execution to be
delayed by specified amount of time. When the Time Delay block is placed in the BD, the
Configure Time Delay dialog box appears. Put 0.1 in the Time Delay (seconds) input box to set
the time delay of the program execution to 0.1 seconds.
Place a For-Loop structure in the BD, enclosing all blocks created so far inside. The For-Loop
structure is used to repeat a certain operations n times, which is an input to the Loop Count
indicator (N) in the For-Loop. To learn more about the For structure, refer to the LabVIEW Help.
Create a constant in the Loop Count parameter of the For-Loop. Set this constant to 10.
Wire the output of the Random Number (0-1) function to the border of the For-Loop. A tunnel is
created. A tunnel interfaces the inside of the For-Loop to the outside. The tunnel created here
should contain a [ ] inside. Note: The [ ] inside the tunnel indicates that the data type is array. By
default, auto-indexing is enabled in a For-Loop and disabled in a While-Loop.
Create another tunnel out of the For-Loop structure, this time, with the auto-indexing disabled. To
disable auto-indexing, right-click the tunnel, then click Disable Indexing.
Create indicators for each tunnel named Output with Indexing for the tunnel with enabled autoindexing and Output without Indexing for other one.
Question: Compare the wires connecting the indicators to the tunnels. Why is this so?
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Page 19
Expand the boxes for the Current Output and Output without Indexing.
Drag the Output with Indexing downwards until ten indicators appear.
Note: The Output with Indexing is an array indicator; it holds values in an array. The number of elements
that is held by this array depends on how many iterations the For-Loop has, which in this case, ten. The
index of an array always starts from zero; thus the first element of the Output with Indexing array has an
index of zero, and the last element has an index of nine.
3. Save the VI and run the program.
Question: Describe the functionality of the program. Compare the output of the Output with
Indexing and Output without Indexing indicators.
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________
Page 20
Page 21