Difference between revisions of "Introduction to LabVIEW"

From EG1004 Lab Manual
Jump to: navigation, search
m (Protected "Introduction to LabVIEW" [edit=sysop:move=sysop])
Line 1: Line 1:
<h1 align=center>EG1004 Lab 5: Introduction to LabVIEW</h1>
== 1 OBJECTIVES ==
The experimental objective of this lab is to design three systems using LabVIEW:
# A digital calculator
# A lighting system for a building
# A thermal control system that automatically turns on heating and cooling equipment


<h2>1 OBJECTIVES</h2>
Building these systems allows us to investigate the potential for using simulated instruments in the laboratory. These programs will let you to obtain data from outside the computer and incorporate it into your program design. In contrast to the more common text-based languages, LabVIEW uses a graphical programming language. You will learn the logic of graphical programming during the course of this lab.


<p>The experimental objective of this lab is to design three systems using LabVIEW:</p>
== 2 OVERVIEW ==
<ol>
''Adapted from Introduction to LabVIEW, Six-Hour Course.<sup>1</sup>''
 
<li>A digital calculator</li>
<li>A lighting system for a building</li>
<li>A thermal control system that automatically turns on heating and cooling equipment</li>
</ol>
 
<p>Building these systems allows us
to investigate the potential for using simulated instruments in the laboratory.
These programs will let you to obtain data from outside the computer and
incorporate it into your program design. In contrast to the more common
text-based languages, LabVIEW uses a graphical programming language. You will
learn the logic of graphical programming during the course of this lab.</p>
 
<h2>2 OVERVIEW</h2>
 
<p><i>Adapted from Introduction to LabVIEW, Six-Hour Course.<sup>1</sup></i></p>
 
<p>LabVIEW is a development
environment for creating graphical programs, called <b><i>virtual instruments (VIs)</i></b>,
to simulate actual laboratory instruments. A VI consists of two parts: a <b><i>front panel</i></b>
 
and a <b><i>back panel</i></b>. The <b><i>front panel</i></b> allows the user to interact
with the VI by displaying output and allowing the user to supply the program with input.
The <b><i>back panel</i></b> consists of the actual code used by the VI to obtain input from
the <b><i>front panel</i></b>, operate on the input, and display the results.</p>
 
<p>The <b><i>front panel</i></b> is built using <b><i>controls</i></b> and <b><i>indicators</i></b>.
 
<b><i>Controls</i></b> are <b>inputs </b>– they allow a user to supply
information to the VI. <b><i>Indicators</i></b> are <b>outputs</b> – they <i>indicate</i>,
or display, the results based on the inputs given to the VI. Controls consist
of switches, knobs, dials, buttons, etc. and indicators consist of meters,
gauges, LEDs, displays, etc. These are located on the Controls palette and can
be placed on the front panel.</p>
 
<p>The <b><i>back panel</i></b>, which is a <b><i>block
diagram</i></b>, contains the graphical source code. All of the objects placed
on the <b><i>front panel</i></b> will appear on the <b><i>back panel</i></b> as <i>terminals</i>. The <b><i>back panel</i></b> also contains <b>structures</b> and <b>functions</b> which perform operations on controls and supply data to
indicators. The <b>structures</b> and <b>functions </b>are found on the <b><i>Functions
palette</i></b> and can be placed on the <b><i>back panel</i></b>. Collectively controls,
indicators, structures and functions will be referred to as <b><i>nodes</i></b>.
 
<b><i>Nodes</i></b>
are connected to one another using wires – e.g. two controls and an indicator
can be wired to the addition function so that the indicator displays the sum of
the two controls.</p>
 
<p>In any programming language,
structures allow you to create conditions. In LabVIEW you can access structures
by opening the <b><i>Functions palette</i></b> and selecting <b><i>Structures</i></b>. The following
are some examples of structures:</p>
 
<ol>
<li>The <b><i>While Loop</i></b> is similar to do loop or while in text-based programming
languages. It executes its subdiagram (or subroutine) until it receives a false value.</li>
 
<li>The <b><i>For Loop </i></b>executes a subdiagram a set number of times, specified
by the value in the count terminal.</li>
 
<li>The <b><i>Case Structure</i></b> is similar to if/else, switch/case or match/with
in text-based programming languages. It contains multiple subdiagrams – one for each
possible value of the input to the case structure (the control wired to the '?').</li>
</ol>
 
<p>The <b><i>data acquisition and control (DAC)</i></b>
board is LabVIEW's physical interface with the outside world. To send or
receive data through the board, you must specify two parameters: the <b><i>device
number</i></b> and the <b><i>channel</i></b>. For our purposes, the <b><i>device
number</i></b> is <b><i>1</i></b>. When there is more than one DAC board attached to a
computer, the device number specifies which DAC board to use. The <b><i>channel</i></b>
 
input specifies which channel on the DAC board to read. There is one DAC board
for analog data and another digital data. The <b><i>analog board</i></b> uses <b><i>pin 1</i></b>
for <b><i>ground</i></b> and <b><i>pins
3-18</i></b> for <b><i>analog I/O (input/output)</i></b>. The <b><i>digital board</i></b> uses <b><i>even-numbered
pins</i></b> for <b><i>ground</i></b> and <b><i>odd-numbered pins 1-47</i></b> for <b><i>digital
I/O</i>. <i>Pin 49 is a constant output of +5 VDC</i>. For convenience, <i>always use
pin 50 as your ground</i>.</b></p>
 
<p>Some useful key shortcuts to keep in mind when working in the LabVIEW environment: </p>
 
<ol type="a">
<li>CTRL+H: Show/hide context help.</li>
<li>CTRL+B: Clean up broken wiring.</li>
<li>CTRL+E: Toggle between front/back panels.</li>
<li>CTRL+Z: Undo last action.</li>
</ol>
<h2>3 YOUR ASSIGNMENT</h2>


<h3>Individual Lab Report</h3>
LabVIEW is a development environment for creating graphical programs, called '''''virtual instruments (VIs)''''', to simulate actual laboratory instruments. A VI consists of two parts: a '''''front panel''''' and a '''''back panel'''''. The '''''front panel''''' allows the user to interact with the VI by displaying output and allowing the user to supply the program with input. The '''''back panel''''' consists of the actual code used by the VI to obtain input from the '''''front panel''''', operate on the input, and display the results.


