Arrays, Loops, and More In LabVIEW
Written by Jeremy Garrett, Edited by Tom Walker, Copyrighted Jan, 2007
No lab warm-up required for this particular lab.
Download “Play_Sound_JG_V2A.vi” and “Pause.vi” from Blackboard and copy them to
the folder in which you will create / save / execute your own LabVIEW VI’s.
To use “for loops” and to control the number of times the loop will run.
To use “while loops” and to control the number of times the loop will run.
To use a loop to create/fill an array
As stated in the previous lab’s overview, arrays are critical ways of storing data, and as a
result, this lab will include a further study of arrays.
In order to create, fill, and process those
arrays two kinds of loops can be used, and it is these loops that will be the primary focus of this
The first type that we will study is the “for loop.”
The second type which we will study is
the “while loop.”
(It should be noted, that although some languages do support types of loops
other than just these two (such as the “do while loop”), those few other types are actually just
simple variations on these two basic types.)
During the last part of this lab, we will use a while
loop to create and fill an array with the output of a sine wave equation, and then we will feed that
data to a sub-VI (which was written by the author of this lab) that scales the data, sends it to the
sound card, and then asks the sound card to use that data to rapidly reposition our computer
speakers – in other words, we will use the loop to calculate a set of numbers which we will
convert into a sound that we can listen to.
Part 1 – “For Loops”:
Part 1 – Background:
In this part of the lab we will explore the “for loop” command.
Part 1 – Procedure:
Open LabVIEW and create a blank VI.
Before continuing further, switch to the text mouse tool, then click in the upper middle of
your block diagram, this will create a “comment.”
In the text input that appears type in
Then repeat this to add a comment that contains “Lab 4, Part 1”.
a third comment that contains the name of your instructor, and a fourth that contains the