Difference between revisions of "Introduction to LabVIEW"

From EG1004 Lab Manual
Jump to: navigation, search
(1003 --> 1004)
 
(123 intermediate revisions by 10 users not shown)
Line 1: Line 1:
<h1 align=center>EG1004 Lab 5: Introduction to LabVIEW</h1>
= Objective =


<h2>1 OBJECTIVES</h2>
The experimental objective of this lab is to use LabVIEW to design a heating and cooling system and a lighting system and to test both systems. Building these systems will demonstrate the potential for using simulated instruments in a laboratory. These programs will also obtain data from outside the computer and incorporate it into a program design.


<p>The experimental objective of this lab is to design three systems using LabVIEW:</p>
= Overview =
<ol>
<!--''Adapted from Introduction to LabVIEW, Six-Hour Course.<ref name="one">''Introduction to LabVIEW, Six-Hour Course ''[Courseware]. (June 2003) Austin, TX: Worldwide Technical Support and Product Information, National Instruments Corporation</ref>''-->


<li>A digital calculator</li>
The <b>Laboratory Virtual Instrument Engineering Workbench (LabVIEW)</b> is a development environment designed by National Instruments that creates graphic-based programs called virtual instruments (VIs) that simulate actual laboratory instruments. A VI consists of two parts: a front panel and a back panel (Figure 1). The <b>front panel</b> allows the user to interact with the VI by displaying outputs and allowing the user to supply the program with inputs. The <b>back panel</b> consists of the code used by the VI to obtain inputs from the front panel, operate on the inputs, and display the results.
<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
[[Image:Lab 7 Figure 1.jpg|500px|thumb|center|Figure 1: Front Panel (Left) and Back Panel (Right)]]
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>
The front panel is built using controls and indicators. <b>Controls</b> are inputs that allow a user to supply information to the VI. <b>Indicators</b> are outputs that display the results based on the inputs given to the VI. Controls can be switches, knobs, dials, and buttons. Indicators can be meters, gauges, LEDs, and displays. These are located on the Controls palette and are placed on the front panel (Figure 2).


<p><i>Adapted from Introduction to LabVIEW, Six-Hour Course.<sup>1</sup></i></p>
[[Image:Lab 7 Figure 2.jpg|225px|thumb|center|Figure 2: Controls Palette]]


<p>LabVIEW is a development
The back panel, which is also known as the block diagram, contains the graphic-based source code. The environment of the back panel is navigated using the <b>Tools palette</b> (Figure 3).
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
[[Image:Lab 7 Figure 3.png|99px|frame|center|Figure 3: Tools Palette]]
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>.
In Figure 3, only the icons in colored boxed will be used in this experiment. The <b><span style="color:red">operating tool</span></b> changes the value of a control (such as a switch or LED). The <b><span style="color:orange">positioning tool</span></b> positions, resizes, and selects objects. The <b><span style="color:green">labeling tool</span></b> is used to create and edit all labels in the VI, such as the name of a Boolean control. The <b><span style="color:blue">wiring tool</span></b> wires objects together on the back panel. The <b><span style="color:purple">scrolling tool</span></b> allows scrolling the window by clicking and dragging.


<b><i>Controls</i></b> are <b>inputs </b>– they allow a user to supply
All of the objects placed on the front panel will appear on the back panel as terminals. <b>Terminals</b> are the ports that exchange information between the front panel and back panel, and appear with small triangles in the icons to indicate that they can be used to process information (Figure 4). A control terminal has the triangle to the right to indicate that it sends data to be processed. An indicator terminal has the triangle to the left to indicate that it receives data.
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
[[Image:Lab 7 Figure 4.jpg|500px|frame|center|Figure 4: Control and Indicator Terminals]]
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>
The back panel also contains structures and functions that perform operations on controls and supply data to indicators. Structures and functions are found on the Functions palette and are placed on the back panel (Figure 5).
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,
[[Image:Lab 7 Figure 5.jpg|225px|thumb|center|Figure 5: Functions Palette]]
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>
<b>Structures</b> are process control elements, such as while loops and for loops. The structure to be used in this experiment is the <b>case structure</b> (Figure 6), which is essentially multiple if-statements. A case structure contains multiple subdiagrams (or cases), and a case will be executed depending on the input to the case structure.  
<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
[[Image:Lab 7 Figure 6.jpg|400px|thumb|center|Figure 6: Case Structure]]
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 Figure 6, Item 1 is the selector label, which displays the input value for which the associated case will execute. The black arrows on the side of the selector label toggle between the different cases. Item 2 is the area for the code that executes for the specific input in the selector label. When the selector label is toggled, the code in this area will also change. Item 3 is the case selector, which gives the input value to the case structure. The data type that is wired to the case selector will determine the possible cases. For example, if a Boolean data type is wired to the case selector, the possible cases will only be true and false.
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>
<b>Functions</b> are the fundamental operating elements of LabVIEW, and have input and output terminals to pass data in and out. They are indicated by a pale yellow background in the icon (Figure 7).
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
[[Image:Lab 7 Figure 7.jpg|200px|thumb|center|Figure 7: Examples of Functions]]
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>
Functions have a certain number of inputs and outputs, depending on the type of function. For example, the addition function (leftmost icon in Figure 7) has two inputs as it will add the two inputs together, and it will have one output, which is the sum of the inputs. The inputs are wired to the left side of the function, and the outputs are wired to the right side of the function. The number of inputs and outputs of a function can be observed by hovering over the icon with the wiring tool and observing the terminals that appear (Figure 8).


<ol type="a">
[[Image:Lab 7 Figure 8.jpg|113px|thumb|center|Figure 8: Function Terminals]]
<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>
Collectively, controls, indicators, structures, and functions are referred to as nodes. <b>Nodes</b> are connected to one another using the wiring tool. For example, two controls and an indicator can be wired to the addition function so that the indicator displays the sum of the two controls (Figure 9).


<ul>
[[Image:Lab 7 Figure 9.png|226px|thumb|center|Figure 9: Wiring Nodes]]
<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 <b>toolbar</b> at the top of the front panel is used to execute and stop the program (Figure 10). The run tool (white arrow) runs the program once. The run continuously tool (two white arrows in a circle) keeps the program running continuously until the program is paused or stopped. This tool should be used when executing programs in this experiment. The abort execution tool (red stop sign) stops the VI immediately. The pause button (two vertical black rectangles) pauses the program, and can be clicked again to continue the program.


<p>Follow the lab report guidelines laid out in the page called
[[Image:Lab 7 Figure 10.png|87px|thumb|center|Figure 10: Toolbar]]
[[Specifications for Writing Your Lab Reports]] in the <i>Technical Communication</i>
section of this manual. As you write, the following discussion points should be addressed
in the appropriate section of your lab report:</p>


<ul>
<b>National Instruments' Educational Laboratory Virtual Instrumentation Suite (NI ELVIS) board</b> (Figure 11) is one solution LabVIEW can utilize to physically interface with external devices. It is a modular engineering device that includes a breadboard, power supply, ground, thermocouple, oscilloscope, function analyzer, and other common lab instruments. In this experiment, an NI ELVIS board will be used to provide inputs and display outputs for the VIs that will be created.
<li>Explain what LabView is and describe how it helps engineers and scientists with their work.</li>


<li>Explain what a VI is.</li>
[[Image:Lab 7 Figure 11.jpg|400px|thumb|center|Figure 11: NI ELVIS II+ Board]]


<li>What is the Front Panel used for? The Back Panel?</li>
= Materials and Equipment =
</ul>


<p><font color=#ff0000><b>IMPORTANT: Because the procedural elements in this lab are extensive,
* Lab PC
please include only the procedures you employed to build Design 2, the Heating and Cooling System
* LabVIEW 2019 software
in your lab report. You do not need to document the procedures you followed to build Design 1:
* NI ELVIS II+ prototyping board
the Simple Calculator, or Design 3: Lighting System.</b></font></p>
* Wires
* Two 100 kΩ resistors (brown, black, yellow)


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