<ul>
The '''''front panel''''' is built using '''''controls''''' and '''''indicators'''''. '''''Controls''''' are '''inputs '''– they allow a user to supply information to the VI. '''''Indicators''''' are '''outputs''' – they ''indicate'', or display, the results based on the inputs given to the VI. Controls consist of switches, knobs, dials, buttons, etc. and indicators consist of meters, gauges, LEDs, displays, etc. These are located on the Controls palette and can be placed on the front panel.
<li><b>A Zip file including all LabVIEW programs (.vi) needs to be submitted to
[http://eg.poly.edu the EG1004 Web site]</b>. If you don't know how to make a zip file, read the page
[[How to Compress Your Files]] in the <i>Instructional Presentations</i> section.</li>
</li>
</ul>


<p><b>Lab report</b></p>
The '''''back panel''''', which is a '''''block diagram''''', contains the graphical source code. All of the objects placed on the '''''front panel''''' will appear on the '''''back panel''''' as ''terminals''. The '''''back panel''''' also contains '''structures''' and '''functions''' which perform operations on controls and supply data to indicators. The '''structures''' and '''functions '''are found on the '''''Functions palette''''' and can be placed on the '''''back panel'''''. Collectively controls, indicators, structures and functions will be referred to as '''''nodes'''''. '''''Nodes''''' are connected to one another using wires – e.g. two controls and an indicator can be wired to the addition function so that the indicator displays the sum of the two controls.


<p>Follow the lab report guidelines laid out in the page called
In any programming language, structures allow you to create conditions. In LabVIEW you can access structures by opening the '''''Functions palette''''' and selecting '''''Structures'''''. The following
[[Specifications for Writing Your Lab Reports]] in the <i>Technical Communication</i>
are some examples of structures:
section of this manual. As you write, the following discussion points should be addressed
in the appropriate section of your lab report:</p>


<ul>
# The '''''While Loop''''' is similar to do loop or while in text-based programming languages. It executes its subdiagram (or subroutine) until it receives a false value.
<li>Explain what LabVIEW is and describe how it helps engineers and scientists with their work.</li>
# The '''''For Loop '''''executes a subdiagram a set number of times, specified by the value in the count terminal.
# The '''''Case Structure''''' is similar to if/else, switch/case or match/with in text-based programming languages. It contains multiple subdiagrams – one for each possible value of the input to the case structure (the control wired to the '?').


<li>Explain what a VI is.</li>
The '''''data acquisition and control (DAC)''''' board is LabVIEW's physical interface with the outside world. To send or receive data through the board, you must specify two parameters: the '''''device number''''' and the '''''channel'''''. For our purposes, the '''''device number''''' is '''''1'''''. When there is more than one DAC board attached to a computer, the device number specifies which DAC board to use. The '''''channel''''' input specifies which channel on the DAC board to read. There is one DAC board for analog data and another digital data. The '''''analog board''''' uses '''''pin 1''''' for '''''ground''''' and '''''pins
3-18''''' for '''''analog I/O (input/output)'''''. The '''''digital board''''' uses '''''even-numbered pins''''' for '''''ground''''' and '''''odd-numbered pins 1-47''''' for '''''digital I/O''. ''Pin 49 is a constant output of +5 VDC''. For convenience, ''always use pin 50 as your ground''.'''


<li>What are controls and indicators?</li>
Some useful key shortcuts to keep in mind when working in the LabVIEW environment:
# CTRL+H: Show/hide context help.
# CTRL+B: Clean up broken wiring.
# CTRL+E: Toggle between front/back panels.
# CTRL+Z: Undo last action.


<li>What are structures and functions?</li>
== 3 YOUR ASSIGNMENT ==
=== Individual Lab Report ===
'''A Zip file including all LabVIEW programs (.vi) needs to be submitted to
[http://eg.poly.edu the EG1004 Web site]'''. If you don't know how to make a zip file, read the page
[[How to Compress Your Files]] in the ''Instructional Presentations'' section.
'''Lab report'''


<li>What is the Front Panel used for? The Back Panel?</li>
Follow the lab report guidelines laid out in the page called [[Specifications for Writing Your Lab Reports]] in the ''Technical Communication'' section of this manual. As you write, the following discussion points should be addressed in the appropriate section of your lab report:
* Explain what LabVIEW is and describe how it helps engineers and scientists with their work.
* Explain what a VI is.
* What are controls and indicators?
* What are structures and functions?
* What is the Front Panel used for? The Back Panel?
* Discuss what a DAC board is.
* Were the objectives of the experiment achieved? If not why?
* Describe the advantages and disadvantages of using LabVIEW.
* Suggest some improvements of how the lab could have be conducted better.


<li>Discuss what a DAC board is.</li>
<font color=#ff0000>'''IMPORTANT: Because the procedural elements in this lab are extensive,
 
<li>Were the objectives of the experiment achieved? If not why?</li>
 
<li>Describe the advantages and disadvantages of using LabVIEW.</li>
 
<li>Suggest some improvements of how the lab could have be conducted better.</li>
</ul>
 
<p><font color=#ff0000><b>IMPORTANT: Because the procedural elements in this lab are extensive,
please include only the procedures you employed to build Design 2, the Heating and Cooling System
please include only the procedures you employed to build Design 2, the Heating and Cooling System
in your lab report. You do not need to document the procedures you followed to build Design 1:
in your lab report. You do not need to document the procedures you followed to build Design 1:
the Simple Calculator, or Design 3: Lighting System.</b></font></p>
the Simple Calculator, or Design 3: Lighting System.'''</font>


<p><b>Note:</b> You still need to include <b>ALL</b> the designs in the other sections of your lab
'''Note:''' You still need to include '''ALL''' the designs in the other sections of your lab report.
report.</p>


<p>Remember, your job in this lab is not to report whether the Heating and Cooling system
Remember, your job in this lab is not to report whether the Heating and Cooling system worked. Your job is to report on what you did to design it. Please consider the value of LabVIEW as a substitute for actual instruments and systems. Your Data/Observations section should include information on ease of use, the LabVIEW user interface, and the help options available to you.
worked. Your job is to report on what you did to design it. Please consider the value of LabVIEW
as a substitute for actual instruments and systems. Your Data/Observations section should
include information on ease of use, the LabVIEW user interface, and the help options available
to you.</p>
 
<p>In describing the design of all the systems, you should show screen shots in your lab reports
showing the Virtual Instruments you designed. If you don't know how to take a screen shot and include
it in your report, look at the Online Manual under "Instructional Web Pages" for instructions on how
to take a screen shot and use it.</p>
 
<h3>Team PowerPoint Presentation</h3>
 
<p>Follow the presentation guidelines laid out in the page called
[[EG1004 Lab Presentation Format]] in the <i>Introduction to Technical Presentations</i>
section of this manual. When you are preparing your presentation, consider the following
points:</p>
 
<ul>
<li>What is the importance of LabVIEW?</li>
<li>Discuss some ways LabVIEW can be used in industry</li>
</ul>


<h2>4 MATERIALS AND EQUIPMENT</h2>
In describing the design of all the systems, you should show screen shots in your lab reports showing the Virtual Instruments you designed. If you don't know how to take a screen shot and include it in your report, look at the Online Manual under "Instructional Web Pages" for instructions on how to take a screen shot and use it.


<ul>
=== Team PowerPoint Presentation ===
<li>Lab PC</li>
Follow the presentation guidelines laid out in the page called [[EG1004 Lab Presentation Format]] in the ''Introduction to Technical Presentations'' section of this manual. When you are preparing your presentation, consider the following points:
<li>LabVIEW Software</li>
* What is the importance of LabVIEW?
<li>Data acquisition and control (DAC) board</li>
* Discuss some ways LabVIEW can be used in industry


<li>Breadboard</li>
== 4 MATERIALS AND EQUIPMENT ==
<li>Several LEDs</li>
* Lab PC
</ul>
* LabVIEW Software
* Data acquisition and control (DAC) board
* Breadboard
* Several LEDs


<h2>5 PROCEDURE</h2>
== 5 PROCEDURE ==


<ol>
<ol>
<li>Open LabVIEW, select <b><i>New</i></b> and <b><i>Blank VI</i></b>.</li>
<li>Open LabVIEW, select '''''New''''' and '''''Blank VI'''''.


<li>Click on <b><i>Window</i></b> and select <b><i>Tile
<li>Click on '''''Window''''' and select '''''Tile
Left &amp; Right</i></b> to set the front panel (left window) and back panel (right
Left &amp; Right''''' to set the front panel (left window) and back panel (right
window) side by side. This will make them visible at the same time, making it
window) side by side. This will make them visible at the same time, making it
easier to work. </li>
easier to work.  


<li>On the right window, pull down the <b><i>View</i></b> menu, select <b><i>Show Tools
<li>On the right window, pull down the '''''View''''' menu, select '''''Show Tools
Palette</i></b>.</li>
Palette'''''.


<li>On the left window, pull down the <b><i>Window</i></b>
<li>On the left window, pull down the '''''Window'''''
menu again, select <b><i>Show Controls Palette</i></b>. At this point your screen should look
menu again, select '''''Show Controls Palette'''''. At this point your screen should look
like Figure 3. Note the <b><i>Controls Palette</i></b> and the <b><i>Tools
like Figure 3. Note the '''''Controls Palette''''' and the '''''Tools
Palette</i></b>, and their icons.</li>
Palette''''', and their icons.
</ol>
</ol>


Line 195: Line 96:
<p class=caption>Figure 3: LabVIEW workspace</p>
<p class=caption>Figure 3: LabVIEW workspace</p>


<p><i><b>Remember:</b> You are required to take notes. Experimental details are
<p>'''''Remember:''' You are required to take notes. Experimental details are
easily forgotten unless written down. EG Standard Note Paper can be downloaded
easily forgotten unless written down. EG Standard Note Paper can be downloaded
and printed from the EG website [http://eg.poly.edu/Note_Paper.zip the EG1004 Web site].
and printed from the EG website [http://eg.poly.edu/Note_Paper.zip the EG1004 Web site].
Line 202: Line 103:
on MyPoly. You must attach your lab notes at the end of your lab report (use the
on MyPoly. You must attach your lab notes at the end of your lab report (use the
"Insert Object" command in MS Word after your Conclusion). Keeping careful notes
"Insert Object" command in MS Word after your Conclusion). Keeping careful notes
is an essential component of all scientific practice.</i></p>
is an essential component of all scientific practice.''</p>


<p>For help with the operation of
<p>For help with the operation of
Line 215: Line 116:
device works.</p>
device works.</p>


<p><b>Note:</b> We'll be doing
<p>'''Note:''' We'll be doing
some tasks a number of times, where you'll be clicking on the same icons to
some tasks a number of times, where you'll be clicking on the same icons to
bring up various components. To help you , we've included a LabVIEW digest at
bring up various components. To help you , we've included a LabVIEW digest at
the end of this lab for your reference to help you navigate.</p>
the end of this lab for your reference to help you navigate.</p>


<h3>Design 1: Simple Calculator</h3>
=== Design 1: Simple Calculator ===


<p>Create a program that simulates a basic calculator. Your calculator will be
<p>Create a program that simulates a basic calculator. Your calculator will be
Line 226: Line 127:


<ol>
<ol>
<li>The <b><i>front panel</i></b> must contain:</li>
<li>The '''''front panel''''' must contain:


<ol type="a">
<ol type="a">
<li>One slide to control the arithmetic operation to be performed. Here's how to do it:</li>
<li>One slide to control the arithmetic operation to be performed. Here's how to do it:


<ol>
<ol>
<li>Select the <b>Num Ctrls</b> icon [[Image:lab_labview_2.gif]] on the <b>Controls Palette</b> (see Figure 4). This
<li>Select the '''Num Ctrls''' icon [[Image:lab_labview_2.gif]] on the '''Controls Palette''' (see Figure 4). This
will bring up the window shown in Figure 5
will bring up the window shown in Figure 5


Line 244: Line 145:


<li>Then select Horizontal Pointer Slide from the icons shown. Click on the left window to place the slide
<li>Then select Horizontal Pointer Slide from the icons shown. Click on the left window to place the slide
on the front panel at the location you select.</li>
on the front panel at the location you select.
<p>Note: If you don't like where
<p>Note: If you don't like where
you put the slide, click on it and hold down the left mouse button to "drag"
you put the slide, click on it and hold down the left mouse button to "drag"
Line 254: Line 155:
the back panel (right window). After we complete the front panel, we'll wire
the back panel (right window). After we complete the front panel, we'll wire
the items on the back panel to make the calculator work.</p>
the items on the back panel to make the calculator work.</p>
<li>Click on the number <i>10
<li>Click on the number ''10


</i>and change it to <i>2</i>. Now the slide control will look like Figure 6.</li>
''and change it to ''2''. Now the slide control will look like Figure 6.


<p align=center>[[Image:lab_labview_6.gif]]</p>
<p align=center>[[Image:lab_labview_6.gif]]</p>
Line 262: Line 163:
<p class=caption>Figure 6: Slide control with range changed from 10 to 2</p>
<p class=caption>Figure 6: Slide control with range changed from 10 to 2</p>


<li>Right click on the slide to bring up a pull down menu. Select <b>Representation</b>,
<li>Right click on the slide to bring up a pull down menu. Select '''Representation''',
and choose the <b>I32 </b>icon. Figure 7
and choose the '''I32 '''icon. Figure 7
shows what the pull down menus look like, and the I32 icon. This completes the
shows what the pull down menus look like, and the I32 icon. This completes the
slide control on the front panel.</li>
slide control on the front panel.


<p align=center>[[Image:lab_labview_7.gif]]</p>
<p align=center>[[Image:lab_labview_7.gif]]</p>
Line 275: Line 176:


<ol>
<ol>
<li>On the Controls palette, select the <b>LEDs</b> icon [[Image:lab_labview_8.gif]].
<li>On the Controls palette, select the '''LEDs''' icon [[Image:lab_labview_8.gif]].
This will bring up the window shown in Figure 8.</li>
This will bring up the window shown in Figure 8.


<p align=center>[[Image:lab_labview_9.gif]]</p>
<p align=center>[[Image:lab_labview_9.gif]]</p>
Line 282: Line 183:
<p class=caption>Figure 8: LEDs Window</p>
<p class=caption>Figure 8: LEDs Window</p>


<li>Select the <b>Round LED</b> icon from the icons shown.
<li>Select the '''Round LED''' icon from the icons shown.
Click on the left window to place the LED on the front panel at the location
Click on the left window to place the LED on the front panel at the location
youh select. The best place to put it is centered under the slide. Do this two
youh select. The best place to put it is centered under the slide. Do this two
more times, putting the lights on each side of the first light you made, so you
more times, putting the lights on each side of the first light you made, so you
have a total of three lights in a row under the slide.</li>
have a total of three lights in a row under the slide.


<li>Rename the three LEDs to correspond to the functions the calculator will be
<li>Rename the three LEDs to correspond to the functions the calculator will be
performing: add, subtract, and multiply. To rename each LED, click on the
performing: add, subtract, and multiply. To rename each LED, click on the
<b>Edit Text</b> icon [[Image:lab_labview_10.gif]] on the <b>Tools
'''Edit Text''' icon [[Image:lab_labview_10.gif]] on the '''Tools
palette</b>. Then click on the 'Boolean' label on each LED and replace it with
palette'''. Then click on the 'Boolean' label on each LED and replace it with
the proper text: "add" for the left light, "subtract" for the center light, and
the proper text: "add" for the left light, "subtract" for the center light, and
"multiply" for the right light.</li>
"multiply" for the right light.


</ol>
</ol>
Line 300: Line 201:


<ol>
<ol>
<li>On the <b>Controls palette</b>, click on the <b>Num Ctrls</b> icon. This will bring up the
<li>On the '''Controls palette''', click on the '''Num Ctrls''' icon. This will bring up the
window shown in Figure 5 again.</li>
window shown in Figure 5 again.


<li>Click on the <b>Num Ctrl</b> icon and click on the left window to the left of
<li>Click on the '''Num Ctrl''' icon and click on the left window to the left of
the slide to place a numeric control there. This will look like a window you can
the slide to place a numeric control there. This will look like a window you can
enter data in. Click the <b>Num Ctrl</b> icon again, and place another numeric control
enter data in. Click the '''Num Ctrl''' icon again, and place another numeric control
on the right side of the slide.</li>
on the right side of the slide.


</ol>
</ol>


<li>A numeric indicator to display the output. Here's how to do it:</li>
<li>A numeric indicator to display the output. Here's how to do it:


<ol>
<ol>
<li>On the Controls palette, click on the <b>Num Inds</b> icon [[Image:lab_labview_11.gif]].
<li>On the Controls palette, click on the '''Num Inds''' icon [[Image:lab_labview_11.gif]].
This will bring up the window shown in Figure 9.</li>
This will bring up the window shown in Figure 9.


<p align=center>[[Image:lab_labview_12.gif]]</p>
<p align=center>[[Image:lab_labview_12.gif]]</p>
Line 320: Line 221:
<p class=caption>Figure 9: Num Inds Window</p>
<p class=caption>Figure 9: Num Inds Window</p>


<li>Click on the <b>Num Ind</b> icon and click on the left window
<li>Click on the '''Num Ind''' icon and click on the left window
centered below the three lights. This numeric indicator will be the answer from
centered below the three lights. This numeric indicator will be the answer from
the calculator.</li>
the calculator.


<p><b>Note</b>: This numeric indicator, used for output, is a different type of object from the
<p>'''Note''': This numeric indicator, used for output, is a different type of object from the
two numeric controls (which are for input) that you constructed earlier in Item c.</p>
two numeric controls (which are for input) that you constructed earlier in Item c.</p>


<li>You are now finished constructing the front panel. The finished <b>Front
<li>You are now finished constructing the front panel. The finished '''Front
Panel</b> should look like Figure 10:</li>
Panel''' should look like Figure 10:
</ol>
</ol>


Line 341: Line 242:
together to make the calculator work.</p>
together to make the calculator work.</p>


<li>The <b><i>back panel</i></b> must contain:</li>
<li>The '''''back panel''''' must contain:


<ol type="a">
<ol type="a">


<li>At least one case statement to control the arithmetic operations. This case statement
<li>At least one case statement to control the arithmetic operations. This case statement
will be the heart of the calculator. Here's how you do it:</li>
will be the heart of the calculator. Here's how you do it:


<ol>
<ol>
Line 352: Line 253:
indicator to the bottom of the window. Place the slide node on the left edge of the window.
indicator to the bottom of the window. Place the slide node on the left edge of the window.
This will leave a large area in the middle that you will fill in at the next few
This will leave a large area in the middle that you will fill in at the next few
steps. Your back panel should now look like Figure 11.</li>
steps. Your back panel should now look like Figure 11.


<p align=center>[[Image:lab_labview_14.gif]]</p>
<p align=center>[[Image:lab_labview_14.gif]]</p>
Line 358: Line 259:
<p class=caption>Figure 11: Rearranged Back Panel</p>
<p class=caption>Figure 11: Rearranged Back Panel</p>


<li>In the block diagram (back panel) of LabVIEW, go to the menu bar, select View, and choose "Functions Palette", just as shown on Figure 12a. This will bring up the Functions Palette, shown in Figure 12b.</li>
<li>In the block diagram (back panel) of LabVIEW, go to the menu bar, select View, and choose "Functions Palette", just as shown on Figure 12a. This will bring up the Functions Palette, shown in Figure 12b.


<p align=center>[[Image:lab_labview_15.gif]]</p>
<p align=center>[[Image:lab_labview_15.gif]]</p>
Line 368: Line 269:
<p class=caption>Figure 12b: Functions Palette</p>
<p class=caption>Figure 12b: Functions Palette</p>


<li>Click on the <b>Exec Ctrl</b> icon [[Image:lab_labview_17.gif]]. This will
<li>Click on the '''Exec Ctrl''' icon [[Image:lab_labview_17.gif]]. This will
bring up the <b><i>Exec Ctrl</i></b> window, shown in Figure 13.</li>
bring up the '''''Exec Ctrl''''' window, shown in Figure 13.


<p align=center>[[Image:lab_labview_18.gif]]</p>
<p align=center>[[Image:lab_labview_18.gif]]</p>
Line 375: Line 276:
<p class=caption>Figure 13: Exec Ctrl Window</p>
<p class=caption>Figure 13: Exec Ctrl Window</p>


<li>Click on the <b>Case Structure</b> icon. Click on the right window to locate it on the
<li>Click on the '''Case Structure''' icon. Click on the right window to locate it on the
back panel. Be careful, it's a very large object, and will have many
back panel. Be careful, it's a very large object, and will have many
connections. Your best strategy is to locate it in the middle of the panel.
connections. Your best strategy is to locate it in the middle of the panel.
Note that at the top of the object there a caption box with the number <b><i>1</i></b>
Note that at the top of the object there a caption box with the number '''''1'''''
in it. On each side of the caption box are arrows pointing to the left and
in it. On each side of the caption box are arrows pointing to the left and
right. Note also the question mark on the left side of the case structure
right. Note also the question mark on the left side of the case structure
object. This is the input to the case structure.</li>
object. This is the input to the case structure.


<li>We will now start
<li>We will now start
connecting things. First, we need to access the proper tool. On the Tools
connecting things. First, we need to access the proper tool. On the Tools
Palette, chose the "Connect Wire" icon [[Image:lab_labview_19.gif]]. We'll now connect
Palette, chose the "Connect Wire" icon [[Image:lab_labview_19.gif]]. We'll now connect
the slide to the case structure. Connect the slide to the <b>case structure</b> by clicking on the slide object, and then on the
the slide to the case structure. Connect the slide to the '''case structure''' by clicking on the slide object, and then on the
question mark on the left side of the case structure. Your back panel should
question mark on the left side of the case structure. Your back panel should
now look like Figure 14.</li>
now look like Figure 14.


<p align=center>[[Image:lab_labview_20.jpg]]</p>
<p align=center>[[Image:lab_labview_20.jpg]]</p>
Line 397: Line 298:
statement is created, it only has two cases. Since you have three operations
statement is created, it only has two cases. Since you have three operations
for the calculator, you need to make another case. To add the third case operation,
for the calculator, you need to make another case. To add the third case operation,
right-click anywhere on the <b>case
right-click anywhere on the '''case
structure</b> and select <b>Add Case After</b>,
structure''' and select '''Add Case After''',
as shown in Figure 15.</li>
as shown in Figure 15.


<p align=center>[[Image:lab_labview_21.gif]]</p>
<p align=center>[[Image:lab_labview_21.gif]]</p>
Line 406: Line 307:


<li>Now we'll add the mathematical operations that the calculator should perform for
<li>Now we'll add the mathematical operations that the calculator should perform for
each case. On the <b><i>Functions Palette</i></b>, click on the <b>Arith/Compare</b>
each case. On the '''''Functions Palette''''', click on the '''Arith/Compare'''
icon <b>[[Image:lab_labview_33.gif]]</b> from the main <b><i>Functions
icon '''[[Image:lab_labview_33.gif]]''' from the main '''''Functions
Palette</i></b>. This will bring up the Arith/Compare window shown in Figure 17.</li>
Palette'''''. This will bring up the Arith/Compare window shown in Figure 17.


<p align=center>[[Image:lab_labview_23.gif]]</p>
<p align=center>[[Image:lab_labview_23.gif]]</p>
Line 414: Line 315:
<p class=caption>Figure 17: Arith/Compare Window</p>
<p class=caption>Figure 17: Arith/Compare Window</p>


<li>On the Arith/Compare window, click on the <b>Numeric</b> icon
<li>On the Arith/Compare window, click on the '''Numeric''' icon
[[Image:lab_labview_24.gif]]. This will bring up the Express Numeric window
[[Image:lab_labview_24.gif]]. This will bring up the Express Numeric window
shown in Figure 18.</li>
shown in Figure 18.


<p align=center>[[Image:lab_labview_25.gif]]</p>
<p align=center>[[Image:lab_labview_25.gif]]</p>
Line 423: Line 324:


<li>Click on the left arrow at the top of the case structure box. This should change the
<li>Click on the left arrow at the top of the case structure box. This should change the
caption for the case structure to <b><i>0</i></b>. In the <b><i>Express Numeric</i></b>
caption for the case structure to '''''0'''''. In the '''''Express Numeric'''''


Window, click on the Add icon <b>[[Image:lab_labview_26.gif]]</b>, and click on a
Window, click on the Add icon '''[[Image:lab_labview_26.gif]]''', and click on a
location in the middle of the case structure box to place it.</li>
location in the middle of the case structure box to place it.


<li>Click on the right arrow at the top of the case structure box. This should change the
<li>Click on the right arrow at the top of the case structure box. This should change the
caption for the case structure to <b><i>1</i></b>. In the <b><i>Express Numeric</i></b>
caption for the case structure to '''''1'''''. In the '''''Express Numeric'''''
Window, click on the Subtract icon <b>[[Image:lab_labview_27.gif]]</b>, and click on
Window, click on the Subtract icon '''[[Image:lab_labview_27.gif]]''', and click on
a location in the middle of the case structure to place it.</li>
a location in the middle of the case structure to place it.


<li>Finally, click on the right arrow at the top of the case structure box one more time,
<li>Finally, click on the right arrow at the top of the case structure box one more time,
changing the number in the caption to <b><i>2</i></b>. In the <b><i>Express Numeric</i></b>
changing the number in the caption to '''''2'''''. In the '''''Express Numeric'''''


Window, click on the Multiply icon <b>[[Image:lab_labview_28.gif]]</b>, and click on
Window, click on the Multiply icon '''[[Image:lab_labview_28.gif]]''', and click on
a location in the middle of the case structure to place it. At this point, each case should
a location in the middle of the case structure to place it. At this point, each case should
look like the ones shown in Figure 19. You can check each case by clicking on the left and
look like the ones shown in Figure 19. You can check each case by clicking on the left and
right arrows to change the case number in the caption.</li>
right arrows to change the case number in the caption.


<p align=center>[[Image:lab_labview_29.gif]][[Image:lab_labview_30.jpg]][[Image:lab_labview_31.gif]]</p>
<p align=center>[[Image:lab_labview_29.gif]][[Image:lab_labview_30.jpg]][[Image:lab_labview_31.gif]]</p>
Line 447: Line 348:
<li>We now need to wire
<li>We now need to wire
the inputs of the calculator. First, set the case structure case to zero by
the inputs of the calculator. First, set the case structure case to zero by
clicking on the left arrow until the caption reads <b><i>0</i></b>. The triangle inside
clicking on the left arrow until the caption reads '''''0'''''. The triangle inside
should be addition, with a plus sign in the middle. Once again, click on the
should be addition, with a plus sign in the middle. Once again, click on the
"Connect Wire" icon [[Image:lab_labview_19.gif]] on the Tools
"Connect Wire" icon [[Image:lab_labview_19.gif]] on the Tools
Line 457: Line 358:
will display the output of the addition calculation in the "Numeric 3" box on
will display the output of the addition calculation in the "Numeric 3" box on
the front panel. At this point you've completed having the calculator do
the front panel. At this point you've completed having the calculator do
addition. Your back panel should look like Figure 20.</li>
addition. Your back panel should look like Figure 20.


<p align=center>[[Image:lab_labview_32.gif]]</p>
<p align=center>[[Image:lab_labview_32.gif]]</p>
Line 465: Line 366:
<li>We now have to do the
<li>We now have to do the
same thing for the other cases. Click on the right arrow next to the case
same thing for the other cases. Click on the right arrow next to the case
structure caption. This will change the caption to <b><i>1</i></b>, and the subtraction
structure caption. This will change the caption to '''''1''''', and the subtraction
triangle will be in the middle of the case structure. As before, connect the
triangle will be in the middle of the case structure. As before, connect the
first Numeric object to the top left of the triangle, the second Numeric to the
first Numeric object to the top left of the triangle, the second Numeric to the
bottom left of the triangle, and the right of the triangle to the <b><i>Numeric
bottom left of the triangle, and the right of the triangle to the '''''Numeric
3</i></b> box at the bottom of the back panel. You can see the preceding step
3''''' box at the bottom of the back panel. You can see the preceding step
for details on how to do this if you need to. Finally, click the right arrow
for details on how to do this if you need to. Finally, click the right arrow
next to the case structure caption one more time. This will change the case
next to the case structure caption one more time. This will change the case
number to 2, and the multiplication triangle will be in the middle of the case
number to 2, and the multiplication triangle will be in the middle of the case
structure. Wire the Numeric objects to the triangle as you did for the other
structure. Wire the Numeric objects to the triangle as you did for the other
two case. At this point you have established the numeric inputs and outputs.</li>
two case. At this point you have established the numeric inputs and outputs.


<li>We now to have to illuminate
<li>We now to have to illuminate
Line 480: Line 381:
the left arrow to the left of the caption of the case structure until the
the left arrow to the left of the caption of the case structure until the
caption says "0, Default". First, we're going to repeat Steps 7 and 8 to bring
caption says "0, Default". First, we're going to repeat Steps 7 and 8 to bring
up the <b><i>Express Numeric</i></b> window: On the <b><i>Functions Palette</i></b>, click
up the '''''Express Numeric''''' window: On the '''''Functions Palette''''', click
on the <b>Arith/Compare</b> icon [[Image:lab_labview_33.gif]] from the main <b>Functions
on the '''Arith/Compare''' icon [[Image:lab_labview_33.gif]] from the main '''Functions
Palette</b>. On the Arith/Compare window, click on the <b>Numeric</b> icon [[Image:lab_labview_24.gif]].
Palette'''. On the Arith/Compare window, click on the '''Numeric''' icon [[Image:lab_labview_24.gif]].
This will bring up the Express Numeric window shown in
This will bring up the Express Numeric window shown in
Figure 18. On the Express Numeric window, click the upward facing arrow. This
Figure 18. On the Express Numeric window, click the upward facing arrow. This
will bring up the Arithmetic and Comparison window shown in Figure 21.</li>
will bring up the Arithmetic and Comparison window shown in Figure 21.


<p align=center>[[Image:lab_labview_23.gif]]</p>
<p align=center>[[Image:lab_labview_23.gif]]</p>
Line 491: Line 392:
<p class=caption>Figure 21: Arithmetic and Comparison Window</p>
<p class=caption>Figure 21: Arithmetic and Comparison Window</p>


<li>On the <b><i>Arithmetic and Comparison</i></b> window, click on the Boolean icon
<li>On the '''''Arithmetic and Comparison''''' window, click on the Boolean icon
[[Image:lab_labview_36.gif]], which will bring up the Express Boolean
[[Image:lab_labview_36.gif]], which will bring up the Express Boolean
window shown in Figure 22.</li>
window shown in Figure 22.


<p align=center>[[Image:lab_labview_37.gif]]</p>
<p align=center>[[Image:lab_labview_37.gif]]</p>
Line 504: Line 405:
other two to be false. We do this by clicking on the True Constant icon [[Image:lab_labview_42.gif]], and then clicking inside the case structure on the right
other two to be false. We do this by clicking on the True Constant icon [[Image:lab_labview_42.gif]], and then clicking inside the case structure on the right
side to the left of the add indicator that's outside the case structure. We
side to the left of the add indicator that's outside the case structure. We
then select the False Constant icon [[Image:lab_labview_43.gif]] and place it inside the case structure on the right side next to the Subtract and Multiply indicators.</li>
then select the False Constant icon [[Image:lab_labview_43.gif]] and place it inside the case structure on the right side next to the Subtract and Multiply indicators.


<li>We now need to wire
<li>We now need to wire
Line 513: Line 414:
next. Then do the same thing for the other two constants and their
next. Then do the same thing for the other two constants and their
corresponding indicators. We've now completed the Add operation. We still need
corresponding indicators. We've now completed the Add operation. We still need
to do the other two operations.</li>
to do the other two operations.


<li>Click on the right arrow next to the case structure icon. The caption should
<li>Click on the right arrow next to the case structure icon. The caption should
now show <b><i>1</i></b>. We need to have the Subtract indicator illuminate for this
now show '''''1'''''. We need to have the Subtract indicator illuminate for this
case. Once again, on the <b><i>Functions
case. Once again, on the '''''Functions
Palette</i></b>, click on the <b>Arith/Compare</b>
Palette''''', click on the '''Arith/Compare'''


icon [[Image:lab_labview_33.gif]] from the main <b>Functions
icon [[Image:lab_labview_33.gif]] from the main '''Functions
Palette</b>. On the Arith/Compare window, click on the <b>Numeric</b> icon [[Image:lab_labview_24.gif]].
Palette'''. On the Arith/Compare window, click on the '''Numeric''' icon [[Image:lab_labview_24.gif]].
This will bring up the Express Numeric window shown in
This will bring up the Express Numeric window shown in
Figure 18. On the Express Numeric window, click the upward facing arrow. This
Figure 18. On the Express Numeric window, click the upward facing arrow. This
will bring up the Arithmetic and Comparison window shown in Figure 21. On the
will bring up the Arithmetic and Comparison window shown in Figure 21. On the
<b><i>Arithmetic and Comparison</i></b> window, click on the Boolean icon
'''''Arithmetic and Comparison''''' window, click on the Boolean icon
[[Image:lab_labview_36.gif]], which will bring up the Express Boolean window shown in
[[Image:lab_labview_36.gif]], which will bring up the Express Boolean window shown in
Figure 22.Click on the True Constant icon [[Image:lab_labview_42.gif]] and click inside the right side of the case
Figure 22.Click on the True Constant icon [[Image:lab_labview_42.gif]] and click inside the right side of the case
Line 534: Line 435:
connect it to the top indicator by clicking on the indicator next. Then do the
connect it to the top indicator by clicking on the indicator next. Then do the
same thing for the other two constants and their corresponding indicators.
same thing for the other two constants and their corresponding indicators.
We've now completed the Subtract operation.</li>
We've now completed the Subtract operation.


<li>We're now ready to finish the calculator. Click on the right arrow next to the case structure
<li>We're now ready to finish the calculator. Click on the right arrow next to the case structure
icon. The caption should now show <b><i>2</i></b>. We need to have the Multiplication
icon. The caption should now show '''''2'''''. We need to have the Multiplication
indicator illuminate for this case. Once again, on the <b><i>Functions Palette</i></b>, click
indicator illuminate for this case. Once again, on the '''''Functions Palette''''', click
on the <b>Arith/Compare</b> icon [[Image:lab_labview_33.gif]]. On the Arith/Compare window,
on the '''Arith/Compare''' icon [[Image:lab_labview_33.gif]]. On the Arith/Compare window,
click on the <b>Numeric</b> icon [[Image:lab_labview_24.gif]]. This will bring up the Express Numeric window shown in
click on the '''Numeric''' icon [[Image:lab_labview_24.gif]]. This will bring up the Express Numeric window shown in
Figure 18. On the Express Numeric window, click the upward facing arrow. This
Figure 18. On the Express Numeric window, click the upward facing arrow. This
will bring up the Arithmetic and Comparison window shown in Figure 21. On the
will bring up the Arithmetic and Comparison window shown in Figure 21. On the
<b><i>Arithmetic
'''''Arithmetic
and Comparison</i></b> window, click on the Boolean icon [[Image:lab_labview_36.gif]] which will bring up the Express Boolean window shown in
and Comparison''''' window, click on the Boolean icon [[Image:lab_labview_36.gif]] which will bring up the Express Boolean window shown in
Figure 22. Click on the True Constant icon [[Image:lab_labview_42.gif]] and click inside the right side of the case structure
Figure 22. Click on the True Constant icon [[Image:lab_labview_42.gif]] and click inside the right side of the case structure
to the left of the Multiplication LED. Click on the False Constant icon [[Image:lab_labview_43.gif]] and click inside the right side of the case
to the left of the Multiplication LED. Click on the False Constant icon [[Image:lab_labview_43.gif]] and click inside the right side of the case
Line 552: Line 453:
structure and connect it to the top indicator by clicking on the indicator
structure and connect it to the top indicator by clicking on the indicator
next. Then do the same thing for the other two constants and their
next. Then do the same thing for the other two constants and their
corresponding indicators. We've now completed the Multiply operation.</li>
corresponding indicators. We've now completed the Multiply operation.


<li>Before moving on, make sure that the boxes on the edges of the <b>case
<li>Before moving on, make sure that the boxes on the edges of the '''case
structure</b> are filled in. If they are not, that box has to be wired in
structure''' are filled in. If they are not, that box has to be wired in
<i>all cases</i> defined by the user.  Your back panel should look like Figure 23.</li>
''all cases'' defined by the user.  Your back panel should look like Figure 23.


<p align=center>[[Image:lab_labview_48.gif]] [[Image:lab_labview_49.jpg]]</p>
<p align=center>[[Image:lab_labview_48.gif]] [[Image:lab_labview_49.jpg]]</p>
Line 564: Line 465:
</ol>
</ol>


<li>After you have created your VI, it must be tested:</li>
<li>After you have created your VI, it must be tested:


<ol type="a">
<ol type="a">
<li>Enter different input numbers through the control icon on the front panel.</li>
<li>Enter different input numbers through the control icon on the front panel.
<li>Make sure the output is correct.</li>
<li>Make sure the output is correct.
<li>Make sure the correct LED lights up for the operation.</li>
<li>Make sure the correct LED lights up for the operation.
<li>Have your TA test your VI.</li>
<li>Have your TA test your VI.
</ol>
</ol>


Line 577: Line 478:
<p class=caption>Figure 24: Completed and Working VI</p>
<p class=caption>Figure 24: Completed and Working VI</p>


<li>Once testing is completed:</li>
<li>Once testing is completed:


<ol type="a">
<ol type="a">
<li>Print the VI you have created.</li>
<li>Print the VI you have created.
<li>Have your TA sign it.</li>
<li>Have your TA sign it.
</ol>
</ol>
</ol>
</ol>


<h3>Design 2: Heating and Cooling System</h3>
=== Design 2: Heating and Cooling System ===


<p>Build a VI that simulates a
<p>Build a VI that simulates a
Line 592: Line 493:


<ul>
<ul>
<li>The air conditioner is turned on when the temperature is above 80°F.</li>
<li>The air conditioner is turned on when the temperature is above 80°F.


<li>The heater is turned on when the temperature is less than 60°F.</li>
<li>The heater is turned on when the temperature is less than 60°F.


<li>The heater and the air conditioner are turned off when the temperature is
<li>The heater and the air conditioner are turned off when the temperature is
between 60°F and 80°F.</li>
between 60°F and 80°F.
</ul>
</ul>


<ol>
<ol>
<li>The <b><i>front panel</i></b> must contain:</li>
<li>The '''''front panel''''' must contain:


<ol type="a">
<ol type="a">
<li>Three LEDs: one to represent the AC, one to represent the heater, and one to show
<li>Three LEDs: one to represent the AC, one to represent the heater, and one to show
that the system is being operated manually.</li>
that the system is being operated manually.


<li>Three switches: one to control the AC, one to control the heater, and one to control
<li>Three switches: one to control the AC, one to control the heater, and one to control
manual or automatic operation.</li>
manual or automatic operation.


<li>A thermometer to set the temperature of the system. The thermometer should be set to 70°F.</li>
<li>A thermometer to set the temperature of the system. The thermometer should be set to 70°F.
</ol>
</ol>


<li>The <b><i>back panel</i></b> must contain:</li>
<li>The '''''back panel''''' must contain:


<ol type="a">
<ol type="a">
<li>A Boolean case statement to control the manual and automatic operation of the AC and the
<li>A Boolean case statement to control the manual and automatic operation of the AC and the
heater.</li>
heater.
</ol>
</ol>




<li>After you have created your VI, it must be tested:</li>
<li>After you have created your VI, it must be tested:


<ol type="a">
<ol type="a">
<li>Using the slide bar on the thermometer, change the system temperature. Make sure
<li>Using the slide bar on the thermometer, change the system temperature. Make sure
the AC and heat come on as directed.</li>
the AC and heat come on as directed.


<li>Test the program's manual operation by turning the manual switch on and then turning
<li>Test the program's manual operation by turning the manual switch on and then turning
the AC and heat switches on. Each of the LEDs should light up when its corresponding
the AC and heat switches on. Each of the LEDs should light up when its corresponding
switch is in the <b><i>On </i></b>position.</li>
switch is in the '''''On '''''position.


<li>Have your TA test your VI.</li>
<li>Have your TA test your VI.
</ol>
</ol>


<li>Once testing is completed:</li>
<li>Once testing is completed:


<ol>
<ol>
<li>Print the VI you have created.</li>
<li>Print the VI you have created.
<li>Have your TA sign it.</li>
<li>Have your TA sign it.
<li>Save your VI. You'll be using it again in Lab 6.</li>
<li>Save your VI. You'll be using it again in Lab 6.
</ol>
</ol>
</ol>
</ol>


<h3>Design 3: Lighting System</h3>
=== Design 3: Lighting System ===


<p>Build a VI that simulates a lighting system in a house with 4 rooms. Your design must
<p>Build a VI that simulates a lighting system in a house with 4 rooms. Your design must include 4 lights (LEDs) and at least 5 switches – one switch per light and one "master" switch which will turn all of the lights off simultaneously (think of this as a circuit breaker). Your program should also interact with real LEDs attached to a DAC board.</p>
include 4 lights (LEDs) and at least 5 switches – one switch per light and one "master" switch
which will turn all of the lights off simultaneously (think of this as a circuit breaker).
Your program should also interact with real LEDs attached to a DAC board.</p>


<ol>
<ol>
<li>The <b><i>front panel</i></b> of your program should include 5 switches and 4 virtual LEDs.</li>
<li>The '''''front panel''''' of your program should include 5 switches and 4 virtual LEDs.


<li>While there are several ways to implement the <b><i>back panel</i></b>, one suggestion
<li>While there are several ways to implement the '''''back panel''''', one suggestion is to use a separate Boolean '''''case structure''''' for each switch. This will also make it easier to interact with the LEDs attached to the DAC board.
is to use a separate Boolean <b><i>case structure</i></b> for each switch. This will also
make it easier to interact with the LEDs attached to the DAC board.</li>


<li>In order to control the LEDs attached to the DAC board, a <b><i>Port Configuration</i></b>
<li>In order to control the LEDs attached to the DAC board, a '''''DAQmx Assist''''' node is required on the back panel.  The LEDs will be connected to pins 47, 45, 43 and 41 (and pin 50 for ground).
and a <b><i>Port Write</i></b> node are required on the back panel.  The LEDs will be connected
to pins 47, 45, 43 and 41 (and pin 50 for ground).</li>


<ol type="a">
<ol type="a">
<li><b><i>Port Config</i></b>. and <b><i>Port Write</i></b> are found in the <b><i>Functions Palette</i></b>, under <b><i>Measurement I/O -&gt; Traditional DAQ -&gt; Digital I/O -&gt; Advanced Digital I/O</i></b>. (see Figures 25a-f)</li>
<li>'''''DAQmx Assistant''''' is found in the '''''Functions Palette''''', under '''''Measurement I/O -&gt; NI-DAQmx'''''. (see Figures 25a-d)


<p align=center>[[Image:lab_labview_51.gif]]</p>
<p align=center>[[Image:lab_labview_51.gif]]</p>
<p class=caption>Figure 25a: Functions Palette. Click on the pull down arrow at the bottom of the Functions Palette to see all the categories available.</p>
<p class=caption>Figure 25a: Functions Palette. Click on the pull down arrow at the bottom of the Functions Palette to see all the categories available.</p>
<p align=center>[[Image:lab_labview_52.gif]]</p>
<p align=center>[[Image:lab_labview_52.gif]]</p>
 
<p class=caption>Figure 25b: Full Functions Palette with the ''Measurement I/O'' category pointed out</p>
<p class=caption>Figure 25b: Full Functions Palette with the <i>Measurement I/O</i> category pointed out</p>
 
<p align=center>[[Image:lab_labview_53.gif]]</p>
<p align=center>[[Image:lab_labview_53.gif]]</p>
 
<p class=caption>Figure 25c: ''Measurement I/O'' category with ''DAQmx'' pointed out</p>
<p class=caption>Figure 25c: <i>Measurement I/O</i> category with <i>Data Acquisition</i> pointed out</p>
 
<p align=center>[[Image:lab_labview_54.gif]]</p>
 
<p class=caption>Figure 25d: <i>Data Acquisition</i> category with <i>Digital I/O </i>pointed out</p>
 
<p align=center>[[Image:lab_labview_55.gif]]</p>
 
<p class=caption>Figure 25e: <i>Digital I/O</i> category with <i>Advanced Digital I/O </i>pointed out</p>
 
<p align=center>[[Image:lab_labview_56.gif]]</p>
<p align=center>[[Image:lab_labview_56.gif]]</p>
<p class=caption>Figure 25d: ''DAQmx'' palette with ''DAQ Assist'' circled</p>


<p class=caption>Figure 25f: <i>Advanced Digital I/O </i>palette with<br>
<li>Once you have placed these on the '''''back panel''''', the DAQ Assistant dialog box will open. Follow Figures 26a-e to set up the DAQmx Task.
<i>Port Config</i> and <i>Port Write</i> circled</p>


<li>Once you have placed these on the <b><i>back panel</i></b>, right click
<p align=center>[[Image:lab_labview_60.gif]]</p>
on them and choose <i>View Terminals</i> (Figure 26).</li>
<p class=caption>Figure 26a: Select ''Generate Signals''</p>
<p align=center>[[Image:lab_labview_61.gif]]</p>
<p class=caption>Figure 26b: Select ''Digital Output''</p>
<p align=center>[[Image:lab_labview_62.gif]]</p>
<p class=caption>Figure 26c: Select ''Port Output''</p>
<p align=center>[[Image:lab_labview_63.gif]]</p>
<p class=caption>Figure 26d: Select ''port1''</p>
<p align=center>[[Image:lab_labview_64.gif]]</p>
<p class=caption>Figure 26e: Click ''OK''</p>


<p align=center>[[Image:lab_labview_57.gif]]</p>
<li>The '''''DAQ Assistant''''', depending on how it's set up, is used for reading or writing information from or to the DAC board. In our case, we only see the one terminal labeled ''data''.
 
<p class=caption>Figure 26: View Terminals</p>
 
<li><b><i>Port Config</i></b>. is used to set up the
DAC board for reading or writing, and consists of several terminals. We are interested in the following five:</li>


<p align=center>[[Image:lab_labview_58.gif]]</p>
<p align=center>[[Image:lab_labview_58.gif]]</p>
<p class=caption>Figure 27: Port Config</p>
<p class=caption>Figure 27: DAQ Assistant</p>
 
<ol>
<li><b><i>Device Line (integer):</i></b> This tells the VI which DAC board to use.  As stated
in the overview, the DAC board has a device number of 1, so wire a numeric constant of 1 to
the first terminal.</li>
 
<li><b><i>Channel (string):</i></b> This specifies the channel we are using on the DAC board
(see Figure 4). It can take a value of "2", "3" or "4".  Since we are using pins 41 – 47,
wire a string constant of "2" to the second terminal.</li>
 
<li><b><i>Port Width (integer):</i></b>  This determines the number of pins used by each channel.
It is a multiple of 8.  Since we are only using 4 pins, wire a numeric constant of 8 to the
third terminal.</li>
 
<li><b><i>Line Direction (integer):</i></b> This tells the DAC board whether it is writing
(-1) or reading (0).  Since we are outputting (writing) to the DAC board, wire a numeric
constant of -1 to the fourth terminal.</li>
 
<li><b><i>Task ID Output</i></b>: This specifies what exactly is being output to the DAC
board. Wire this to the Task ID Input terminal on the Port Write (see Figure 28).</li>
</ol>
<li><b><i>Port Write</i></b> is used send information to the DAC board.  It also consists
of several terminals however we are only interested in two.</li>
 
<p align=center>[[Image:lab_labview_59.gif]]</p>
 
<p class=caption>Figure 28: Port Write</p>


<ol>
<ol>
<li><b><i>Task ID Input:</i></b> this is wired to the <i>Task ID Output</i> terminal on the
<li>'''''data (integer array):''''' This determines which pins on the DAC board will be activated (in other words, which LEDs will light up).
<b><i>Port Config.</i></b></li>
<li><b><i>Pattern (integer):</i></b> This determines
which pins on the DAC board will be activated (in other words, which LEDs will
light up).</li>


<ol type="i">
<ol type="i">
<li>Each pin is represented by a number that is a power of 2 (see <i>Pattern Table</i>).
<li>Each pin is represented by a number that is a power of 2 (see ''Pattern Table''). For example, sending a value of 1 will light up the LED connected to pin 47.
For example, sending a value of 1 will light up the LED connected to pin 47.</li>


<li>To light up more than one pin at a time, add the values of each pin together and
<li>To light up more than one pin at a time, add the values of each pin together and use the sum.  For example, sending a value of 3 to the Pattern will result in the LEDs connected to pins 47 and 45 to light up.
use the sum.  For example, sending a value of 3 to the Pattern will result in the LEDs
connected to pins 47 and 45 to light up.</li>
</ol>
</ol>
</ol>
</ol>


<li>If you used separate Boolean case structures for each
<li>If you used separate Boolean case structures for each switch, then setting up the pattern for '''''DAQ Assistant''''' can be achieved as follows:
switch, then setting up the pattern for <b><i>Port Write</i></b> can be achieved as
follows:</li>


<ol>
<ol>
<li>In each Boolean case, if the switch is off, place a <b><i>numeric constant</i></b> of 0.</li>
<li>In each Boolean case, if the switch is off, place a '''''numeric constant''''' of 0.
 
<li>If the switch is on, then include a '''''numeric constant''''' of the appropriate value (''see Pattern Table'').  For example, the switch corresponding to pin 47 should have a numeric constant of 1.


<li>If the switch is on, then include a <b><i>numeric constant</i></b> of the appropriate value
<li>Once every Boolean case structure has a numeric constant in it, they must all be added togetherThis can easily be achieved using the '''''Compound Arithmetic''''' operator.
(<i>see Pattern Table</i>)For example, the switch corresponding to pin 47 should have a
numeric constant of 1.</li>


<li>Once every Boolean case structure has a numeric constant in it, they must all be added
<p>Don't forget to wire both the numeric constant in the True case and the numeric constant in the False case.</p>
together.  This can easily be achieved using the <b><i>Compound Arithmetic</i></b> operator.
The output from the <b><i>Compound Arithmetic</i></b> operator should be wired to the


<i>Pattern</i> on <b><i>Port Write</i></b>.</li>
<li>The output from the '''''Compound Arithmetic''''' operator should be wired to a '''''Build Array''''' icon. Depending on your background, you may or may not understand what an array is, but that is not important. Conceptually, think of a line of people waiting to get in to a movie theater. In our case, the movie theater is the ''data'' terminal on the '''''DAQ Assistant''''' icon and the line is the array. This movie theater doesn't care if there is one person in line or if there are a million people on line: it just wants a line. In our case there will only be one person on line or rather only one '''element''' in the '''array''': the result of the '''''Compound Arithmetic''''' operator. '''''Build Array''''' can be found in the '''''Functions Palette''''', under '''''Proramming -&gt; Array'''''. (see Figures 28a-c)
<p align=center>[[Image:lab_labview_65.gif]]</p>
<p class=caption>Figure 28a: Full Functions Palette with the ''Programming'' category pointed out</p>
<p align=center>[[Image:lab_labview_66.gif]]</p>
<p class=caption>Figure 28b: ''Programming'' category with ''Array'' pointed out</p>
<p align=center>[[Image:lab_labview_67.gif]]</p>
<p class=caption>Figure 28c: ''Array'' palette with ''Build Array'' circled</p>


<p>Don't forget to wire both the numeric constant in the True
<li>Also keep in mind that if the master switch is off, then all of the LEDs connected to the DAC board should shut off as well.
case and the numeric constant in the False case.</p>


<li>Also keep in mind that if the master switch is off, then all of the LEDs connected to
the DAC board should shut off as well.</li>
</ol>
</ol>
</ol>
</ol>
</ol>
</ol>
 
{| border="1" style="margin-left: auto; margin-right: auto"
<p class=caption>Pattern Table</p>
|+ class="caption" align="bottom"|Pattern Table
 
!colspan="9"|Pattern
<table border=1 cellspacing=0 align=center>
|-
<tr>
!
<td colspan=9>
|128||64||32||16||8||4||2||1
<p align=center>Pattern</p>
|-
  </td>
!Port!!colspan="8"|Corresponding Pin Number
</tr>
|-
<tr>
!1
<td>
|33||35||37||39||41||43||45||47
<p align=center>&nbsp;</p>
|}
  </td>
<td>
<p align=center>128</p>
 
  </td>
<td>
<p align=center>64</p>
  </td>
<td>
<p align=center>32</p>
  </td>
<td>
<p align=center>16</p>
  </td>
 
<td>
<p align=center>8</p>
  </td>
<td>
<p align=center>4</p>
  </td>
<td>
<p align=center>2</p>
  </td>
<td>
<p align=center>1</p>
 
  </td>
</tr>
<tr>
<td>
<p align=center>Channel</p>
  </td>
<td colspan=8>
<p align=center>Corresponding Pin
  Number (for Port Width of 8)</p>
  </td>
</tr>
 
<tr>
<td>
<p align=center>2</p>
  </td>
<td>
<p align=center>33</p>
  </td>
<td>
<p align=center>35</p>
  </td>
<td>
 
<p align=center>37</p>
  </td>
<td>
<p align=center>39</p>
  </td>
<td>
<p align=center>41</p>
  </td>
<td>
<p align=center>43</p>
 
  </td>
<td>
<p align=center>45</p>
  </td>
<td>
<p align=center>47</p>
  </td>
</tr>
<tr>
<td>
<p align=center>3</p>
 
  </td>
<td>
<p align=center>17</p>
  </td>
<td>
<p align=center>19</p>
  </td>
<td>
<p align=center>21</p>
  </td>
 
<td>
<p align=center>23</p>
  </td>
<td>
<p align=center>25</p>
  </td>
<td>
<p align=center>27</p>
  </td>
<td>
<p align=center>29</p>
 
  </td>
<td>
<p align=center>31</p>
  </td>
</tr>
<tr>
<td>
<p align=center>4</p>
  </td>
<td>
<p align=center>1</p>
 
  </td>
<td>
<p align=center>3</p>
  </td>
<td>
<p align=center>5</p>
  </td>
<td>
<p align=center>7</p>
  </td>
 
<td>
<p align=center>9</p>
  </td>
<td>
<p align=center>11</p>
  </td>
<td>
<p align=center>13</p>
  </td>
<td>
<p align=center>15</p>
 
  </td>
</tr>
</table>


<p>Your lab work is now complete. Please clean up your workstation. Return all unused
<p>Your lab work is now complete. Please clean up your workstation. Return all unused
materials to your TA. Refer to section <b><i>3 Your Assignment </i></b>for the
materials to your TA. Refer to section [[#3 Your Assignment]] for the
instructions you need to prepare your lab report.</p>
instructions you need to prepare your lab report.</p>


<h2>LabVIEW Digest of Common Tasks</h2>
== LabVIEW Digest of Common Tasks ==


<h3>Front Panel Controls and Indicators</h3>
=== Front Panel Controls and Indicators ===


<h4>How to get a slide control:</h4>
==== How to get a slide control: ====


<ol>
<ol>
<li>On the Controls palette, select the <b>Num Ctrls</b> icon [[Image:lab_labview_2.gif]]</li>
<li>On the Controls palette, select the '''Num Ctrls''' icon [[Image:lab_labview_2.gif]]
<li>Select Horizontal Pointer Slide</li>
<li>Select Horizontal Pointer Slide
<li>Click on the front panel to place the slide on the front panel at the location you select</li>
<li>Click on the front panel to place the slide on the front panel at the location you select
</ol>
</ol>


<h4>How to get a LED indicator:</h4>
==== How to get a LED indicator: ====


<ol>
<ol>
<li>On the Controls palette, select the <b>LEDs</b> icon [[Image:lab_labview_8.gif]].</li>
<li>On the Controls palette, select the '''LEDs''' icon [[Image:lab_labview_8.gif]].


<li>Select the <b>Round LED</b> icon from the icons shown.</li>
<li>Select the '''Round LED''' icon from the icons shown.


<li>Click on the left window to place the LED on the front panel at the location you select.</li>
<li>Click on the left window to place the LED on the front panel at the location you select.


<li>Rename the LED with a label that indicates what the LED stands for. To rename the LED,
<li>Rename the LED with a label that indicates what the LED stands for. To rename the LED,
click on the <b>Edit Text</b> icon [[Image:lab_labview_10.gif]] on the <b>Tools
click on the '''Edit Text''' icon [[Image:lab_labview_10.gif]] on the '''Tools
palette</b>. Then click on the 'Boolean' label on each LED and replace it with
palette'''. Then click on the 'Boolean' label on each LED and replace it with
the proper text.</li>
the proper text.
</ol>
</ol>
<h4>How to get a Numeric Input Control</h4>
==== How to get a Numeric Input Control ====
<ol>
<ol>
<li>On the <b>Controls palette</b>, click on the <b>Num Ctrls</b> icon. This will bring up
<li>On the '''Controls palette''', click on the '''Num Ctrls''' icon. This will bring up
the window shown in Figure 5.</li>
the window shown in Figure 5.


<li>Click on the <b>Num Ctrl</b> icon and click on the location
<li>Click on the '''Num Ctrl''' icon and click on the location
where you want to place the control.</li>
where you want to place the control.
</ol>
</ol>


<h4>How to get a Numeric Indicator Output</h4>
==== How to get a Numeric Indicator Output ====
<ol>
<ol>
<li>On the Controls palette, click on the <b>Num Inds</b> icon [[Image:lab_labview_11.gif]].
<li>On the Controls palette, click on the '''Num Inds''' icon [[Image:lab_labview_11.gif]].
This will bring up the window shown in Figure 9.</li>
This will bring up the window shown in Figure 9.


<li>Click on the <b>Num Ind</b> icon and click on the front
<li>Click on the '''Num Ind''' icon and click on the front
panel location where you want the indicator.</li>
panel location where you want the indicator.
</ol>
</ol>


<h3>Back Panel Objects</h3>
=== Back Panel Objects ===


<h4>How to define a case structure</h4>
==== How to define a case structure ====


<ol>
<ol>
<li>In the block diagram (back panel) of LabVIEW, go to the menu bar, select window,
<li>In the block diagram (back panel) of LabVIEW, go to the menu bar, select window,
and choose "Show Functions Palette", just as shown on Figure 29a. This will bring up
and choose "Show Functions Palette", just as shown on Figure 29a. This will bring up
the Functions Palette, shown in Figure 29b.</li>
the Functions Palette, shown in Figure 29b.


<p align=center>[[Image:lab_labview_15.gif]]</p>
<p align=center>[[Image:lab_labview_15.gif]]</p>
Line 984: Line 697:
<p class=caption>Figure 29b: Functions Palette</p>
<p class=caption>Figure 29b: Functions Palette</p>


<li>Clink on the <b>Exec Ctrl</b> icon. This will bring up the <b><i>Exec Ctrl</i></b> window, shown
<li>Clink on the '''Exec Ctrl''' icon. This will bring up the '''''Exec Ctrl''''' window, shown
in Figure 13.</li>
in Figure 13.


<li>Click on the <b>Case Structure</b> icon. Click on the right window to locate it on the back panel.</li>
<li>Click on the '''Case Structure''' icon. Click on the right window to locate it on the back panel.


<li>The default is two cases: 0 and 1. To add more cases, right-click anywhere on the
<li>The default is two cases: 0 and 1. To add more cases, right-click anywhere on the
<b>case structure</b> and select <b>Add Case After</b>, as shown in Figure 15.</li>
'''case structure''' and select '''Add Case After''', as shown in Figure 15.


<li>Define what happens for each case. On each side of the caption are arrows that will
<li>Define what happens for each case. On each side of the caption are arrows that will
count the case number up and down. Choose the case number you want to define and then fill in
count the case number up and down. Choose the case number you want to define and then fill in
the case structure with whatever needs to be done for this case. Make sure
the case structure with whatever needs to be done for this case. Make sure
every case is fully defined. It is very easy to forget things.</li>
every case is fully defined. It is very easy to forget things.


</ol>
</ol>


<h4>How to define an arithmetic operation</h4>
==== How to define an arithmetic operation ====


<ol>
<ol>
<li>On the <b><i>Functions Palette</i></b>, click on the <b>Arith/Compare</b>
<li>On the '''''Functions Palette''''', click on the '''Arith/Compare'''
icon [[Image:lab_labview_33.gif]]. will bring up the Arith/Compare window shown
icon [[Image:lab_labview_33.gif]]. will bring up the Arith/Compare window shown
in Figure 17.</li>
in Figure 17.


<li>On the Arith/Compare window, click on the <b>Numeric</b> icon [[Image:lab_labview_24.gif]].
<li>On the Arith/Compare window, click on the '''Numeric''' icon [[Image:lab_labview_24.gif]].
This will bring up the <b><i>Express Numeric</i></b> window shown in Figure 18.</li>
This will bring up the '''''Express Numeric''''' window shown in Figure 18.


<li>In the <b><i>Express Numeric</i></b> Window, click on the icon for the arithmetic
<li>In the '''''Express Numeric''''' Window, click on the icon for the arithmetic
operation you want. Click on the front panel location where the icon goes.</li>
operation you want. Click on the front panel location where the icon goes.
</ol>
</ol>


<h4>How to define Boolean constants (usually used to illuminate LEDs)</h4>
==== How to define Boolean constants (usually used to illuminate LEDs) ====


<ol>
<ol>
<li>On the <b><i>Functions Palette</i></b>, click on the <b>Arith/Compare</b>
<li>On the '''''Functions Palette''''', click on the '''Arith/Compare'''


icon [[Image:lab_labview_33.gif]]. This will bring up the
icon [[Image:lab_labview_33.gif]]. This will bring up the
<b><i>Arith/Compare</i></b> window.</li>
'''''Arith/Compare''''' window.


<li>On the <b><i>Arith/Compare</i></b> window, click on the <b>Numeric</b> icon
<li>On the '''''Arith/Compare''''' window, click on the '''Numeric''' icon
[[Image:lab_labview_24.gif]]. This will bring up the <b><i>Express Numeric</i></b> window
[[Image:lab_labview_24.gif]]. This will bring up the '''''Express Numeric''''' window
shown in Figure 18. On the <b><i>Express Numeric</i></b> window, click the
shown in Figure 18. On the '''''Express Numeric''''' window, click the
upward facing arrow. This will bring up the <b><i>Arithmetic and Comparison</i></b>
upward facing arrow. This will bring up the '''''Arithmetic and Comparison'''''
window shown in Figure 21.</li>
window shown in Figure 21.


<li>On the <b><i>Arithmetic and Comparison</i></b> window, click on the Boolean icon
<li>On the '''''Arithmetic and Comparison''''' window, click on the Boolean icon
[[Image:lab_labview_36.gif]], which will bring up the <b><i>Express Boolean</i></b>
[[Image:lab_labview_36.gif]], which will bring up the '''''Express Boolean'''''
window shown in Figure 22.</li>
window shown in Figure 22.


<li>Click on the True Constant icon [[Image:lab_labview_42.gif]] or False Constant
<li>Click on the True Constant icon [[Image:lab_labview_42.gif]] or False Constant
icon [[Image:lab_labview_43.gif]], and then clicking the location of the constant
icon [[Image:lab_labview_43.gif]], and then clicking the location of the constant
on the back panel.</li>
on the back panel.


</ol>
</ol>


<h4>How to wire things</h4>
==== How to wire things ====
<ol>
<ol>
<li>Objects have inputs on their left side and outputs on their right side. You always
<li>Objects have inputs on their left side and outputs on their right side. You always
wire the output (right side) of one object to the input (left side) of another object.</li>
wire the output (right side) of one object to the input (left side) of another object.


<li>On the Tools Palette, chose the "Connect Wire" icon [[Image:lab_labview_19.gif]].</li>
<li>On the Tools Palette, chose the "Connect Wire" icon [[Image:lab_labview_19.gif]].


<li>Click the object output that you want to wire from. Click the object input you want to
<li>Click the object output that you want to wire from. Click the object input you want to
wire to. The first object's output is now connected to the second object's input.</li>
wire to. The first object's output is now connected to the second object's input.
</ol>
</ol>


<h2>Footnotes</h2>
== Footnotes ==


<p><sup>1</sup> <i>Introduction to LabVIEW, Six-Hour Course </i>[Courseware]. (June 2003) Austin, TX: Worldwide
<p><sup>1</sup> ''Introduction to LabVIEW, Six-Hour Course ''[Courseware]. (June 2003) Austin, TX: Worldwide
Technical Support and Product Information, National Instruments Corporation</p>
Technical Support and Product Information, National Instruments Corporation</p>


[[Main_Page | Return to Table of Contents]]
[[Main_Page | Return to Table of Contents]]

Revision as of 01:37, 7 July 2009

1 OBJECTIVES

The experimental objective of this lab is to design three systems using LabVIEW:

  1. A digital calculator
  2. A lighting system for a building
  3. A thermal control system that automatically turns on heating and cooling equipment

Building these systems allows us to investigate the potential for using simulated instruments in the laboratory. These programs will let you to obtain data from outside the computer and incorporate it into your program design. In contrast to the more common text-based languages, LabVIEW uses a graphical programming language. You will learn the logic of graphical programming during the course of this lab.

2 OVERVIEW

Adapted from Introduction to LabVIEW, Six-Hour Course.1

LabVIEW is a development environment for creating graphical programs, called virtual instruments (VIs), to simulate actual laboratory instruments. A VI consists of two parts: a front panel and a back panel. The front panel allows the user to interact with the VI by displaying output and allowing the user to supply the program with input. The back panel consists of the actual code used by the VI to obtain input from the front panel, operate on the input, and display the results.

The front panel is built using controls and indicators. Controls are inputs – they allow a user to supply information to the VI. Indicators are outputs – they indicate, or display, the results based on the inputs given to the VI. Controls consist of switches, knobs, dials, buttons, etc. and indicators consist of meters, gauges, LEDs, displays, etc. These are located on the Controls palette and can be placed on the front panel.

The back panel, which is a block diagram, contains the graphical source code. All of the objects placed on the front panel will appear on the back panel as terminals. The back panel also contains structures and functions which perform operations on controls and supply data to indicators. The structures and functions are found on the Functions palette and can be placed on the back panel. Collectively controls, indicators, structures and functions will be referred to as nodes. Nodes are connected to one another using wires – e.g. two controls and an indicator can be wired to the addition function so that the indicator displays the sum of the two controls.

In any programming language, structures allow you to create conditions. In LabVIEW you can access structures by opening the Functions palette and selecting Structures. The following are some examples of structures:

  1. The While Loop is similar to do loop or while in text-based programming languages. It executes its subdiagram (or subroutine) until it receives a false value.
  2. The For Loop executes a subdiagram a set number of times, specified by the value in the count terminal.
  3. The Case Structure is similar to if/else, switch/case or match/with in text-based programming languages. It contains multiple subdiagrams – one for each possible value of the input to the case structure (the control wired to the '?').

The data acquisition and control (DAC) board is LabVIEW's physical interface with the outside world. To send or receive data through the board, you must specify two parameters: the device number and the channel. For our purposes, the device number is 1. When there is more than one DAC board attached to a computer, the device number specifies which DAC board to use. The channel input specifies which channel on the DAC board to read. There is one DAC board for analog data and another digital data. The analog board uses pin 1 for ground and pins 3-18 for analog I/O (input/output). The digital board uses even-numbered pins for ground and odd-numbered pins 1-47 for digital I/O. Pin 49 is a constant output of +5 VDC. For convenience, always use pin 50 as your ground.'

Some useful key shortcuts to keep in mind when working in the LabVIEW environment:

  1. CTRL+H: Show/hide context help.
  2. CTRL+B: Clean up broken wiring.
  3. CTRL+E: Toggle between front/back panels.
  4. CTRL+Z: Undo last action.

3 YOUR ASSIGNMENT

Individual Lab Report

A Zip file including all LabVIEW programs (.vi) needs to be submitted to the EG1004 Web site. If you don't know how to make a zip file, read the page How to Compress Your Files in the Instructional Presentations section. Lab report

Follow the lab report guidelines laid out in the page called Specifications for Writing Your Lab Reports in the Technical Communication section of this manual. As you write, the following discussion points should be addressed in the appropriate section of your lab report:

  • Explain what LabVIEW is and describe how it helps engineers and scientists with their work.
  • Explain what a VI is.
  • What are controls and indicators?
  • What are structures and functions?
  • What is the Front Panel used for? The Back Panel?
  • Discuss what a DAC board is.
  • Were the objectives of the experiment achieved? If not why?
  • Describe the advantages and disadvantages of using LabVIEW.
  • Suggest some improvements of how the lab could have be conducted better.

IMPORTANT: Because the procedural elements in this lab are extensive, please include only the procedures you employed to build Design 2, the Heating and Cooling System in your lab report. You do not need to document the procedures you followed to build Design 1: the Simple Calculator, or Design 3: Lighting System.

Note: You still need to include ALL the designs in the other sections of your lab report.

Remember, your job in this lab is not to report whether the Heating and Cooling system worked. Your job is to report on what you did to design it. Please consider the value of LabVIEW as a substitute for actual instruments and systems. Your Data/Observations section should include information on ease of use, the LabVIEW user interface, and the help options available to you.

In describing the design of all the systems, you should show screen shots in your lab reports showing the Virtual Instruments you designed. If you don't know how to take a screen shot and include it in your report, look at the Online Manual under "Instructional Web Pages" for instructions on how to take a screen shot and use it.

Team PowerPoint Presentation

Follow the presentation guidelines laid out in the page called EG1004 Lab Presentation Format in the Introduction to Technical Presentations section of this manual. When you are preparing your presentation, consider the following points:

  • What is the importance of LabVIEW?
  • Discuss some ways LabVIEW can be used in industry

4 MATERIALS AND EQUIPMENT

  • Lab PC
  • LabVIEW Software
  • Data acquisition and control (DAC) board
  • Breadboard
  • Several LEDs

5 PROCEDURE

  1. Open LabVIEW, select New and Blank VI.
  2. Click on Window and select Tile Left & Right to set the front panel (left window) and back panel (right window) side by side. This will make them visible at the same time, making it easier to work.
  3. On the right window, pull down the View menu, select Show Tools Palette.
  4. On the left window, pull down the Window menu again, select Show Controls Palette. At this point your screen should look like Figure 3. Note the Controls Palette and the Tools Palette, and their icons.

Lab labview 1.gif

Figure 3: LabVIEW workspace

Remember: You are required to take notes. Experimental details are easily forgotten unless written down. EG Standard Note Paper can be downloaded and printed from the EG website the EG1004 Web site. Use your lab notes to write the Procedure section of your lab report. At the end of each lab your TA will scan your lab notes and upload them to the EG1004 course section on MyPoly. You must attach your lab notes at the end of your lab report (use the "Insert Object" command in MS Word after your Conclusion). Keeping careful notes is an essential component of all scientific practice.

For help with the operation of any LabVIEW icon, select Help from the main menu bar, choose Show Context Help, and click the icon whose operation you don't understand. It will be explained in the open window.

The overall approach for each of these projects is to place items on the front panel that the user will see and interact with. The corresponding items on the back panel will then actually make the device work, and how you "wire" them together will determine how your device works.

Note: We'll be doing some tasks a number of times, where you'll be clicking on the same icons to bring up various components. To help you , we've included a LabVIEW digest at the end of this lab for your reference to help you navigate.

Design 1: Simple Calculator

Create a program that simulates a basic calculator. Your calculator will be able to add, subtract, and multiply.

  1. The front panel must contain:
    1. One slide to control the arithmetic operation to be performed. Here's how to do it:
      1. Select the Num Ctrls icon Lab labview 2.gif on the Controls Palette (see Figure 4). This will bring up the window shown in Figure 5

        Lab labview 3.gif

        Figure 4: Controls Palette

        Lab labview 5.gif

        Figure 5: Numerical Controls window

      2. Then select Horizontal Pointer Slide from the icons shown. Click on the left window to place the slide on the front panel at the location you select.

        Note: If you don't like where you put the slide, click on it and hold down the left mouse button to "drag" the control where you want it. When it's at the right place, let go of the left mouse button. This will work for everything you do on both windows (front and back panels).

        Note: As you place items on the front panel (left window), symbols corresponding to each item will appear on the back panel (right window). After we complete the front panel, we'll wire the items on the back panel to make the calculator work.

      3. Click on the number 10 and change it to 2. Now the slide control will look like Figure 6.

        Lab labview 6.gif

        Figure 6: Slide control with range changed from 10 to 2

      4. Right click on the slide to bring up a pull down menu. Select Representation, and choose the I32 icon. Figure 7 shows what the pull down menus look like, and the I32 icon. This completes the slide control on the front panel.

        Lab labview 7.gif

        Figure 7: I32 Representation pull down menus

    2. Three Boolean indicators to specify the operation selected. Here's how to do it:
      1. On the Controls palette, select the LEDs icon Lab labview 8.gif. This will bring up the window shown in Figure 8.

        Lab labview 9.gif

        Figure 8: LEDs Window

      2. Select the Round LED icon from the icons shown. Click on the left window to place the LED on the front panel at the location youh select. The best place to put it is centered under the slide. Do this two more times, putting the lights on each side of the first light you made, so you have a total of three lights in a row under the slide.
      3. Rename the three LEDs to correspond to the functions the calculator will be performing: add, subtract, and multiply. To rename each LED, click on the Edit Text icon Lab labview 10.gif on the Tools palette. Then click on the 'Boolean' label on each LED and replace it with the proper text: "add" for the left light, "subtract" for the center light, and "multiply" for the right light.
    3. Two numeric controls to allow the user to input data from the keyboard. Here's how to do it:
      1. On the Controls palette, click on the Num Ctrls icon. This will bring up the window shown in Figure 5 again.
      2. Click on the Num Ctrl icon and click on the left window to the left of the slide to place a numeric control there. This will look like a window you can enter data in. Click the Num Ctrl icon again, and place another numeric control on the right side of the slide.
    4. A numeric indicator to display the output. Here's how to do it:
      1. On the Controls palette, click on the Num Inds icon Lab labview 11.gif. This will bring up the window shown in Figure 9.

        Lab labview 12.gif

        Figure 9: Num Inds Window

      2. Click on the Num Ind icon and click on the left window centered below the three lights. This numeric indicator will be the answer from the calculator.

        Note: This numeric indicator, used for output, is a different type of object from the two numeric controls (which are for input) that you constructed earlier in Item c.

      3. You are now finished constructing the front panel. The finished Front Panel should look like Figure 10:

    Lab labview 13.gif

    Figure 10: Finished Front Panel

    As we stated earlier, on the back panel there are icons corresponding to everything you put on the front panel. We will now arrange them, add additional objects, and connect them together to make the calculator work.

  2. The back panel must contain:
    1. At least one case statement to control the arithmetic operations. This case statement will be the heart of the calculator. Here's how you do it:
      1. Drag all the Boolean nodes to the right edge of the window and all numeric controls and indicator to the bottom of the window. Place the slide node on the left edge of the window. This will leave a large area in the middle that you will fill in at the next few steps. Your back panel should now look like Figure 11.

        Lab labview 14.gif

        Figure 11: Rearranged Back Panel

      2. In the block diagram (back panel) of LabVIEW, go to the menu bar, select View, and choose "Functions Palette", just as shown on Figure 12a. This will bring up the Functions Palette, shown in Figure 12b.

        Lab labview 15.gif

        Figure 12a: How to bring up the Functions Palette

        Lab labview 16.gif

        Figure 12b: Functions Palette

      3. Click on the Exec Ctrl icon Lab labview 17.gif. This will bring up the Exec Ctrl window, shown in Figure 13.

        Lab labview 18.gif

        Figure 13: Exec Ctrl Window

      4. Click on the Case Structure icon. Click on the right window to locate it on the back panel. Be careful, it's a very large object, and will have many connections. Your best strategy is to locate it in the middle of the panel. Note that at the top of the object there a caption box with the number 1 in it. On each side of the caption box are arrows pointing to the left and right. Note also the question mark on the left side of the case structure object. This is the input to the case structure.
      5. We will now start connecting things. First, we need to access the proper tool. On the Tools Palette, chose the "Connect Wire" icon Lab labview 19.gif. We'll now connect the slide to the case structure. Connect the slide to the case structure by clicking on the slide object, and then on the question mark on the left side of the case structure. Your back panel should now look like Figure 14.

        Lab labview 20.jpg

        Figure 14: Back Panel Slide to Case Structure Connection

      6. When the case statement is created, it only has two cases. Since you have three operations for the calculator, you need to make another case. To add the third case operation, right-click anywhere on the case structure and select Add Case After, as shown in Figure 15.

        Lab labview 21.gif

        Figure 15: Adding Another Case

      7. Now we'll add the mathematical operations that the calculator should perform for each case. On the Functions Palette, click on the Arith/Compare icon Lab labview 33.gif' from the main Functions Palette. This will bring up the Arith/Compare window shown in Figure 17.

        Lab labview 23.gif

        Figure 17: Arith/Compare Window

      8. On the Arith/Compare window, click on the Numeric icon Lab labview 24.gif. This will bring up the Express Numeric window shown in Figure 18.

        Lab labview 25.gif

        Figure 18: Express Numeric Window

      9. Click on the left arrow at the top of the case structure box. This should change the caption for the case structure to 0. In the Express Numeric Window, click on the Add icon Lab labview 26.gif, and click on a location in the middle of the case structure box to place it.
      10. Click on the right arrow at the top of the case structure box. This should change the caption for the case structure to 1. In the Express Numeric Window, click on the Subtract icon Lab labview 27.gif, and click on a location in the middle of the case structure to place it.
      11. Finally, click on the right arrow at the top of the case structure box one more time, changing the number in the caption to 2. In the Express Numeric Window, click on the Multiply icon Lab labview 28.gif, and click on a location in the middle of the case structure to place it. At this point, each case should look like the ones shown in Figure 19. You can check each case by clicking on the left and right arrows to change the case number in the caption.

        Lab labview 29.gifLab labview 30.jpgLab labview 31.gif

        Figure 19: Case Structure Cases

      12. We now need to wire the inputs of the calculator. First, set the case structure case to zero by clicking on the left arrow until the caption reads 0. The triangle inside should be addition, with a plus sign in the middle. Once again, click on the "Connect Wire" icon Lab labview 19.gif on the Tools Palette. Click on the leftmost Numeric icon, and click on the top left side of the operation triangle to wire the first numeric input to the input of the addition operation. Next, click on the second numeric icon, and on the left bottom of the addition triangle, establishing the second input. Finally, click on the right side of the triangle, and click on the third Numeric icon. This will display the output of the addition calculation in the "Numeric 3" box on the front panel. At this point you've completed having the calculator do addition. Your back panel should look like Figure 20.

        Lab labview 32.gif

        Figure 20: Completed Back Panel for Addition

      13. We now have to do the same thing for the other cases. Click on the right arrow next to the case structure caption. This will change the caption to 1, and the subtraction triangle will be in the middle of the case structure. As before, connect the first Numeric object to the top left of the triangle, the second Numeric to the bottom left of the triangle, and the right of the triangle to the Numeric 3 box at the bottom of the back panel. You can see the preceding step for details on how to do this if you need to. Finally, click the right arrow next to the case structure caption one more time. This will change the case number to 2, and the multiplication triangle will be in the middle of the case structure. Wire the Numeric objects to the triangle as you did for the other two case. At this point you have established the numeric inputs and outputs.
      14. We now to have to illuminate the proper LED on the front panel corresponding to each operation. First, click the left arrow to the left of the caption of the case structure until the caption says "0, Default". First, we're going to repeat Steps 7 and 8 to bring up the Express Numeric window: On the Functions Palette, click on the Arith/Compare icon Lab labview 33.gif from the main Functions Palette. On the Arith/Compare window, click on the Numeric icon Lab labview 24.gif. This will bring up the Express Numeric window shown in Figure 18. On the Express Numeric window, click the upward facing arrow. This will bring up the Arithmetic and Comparison window shown in Figure 21.

        Lab labview 23.gif

        Figure 21: Arithmetic and Comparison Window

      15. On the Arithmetic and Comparison window, click on the Boolean icon Lab labview 36.gif, which will bring up the Express Boolean window shown in Figure 22.

        Lab labview 37.gif

        Figure 22: Express Boolean Window

      16. We are now going to put three Boolean constants into the case structure. Since this is case 0, which corresponds to add, we want to have the add indicator to be true, and the other two to be false. We do this by clicking on the True Constant icon Lab labview 42.gif, and then clicking inside the case structure on the right side to the left of the add indicator that's outside the case structure. We then select the False Constant icon Lab labview 43.gif and place it inside the case structure on the right side next to the Subtract and Multiply indicators.
      17. We now need to wire the constants to their respective indicators. Once again, click on the Connect Wire icon Lab labview 19.gif on the Tools Palette. Click on the right side of the top constant inside the case structure and connect it to the top indicator by clicking on the indicator next. Then do the same thing for the other two constants and their corresponding indicators. We've now completed the Add operation. We still need to do the other two operations.
      18. Click on the right arrow next to the case structure icon. The caption should now show 1. We need to have the Subtract indicator illuminate for this case. Once again, on the Functions Palette, click on the Arith/Compare' icon Lab labview 33.gif from the main Functions Palette. On the Arith/Compare window, click on the Numeric icon Lab labview 24.gif. This will bring up the Express Numeric window shown in Figure 18. On the Express Numeric window, click the upward facing arrow. This will bring up the Arithmetic and Comparison window shown in Figure 21. On the Arithmetic and Comparison window, click on the Boolean icon Lab labview 36.gif, which will bring up the Express Boolean window shown in Figure 22.Click on the True Constant icon Lab labview 42.gif and click inside the right side of the case structure to the left of the Subtract LED. Click on the False Constant icon Lab labview 43.gif and click inside the right side of the case structure to the left of the Add LED, and again to the left of the Multiply LED. Click on the Connect Wire icon Lab labview 19.gif on the Tools Palette. Click on the right side of the top constant inside the case structure and connect it to the top indicator by clicking on the indicator next. Then do the same thing for the other two constants and their corresponding indicators. We've now completed the Subtract operation.
      19. We're now ready to finish the calculator. Click on the right arrow next to the case structure icon. The caption should now show 2. We need to have the Multiplication indicator illuminate for this case. Once again, on the Functions Palette, click on the Arith/Compare icon Lab labview 33.gif. On the Arith/Compare window, click on the Numeric icon Lab labview 24.gif. This will bring up the Express Numeric window shown in Figure 18. On the Express Numeric window, click the upward facing arrow. This will bring up the Arithmetic and Comparison window shown in Figure 21. On the Arithmetic and Comparison window, click on the Boolean icon Lab labview 36.gif which will bring up the Express Boolean window shown in Figure 22. Click on the True Constant icon Lab labview 42.gif and click inside the right side of the case structure to the left of the Multiplication LED. Click on the False Constant icon Lab labview 43.gif and click inside the right side of the case structure to the left of the Add LED, and again to the left of the Subtraction LED. Click on the Connect Wire icon Lab labview 19.gif on the Tools Palette. Click on the right side of the top constant inside the case structure and connect it to the top indicator by clicking on the indicator next. Then do the same thing for the other two constants and their corresponding indicators. We've now completed the Multiply operation.
      20. Before moving on, make sure that the boxes on the edges of the case structure are filled in. If they are not, that box has to be wired in all cases defined by the user. Your back panel should look like Figure 23.

        Lab labview 48.gif Lab labview 49.jpg

        Figure 23: Completed Calculator Back Panel

  3. After you have created your VI, it must be tested:
    1. Enter different input numbers through the control icon on the front panel.
    2. Make sure the output is correct.
    3. Make sure the correct LED lights up for the operation.
    4. Have your TA test your VI.

    Lab labview 50.gif

    Figure 24: Completed and Working VI

  4. Once testing is completed:
    1. Print the VI you have created.
    2. Have your TA sign it.

Design 2: Heating and Cooling System

Build a VI that simulates a heating and cooling system. Your system must be controlled either manually or automatically. Design your VI so that:

  • The air conditioner is turned on when the temperature is above 80°F.
  • The heater is turned on when the temperature is less than 60°F.
  • The heater and the air conditioner are turned off when the temperature is between 60°F and 80°F.
  1. The front panel must contain:
    1. Three LEDs: one to represent the AC, one to represent the heater, and one to show that the system is being operated manually.
    2. Three switches: one to control the AC, one to control the heater, and one to control manual or automatic operation.
    3. A thermometer to set the temperature of the system. The thermometer should be set to 70°F.
  2. The back panel must contain:
    1. A Boolean case statement to control the manual and automatic operation of the AC and the heater.


  3. After you have created your VI, it must be tested:
    1. Using the slide bar on the thermometer, change the system temperature. Make sure the AC and heat come on as directed.
    2. Test the program's manual operation by turning the manual switch on and then turning the AC and heat switches on. Each of the LEDs should light up when its corresponding switch is in the On position.
    3. Have your TA test your VI.
  4. Once testing is completed:
    1. Print the VI you have created.
    2. Have your TA sign it.
    3. Save your VI. You'll be using it again in Lab 6.

Design 3: Lighting System

Build a VI that simulates a lighting system in a house with 4 rooms. Your design must include 4 lights (LEDs) and at least 5 switches – one switch per light and one "master" switch which will turn all of the lights off simultaneously (think of this as a circuit breaker). Your program should also interact with real LEDs attached to a DAC board.

  1. The front panel of your program should include 5 switches and 4 virtual LEDs.
  2. While there are several ways to implement the back panel, one suggestion is to use a separate Boolean case structure for each switch. This will also make it easier to interact with the LEDs attached to the DAC board.
  3. In order to control the LEDs attached to the DAC board, a DAQmx Assist node is required on the back panel. The LEDs will be connected to pins 47, 45, 43 and 41 (and pin 50 for ground).
    1. DAQmx Assistant is found in the Functions Palette, under Measurement I/O -> NI-DAQmx. (see Figures 25a-d)

      Lab labview 51.gif

      Figure 25a: Functions Palette. Click on the pull down arrow at the bottom of the Functions Palette to see all the categories available.

      Lab labview 52.gif

      Figure 25b: Full Functions Palette with the Measurement I/O category pointed out

      Lab labview 53.gif

      Figure 25c: Measurement I/O category with DAQmx pointed out

      Lab labview 56.gif

      Figure 25d: DAQmx palette with DAQ Assist circled

    2. Once you have placed these on the back panel, the DAQ Assistant dialog box will open. Follow Figures 26a-e to set up the DAQmx Task.

      File:Lab labview 60.gif

      Figure 26a: Select Generate Signals

      File:Lab labview 61.gif

      Figure 26b: Select Digital Output

      File:Lab labview 62.gif

      Figure 26c: Select Port Output

      File:Lab labview 63.gif

      Figure 26d: Select port1

      File:Lab labview 64.gif

      Figure 26e: Click OK

    3. The DAQ Assistant, depending on how it's set up, is used for reading or writing information from or to the DAC board. In our case, we only see the one terminal labeled data.

      Lab labview 58.gif

      Figure 27: DAQ Assistant

      1. data (integer array): This determines which pins on the DAC board will be activated (in other words, which LEDs will light up).
        1. Each pin is represented by a number that is a power of 2 (see Pattern Table). For example, sending a value of 1 will light up the LED connected to pin 47.
        2. To light up more than one pin at a time, add the values of each pin together and use the sum. For example, sending a value of 3 to the Pattern will result in the LEDs connected to pins 47 and 45 to light up.
    4. If you used separate Boolean case structures for each switch, then setting up the pattern for DAQ Assistant can be achieved as follows:
      1. In each Boolean case, if the switch is off, place a numeric constant of 0.
      2. If the switch is on, then include a numeric constant of the appropriate value (see Pattern Table). For example, the switch corresponding to pin 47 should have a numeric constant of 1.
      3. Once every Boolean case structure has a numeric constant in it, they must all be added together. This can easily be achieved using the Compound Arithmetic operator.

        Don't forget to wire both the numeric constant in the True case and the numeric constant in the False case.

      4. The output from the Compound Arithmetic operator should be wired to a Build Array icon. Depending on your background, you may or may not understand what an array is, but that is not important. Conceptually, think of a line of people waiting to get in to a movie theater. In our case, the movie theater is the data terminal on the DAQ Assistant icon and the line is the array. This movie theater doesn't care if there is one person in line or if there are a million people on line: it just wants a line. In our case there will only be one person on line or rather only one element in the array: the result of the Compound Arithmetic operator. Build Array can be found in the Functions Palette, under Proramming -> Array. (see Figures 28a-c)

        File:Lab labview 65.gif

        Figure 28a: Full Functions Palette with the Programming category pointed out

        File:Lab labview 66.gif

        Figure 28b: Programming category with Array pointed out

        File:Lab labview 67.gif

        Figure 28c: Array palette with Build Array circled

      5. Also keep in mind that if the master switch is off, then all of the LEDs connected to the DAC board should shut off as well.
Pattern Table
Pattern
128 64 32 16 8 4 2 1
Port Corresponding Pin Number
1 33 35 37 39 41 43 45 47

Your lab work is now complete. Please clean up your workstation. Return all unused materials to your TA. Refer to section #3 Your Assignment for the instructions you need to prepare your lab report.

LabVIEW Digest of Common Tasks

Front Panel Controls and Indicators

How to get a slide control:

  1. On the Controls palette, select the Num Ctrls icon Lab labview 2.gif
  2. Select Horizontal Pointer Slide
  3. Click on the front panel to place the slide on the front panel at the location you select

How to get a LED indicator:

  1. On the Controls palette, select the LEDs icon Lab labview 8.gif.
  2. Select the Round LED icon from the icons shown.
  3. Click on the left window to place the LED on the front panel at the location you select.
  4. Rename the LED with a label that indicates what the LED stands for. To rename the LED, click on the Edit Text icon Lab labview 10.gif on the Tools palette. Then click on the 'Boolean' label on each LED and replace it with the proper text.

How to get a Numeric Input Control

  1. On the Controls palette, click on the Num Ctrls icon. This will bring up the window shown in Figure 5.
  2. Click on the Num Ctrl icon and click on the location where you want to place the control.

How to get a Numeric Indicator Output

  1. On the Controls palette, click on the Num Inds icon Lab labview 11.gif. This will bring up the window shown in Figure 9.
  2. Click on the Num Ind icon and click on the front panel location where you want the indicator.

Back Panel Objects

How to define a case structure

  1. In the block diagram (back panel) of LabVIEW, go to the menu bar, select window, and choose "Show Functions Palette", just as shown on Figure 29a. This will bring up the Functions Palette, shown in Figure 29b.

    Lab labview 15.gif

    Figure 29a: How to bring up the Functions Palette

    Lab labview 51.gif

    Figure 29b: Functions Palette

  2. Clink on the Exec Ctrl icon. This will bring up the Exec Ctrl window, shown in Figure 13.
  3. Click on the Case Structure icon. Click on the right window to locate it on the back panel.
  4. The default is two cases: 0 and 1. To add more cases, right-click anywhere on the case structure and select Add Case After, as shown in Figure 15.
  5. Define what happens for each case. On each side of the caption are arrows that will count the case number up and down. Choose the case number you want to define and then fill in the case structure with whatever needs to be done for this case. Make sure every case is fully defined. It is very easy to forget things.

How to define an arithmetic operation

  1. On the Functions Palette, click on the Arith/Compare icon Lab labview 33.gif. will bring up the Arith/Compare window shown in Figure 17.
  2. On the Arith/Compare window, click on the Numeric icon Lab labview 24.gif. This will bring up the Express Numeric window shown in Figure 18.
  3. In the Express Numeric Window, click on the icon for the arithmetic operation you want. Click on the front panel location where the icon goes.

How to define Boolean constants (usually used to illuminate LEDs)

  1. On the Functions Palette, click on the Arith/Compare icon Lab labview 33.gif. This will bring up the Arith/Compare window.
  2. On the Arith/Compare window, click on the Numeric icon Lab labview 24.gif. This will bring up the Express Numeric window shown in Figure 18. On the Express Numeric window, click the upward facing arrow. This will bring up the Arithmetic and Comparison window shown in Figure 21.
  3. On the Arithmetic and Comparison window, click on the Boolean icon Lab labview 36.gif, which will bring up the Express Boolean window shown in Figure 22.
  4. Click on the True Constant icon Lab labview 42.gif or False Constant icon Lab labview 43.gif, and then clicking the location of the constant on the back panel.

How to wire things

  1. Objects have inputs on their left side and outputs on their right side. You always wire the output (right side) of one object to the input (left side) of another object.
  2. On the Tools Palette, chose the "Connect Wire" icon Lab labview 19.gif.
  3. Click the object output that you want to wire from. Click the object input you want to wire to. The first object's output is now connected to the second object's input.

Footnotes

1 Introduction to LabVIEW, Six-Hour Course [Courseware]. (June 2003) Austin, TX: Worldwide Technical Support and Product Information, National Instruments Corporation

Return to Table of Contents