<p>Remember, your job in this lab is not to report whether the Heating and Cooling system
Note: Some tasks will be repeated and the same icons will be used. A LabVIEW digest of common tasks at the bottom of the page contains references for faster navigation.
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
== Setting up a Blank VI ==
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>
# Open LabVIEW and select Blank VI under Create Project.
# Click Window > Tile Left and Right to display 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.
# With the back panel selected, click View > Tools Palette to open the Tools palette.
# With the front panel selected, click View > Controls Palette. The workspace should look like Figure 12. To open the Controls palette in the future, simply right click in the front panel.  Similarly, to open the Functions palette, simply right click in the back panel.


<p>Follow the presentation guidelines laid out in the page called
[[Image:lab_labview_1.png|thumb|500px|center|Figure 12: LabVIEW Workspace]]
[[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>
For help with the operation of any LabVIEW icon, select Help > Show Context Help > click the icon for the operation that is unclear. It will be explained in the Context Help window.
<li>What is your conclusion of the importance of LabVIEW?</li>
<li>Discuss some ways LabVIEW can be used in industry</li>
</ul>


<h2>4 MATERIALS AND EQUIPMENT</h2>
== 1. Heating and Cooling System ==


<ul>
Build a VI that simulates a heating and cooling system. The system must be able to be controlled manually or automatically. The VI’s specifications are listed below.
<li>Lab PC</li>
* Must be able to be controlled automatically or manually
<li>LabVIEW Software</li>
* In manual mode, the heater and air conditioning (AC) can be switched on/off by the user
<li>Data Acquisition and Control (DAC) Board</li>
* In automatic mode, the heater and AC turn on/off based on the following conditions:
** The air conditioner is turned on when the temperature is above 80°F
** The heater is turned on when the temperature is below 60°F
** The heater and the air conditioner are turned off when the temperature is between 60°F and 80°F


<li>Breadboard</li>
# In the front panel, drag and drop three Round LEDs and three Slide Switches by going to the Controls palette > Modern tab > Boolean (Figure 13). Each round LED and each slide switch will represent the AC, heater, and manual mode. The round LEDs will indicate if the item is on, and the slide switches will toggle the items on/off.
<li>Several LEDs</li>
#: [[Image:Switches.PNG|thumb|400px|center|Figure 13: Slide Switches and Round LEDs in the Controls Palette]]
</ul>
# Rename the LEDs and their corresponding switches "Manual," "AC," and "Heater" to make building the system clearer (Figure 14). This can be done by using the editing text tool in the Tools palette.
#: [[Image:Code_switches_leds.PNG|thumb|400px|center|Figure 14: Named Switches and LEDs in the Front Panel]]
# Drag and drop a thermometer (Figure 15) into the front panel (Controls palette > Modern tab > Numeric > Thermometer).
#: [[Image:thermometer.PNG|thumb|400px|center|Figure 15: Thermometer Control]]
# In the back panel, right click the thermometer terminal and select Change to Control, and observe how the arrow switches from the left side to the right side (Figure 16). This makes the thermometer a control that will give an input to the program, which in this case is temperature.
#: [[Image:control_vs_indicator.PNG|thumb|400px|center|Figure 16: Indicator (Left) vs Control (Right)]]
# In the back panel, insert a case structure to control the manual and automatic operation of the heating and cooling system (Functions palette > Structures > Case Structure). To place the case structure, click once to place one corner of the case structure, and once more to place the other corner of the case structure (Figure 17).
#: [[Image:Lab 7 Figure 17.PNG|thumb|400px|center|Figure 17: Case Structure]]
# Wire the slide switch designated as Manual to the case selector on the case structure (Figure 18). This should automatically change the selector label values to True and False, if they were not already, because the slide switch is a Boolean data type. The true value corresponds to manual mode being on (where the user can directly toggle the heater and AC), while the false value corresponds to manual mode being off (where the heater and AC are automatically toggled by the system).
#: [[Image:Case_structure_wired.PNG|thumb|400px|center|Figure 18: Manual Switch as Case Selector]]
# Because the temperature of the room is input into the system only when the system is not in manual mode (the false case), the thermometer terminal should be moved into the false subdiagram (Figure 19).
#: [[Image:Thermometer_in_structure.PNG|thumb|400px|center|Figure 19: Thermometer in the False Subdiagram]]
# In the true subdiagram, wire the AC and heater switches directly to their corresponding LEDs (Figure 20). This allows the switches to directly toggle their corresponding LEDs.
#: [[Image:Lab 7 Figure 20.PNG|thumb|400px|center|Figure 20: Wiring the Switches to the LEDs]]
# Staying in the true subdiagram, insert a True Constant (Functions palette > Programming tab > Boolean > True Constant). Wire the true constant to the manual LED to turn the manual LED on and indicate that the system is in manual mode (Figure 21).
#: [[Image:Lab 7 Figure 21.PNG|thumb|400px|center|Figure 21: Subdiagram for True Case]]
# In the false subdiagram, insert two Numeric Constants (Functions palette > Programming > Numeric > Numeric Constant), one Greater? function and one Less? function (Functions palette > Programming > Comparison). These will be used to build the program for the heating and cooling system in automatic mode (Figure 22).
#: [[Image:Lab 7 Figure 22.PNG|thumb|400px|center|Figure 22: Terminals for False Subdiagram]]
# The less and greater functions compare what is wired to the upper input terminal to what is wired to the lower input terminal. Wire the thermometer to the upper input terminals of the less and greater functions. Set a numeric constant to 60 and the other to 80. Wire the 60 numeric constant to the lower input terminal of the less function and the 80 numeric constant to the lower input terminal of the greater function. Wire the output terminal of the greater function to the AC LED and wire the output of the less function to the heater LED  (Figure 23).
#: [[Image:Lab 7 Figure 23.PNG|thumb|400px|center|Figure 23: Wiring to Heater and AC LEDs]]
# In the false subdiagram, Insert a False Constant (Functions palette > Programming > Boolean > False Constant) and wire it to the manual LED (Figure 24). This is to turn off the manual LED and indicate that the system is in automatic mode.
#: [[Image:Lab 7 Figure 24.PNG|thumb|400px|center|Figure 24: Subdiagram for False Case]]
# The system is now complete. Click the continuously run button to control and test the VI. If the continuously run button is faded out, that means the system is wired completely. When successfully running the system, the gridlines in the background of the front panel should disappear (Figure 25). Click the switches and thermometer on the front panel to test the system.
#: [[Image:Lab 7 Figure 25.PNG|thumb|400px|center|Figure 25: Running Heating and Cooling System]]
# Have a TA check the VI. Once testing is complete, take a screenshot of the VI. Save the heating and cooling system as a VI file (saving the file will save both the front panel and back panel in one file). Send the VI file to you and your teammates via email.


<h2>5 PROCEDURE</h2>
== Interfacing with a Heat Cube ==


<ol>
The VI will now be altered to interact with a <b>heat cube</b>, which is a physical device that houses a heating element, a fan, and a thermocouple, and LEDs located on an NI ELVIS board. The heat cube will take the ambient temperature of the room and input it into the heating and cooling system. The fan (i.e. the AC) and heater in the heat cube can be turned on/off manually or automatically using the heating and cooling VI that was just created. This will be done by uploading pre-written sub-VIs that will interface the heating and cooling VI with the circuit on the NI ELVIS board.
<li>Open LabVIEW, select <b><i>New</i></b> and <b><i>Blank VI</i></b>.</li>


<li>Click on <b><i>Window</i></b> and select <b><i>Tile
# [[Media:Sub-VIs.zip | Download the sub-VIs onto the desktop.]] Unzip the folder. There should be three sub-VIs – Cooling Control.vi, Heat Control.vi, and Temp Reading.vi.
Left &amp; Right</i></b> to set the front panel (left window) and back panel (right
# Insert the sub-VIs into the back panel by right-clicking on the back panel > Select a VI… > click the sub-VI. Click on the back panel outside of the case structure to place the sub-VIs. They should appear as small boxes with text and an icon (Figure 26).
window) side by side. This will make them visible at the same time, making it
#: [[Image:Lab 7 Figure 26.PNG|thumb|center|Figure 26: Sub-VI Terminals]]
easier to work. </li>
# In the automatic subdiagram, wire the output tunnel (green box along the border of the case structure) of the less function to the input terminal of the Heat Control sub-VI labeled Heat. Wire the output tunnel of the greater function to the input terminal of the Cool Control sub-VI labeled Cooling.
# Delete the orange wiring from the thermometer terminal to the upper input terminals of the less and greater comparison functions. Wire the output terminal of the Temp Reading sub-VI labeled Result to the upper input terminals of the comparison functions. The Temp Reading sub-VI will effectively replace the thermometer control terminal.
# Change the thermometer node to an indicator similarly to how it was earlier changed to a control.
# Wire the Result output terminal on the Temp Reading sub-VI to the thermometer indicator terminal. The thermometer indicator terminal will be used to display the temperature being read by the thermocouple in the heat cube.
# A device constant must be defined for each of the pre-written sub-VIs. The device constant selects the external device the sub-VIs transmit data to and receive data from, similar to selecting a port for an Arduino program.
# With the wiring tool selected, right click on the input terminal of the sub-VIs labeled Device Name > Create > Constant.
# Verify that all three device constants are equivalent. The device constant can be changed using the operating tool in the Tools palette.
# Ask the TA to check over the modifications to the VI. If correct, the TA will supply an NI ELVIS board, a heat cube, two 100 kΩ resistors, and electrical wires.
# Using two 100 kΩ resistors (Brown, Black, Yellow), insert one end of each resistor into AIGND (row 18) of the NI ELVIS board.
# Insert the other end of one of the resistors into the AI 7+ (row 15), and the end of the other resistor into AI 7- (row 16).
# Using a wire, connect the AI 7+ port (row 15) to the screw terminal 1 port (row 46).
# Using a wire, connect the AI 7- port (row 16) to the screw terminal 2 port (row 47).
# Insert the positive and negative wires from the fan into Variable Power Supplies SUPPLY+ (row 48) and Variable Power Supplies GROUND (row 49), respectively, at the lower-left-hand corner of the NI ELVIS board.
# Connect the positive wire from the heater to DC +5V (row 54) on the lower-right-hand corner of the NI ELVIS board.
# Connect the source of the MOSFET from the heat cube circuit to DC ground (row 53) on the lower-right-hand corner of the NI ELVIS board.
# Connect the gate of the MOSFET from the heat cube circuit to DIO 19 (row 20) on the upper-right-hand corner of the NI ELVIS board.
# Power the NI ELVIS board with the power cable and also connect it to the PC with the USB cable. The device constants on the back panel of the VI should update to reference the NI ELVIS board.
# Run the VI. Observe how the fan and heater in the heat cube can be turned on manually and automatically. Observe how the thermometer indicator in the front panel displays the actual temperature of the room.


<li>On the right window, pull down the <b><i>Window</i></b> menu, select <b><i>Show Tools
== 2. Lighting System ==
Palette</i></b>.</li>


<li>On the left window, pull down the <b><i>Window</i></b>
Build a VI that simulates a lighting system in a house with four rooms. The design must use four lights (LEDs) and at least five switches — one switch per light and one master switch that will turn all of the lights off simultaneously (think of this as a circuit breaker). The program should also interact with real LEDs located on the NI ELVIS board.
menu again, select <b><i>Show Controls Palette</i></b>. At this point your screen should look
like Figure 3. Note the <b><i>Controls Palette</i></b> and the <b><i>Tools
Palette</i></b>, and their icons.</li>
</ol>


<p align=center>[[Image:lab_labview_1.gif]]</p>
# The front panel of the program should use five switches and four LEDs.
# The back panel requires a case structure for the master switch to turn off all the lights. Think of the cases that will be required for the function of the master switch.
# Create the program in the case structure using the appropriate functions and wiring. Use knowledge acquired from creating the heating and cooling system, information from the Overview, and the LabVIEW Digest at the bottom of the page.
# After completing the program, the VI must be interfaced to the physical NI ELVIS board. The VI is interfaced to the NI ELVIS board using a function called the Digital Writer, which writes data to the DIO (Digital Input and Output) pins on the board, and can display outputs on the board’s built-in LEDs from the VI. To access the  Digital Writer node, go to the Functions palette > Measurement I/O tab > NI ELVISmx > Digital Writer (Figure 27). Place the Digital Writer node on the back panel.
#: [[Image:Lab 7 Figure 27.png|225px|frame|center|Figure 27: NI ELVISmx Digital Writer]]
# Hover over the blue square at the bottom of the Digital Writer node, click, and drag down. Six colored lines should appear (Figure 28). If this cannot be performed, double click on the Digital Writer node and click OK in the NI ELVISmx dialog that pops up. Try to expand the node again.
#: [[Image:Lab 7 Figure 28.png|frame|center|Figure 28: NI ELVISmx Digital Writer Node]]
# Only two of the lines in the Digital Writer node will be used in this experiment. The <b>Lines to Write</b> determine which group of eight DIO pins will be used in the VI. The Lines to Write come in groups of eight (starting at 0) because the program works in 8-bit. The <b>DO (Digital Output) Lines</b> input the Boolean values into the DIO pins.
# For the purposes of this lab, DIO lines 0–7 will be utilized (Figure 29). To establish this setting, right-click Lines to Write on the Digital Writer node > Create > Constant. By default, the constant  is set to 0–7. The operating tool in the Tools palette can be used to change this value.
#: [[Image:Lab 7 Figure 29.png|145px|frame|center|Figure 29: Lines to Write]]
# The DO Lines require an input for each of the eight DIO lines, indicating whether each one is true or false (on or off), but the Digital Writer can only receive one input for the DO Lines (as observed by the one input terminal for the DO Lines on the Digital Writer node). Therefore, the eight Boolean values will be placed in an array, and the array will be input to the DO Lines.
# A Build Array function will be used by going to the Functions palette > Programming > Build Array (Figure 30). The array should be eight indices long to represent each DIO line. When first placing the array, it only appears as one index. Hover over the bottom of the array until a two-sided arrow appears, then click and drag down until the array is eight indices long.
#: [[Image:Lab 7 Figure 30.png|225px|frame|center|Figure 30: Array Function]]
# Each LED should be wired to an individual index in the array, at the element terminal on the left side of the array node. The remaining four indices in the array should be wired to false constants, as those DIO lines should remain false at all times as they are not in use.
# The resulting array should be wired to the Lines to Write of the Digital Writer node, from the appended array terminal on the right side of the array node (Figure 31).
#: [[Image:Lab 7 Figure 31.png|145px|frame|center|Figure 31: Completed Digital Writer Node]]
# For the LEDs on the NI ELVIS board to light up, wires must be used to connect the DIO lines (rows 0–7) directly to the LEDs on the NI ELVIS board (rows 35–42).
# Test the VI. Double click the Digital Writer node. Ensure the correct Device and Lines to Write are selected under Configuration of the NI ELVISmx dialog. Click OK. Run the VI in LabVIEW. Ask a TA to check the program.
# Take screenshots of the lighting system. Save the lighting system as a VI file.
# Submit a ZIP file of both the heating and cooling system and the lighting system to the EG1004 website before 11:59PM the night before the next lab.


<p class=caption>Figure 3: LabVIEW workspace</p>
The lab work is now complete. Please clean up the workstation. Return all unused materials to the TA. Refer to the Assignment section for the instructions needed to prepare the lab report.


<p><b>Remember: </b><i>You are required to take notes. Experimental details are
= Assignment =
easily forgotten unless written down. You should keep a laboratory notebook for
this purpose. Use your lab notes to write the Procedure section of your lab
report. You <b>must </b>attach a copy of your lab notes to the <b>WC </b>copy
of your lab report. Keeping careful notes is an essential component of all
scientific practice.</i></p>


<p>For help with the operation of
<b><span style="color:red">A ZIP folder containing both LabVIEW programs (in VI format) must be submitted to the [http://eg.poly.edu EG1004 Website] by 11:59PM the night before the next lab. There is no Team PowerPoint Presentation for this lab.</span></b>
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.</p>


<p>The overall approach for each of
== Team Lab Report ==
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.</p>


<p><b>Note:</b> We’ll be doing
{{Labs:Lab Report}}
some tasks a number of times, where you’ll be clicking on the same icons to
* How is LabVIEW important today?
bring up various components. To help you , we’ve included a LabVIEW digest at
* Explain what LabVIEW is and describe how it helps engineers and scientists with their work
the end of this lab for your reference to help you navigate.</p>
* 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 an NI ELVIS board is
* State whether the VIs were successful or not. If not, explain why.
* State whether interfacing the VIs with the NI ELVIS board was successful or not
* Describe the advantages and disadvantages of using LabVIEW
* Suggest some improvements for the lab procedure
* Suggest improvements for each VI
* Because the procedural elements in this lab are extensive, please include only the procedures employed to build the lighting system in the lab report. Do not document the procedures followed to build the heating and cooling system
* Though the Procedure section is limited to the lighting system, discuss both of the designs in the Data/Observations and Conclusion sections of the lab report
* Please consider the value of LabVIEW as a substitute for actual instruments and systems. The Data/Observations section should include information on ease of use, the LabVIEW user interface, and the available help options
* In describing the design of all the systems, present screenshots in the lab reports showing the VIs that were designed


<h3>Design 1: Simple Calculator</h3>
{{Labs:Lab Notes}}


<p>Create a program that simulates a basic calculator. Your calculator will be
<!--
able to add, subtract, and multiply.</p>
== Team PowerPoint Presentation (EGED I Only) ==
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 preparing the presentation, consider the following points:
* What is the importance of LabVIEW?
* Discuss some ways LabVIEW can be used in industry.
-->


<ol>
= LabVIEW Digest of Common Tasks =
<li>The <b><i>front panel</i></b> must contain:</li>


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


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


<p align=center>[[Image:lab_labview_3.gif]]</p>
* <b>How to get a slide control:</b>
** Controls palette > Modern tab > Numeric [[Image:lab_labview_2.png]]
** Select Horizontal Pointer Slide [[Image:Slide Control 2.png|55px]]
** Click on the front panel to place the slide at a specific location


<p class=caption>Figure 4: Controls Palette</p>
* <b>How to get an LED indicator:</b>
** Controls palette > Modern tab > Boolean [[Image:lab_labview_8.png]]
** Select the Round LED [[File:LED 1.png|55px]] or Square LED [[File:LED 2.png|55px]]
** Click on the front panel to place the LED at a specific location


<p align=center>[[Image:lab_labview_5.gif]]</p>
* <b>How to get a numeric control:</b>
** Controls palette > Modern tab > Numeric [[Image:lab_labview_2.png]]
** Click on Numeric Control [[Image:NC.png|55px]]
** Click on the front panel to place the numeric control at a specific location


<p class=caption>Figure 5: Numerical Controls window</p>
* <b>How to get a numeric indicator:</b>
** Controls palette > Modern tab > Numeric [[Image:lab_labview_2.png]]
** Click on Numeric Indicator [[Image:NI.png|55px]]
** Click on the front panel to place the numeric indicator at a specific location


<li>Then select Horizontal Pointer Slide from the icons shown. Click on the left window to place the slide
== Back Panel ==
on the front panel at the location you select.</li>
<p>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).</p>
<p>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.</p>
<li>Click on the number <i>10


</i>and change it to <i>2</i>. Now the slide control will look like Figure 6.</li>
* <b>How to define an arithmetic operation:</b>
** Functions palette > Programming tab > Numeric [[Image:lab_labview_33.png]]
** Click on the function of the desired arithmetic operation [[Image:Arithmetic.png|300px]]
** Click on the back panel to place the arithmetic function at a specific location


<p align=center>[[Image:lab_labview_6.gif]]</p>
* <b>How to define Boolean constants (usually used to turn on/off LEDs):</b>
** Functions palette > Programming tab > Boolean [[Image:lab_labview_36.png]]
** Click on the True Constant [[Image:lab_labview_42.png]] or False Constant [[Image:lab_labview_43.png]]
** Click on the back panel to place the Boolean constant at a specific location


<p class=caption>Figure 6: Slide control with range changed from 10 to 2</p>
* <b>How to wire:</b>
** Tools palette > Wiring tool [[Image:lab_labview_19.png]]
** Click the desired object output terminal (on the left side) to wire from
** Click the desired object input terminal (on the right side) to wire to


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


<p align=center>[[Image:lab_labview_7.gif]]</p>
Introduction to LabVIEW, Six-Hour Course [Courseware]. (June 2003) Austin, TX: Worldwide Technical Support and Product Information, National Instruments Corporation.


<p class=caption>Figure 7: I32 Representation pull down menus</p>
“LabVIEW Block Diagram Explained.” National Instruments, National Instruments, 4 Feb. 2020, www.ni.com/en-us/support/documentation/supplemental/08/labview-block-diagram-explained.html.
</ol>


<li>Three Boolean indicators to specify the operation selected. Here’s how to do it:
“Case Structure.” National Instruments, National Instruments, 4 Feb. 2020, www.zone.ni.com/reference/en-XX/help/371361R-01/glang/case_structure/.


<ol>
“LabVIEW Front Panel Explained.” National Instruments, National Instruments, 4 Feb. 2020, www.ni.com/en-us/support/documentation/supplemental/08/labview-front-panel-explained.html.
<li>On the Controls palette, select the <b>LEDs</b> icon [[Image:lab_labview_8.gif]].
This will bring up the window shown in Figure 8.</li>


<p align=center>[[Image:lab_labview_9.gif]]</p>
{{Laboratory Experiments}}
 
<p class=caption>Figure 8: LEDs Window</p>
 
<li>Select the <b>Round LED</b> 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.</li>
 
<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
<b>Edit Text</b> icon [[Image:lab_labview_10.gif]] on the <b>Tools
palette</b>. 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.</li>
 
</ol>
 
<li>Two numeric controls to allow the user to input data from the keyboard. Here’s how to do it:
 
<ol>
<li>On the <b>Controls palette</b>, click on the <b>Num Ctrls</b> icon. This will bring up the
window shown in Figure 5 again.</li>
 
<li>Click on the <b>Num Ctrl</b> 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 <b>Num Ctrl</b> icon again, and place another numeric control
on the right side of the slide.</li>
 
</ol>
 
<li>A numeric indicator to display the output. Here’s how to do it:</li>
 
<ol>
<li>On the Controls palette, click on the <b>Num Inds</b> icon [[Image:lab_labview_11.gif]].
This will bring up the window shown in Figure 9.</li>
 
<p align=center>[[Image:lab_labview_12.gif]]</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
centered below the three lights. This numeric indicator will be the answer from
the calculator.</li>
 
<p><b>Note</b>: 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>
 
<li>You are now finished constructing the front panel. The finished <b>Front
Panel</b> should look like Figure 10:</li>
</ol>
 
</ol>
 
<p align=center>[[Image:lab_labview_13.gif]]</p>
 
<p class=caption>Figure 10: Finished Front Panel</p>
 
<p>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.</p>
 
<li>The <b><i>back panel</i></b> must contain:</li>
 
<ol type="a">
 
<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>
 
<ol>
<li>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.</li>
 
<p align=center>[[Image:lab_labview_14.gif]]</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 window,
and choose “Show Functions Palette�?, just as shown on Figure 12a. This will bring up the
Functions Palette, shown in Figure 12b.</li>
 
<p align=center>[[Image:lab_labview_15.gif]]</p>
 
<p class=caption>Figure 12a: How to bring up the Functions Palette</p>
 
<p align=center>[[Image:lab_labview_16.gif]]</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
bring up the <b><i>Exec Ctrl</i></b> window, shown in Figure 13.</li>
 
<p align=center>[[Image:lab_labview_18.gif]]</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
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 <b><i>1</i></b>
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.</li>
 
<li>We will now start
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
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
question mark on the left side of the case structure. Your back panel should
now look like Figure 14.</li>
 
<p align=center>[[Image:lab_labview_20.jpg]]</p>
 
<p class=caption>Figure 14: Back Panel Slide to Case Structure Connection</p>
 
<li>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 <b>case
structure</b> and select <b>Add Case After</b>,
as shown in Figure 15.</li>
 
<p align=center>[[Image:lab_labview_21.gif]]</p>
 
<p class=caption>Figure 15: Adding Another Case</p>
 
<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>
icon <b>[[Image:lab_labview_33.gif]]</b> from the main <b><i>Functions
Palette</i></b>. This will bring up the Arith/Compare window shown in Figure 17.</li>
 
<p align=center>[[Image:lab_labview_23.gif]]</p>
 
<p class=caption>Figure 17: Arith/Compare Window</p>
 
<li>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 Figure 18.</li>
 
<p align=center>[[Image:lab_labview_25.gif]]</p>
 
<p class=caption>Figure 18: Express Numeric Window</p>
 
<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>
 
Window, click on the Add icon <b>[[Image:lab_labview_26.gif]]</b>, and click on a
location in the middle of the case structure box to place it.</li>
 
<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>
Window, click on the Subtract icon <b>[[Image:lab_labview_27.gif]]</b>, and click on
a location in the middle of the case structure to place it.</li>
 
<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>
 
Window, click on the Multiply icon <b>[[Image:lab_labview_28.gif]]</b>, 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.</li>
 
<p align=center>[[Image:lab_labview_29.gif]][[Image:lab_labview_30.jpg]][[Image:lab_labview_31.gif]]</p>
 
<p class=caption>Figure 19: Case Structure Cases</p>
 
<li>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 <b><i>0</i></b>. The triangle inside
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
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.</li>
 
<p align=center>[[Image:lab_labview_32.gif]]</p>
 
<p class=caption>Figure 20: Completed Back Panel for Addition</p>
 
<li>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 <b><i>1</i></b>, 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 <b><i>Numeric
3</i></b> 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.</li>
 
<li>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 <b><i>Express Numeric</i></b> window: On the <b><i>Functions Palette</i></b>, click
on the <b>Arith/Compare</b> icon [[Image:lab_labview_33.gif]] from the main <b>Functions
Palette</b>. 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
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>
 
<p align=center>[[Image:lab_labview_23.gif]]</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
[[Image:lab_labview_36.gif]], which will bring up the Express Boolean
window shown in Figure 22.</li>
 
<p align=center>[[Image:lab_labview_37.gif]]</p>
 
<p class=caption>Figure 22: Express Boolean Window</p>
 
<li>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 [[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
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>
 
<li>We now need to wire
the constants to their respective indicators. Once again, click on the Connect
Wire icon [[Image: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.</li>
 
<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
case. Once again, on the <b><i>Functions
Palette</i></b>, click on the <b>Arith/Compare</b>
 
icon [[Image:lab_labview_33.gif]] from the main <b>Functions
Palette</b>. 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
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
<b><i>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
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 Subtract LED. Click on the False Constant icon [[Image: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 [[Image: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.</li>
 
<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
indicator illuminate for this case. Once again, on the <b><i>Functions Palette</i></b>, click
on the <b>Arith/Compare</b> 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
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
<b><i>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
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
structure to the left of the Add LED, and again to the left of the Subtraction
LED. Click on the Connect Wire icon [[Image: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.</li>
 
<li>Before moving on, make sure that the boxes on the edges of the <b>case
structure</b> 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>
 
<p align=center>[[Image:lab_labview_48.gif]] [[Image:lab_labview_49.jpg]]</p>
 
<p class=caption>Figure 23: Completed Calculator Back Panel</p>
</ol>
</ol>
 
<li>After you have created your VI, it must be tested:</li>
 
<ol type="a">
<li>Enter different input numbers through the control icon on the front panel.</li>
<li>Make sure the output is correct.</li>
<li>Make sure the correct LED lights up for the operation.</li>
<li>Have your TA test your VI.</li>
</ol>
 
<p align=center>[[Image:lab_labview_50.gif]]</p>
 
<p class=caption>Figure 24: Completed and Working VI</p>
 
<li>Once testing is completed:</li>
 
<ol type="a">
<li>Print the VI you have created.</li>
<li>Have your TA sign it.</li>
</ol>
</ol>
 
<h3>Design 2: Heating and Cooling System</h3>
 
<p>Build a VI that simulates a
heating and cooling system. Your system must be controlled either manually or
automatically. Design your VI so that:</p>
 
<ul>
<li>The air conditioner is turned on when the temperature is above 80°F.</li>
 
<li>The heater is turned on when the temperature is less than 60°F.</li>
 
<li>The heater and the air conditioner are turned off when the temperature is
between 60°F and 80°F.</li>
</ul>
 
<ol>
<li>The <b><i>front panel</i></b> must contain:</li>
 
<ol type="a">
<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>
 
<li>Three switches: one to control the AC, one to control the heater, and one to control
manual or automatic operation.</li>
 
<li>A thermometer to set the temperature of the system. The thermometer should be set to 70°F.</li>
</ol>
 
<li>The <b><i>back panel</i></b> must contain:</li>
 
<ol type="a">
<li>A Boolean case statement to control the manual and automatic operation of the AC and the
heater.</li>
</ol>
 
 
<li>After you have created your VI, it must be tested:</li>
 
<ol type="a">
<li>Using the slide bar on the thermometer, change the system temperature. Make sure
the AC and heat come on as directed.</li>
 
<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
switch is in the <b><i>On </i></b>position.</li>
 
<li>Have your TA test your VI.</li>
</ol>
 
<li>Once testing is completed:</li>
 
<ol>
<li>Print the VI you have created.</li>
<li>Have your TA sign it.</li>
<li>Save your VI. You'll be using it again in Lab 6.</li>
</ol>
</ol>
 
<h3>Design 3: Lighting System</h3>
 
<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>
 
<ol>
<li>The <b><i>front panel</i></b> of your program should include 5 switches and 4 virtual LEDs.</li>
 
<li>While there are several ways to implement the <b><i>back panel</i></b>, one suggestion
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>
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">
<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>All Functions -&gt; NI Measurements -&gt;Data Acquisition -&gt;
 
Digital I/O -&gt; Advanced Digital I/O</i></b>. (see Figures 25a-f)</li>
 
<p align=center>[[Image:lab_labview_51.gif]]</p>
 
<p class=caption>Figure 25a: Functions Palette</p>
 
<p align=center>[[Image:lab_labview_52.gif]]</p>
 
<p class=caption>Figure 25b: <i>All Functions</i> palette with <i>NI Measurements</i> pointed out</p>
 
<p align=center>[[Image:lab_labview_53.jpg]]</p>
 
<p class=caption>Figure 25c: <i>NI Measurements</i> palette 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> palette 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>palette with <i>Advanced Digital I/O </i>pointed out</p>
 
<p align=center>[[Image:lab_labview_56.gif]]</p>
 
<p class=caption>Figure 25f: <i>Advanced Digital I/O </i>palette with<br>
<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
on them and choose <i>View Terminals</i> (Figure 26).</li>
 
<p align=center>[[Image:lab_labview_57.gif]]</p>
 
<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.jpg]]</p>
<p class=caption>Figure 27: Port Config</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 2).</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>
<li><b><i>Task ID Input:</i></b> this is wired to the <i>Task ID Output</i> terminal on the
<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">
<li>Each pin is represented by a number that is a power of 2 (see <i>Pattern Table</i>).
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
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>
 
<li>If you used separate Boolean case structures for each
switch, then setting up the pattern for <b><i>Port Write</i></b> can be achieved as
follows:</li>
 
<ol>
<li>In each Boolean case, if the switch is off, place a <b><i>numeric constant</i></b> of 0.</li>
 
<li>If the switch is on, then include a <b><i>numeric constant</i></b> of the appropriate value
(<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
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>
 
<p>Don’t forget to wire both the numeric constant in the True
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>
 
<p class=caption>Pattern Table</p>
 
<table border=1 cellspacing=0 align=center>
<tr>
<td colspan=9>
<p align=center>Pattern</p>
  </td>
</tr>
<tr>
<td>
<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
materials to your TA. Refer to section <b><i>3 Your Assignment </i></b>for the
instructions you need to prepare your lab report.</p>
 
<h2>LabVIEW Digest of Common Tasks</h2>
 
<h3>Front Panel Controls and Indicators</h3>
 
<h4>How to get a slide control:</h4>
 
<ol>
<li>On the Controls palette, select the <b>Num Ctrls</b> icon [[Image:lab_labview_2.gif]]</li>
<li>Select Horizontal Pointer Slide</li>
<li>Click on the front panel to place the slide on the front panel at the location you select</li>
</ol>
 
<h4>How to get a LED indicator:</h4>
 
<ol>
<li>On the Controls palette, select the <b>LEDs</b> icon [[Image:lab_labview_8.gif]].</li>
 
<li>Select the <b>Round LED</b> icon from the icons shown.</li>
 
<li>Click on the left window to place the LED on the front panel at the location you select.</li>
 
<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
palette</b>. Then click on the ‘Boolean’ label on each LED and replace it with
the proper text.</li>
</ol>
<h4>How to get a Numeric Input Control</h4>
<ol>
<li>On the <b>Controls palette</b>, click on the <b>Num Ctrls</b> icon. This will bring up
the window shown in Figure 5.</li>
 
<li>Click on the <b>Num Ctrl</b> icon and click on the location
where you want to place the control.</li>
</ol>
 
<h4>How to get a Numeric Indicator Output</h4>
<ol>
<li>On the Controls palette, click on the <b>Num Inds</b> icon [[Image:lab_labview_11.gif]].
This will bring up the window shown in Figure 9.</li>
 
<li>Click on the <b>Num Ind</b> icon and click on the front
panel location where you want the indicator.</li>
</ol>
 
<h3>Back Panel Objects</h3>
 
<h4>How to define a case structure</h4>
 
<ol>
<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
the Functions Palette, shown in Figure 29b.</li>
 
<p align=center>[[Image:lab_labview_15.gif]]</p>
 
<p class=caption>Figure 29a: How to bring up the Functions Palette</p>
 
<p align=center>[[Image:lab_labview_51.gif]]</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
in Figure 13.</li>
 
<li>Click on the <b>Case Structure</b> icon. Click on the right window to locate it on the back panel.</li>
 
<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>
 
<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
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>
 
</ol>
 
<h4>How to define an arithmetic operation</h4>
 
<ol>
<li>On the <b><i>Functions Palette</i></b>, click on the <b>Arith/Compare</b>
icon [[Image:lab_labview_33.gif]]. will bring up the Arith/Compare window shown
in Figure 17.</li>
 
<li>On the Arith/Compare window, click on the <b>Numeric</b> icon [[Image:lab_labview_24.gif]].
This will bring up the <b><i>Express Numeric</i></b> window shown in Figure 18.</li>
 
<li>In the <b><i>Express Numeric</i></b> Window, click on the icon for the arithmetic
operation you want. Click on the front panel location where the icon goes.</li>
</ol>
 
<h4>How to define Boolean constants (usually used to illuminate LEDs)</h4>
 
<ol>
<li>On the <b><i>Functions Palette</i></b>, click on the <b>Arith/Compare</b>
 
icon [[Image:lab_labview_33.gif]]. This will bring up the
<b><i>Arith/Compare</i></b> window.</li>
 
<li>On the <b><i>Arith/Compare</i></b> window, click on the <b>Numeric</b> icon
[[Image:lab_labview_24.gif]]. This will bring up the <b><i>Express Numeric</i></b> window
shown in Figure 18. On the <b><i>Express Numeric</i></b> window, click the
upward facing arrow. This will bring up the <b><i>Arithmetic and Comparison</i></b>
window shown in Figure 21.</li>
 
<li>On the <b><i>Arithmetic and Comparison</i></b> window, click on the Boolean icon
[[Image:lab_labview_36.gif]], which will bring up the <b><i>Express Boolean</i></b>
window shown in Figure 22.</li>
 
<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
on the back panel.</li>
 
</ol>
 
<h4>How to wire things</h4>
<ol>
<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>
 
<li>On the Tools Palette, chose the “Connect Wire�? icon [[Image:lab_labview_19.gif]].</li>
 
<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>
</ol>
 
<h2>Footnotes</h2>
 
<p><sup>1</sup> <i>Introduction to LabVIEW, Six-Hour Course </i>[Courseware]. (June 2003) Austin, TX: Worldwide
Technical Support and Product Information, National Instruments Corporation</p>
 
[[Main_Page | Return to Table of Contents]]

Latest revision as of 02:30, 31 August 2022

Objective

The experimental objective of this lab is to use LabVIEW to design a heating and cooling system and a lighting system and to test both systems. Building these systems will demonstrate the potential for using simulated instruments in a laboratory. These programs will also obtain data from outside the computer and incorporate it into a program design.

Overview

The Laboratory Virtual Instrument Engineering Workbench (LabVIEW) is a development environment designed by National Instruments that creates graphic-based programs called virtual instruments (VIs) that simulate actual laboratory instruments. A VI consists of two parts: a front panel and a back panel (Figure 1). The front panel allows the user to interact with the VI by displaying outputs and allowing the user to supply the program with inputs. The back panel consists of the code used by the VI to obtain inputs from the front panel, operate on the inputs, and display the results.

Figure 1: Front Panel (Left) and Back Panel (Right)

The front panel is built using controls and indicators. Controls are inputs that allow a user to supply information to the VI. Indicators are outputs that display the results based on the inputs given to the VI. Controls can be switches, knobs, dials, and buttons. Indicators can be meters, gauges, LEDs, and displays. These are located on the Controls palette and are placed on the front panel (Figure 2).

Figure 2: Controls Palette

The back panel, which is also known as the block diagram, contains the graphic-based source code. The environment of the back panel is navigated using the Tools palette (Figure 3).

Figure 3: Tools Palette

In Figure 3, only the icons in colored boxed will be used in this experiment. The operating tool changes the value of a control (such as a switch or LED). The positioning tool positions, resizes, and selects objects. The labeling tool is used to create and edit all labels in the VI, such as the name of a Boolean control. The wiring tool wires objects together on the back panel. The scrolling tool allows scrolling the window by clicking and dragging.

All of the objects placed on the front panel will appear on the back panel as terminals. Terminals are the ports that exchange information between the front panel and back panel, and appear with small triangles in the icons to indicate that they can be used to process information (Figure 4). A control terminal has the triangle to the right to indicate that it sends data to be processed. An indicator terminal has the triangle to the left to indicate that it receives data.

Figure 4: Control and Indicator Terminals

The back panel also contains structures and functions that perform operations on controls and supply data to indicators. Structures and functions are found on the Functions palette and are placed on the back panel (Figure 5).

Figure 5: Functions Palette

Structures are process control elements, such as while loops and for loops. The structure to be used in this experiment is the case structure (Figure 6), which is essentially multiple if-statements. A case structure contains multiple subdiagrams (or cases), and a case will be executed depending on the input to the case structure.

Figure 6: Case Structure

In Figure 6, Item 1 is the selector label, which displays the input value for which the associated case will execute. The black arrows on the side of the selector label toggle between the different cases. Item 2 is the area for the code that executes for the specific input in the selector label. When the selector label is toggled, the code in this area will also change. Item 3 is the case selector, which gives the input value to the case structure. The data type that is wired to the case selector will determine the possible cases. For example, if a Boolean data type is wired to the case selector, the possible cases will only be true and false.

Functions are the fundamental operating elements of LabVIEW, and have input and output terminals to pass data in and out. They are indicated by a pale yellow background in the icon (Figure 7).

Figure 7: Examples of Functions

Functions have a certain number of inputs and outputs, depending on the type of function. For example, the addition function (leftmost icon in Figure 7) has two inputs as it will add the two inputs together, and it will have one output, which is the sum of the inputs. The inputs are wired to the left side of the function, and the outputs are wired to the right side of the function. The number of inputs and outputs of a function can be observed by hovering over the icon with the wiring tool and observing the terminals that appear (Figure 8).

Figure 8: Function Terminals

Collectively, controls, indicators, structures, and functions are referred to as nodes. Nodes are connected to one another using the wiring tool. For example, two controls and an indicator can be wired to the addition function so that the indicator displays the sum of the two controls (Figure 9).

Figure 9: Wiring Nodes

The toolbar at the top of the front panel is used to execute and stop the program (Figure 10). The run tool (white arrow) runs the program once. The run continuously tool (two white arrows in a circle) keeps the program running continuously until the program is paused or stopped. This tool should be used when executing programs in this experiment. The abort execution tool (red stop sign) stops the VI immediately. The pause button (two vertical black rectangles) pauses the program, and can be clicked again to continue the program.

Figure 10: Toolbar

National Instruments' Educational Laboratory Virtual Instrumentation Suite (NI ELVIS) board (Figure 11) is one solution LabVIEW can utilize to physically interface with external devices. It is a modular engineering device that includes a breadboard, power supply, ground, thermocouple, oscilloscope, function analyzer, and other common lab instruments. In this experiment, an NI ELVIS board will be used to provide inputs and display outputs for the VIs that will be created.

Figure 11: NI ELVIS II+ Board

Materials and Equipment

  • Lab PC
  • LabVIEW 2019 software
  • NI ELVIS II+ prototyping board
  • Wires
  • Two 100 kΩ resistors (brown, black, yellow)

Procedure

Note: Some tasks will be repeated and the same icons will be used. A LabVIEW digest of common tasks at the bottom of the page contains references for faster navigation.

Setting up a Blank VI

  1. Open LabVIEW and select Blank VI under Create Project.
  2. Click Window > Tile Left and Right to display 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. With the back panel selected, click View > Tools Palette to open the Tools palette.
  4. With the front panel selected, click View > Controls Palette. The workspace should look like Figure 12. To open the Controls palette in the future, simply right click in the front panel. Similarly, to open the Functions palette, simply right click in the back panel.
Figure 12: LabVIEW Workspace

For help with the operation of any LabVIEW icon, select Help > Show Context Help > click the icon for the operation that is unclear. It will be explained in the Context Help window.

1. Heating and Cooling System

Build a VI that simulates a heating and cooling system. The system must be able to be controlled manually or automatically. The VI’s specifications are listed below.

  • Must be able to be controlled automatically or manually
  • In manual mode, the heater and air conditioning (AC) can be switched on/off by the user
  • In automatic mode, the heater and AC turn on/off based on the following conditions:
    • The air conditioner is turned on when the temperature is above 80°F
    • The heater is turned on when the temperature is below 60°F
    • The heater and the air conditioner are turned off when the temperature is between 60°F and 80°F
  1. In the front panel, drag and drop three Round LEDs and three Slide Switches by going to the Controls palette > Modern tab > Boolean (Figure 13). Each round LED and each slide switch will represent the AC, heater, and manual mode. The round LEDs will indicate if the item is on, and the slide switches will toggle the items on/off.
    Figure 13: Slide Switches and Round LEDs in the Controls Palette
  2. Rename the LEDs and their corresponding switches "Manual," "AC," and "Heater" to make building the system clearer (Figure 14). This can be done by using the editing text tool in the Tools palette.
    Figure 14: Named Switches and LEDs in the Front Panel
  3. Drag and drop a thermometer (Figure 15) into the front panel (Controls palette > Modern tab > Numeric > Thermometer).
    Figure 15: Thermometer Control
  4. In the back panel, right click the thermometer terminal and select Change to Control, and observe how the arrow switches from the left side to the right side (Figure 16). This makes the thermometer a control that will give an input to the program, which in this case is temperature.
    Figure 16: Indicator (Left) vs Control (Right)
  5. In the back panel, insert a case structure to control the manual and automatic operation of the heating and cooling system (Functions palette > Structures > Case Structure). To place the case structure, click once to place one corner of the case structure, and once more to place the other corner of the case structure (Figure 17).
    Figure 17: Case Structure
  6. Wire the slide switch designated as Manual to the case selector on the case structure (Figure 18). This should automatically change the selector label values to True and False, if they were not already, because the slide switch is a Boolean data type. The true value corresponds to manual mode being on (where the user can directly toggle the heater and AC), while the false value corresponds to manual mode being off (where the heater and AC are automatically toggled by the system).
    Figure 18: Manual Switch as Case Selector
  7. Because the temperature of the room is input into the system only when the system is not in manual mode (the false case), the thermometer terminal should be moved into the false subdiagram (Figure 19).
    Figure 19: Thermometer in the False Subdiagram
  8. In the true subdiagram, wire the AC and heater switches directly to their corresponding LEDs (Figure 20). This allows the switches to directly toggle their corresponding LEDs.
    Figure 20: Wiring the Switches to the LEDs
  9. Staying in the true subdiagram, insert a True Constant (Functions palette > Programming tab > Boolean > True Constant). Wire the true constant to the manual LED to turn the manual LED on and indicate that the system is in manual mode (Figure 21).
    Figure 21: Subdiagram for True Case
  10. In the false subdiagram, insert two Numeric Constants (Functions palette > Programming > Numeric > Numeric Constant), one Greater? function and one Less? function (Functions palette > Programming > Comparison). These will be used to build the program for the heating and cooling system in automatic mode (Figure 22).
    Figure 22: Terminals for False Subdiagram
  11. The less and greater functions compare what is wired to the upper input terminal to what is wired to the lower input terminal. Wire the thermometer to the upper input terminals of the less and greater functions. Set a numeric constant to 60 and the other to 80. Wire the 60 numeric constant to the lower input terminal of the less function and the 80 numeric constant to the lower input terminal of the greater function. Wire the output terminal of the greater function to the AC LED and wire the output of the less function to the heater LED (Figure 23).
    Figure 23: Wiring to Heater and AC LEDs
  12. In the false subdiagram, Insert a False Constant (Functions palette > Programming > Boolean > False Constant) and wire it to the manual LED (Figure 24). This is to turn off the manual LED and indicate that the system is in automatic mode.
    Figure 24: Subdiagram for False Case
  13. The system is now complete. Click the continuously run button to control and test the VI. If the continuously run button is faded out, that means the system is wired completely. When successfully running the system, the gridlines in the background of the front panel should disappear (Figure 25). Click the switches and thermometer on the front panel to test the system.
    Figure 25: Running Heating and Cooling System
  14. Have a TA check the VI. Once testing is complete, take a screenshot of the VI. Save the heating and cooling system as a VI file (saving the file will save both the front panel and back panel in one file). Send the VI file to you and your teammates via email.

Interfacing with a Heat Cube

The VI will now be altered to interact with a heat cube, which is a physical device that houses a heating element, a fan, and a thermocouple, and LEDs located on an NI ELVIS board. The heat cube will take the ambient temperature of the room and input it into the heating and cooling system. The fan (i.e. the AC) and heater in the heat cube can be turned on/off manually or automatically using the heating and cooling VI that was just created. This will be done by uploading pre-written sub-VIs that will interface the heating and cooling VI with the circuit on the NI ELVIS board.

  1. Download the sub-VIs onto the desktop. Unzip the folder. There should be three sub-VIs – Cooling Control.vi, Heat Control.vi, and Temp Reading.vi.
  2. Insert the sub-VIs into the back panel by right-clicking on the back panel > Select a VI… > click the sub-VI. Click on the back panel outside of the case structure to place the sub-VIs. They should appear as small boxes with text and an icon (Figure 26).
    Figure 26: Sub-VI Terminals
  3. In the automatic subdiagram, wire the output tunnel (green box along the border of the case structure) of the less function to the input terminal of the Heat Control sub-VI labeled Heat. Wire the output tunnel of the greater function to the input terminal of the Cool Control sub-VI labeled Cooling.
  4. Delete the orange wiring from the thermometer terminal to the upper input terminals of the less and greater comparison functions. Wire the output terminal of the Temp Reading sub-VI labeled Result to the upper input terminals of the comparison functions. The Temp Reading sub-VI will effectively replace the thermometer control terminal.
  5. Change the thermometer node to an indicator similarly to how it was earlier changed to a control.
  6. Wire the Result output terminal on the Temp Reading sub-VI to the thermometer indicator terminal. The thermometer indicator terminal will be used to display the temperature being read by the thermocouple in the heat cube.
  7. A device constant must be defined for each of the pre-written sub-VIs. The device constant selects the external device the sub-VIs transmit data to and receive data from, similar to selecting a port for an Arduino program.
  8. With the wiring tool selected, right click on the input terminal of the sub-VIs labeled Device Name > Create > Constant.
  9. Verify that all three device constants are equivalent. The device constant can be changed using the operating tool in the Tools palette.
  10. Ask the TA to check over the modifications to the VI. If correct, the TA will supply an NI ELVIS board, a heat cube, two 100 kΩ resistors, and electrical wires.
  11. Using two 100 kΩ resistors (Brown, Black, Yellow), insert one end of each resistor into AIGND (row 18) of the NI ELVIS board.
  12. Insert the other end of one of the resistors into the AI 7+ (row 15), and the end of the other resistor into AI 7- (row 16).
  13. Using a wire, connect the AI 7+ port (row 15) to the screw terminal 1 port (row 46).
  14. Using a wire, connect the AI 7- port (row 16) to the screw terminal 2 port (row 47).
  15. Insert the positive and negative wires from the fan into Variable Power Supplies SUPPLY+ (row 48) and Variable Power Supplies GROUND (row 49), respectively, at the lower-left-hand corner of the NI ELVIS board.
  16. Connect the positive wire from the heater to DC +5V (row 54) on the lower-right-hand corner of the NI ELVIS board.
  17. Connect the source of the MOSFET from the heat cube circuit to DC ground (row 53) on the lower-right-hand corner of the NI ELVIS board.
  18. Connect the gate of the MOSFET from the heat cube circuit to DIO 19 (row 20) on the upper-right-hand corner of the NI ELVIS board.
  19. Power the NI ELVIS board with the power cable and also connect it to the PC with the USB cable. The device constants on the back panel of the VI should update to reference the NI ELVIS board.
  20. Run the VI. Observe how the fan and heater in the heat cube can be turned on manually and automatically. Observe how the thermometer indicator in the front panel displays the actual temperature of the room.

2. Lighting System

Build a VI that simulates a lighting system in a house with four rooms. The design must use four lights (LEDs) and at least five switches — one switch per light and one master switch that will turn all of the lights off simultaneously (think of this as a circuit breaker). The program should also interact with real LEDs located on the NI ELVIS board.

  1. The front panel of the program should use five switches and four LEDs.
  2. The back panel requires a case structure for the master switch to turn off all the lights. Think of the cases that will be required for the function of the master switch.
  3. Create the program in the case structure using the appropriate functions and wiring. Use knowledge acquired from creating the heating and cooling system, information from the Overview, and the LabVIEW Digest at the bottom of the page.
  4. After completing the program, the VI must be interfaced to the physical NI ELVIS board. The VI is interfaced to the NI ELVIS board using a function called the Digital Writer, which writes data to the DIO (Digital Input and Output) pins on the board, and can display outputs on the board’s built-in LEDs from the VI. To access the Digital Writer node, go to the Functions palette > Measurement I/O tab > NI ELVISmx > Digital Writer (Figure 27). Place the Digital Writer node on the back panel.
    Figure 27: NI ELVISmx Digital Writer
  5. Hover over the blue square at the bottom of the Digital Writer node, click, and drag down. Six colored lines should appear (Figure 28). If this cannot be performed, double click on the Digital Writer node and click OK in the NI ELVISmx dialog that pops up. Try to expand the node again.
    Figure 28: NI ELVISmx Digital Writer Node
  6. Only two of the lines in the Digital Writer node will be used in this experiment. The Lines to Write determine which group of eight DIO pins will be used in the VI. The Lines to Write come in groups of eight (starting at 0) because the program works in 8-bit. The DO (Digital Output) Lines input the Boolean values into the DIO pins.
  7. For the purposes of this lab, DIO lines 0–7 will be utilized (Figure 29). To establish this setting, right-click Lines to Write on the Digital Writer node > Create > Constant. By default, the constant is set to 0–7. The operating tool in the Tools palette can be used to change this value.
    Figure 29: Lines to Write
  8. The DO Lines require an input for each of the eight DIO lines, indicating whether each one is true or false (on or off), but the Digital Writer can only receive one input for the DO Lines (as observed by the one input terminal for the DO Lines on the Digital Writer node). Therefore, the eight Boolean values will be placed in an array, and the array will be input to the DO Lines.
  9. A Build Array function will be used by going to the Functions palette > Programming > Build Array (Figure 30). The array should be eight indices long to represent each DIO line. When first placing the array, it only appears as one index. Hover over the bottom of the array until a two-sided arrow appears, then click and drag down until the array is eight indices long.
    Figure 30: Array Function
  10. Each LED should be wired to an individual index in the array, at the element terminal on the left side of the array node. The remaining four indices in the array should be wired to false constants, as those DIO lines should remain false at all times as they are not in use.
  11. The resulting array should be wired to the Lines to Write of the Digital Writer node, from the appended array terminal on the right side of the array node (Figure 31).
    Figure 31: Completed Digital Writer Node
  12. For the LEDs on the NI ELVIS board to light up, wires must be used to connect the DIO lines (rows 0–7) directly to the LEDs on the NI ELVIS board (rows 35–42).
  13. Test the VI. Double click the Digital Writer node. Ensure the correct Device and Lines to Write are selected under Configuration of the NI ELVISmx dialog. Click OK. Run the VI in LabVIEW. Ask a TA to check the program.
  14. Take screenshots of the lighting system. Save the lighting system as a VI file.
  15. Submit a ZIP file of both the heating and cooling system and the lighting system to the EG1004 website before 11:59PM the night before the next lab.

The lab work is now complete. Please clean up the workstation. Return all unused materials to the TA. Refer to the Assignment section for the instructions needed to prepare the lab report.

Assignment

A ZIP folder containing both LabVIEW programs (in VI format) must be submitted to the EG1004 Website by 11:59PM the night before the next lab. There is no Team PowerPoint Presentation for this lab.

Team Lab Report

Follow the lab report guidelines laid out in the EG1004 Writing Style Guide in the Technical Writing section of the manual. Use the outline below to write this report.

  • How is LabVIEW important today?
  • 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 an NI ELVIS board is
  • State whether the VIs were successful or not. If not, explain why.
  • State whether interfacing the VIs with the NI ELVIS board was successful or not
  • Describe the advantages and disadvantages of using LabVIEW
  • Suggest some improvements for the lab procedure
  • Suggest improvements for each VI
  • Because the procedural elements in this lab are extensive, please include only the procedures employed to build the lighting system in the lab report. Do not document the procedures followed to build the heating and cooling system
  • Though the Procedure section is limited to the lighting system, discuss both of the designs in the Data/Observations and Conclusion sections of the lab report
  • Please consider the value of LabVIEW as a substitute for actual instruments and systems. The Data/Observations section should include information on ease of use, the LabVIEW user interface, and the available help options
  • In describing the design of all the systems, present screenshots in the lab reports showing the VIs that were designed

Remember: Lab notes must be taken. Experimental details are easily forgotten unless written down. EG1004 Lab Notes paper can be downloaded and printed from the EG1004 Website. Use the lab notes to write the Procedure section of the lab report. At the end of each lab, a TA will scan the lab notes and upload them to the Lab Documents section of the EG1004 Website. One point of extra credit is awarded if the lab notes are attached at the end of the lab report. Keeping careful notes is an essential component of all scientific practice.


LabVIEW Digest of Common Tasks

Front Panel

  • How to get a slide control:
    • Controls palette > Modern tab > Numeric Lab labview 2.png
    • Select Horizontal Pointer Slide Slide Control 2.png
    • Click on the front panel to place the slide at a specific location
  • How to get an LED indicator:
    • Controls palette > Modern tab > Boolean Lab labview 8.png
    • Select the Round LED LED 1.png or Square LED LED 2.png
    • Click on the front panel to place the LED at a specific location
  • How to get a numeric control:
    • Controls palette > Modern tab > Numeric Lab labview 2.png
    • Click on Numeric Control NC.png
    • Click on the front panel to place the numeric control at a specific location
  • How to get a numeric indicator:
    • Controls palette > Modern tab > Numeric Lab labview 2.png
    • Click on Numeric Indicator NI.png
    • Click on the front panel to place the numeric indicator at a specific location

Back Panel

  • How to define an arithmetic operation:
    • Functions palette > Programming tab > Numeric Lab labview 33.png
    • Click on the function of the desired arithmetic operation Arithmetic.png
    • Click on the back panel to place the arithmetic function at a specific location
  • How to define Boolean constants (usually used to turn on/off LEDs):
    • Functions palette > Programming tab > Boolean Lab labview 36.png
    • Click on the True Constant Lab labview 42.png or False Constant Lab labview 43.png
    • Click on the back panel to place the Boolean constant at a specific location
  • How to wire:
    • Tools palette > Wiring tool Lab labview 19.png
    • Click the desired object output terminal (on the left side) to wire from
    • Click the desired object input terminal (on the right side) to wire to

References

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

“LabVIEW Block Diagram Explained.” National Instruments, National Instruments, 4 Feb. 2020, www.ni.com/en-us/support/documentation/supplemental/08/labview-block-diagram-explained.html.

“Case Structure.” National Instruments, National Instruments, 4 Feb. 2020, www.zone.ni.com/reference/en-XX/help/371361R-01/glang/case_structure/.

“LabVIEW Front Panel Explained.” National Instruments, National Instruments, 4 Feb. 2020, www.ni.com/en-us/support/documentation/supplemental/08/labview-front-panel-explained.html.